In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/f4de6fcdcabdf1364f83a3eced84f2b4e4cbd415?hp=2c2284d8d809e9f9c80b47ca3dd3d3ddd99d8c13>

- Log -----------------------------------------------------------------
commit f4de6fcdcabdf1364f83a3eced84f2b4e4cbd415
Author: Jarkko Hietaniemi <[email protected]>
Date:   Fri Oct 28 21:34:42 2016 -0400

    Archive-Tar: customized.dat

M       t/porting/customized.dat

commit 3194f0d062547f8e1470767eb52c6fa82987126f
Author: Jarkko Hietaniemi <[email protected]>
Date:   Fri Oct 28 19:44:27 2016 -0400

    Archive-Tar: Maintainers customization

M       Porting/Maintainers.pl

commit fc5b2724b3f430773ec5560561a0ed6c6bb5e678
Author: Jarkko Hietaniemi <[email protected]>
Date:   Fri Oct 28 19:42:10 2016 -0400

    Archive-Tar: customized version bump

M       cpan/Archive-Tar/lib/Archive/Tar.pm

commit d81914c7e2432828ca2291fcd5c68e0a285f2bf1
Author: Jarkko Hietaniemi <[email protected]>
Date:   Fri Oct 28 19:38:46 2016 -0400

    Archive-Tar: detect if external tar fails

M       cpan/Archive-Tar/t/09_roundtrip.t

commit 356a893ca85ec4486fe0880f5146186a2ae417d0
Author: Craig A. Berry <[email protected]>
Date:   Fri Oct 28 18:58:03 2016 -0400

    Archive-Tar: in VMS gnutar requires filenames in native format

M       cpan/Archive-Tar/t/09_roundtrip.t

commit 202b0c8a3ba3de0efe5cb730b242b8c0502e1add
Author: Jarkko Hietaniemi <[email protected]>
Date:   Fri Oct 28 08:32:23 2016 -0400

    Archive-Tar: RT #118476: scan for the right tar more robustly
    
    (1) Do not assume it is called 'tar'.
    (2) Do not assume it has the compression features.
    (3) Do not assume there is only one 'tar'.
    (4) Do not assume the first one found has the compression features.
    (5) Add the platform executable suffix to the name.

M       cpan/Archive-Tar/t/09_roundtrip.t
-----------------------------------------------------------------------

Summary of changes:
 Porting/Maintainers.pl              |   2 +
 cpan/Archive-Tar/lib/Archive/Tar.pm |   2 +-
 cpan/Archive-Tar/t/09_roundtrip.t   | 137 +++++++++++++++++++++++++++---------
 t/porting/customized.dat            |   2 +
 4 files changed, 107 insertions(+), 36 deletions(-)

diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl
index f4ed345..73ab08b 100755
--- a/Porting/Maintainers.pl
+++ b/Porting/Maintainers.pl
@@ -126,6 +126,8 @@ use File::Glob qw(:case);
         'EXCLUDED'     => [
             qw(t/07_ptardiff.t),
         ],
