develooper Front page | perl.module-authors | Postings from January 2010

Module::Build and ActiveState

Thread Next
From:
Klaus
Date:
January 6, 2010 08:42
Subject:
Module::Build and ActiveState
Message ID:
d4e880d3-954e-4e9f-8851-0032c94b5437@a15g2000yqm.googlegroups.com
There are problems in the way that Module::Build interacts with
ActiveState Perl, those problems are:

- HTML generated with Module::Build is not conform
  with the way HTML is generated by ActiveState /
  ExtUtils::MakeMaker

- with Module::Build, ActiveState's Table of Contents
  (html\index.html) is not updated (with
  ExtUtils::MakeMaker it is updated)

- with Module::Build, the file 'lib/perllocal.pod' is not
  updated, which leaves ActiveState's PPM-utility in
  the dark about the newly installed distribution. (with
  ExtUtils::MakeMaker the file 'lib/perllocal.pod' is
  correctly updated)

I have a patch that fixes those problems. 3 modules are to be patched:
"ActivePerl::DocTools::Pod", "ExtUtils::Command::MM" and
"Module::Build::Base".

Who do I need to contact to have all 3 modules patched at the same
time ?

Here are the details of the patch:

--- lib/ActivePerl/DocTools/Pod.pm.bak 2010-01-06 15:17:20.201000000
+0100
+++ lib/ActivePerl/DocTools/Pod.pm     2010-01-06 15:17:20.201000000
+0100
@@ -43,6 +43,11 @@
              "--outfile=$outfile",
              "--css=${html_root}/Active.css",
          );
+    html_fix($outfile, $html_root, $index, $depth);
+}
+
+sub html_fix {
+    my ($outfile, $html_root, $index, $depth) = @_;

     open (HTMLFILE, "<$outfile") or die "Couldn't open $outfile: $!";
     open (TMPFILE, ">$outfile.tmp") or die "Couldn't open
$outfile.tmp: $!";
@@ -71,7 +76,9 @@
         if ($content =~ /<TITLE>/i) {
             until ($content =~ /<\/TITLE>/i) {
                 chomp $content;
-                $content .= " " . <HTMLFILE>;
+                my $fragment = <HTMLFILE>;
+                last unless defined $fragment; # bail-out if you hit
End-of-File
+                $content .= " " . $fragment;
             }
         }

--- lib/ExtUtils/Command/MM.pm.bak     2010-01-06 15:17:20.201000000
+0100
+++ lib/ExtUtils/Command/MM.pm         2010-01-06 15:17:20.201000000
+0100
@@ -206,6 +206,13 @@
     my @mod_info = $Is_VMS ? split /\|/, <STDIN>
                            : @ARGV;

+    print perllocal_instd($type, $name, @mod_info);
+}
+
+sub perllocal_instd {
+    my($type, $name) = splice(@_, 0, 2);
+    my @mod_info = @_;
+
     my $pod;
     $pod = sprintf <<POD, scalar localtime;
  =head2 %s: C<$type> L<$name|$name>
@@ -228,9 +235,8 @@

     $pod .= "=back\n\n";
     $pod =~ s/^ //mg;
-    print $pod;

-    return 1;
+    return $pod;
 }

 =item B<uninstall>
--- lib/Module/Build/Base.pm.bak       2010-01-06 15:17:20.201000000
+0100
+++ lib/Module/Build/Base.pm           2010-01-06 15:17:20.201000000
+0100
@@ -861,8 +861,9 @@
   },
 );

+my $Is_ActivePerl;
 {
-  my $Is_ActivePerl = eval {require ActivePerl::DocTools};
+  $Is_ActivePerl = eval {require ActivePerl::DocTools};
   __PACKAGE__->add_property(html_css => $Is_ActivePerl ?
'Active.css' : '');
 }

@@ -2871,7 +2872,8 @@
     my $path2root = join( '/', ('..') x (@rootdirs+@dirs) );
     my $htmlroot = join( '/',
                          ($path2root,
-                          $self->installdirs eq 'core' ? () : qw
(site) ) );
+                          ($self->installdirs eq 'core' or
$Is_ActivePerl)
+                            ? () : qw(site) ) );

     my $fh = IO::File->new($infile) or die "Can't read $infile: $!";
     my $abstract = Module::Build::PodParser->new(fh => $fh)-
