In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/c72cb6ab5d35e3fb80cc6b454c008c01c3064b95?hp=be544edcaf8e3776336365b1525882f35e4ea6f3>

- Log -----------------------------------------------------------------
commit c72cb6ab5d35e3fb80cc6b454c008c01c3064b95
Merge: be544ed e38fc30
Author: Nicholas Clark <[email protected]>
Date:   Sat Jul 13 12:16:57 2013 +0200

    Merge installperl and installman refactoring to blead.

commit e38fc308c4911dd6d100bc642eb4213595bd0c30
Author: Nicholas Clark <[email protected]>
Date:   Sat Jul 13 12:16:20 2013 +0200

    Document installperl and installman refactoring in perldelta.pod

M       pod/perldelta.pod

commit 8cef6e50d7e4e0d0b1a8ff82c512b15ee1dfeaff
Author: Nicholas Clark <[email protected]>
Date:   Wed Apr 25 15:48:33 2012 +0200

    Add a no-op option --strip to installman.
    
    This intentionally does nothing.
    
    --strip for installperl instructs it to strip the installed binaries. Hence
    by permitting installman to accept --strip without error Makefile.SH can be
    simplified, as it's possible to pass identical flags to both install 
scripts.

M       installman

commit bbb454562ee7ec7c6a191910bfa339cb2168a7a2
Author: Nicholas Clark <[email protected]>
Date:   Wed Apr 25 15:21:54 2012 +0200

    Refactor installman's option handling to use Getopt::Long's "multiple 
names".
    
    Previously installman specified synonyms for options as distinct
    options, and then used explicit code to merge them.
    
    Also add -h and -? as synonyms for --help.

M       installman

commit 3f7e1bf8b573541d1d93e89278657b6e6438b69a
Author: Nicholas Clark <[email protected]>
Date:   Wed Apr 25 14:38:00 2012 +0200

    Convert installperl to use Getopt::Long.
    
    This requires some special handling for the +v option. Fortunately, we can
    cheat, because we know that no other non-options are acceptable. This does
    change the behaviour slightly from before:
    
    * single letter options now also have long names
    * invalid options are now rejected
    * command line arguments that are not options are now rejected
    
    However, the behaviour for all valid documented invocations is unchanged.
    
    Also, add a --help option to display the usage message.

M       installperl

commit 4609f84fc954f9ef279e0204408c7e7f64fa58c9
Author: Nicholas Clark <[email protected]>
Date:   Wed Apr 25 16:57:22 2012 +0200

    In installperl rename $opt{dostrip} to $opt{strip}.
    
    This will provide a more meaningful long option name once installperl is
    converted to Getopt::Long.

M       installperl

commit c164bd944ffd768f738cd42ae5ea26f282503d42
Author: Nicholas Clark <[email protected]>
Date:   Wed Apr 25 13:17:41 2012 +0200

    In installperl, record the state of options in %opts instead of lexicals.
    
    Replace all lexicals used to track the state of command line options with
    entries in the hash %opts. Make an exception for $versiononly, as it is
    controlled by 2 different command line options, and accessed in 
significantly
    more places than the state of any other command line option.

M       installperl

commit 570f643f365e92afac29fc9b092792d455829e99
Author: Nicholas Clark <[email protected]>
Date:   Wed Apr 25 12:47:53 2012 +0200

    In installperl, invert the sense of the variable used for the -o option.
    
    Previously it was $otherperls, and had to have its default of 1 explicitly
    set. Change it to $skip_otherperls, and the default default of undef is
    perfect.

M       installperl

