Hello everyone,
Well, I got DocSet ported to Win32. It wasn't such a big task afterwards. What was changed:
- replaced call to `which` with a portable which function in DocSet::Util (taken from Apache::Build in modperl-2.0 and made to use the PATHEXT env variable on WinNT: I can re-submit this one into the modperl-2.0 tree if you think that'll be useful, it finds the specified file terminated by .exe, .bat, etc..
- use perl %ENV instead of `env` to set PERL5LIB whenh calling docset_build
- had to replace all regexes that used a directory/file path, and use quotemeta() there, because the backslahes created illegal escape sequences.
- changed some things before calling URI in DocSet::Doc; it not, the directory name would be considered part of the host name and thus not tried to be opened. So I replaced \ with /, as that'll open the file correctly.
I think that's it.
For bin/build to work correctly, there must also be .bat versions of build and docset_build. I'm not sure about how to handle this in a general way, maybe the bat files should be integrated into CVS or something? I need some tips on that.
Furthermore, there was a problem with html2ps: it begins with a line saying
: # Use Perl
When converting it to .bat (as it is when it's installed into perl/bin), that colon is a problem. It should be removed.
For the PDF version, it all seems to have been build correctly, but after a loong wait (it takes a long time, even on a pretty decent computer here, but I guess that's normal), I get the following errors:
Invalid Parameter - \svs..ppm
Output file write error --- out of disk space?
Invalid Parameter - \sds..ppm
Output file write error --- out of disk space?
Invalid Parameter - \sr0..ppm
Invalid Parameter - \sr0..ppm
Invalid Parameter - \sr0..ppm
Invalid Parameter - \sr0..ppm
Invalid Parameter - \su0..ppm
Invalid Parameter - \su0..ppm
Invalid Parameter - \su0..ppm
Invalid Parameter - \su0..ppm
Does anyone know where this is coming from? I don't have the guts to try and debug it now. Please tell me if you know where it's coming from (DocSet or Ghostscript?)
The patches to DocSet are against the modperl-docs repository. I guess this might be a problem. If it is, please tell me and I'll resubmit the patch.
Patch is below the sig.
-- Per Einar Ellefsen [EMAIL PROTECTED]
Index: bin/build
===================================================================
RCS file: /home/cvspublic/modperl-docs/bin/build,v
retrieving revision 1.2
diff -u -r1.2 build
--- bin/build 5 Jan 2002 19:38:51 -0000 1.2
+++ bin/build 29 Mar 2002 20:44:37 -0000
@@ -12,7 +12,11 @@
my $perl5lib = $ENV{PERL5LIB} || $ENV{PERLLIB};
my $lib = join ":", grep defined($_), "$Bin/../lib", $perl5lib;+# Add PERl5LIB to environment for docset_build to pick up on local DocSet
+# modules
+$ENV{PERL5LIB} = $lib;
+
# forward the @ARGV
-my $command = "env PERL5LIB=$lib $Bin/docset_build @ARGV $Bin/.. src/config.cfg";
+my $command = "$Bin/docset_build @ARGV $Bin/.. src/config.cfg";
#print $command;
system $command;
Index: lib/DocSet/Doc.pm
===================================================================
RCS file: /home/cvspublic/modperl-docs/lib/DocSet/Doc.pm,v
retrieving revision 1.5
diff -u -r1.5 Doc.pm
--- lib/DocSet/Doc.pm 22 Mar 2002 07:00:29 -0000 1.5
+++ lib/DocSet/Doc.pm 29 Mar 2002 20:44:38 -0000
@@ -71,7 +71,11 @@
my($self) = @_;
# META: at this moment everything is a file path
- my $src_uri = "file://" . $self->{src_path};
+ my $src_path = $self->{src_path};
+ $src_path =~ s|\\|/|g; # need this for Win32, if not part of the path
+ # becomes the hostname (\ or / don't matter
+ # when opening files on Win32)
+ my $src_uri = "file://" . $src_path;
my $u = URI->new($src_uri); my $scheme = $u->scheme;
Index: lib/DocSet/DocSet.pm
===================================================================
RCS file: /home/cvspublic/modperl-docs/lib/DocSet/DocSet.pm,v
retrieving revision 1.5
diff -u -r1.5 DocSet.pm
--- lib/DocSet/DocSet.pm 22 Mar 2002 02:01:51 -0000 1.5
+++ lib/DocSet/DocSet.pm 29 Mar 2002 20:44:39 -0000
@@ -73,7 +73,8 @@
# cache the location of the parent node cache
if (my $parent_o = $self->get('parent_o')) {
my $parent_src_root = $parent_o->get_dir('src_root');
- (my $rel2parent_src_root = $src_root) =~ s|$parent_src_root||;
+ my $parent_src_root_regex = quotemeta($parent_src_root);
+ (my $rel2parent_src_root = $src_root) =~ s|$parent_src_root_regex||;
my $rel_dir = join '/', ("..") x ($rel2parent_src_root =~ tr|/|/|);
my $parent_cache_path = "$parent_src_root/cache.$mode.dat";
$cache->parent_node($parent_cache_path,
@@ -279,7 +280,8 @@
# # some OSs's File::Find returns files with no dir prefix root
# # (that's what ()* is for
# $dst_path =~ s/(?:$src_root)*/$dst_root/;
- $dst_path =~ s/$src_root/$dst_root/;
+ my $src_root_regex = quotemeta($src_root);
+ $dst_path =~ s/$src_root_regex/$dst_root/; # to rebuild or not to rebuild
my($should_update, $reason) =
Index: lib/DocSet/RunTime.pm
===================================================================
RCS file: /home/cvspublic/modperl-docs/lib/DocSet/RunTime.pm,v
retrieving revision 1.3
diff -u -r1.3 RunTime.pm
--- lib/DocSet/RunTime.pm 22 Mar 2002 07:00:30 -0000 1.3
+++ lib/DocSet/RunTime.pm 29 Mar 2002 20:44:40 -0000
@@ -53,7 +53,9 @@
return HAS_STORABLE;
}-my $html2ps_exec = `which html2ps` || '';
+# check for existence of html2ps and ps2pdf
+
+my $html2ps_exec = which('html2ps') || '';
chomp $html2ps_exec;
sub can_create_ps {
# ps2html is bundled, so we can always create PS
@@ -63,7 +65,7 @@
# can_create_pdf()
}-my $ps2pdf_exec = `which ps2pdf` || '';
+my $ps2pdf_exec = which('ps2pdf') || '';
chomp $ps2pdf_exec;
sub can_create_pdf {
# check whether ps2pdf exists
@@ -93,9 +95,10 @@
my $rsub_skip_seen =
build_matchmany_sub([EMAIL PROTECTED]);+ my $full_path_regex = quotemeta($full_path);
$src_docs{$rel_path} = {
map { $_ => 1 }
- map {s|$full_path/||; $_}
+ map {s|$full_path_regex/||; $_}
grep $rsub_keep_ext->($_), # get files with wanted exts
grep !$rsub_skip_seen->($_), # skip seen base dirs
@{ expand_dir($full_path) }
Index: lib/DocSet/Util.pm
===================================================================
RCS file: /home/cvspublic/modperl-docs/lib/DocSet/Util.pm,v
retrieving revision 1.6
diff -u -r1.6 Util.pm
--- lib/DocSet/Util.pm 22 Mar 2002 07:01:25 -0000 1.6
+++ lib/DocSet/Util.pm 29 Mar 2002 20:44:40 -0000
@@ -15,13 +15,15 @@require DocSet::RunTime; # interdependency with DocSet::Util
+use constant is_win32 => $^O eq 'MSWin32';
+
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(read_file read_file_paras copy_file gzip_file write_file
create_dir filename filename_ext require_package dumper
sub_trace note get_date get_timestamp proc_tmpl
build_matchmany_sub banner should_update confess cluck
- carp format_bytes expand_dir);
+ carp format_bytes expand_dir which); # copy_file($src_path, $dst_path);
# copy a file at $src_path to $dst_path,
@@ -272,6 +274,27 @@
return [EMAIL PROTECTED];
}+# which($short_exec_name)
+# Portable which
+# gotten from modperl-2.0/lib/Apache/Build.pm
+# and modified to take into account Win32 PATHEXT
+########################
+
+my @path_ext = ();
+if(is_win32 and $ENV{PATHEXT}) {
+ @path_ext = split ';', $ENV{PATHEXT};
+}
+
+sub which {
+ foreach (map { catfile($_, $_[0]) } path()) {
+ return $_ if -x;
+ if(is_win32 and @path_ext) { # AFAIK, Win9x doesn't have PATHEXT
+ foreach my $ext (@path_ext) {
+ return $_.$ext if -x $_.$ext;
+ }
+ }
+ }
+} sub dumper {
print Dumper @_;
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