>get_abstract();
@@ -2880,8 +2882,9 @@
     $title .= " - $abstract" if $abstract;

     my @opts = (
-                '--flush',
-                "--title=$title",
+                ($Is_ActivePerl ? ('--quiet', '--index',
+                  '--
libpods=perlfunc:perlguts:perlvar:perlrun:perlopt')
+                                : ('--flush', "--title=$title")),
                 "--podpath=$podpath",
                 "--infile=$infile",
                 "--outfile=$outfile",
@@ -2890,7 +2893,7 @@
                );

     if ( eval{Pod::Html->VERSION(1.03)} ) {
-      push( @opts, ('--header', '--backlink=Back to Top') );
+      push( @opts, ('--header', '--backlink=Back to Top') ) unless
$Is_ActivePerl;
       push( @opts, "--css=$path2root/" . $self->html_css) if $self-
>html_css;
     }

@@ -2898,6 +2901,13 @@
     $self->log_verbose("pod2html @opts\n");
     eval { Pod::Html::pod2html(@opts); 1 }
       or $self->log_warn("pod2html @opts failed: $@");
+
+    if ($Is_ActivePerl) {
+        my $dp = @rootdirs + @dirs;
+        require ActivePerl::DocTools::Pod;
+        ActivePerl::DocTools::Pod::html_fix($outfile, $htmlroot,
'index', $dp);
+    }
+
   }

 }
@@ -2983,6 +2993,17 @@
   require ExtUtils::Install;
   $self->depends_on('build');
   ExtUtils::Install::install($self->install_map, !$self->quiet, 0,
$self->{args}{uninst}||0);
+
+  if ($Is_ActivePerl) {
+      # The main reason for writing to "lib/perllocal.pod" is to get
a new timestamp
+      # for that file. The new timestamp is very important for
ActiveState's ppm-utility,
+      # see also 'ActivePerl/PPM/InstallArea.pm', subroutine _init_db
(),
+      # ==> expression ((stat $perllocal)[9] || 0))
+      $self->write_perllocal();
+
+      # writing ActiveState Table of Content in HTML Format
+      ActivePerl::DocTools::WriteTOC();
+  }
 }

 sub ACTION_fakeinstall {
@@ -3013,6 +3034,41 @@
   only::install::install(%onlyargs);
 }

+sub write_perllocal {
+    my $self = shift;
+
+    if (my $corelib = $self->{config}->get('installprivlib')) {
+
+        # the following '$into_dir' could be more flexible
+        # ==> hint: $self->installdirs, [$self->install_types],
+        #           $self->install_destination($type)
+        my $into_dir = $self->install_destination('arch') || '';
+
+        require ExtUtils::Command::MM;
+        my $podinfo = ExtUtils::Command::MM::perllocal_instd(
+          'Module'         => $self->module_name,  # Module name
+          'installed into' => $into_dir,           # where the distro
is installed into
+          'LINKTYPE'       => 'dynamic',           # don't know if
LINKTYPE is always 'dynamic' ?
+          'VERSION'        => $self->dist_version, # Version of the
distribution
+          'EXE_FILES'      => '',                  # Can't find
anything meaningful in properties
+        );
+
+        my $perllocal = File::Spec->catfile($corelib,
'perllocal.pod');
+        if (open(PODF, ">>$perllocal")) {
+            print PODF $podinfo;
+            close PODF;
+            print "Appending installation info to $perllocal\n"
unless $self->quiet;
+        }
+        else {
+            print "Warning: Could not open >> '$perllocal' because $!
\n" unless $self->quiet;
+        }
+    }
+    else {
+        print "Warning: Could not find \$self->{config}->get
('installprivlib') ",
+              "for self ==> $self\n" unless $self->quiet;
+    }
+}
+
 sub ACTION_clean {
   my ($self) = @_;
   foreach my $item (map glob($_), $self->cleanup) {


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About