commit 236818e0b9d9fe874831086b4d0b94dc6f245dfd
Author: Nicholas Clark <[email protected]>
Date:   Wed Apr 25 12:06:26 2012 +0200

    Remove dead code from installperl, related to a 5.000->5.001 change.
    
    5.000 installed autosplit files into archlib. 5.001 and later install into
    privlib. archlib is earlier in @INC. It wasn't until 5.005 that perl put the
    version number into the paths used for privlib and archlib, hence without
    special treatment, the files installed by 5.001 would not be found, because
    those from 5.000 would be earlier in @INC.
    
    See commit a841533b5cf319b3 (Oct 2009) which removes similar special casing
    code dealing with perldiag.pod confusion between 5.003 and 5.004
    
    All this code became redundant when 5.005 added the version number to
    library paths. (strictly, commit bfb7748a896459cc in Jul 1998)

M       installperl
-----------------------------------------------------------------------

Summary of changes:
 installman        |  9 ++++---
 installperl       | 75 ++++++++++++++++++++++++++-----------------------------
 pod/perldelta.pod | 27 +++++++++++++++++++-
 3 files changed, 66 insertions(+), 45 deletions(-)

diff --git a/installman b/installman
index cd8b094..4f9d469 100755
--- a/installman
+++ b/installman
@@ -36,9 +36,12 @@ my $usage =
         --verbose (or -V) report all progress.
         --silent  (or -S) be silent. Only report errors.\n";
 
+# --strip intentionally does nothing. By permitting installman to accept it
+# without error, the Makefile can pass the same options to installperl and
+# installman, which permits more simplification there than this comment costs.
 GetOptions( \%opts,
             qw( man1dir=s man1ext=s man3dir=s man3ext=s
-                destdir:s notify n help silent S verbose V))
+                destdir:s notify|n help|h|? silent|S verbose|V strip))
        || die $usage;
 die $usage if $opts{help};
 $opts{destdir} //= '';
@@ -47,9 +50,7 @@ foreach my $pre (qw(man1 man3)) {
     $opts{"${pre}dir"} //= $opts{destdir} . $Config{"install${pre}dir"};
     $opts{"${pre}ext"} //= $Config{"${pre}ext"};
 }
-$opts{silent} ||= $opts{S};
-$opts{notify} ||= $opts{n};
-$opts{verbose} ||= $opts{V} || $opts{notify};
+$opts{verbose} ||= $opts{notify};
 
 #Sanity checks
 