+        # CPAN RT 118476
+        'CUSTOMIZED'   => [ 'lib/Archive/Tar.pm', 't/09_roundtrip.t' ],
     },
 
     'Attribute::Handlers' => {
diff --git a/cpan/Archive-Tar/lib/Archive/Tar.pm 
b/cpan/Archive-Tar/lib/Archive/Tar.pm
index 858696f..3b92003 100644
--- a/cpan/Archive-Tar/lib/Archive/Tar.pm
+++ b/cpan/Archive-Tar/lib/Archive/Tar.pm
@@ -31,7 +31,7 @@ use vars qw[$DEBUG $error $VERSION $WARN $FOLLOW_SYMLINK 
$CHOWN $CHMOD
 $DEBUG                  = 0;
 $WARN                   = 1;
 $FOLLOW_SYMLINK         = 0;
-$VERSION                = "2.14";
+$VERSION                = "2.14_01";
 $CHOWN                  = 1;
 $CHMOD                  = 1;
 $SAME_PERMISSIONS       = $> == 0 ? 1 : 0;
diff --git a/cpan/Archive-Tar/t/09_roundtrip.t 
b/cpan/Archive-Tar/t/09_roundtrip.t
index 7e0120c..e02a6ee 100644
--- a/cpan/Archive-Tar/t/09_roundtrip.t
+++ b/cpan/Archive-Tar/t/09_roundtrip.t
@@ -26,7 +26,7 @@ BEGIN {
         for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
           next if $dir eq '';
           require File::Spec;
-          my $abs = File::Spec->catfile($dir, $cmd);
+          my $abs = File::Spec->catfile($dir, $cmd, $Config::Config{exe_ext});
           return $abs if (-x $abs or $abs = MM->maybe_command($abs));
         }
         return;
@@ -106,58 +106,125 @@ for my $archive_name (@file_only_archives) {
 # what we'll get when round-tripping on an archive which contains one or more
 # entries for directories.
 
+# Divine whether the external tar command can do gzip/bzip2
+# from the output of 'tar --help'.
+# GNU tar:
+# ...
+# -j, --bzip2                filter the archive through bzip2
+# -z, --gzip, --gunzip, --ungzip   filter the archive through gzip
+#
+# BSD tar:
+# ....
+#   -z, -j, -J, --lzma  Compress archive with gzip/bzip2/xz/lzma
+# ...
+#
+# BSD tar (older)
+# tar: unknown option -- help
+# usage: tar [-]{crtux}[-befhjklmopqvwzHOPSXZ014578] [archive] [blocksize]
+# ...
+
+sub can_tar_gzip {
+  my ($tar_help) = @_;
+  $tar_help =~ /-z, --gzip|-z,.+gzip/;
+}
+
+sub can_tar_bzip2 {
+  my ($tar_help) = @_;
+  $tar_help =~ /-j, --bzip2|-j,+bzip2/;
+}
+
+# The name of the external tar executable.
+my $TAR_EXE;
+
 SKIP: {
-  skip 'No tar command found', scalar @file_and_directory_archives unless 
can_run('tar');
+  my $skip_count = scalar @file_and_directory_archives;
+
+  # The preferred 'tar' command may not be called tar,:
+  # especially on legacy unix systems.  Test first various
+  # alternative names that are more likely to work for us.
+  #
+  my @TRY_TAR = qw[gtar gnutar bsdtar tar];
+  my $can_tar_gzip;
+  my $can_tar_bzip2;
+  for my $tar_try (@TRY_TAR) {
+    if (can_run($tar_try)) {
+      print "# Found tar executable '$tar_try'\n";
+      my $tar_help = qx{$tar_try --help};
+      $can_tar_gzip  = can_tar_gzip($tar_help);
+      $can_tar_bzip2 = can_tar_bzip2($tar_help);
+      printf "# can_tar_gzip  = %d\n", $can_tar_gzip;
+      printf "# can_tar_bzip2 = %d\n", $can_tar_bzip2;
+      # We could dance more intricately and handle the case
+      # of only either of gzip and bzip2 being supported,
+      # or neither, but let's keep this simple.
+      if ($can_tar_gzip && $can_tar_bzip2) {
+        $TAR_EXE = $tar_try;
+        last;
+      }
+    }
+  }
+  unless (defined $TAR_EXE) {
+    skip("No suitable tar command found (tried: @TRY_TAR)", $skip_count);
+  }
 
   for my $archive_name (@file_and_directory_archives) {
-    my @contents;
+    if ($^O eq 'VMS' && $TAR_EXE =~ m/gnutar$/i) {
+      $archive_name = VMS::Filespec::unixify($archive_name);
+    }
+    my $command;
     if ($archive_name =~ m/\.tar$/) {
-        @contents = qx{tar tvf $archive_name};
+      $command = "$TAR_EXE tvf $archive_name";
     }
     elsif ($archive_name =~ m/\.tgz$/) {
-        @contents = qx{tar tzvf $archive_name};
+      $command = "$TAR_EXE tzvf $archive_name";
     }
     elsif ($archive_name =~ m/\.tbz$/) {
-        @contents = qx{tar tjvf $archive_name};
+      $command = "$TAR_EXE tjvf $archive_name";
     }
-    chomp(@contents);
-    my @directory_or_not;
-    for my $entry (@contents) {
+    print "# command = '$command'\n";
+    my @contents = qx{$command};
+    if ($?) {
+      fail("Failed running '$command'");
+    } else {
+      chomp(@contents);
+      my @directory_or_not;
+      for my $entry (@contents) {
         my $perms = (split(/\s+/ => $entry))[0];
         my @chars = split('' => $perms);
-        push @directory_or_not,
-            ($chars[0] eq 'd' ? 1 : 0);
-    }
+            push @directory_or_not,
+          ($chars[0] eq 'd' ? 1 : 0);
+      }
 
-    # create a new tarball with the same content as the old one
-    my $old = Archive::Tar->new($archive_name);
-    my $new = Archive::Tar->new();
-    $new->add_files( $old->get_files );
+      # create a new tarball with the same content as the old one
+      my $old = Archive::Tar->new($archive_name);
+      my $new = Archive::Tar->new();
+      $new->add_files( $old->get_files );
 
-    # save differently if compressed
-    my $ext = ( split /\./, $archive_name )[-1];
-    my @compress =
+      # save differently if compressed
+      my $ext = ( split /\./, $archive_name )[-1];
+      my @compress =
         $ext =~ /t?gz$/       ? (COMPRESS_GZIP)
-      : $ext =~ /(tbz|bz2?)$/ ? (COMPRESS_BZIP)
-      : ();
+          : $ext =~ /(tbz|bz2?)$/ ? (COMPRESS_BZIP)
+          : ();
 
-    my ( $fh, $filename ) = tempfile( UNLINK => 1 );
-    $new->write( $filename, @compress );
+      my ( $fh, $filename ) = tempfile( UNLINK => 1 );
+      $new->write( $filename, @compress );
 
-    # read the archive again from disk
-    $new = Archive::Tar->new($filename);
+      # read the archive again from disk
+      $new = Archive::Tar->new($filename);
 
-    # Adjust our expectations of
-    my @oldfiles = $old->list_files;
-    for (my $i = 0; $i <= $#oldfiles; $i++) {
+      # Adjust our expectations of
+      my @oldfiles = $old->list_files;
+      for (my $i = 0; $i <= $#oldfiles; $i++) {
         chop $oldfiles[$i] if $directory_or_not[$i];
-    }
+      }
 
-    # compare list of files
-    is_deeply(
-        [ $new->list_files ],
-        [ @oldfiles ],
-        "$archive_name roundtrip on file names"
-    );
+      # compare list of files
+      is_deeply(
+                [ $new->list_files ],
+                [ @oldfiles ],
+                "$archive_name roundtrip on file names"
+               );
+    }
   }
 }
diff --git a/t/porting/customized.dat b/t/porting/customized.dat
index 35b0db1..6543394 100644
--- a/t/porting/customized.dat
+++ b/t/porting/customized.dat
@@ -1,3 +1,5 @@
+Archive::Tar cpan/Archive-Tar/lib/Archive/Tar.pm 
89bcdfaed6b1716915a8cb46bc3b89a231e5a19e
+Archive::Tar cpan/Archive-Tar/t/09_roundtrip.t 
25278e593cc6b4a691d7d57e8cad938f6ac18a3b
 CPAN cpan/CPAN/lib/App/Cpan.pm 3cef68c2a44a4996b432bc25622e3a544a188aa5
 CPAN cpan/CPAN/lib/CPAN.pm 4616a44963045f7bd07bb7f8e5f99bbd789af4e5
 CPAN cpan/CPAN/scripts/cpan 22610ed0301d48a269d1739afd2f7f84359d956f

--
Perl5 Master Repository

Reply via email to