diff --git a/installperl b/installperl
index 60d392e..9cf7d7b 100755
--- a/installperl
+++ b/installperl
@@ -13,8 +13,7 @@ BEGIN {
 use strict;
 use vars qw($Is_VMS $Is_W32 $Is_OS2 $Is_Cygwin $Is_Darwin $Is_NetWare
            %opts $packlist);
-my ($dostrip, $versiononly, $force,
-    $otherperls, $archname, $nwinstall, $nopods);
+my $versiononly;
 
 BEGIN {
     if ($Is_VMS) { eval 'use VMS::Filespec;' }
@@ -28,6 +27,8 @@ use File::Copy ();
 use File::Path ();
 use ExtUtils::Packlist;
 use Cwd;
+# nogetopt_compat to disable treating +v as meaning -v
+use Getopt::Long qw(:config nogetopt_compat no_auto_abbrev noignorecase);
 
 require './Porting/pod_lib.pl';
 
@@ -65,29 +66,31 @@ if ( $Is_VMS ) {
     }
 }
 
-$otherperls = 1;
 # This little hack simplifies making the code after the comment "Fetch some
 # frequently-used items from %Config" warning free. With $opts{destdir} always
 # defined, it's also possible to make the s/\Q$opts{destdir}\E unconditional.
 
 $opts{destdir} = '';
-# Consider refactoring this to use Getopt::Long once Getopt::Long's planned
-# feature is implemented, to distinguish + and - options.
-while (@ARGV) {
-    $opts{notify} = 1 if $ARGV[0] eq '-n';
-    $dostrip = 1 if $ARGV[0] eq '-s';
-    $versiononly = 1 if $ARGV[0] eq '-v';
-    $versiononly = 0 if $ARGV[0] eq '+v';
-    $opts{silent} = 1 if $ARGV[0] eq '-S';
-    $otherperls = 0 if $ARGV[0] eq '-o';
-    $force = 1 if $ARGV[0] eq '-f';
-    $opts{verbose} = 1 if $ARGV[0] eq '-V' || $ARGV [0] eq '-n';
-    $archname = 1 if $ARGV[0] eq '-A';
-    $nwinstall = 1 if $ARGV[0] eq '-netware';
-    $nopods = 1 if $ARGV[0] eq '-p';
-    $opts{destdir} = $1 if $ARGV[0] =~ /^-?-destdir=(.*)$/;
-    if ($ARGV[0] eq '-?' or $ARGV[0] =~ /^-?-h/) {
-       print <<"EOT";
+{
+    my $usage = 0;
+    if (!GetOptions(\%opts, 'notify|n', 'strip|s', 'silent|S',
+                    'skip-otherperls|o', 'force|f', 'verbose|V', 'archname|A',
+                    'netware', 'nopods|p', 'destdir:s', 'help|h|?',
+                    'versiononly|v' => \$versiononly, '<>' => sub {
+                        if ($_[0] eq '+v') {
+                            $versiononly = 0;
+                        } else {
+                            # Any other unknown argument is going to be an 
error
+                            $usage = 1;
+                        }
+                    },
+                   )) {
+        $usage = 1;
+    }
+    $opts{verbose} ||= $opts{notify};
+
+    if ($usage || $opts{help}) {
+        print <<"EOT";
 Usage $0: [switches]
   -n       Don't actually run any commands; just print them.
   -s        Run strip on installed binaries.
@@ -104,10 +107,10 @@ Usage $0: [switches]
   -p        Don't install the pod files. [This will break use diagnostics;]
   -netware  Install correctly on a Netware server.
   -destdir  Prefix installation directories by this string.
+  -h        Display this help message.
 EOT
-       exit;
+        exit $usage;
     }
-    shift;
 }
 
 $versiononly = 1 if $Config{versiononly} && !defined $versiononly;
@@ -213,7 +216,7 @@ if ($^O eq 'os390') {
     }
 }
 
-if ($nwinstall) {
+if ($opts{netware}) {
     # This is required only if we are installing on a NetWare server
     $installscript = $Config{installnwscripts};
     $installprivlib = $Config{installnwlib};
@@ -308,7 +311,7 @@ elsif ($^O ne 'dos') {
     }
     else {
        # If installing onto a NetWare server
-       if ($nwinstall) {
+        if ($opts{netware}) {
            # Copy perl.nlm, echo.nlm, type.nlm, a2p.nlm & cgi2perl.nlm
             mkpath($Config{installnwsystem}, $opts{verbose}, 0777);
            copy("netware\\".$ENV{'MAKE_TYPE'}."\\perl.nlm", 
$Config{installnwsystem});
@@ -411,7 +414,7 @@ if (! $versiononly && ! samepath($installbin, '.') && ($^O 
ne 'dos') && ! $Is_VM
 
 # For development purposes it can be very useful to have multiple perls
 # build for different "architectures" (eg threading or not) simultaneously.
-if ($archname && ! samepath($installbin, '.') && ($^O ne 'dos') && ! $Is_VMS) {
+if ($opts{archname} && ! samepath($installbin, '.') && ($^O ne 'dos') && ! 
$Is_VMS) {
     my $archperl = "$perl_verbase$ver-$Config{archname}$exe_ext";
     safe_unlink("$installbin/$archperl");
     if ($^O eq 'vos') {
@@ -528,7 +531,7 @@ if ($versiononly) {
 
 # Install pod pages.  Where? I guess in $installprivlib/pod
 # ($installprivlib/pods for cygwin).
-if (!$nopods && (!$versiononly || ($installprivlib =~ m/\Q$vershort/))) {
+if (!$opts{nopods} && (!$versiononly || ($installprivlib =~ m/\Q$vershort/))) {
     my $pod = ($Is_Cygwin || $Is_Darwin || $Is_VMS || $Is_W32) ? 'pods' : 
'pod';
     mkpath("${installprivlib}/$pod", $opts{verbose}, 0777);
 
@@ -547,7 +550,7 @@ if (!$nopods && (!$versiononly || ($installprivlib =~ 
m/\Q$vershort/))) {
 # Also skip $mainperl if the user opted to have it be a link to the
 # installed perl.
 
-if (!$versiononly && $otherperls) {
+if (!$versiononly && !$opts{'skip-otherperls'}) {
     my ($path, @path);
     my $dirsep = ($Is_OS2 || $Is_W32 || $Is_NetWare) ? ';' : ':' ;
     ($path = $ENV{"PATH"}) =~ s:\\:/:g ;
@@ -751,27 +754,19 @@ sub installlib {
        return unless $do_installprivlib;
     }
 
-    if ($Is_NetWare && !$nwinstall && /\.(?:nlp|nlm|bs)$/) {
+    if ($Is_NetWare && !$opts{netware} && /\.(?:nlp|nlm|bs)$/) {
         # Don't copy .nlp,.nlm files, doesn't make sense on Windows and also
         # if copied will give problems when building new extensions.
         # Has to be copied if we are installing on a NetWare server and
-        # hence the check !$nwinstall
+        # hence the check !$opts{netware}
         return;
     }
 
     if (-f $_) {
-       if (/\.(?:al|ix)$/ && !($dir =~ m[^auto/(.*)$])) {
-           $installlib = $installprivlib;
-           #We're installing *.al and *.ix files into $installprivlib,
-           #but we have to delete old *.al and *.ix files from the 5.000
-           #distribution:
-           #This might not work because $archname might have changed.
-           unlink("$installarchlib/$name");
-       }
        my $xname = "$installlib/$name";
        $xname =~ s/^\Q$opts{destdir}\E//;
        $packlist->{$xname} = { type => 'file' };
-       if ($force || compare($_, "$installlib/$name") || $opts{notify}) {
+        if ($opts{force} || compare($_, "$installlib/$name") || $opts{notify}) 
{
            unlink("$installlib/$name");
            mkpath("$installlib/$dir", $opts{verbose}, 0777);
            # HP-UX (at least) needs to maintain execute permissions
@@ -813,7 +808,7 @@ sub copy_if_diff {
     }
     -f $from || $perlpodbadsymlink || warn "$0: $from not found";
     $packlist->{$xto} = { type => 'file' };
-    if ($force || compare($from, $to) || $opts{notify}) {
+    if ($opts{force} || compare($from, $to) || $opts{notify}) {
        safe_unlink($to);   # In case we don't have write permissions.
        if ($perlpodbadsymlink && $from =~ m!^pod/perl(.+)\.pod$!) {
            $from = "README.$1";
@@ -832,7 +827,7 @@ sub strip
 {
     my(@args) = @_;
 
-    return unless $dostrip;
+    return unless $opts{strip};
 
     my @opts;
     while (@args && $args[0] =~ /^(-\w+)$/) {
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 137b242..b53dfc5 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -277,7 +277,32 @@ L</Platform Support> section, instead.
 
 =item *
 
-XXX
+F<installperl> and F<installman>'s option handling has been refactored to use
+L<Getopt::Long>. Both are used by the F<Makefile> C<install> targets, and
+are not installed, so these changes are only likely to affect custom
+installation scripts.
+
+=over 4
+
+=item *
+
+single letter options now also have long names
+
+=item *
+
+invalid options are now rejected
+
+=item *
+
+command line arguments that are not options are now rejected
+
+=item *
+
+Each now has a C<--help> option to display the usage message.
+
+=back
+
+The behaviour for all valid documented invocations is unchanged.
 
 =back
 

--
Perl5 Master Repository

Reply via email to