Update Archive::Tar to 1.46
authorJos I. Boumans <jos@dwim.org>
Thu, 5 Mar 2009 16:24:05 +0000 (17:24 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 15 Apr 2009 19:07:10 +0000 (20:07 +0100)
(cherry picked from commit bef46b70a2ecc24f7978a352079836f3e02b53bd)

13 files changed:
MANIFEST
lib/Archive/Tar.pm
lib/Archive/Tar/File.pm
lib/Archive/Tar/t/04_resolved_issues.t
lib/Archive/Tar/t/src/header/signed.tar.packed [new file with mode: 0644]
lib/Archive/Tar/t/src/linktest/linktest_missing_dir.tar.packed
lib/Archive/Tar/t/src/linktest/linktest_with_dir.tar.packed
lib/Archive/Tar/t/src/long/bar.tar.packed
lib/Archive/Tar/t/src/long/foo.tbz.packed
lib/Archive/Tar/t/src/long/foo.tgz.packed
lib/Archive/Tar/t/src/short/bar.tar.packed
lib/Archive/Tar/t/src/short/foo.tbz.packed
lib/Archive/Tar/t/src/short/foo.tgz.packed

index 1d6e83d..68d8b89 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -1685,6 +1685,7 @@ lib/Archive/Tar/t/04_resolved_issues.t    Archive::Tar tests
 lib/Archive/Tar/t/05_iter.t    Archive::Tar tests
 lib/Archive/Tar/t/90_symlink.t Archive::Tar tests
 lib/Archive/Tar/t/99_pod.t     Archive::Tar tests
+lib/Archive/Tar/t/src/header/signed.tar.packed Archive::Tar tests
 lib/Archive/Tar/t/src/linktest/linktest_missing_dir.tar.packed Archive::Tar tests
 lib/Archive/Tar/t/src/linktest/linktest_with_dir.tar.packed    Archive::Tar tests
 lib/Archive/Tar/t/src/long/b   Archive::Tar tests
index db46367..09dab10 100644 (file)
@@ -27,11 +27,11 @@ use vars qw[$DEBUG $error $VERSION $WARN $FOLLOW_SYMLINK $CHOWN $CHMOD
          ];
 
 @ISA                    = qw[Exporter];
-@EXPORT                 = ( COMPRESS_GZIP, COMPRESS_BZIP );
+@EXPORT                 = qw[ COMPRESS_GZIP COMPRESS_BZIP ];
 $DEBUG                  = 0;
 $WARN                   = 1;
 $FOLLOW_SYMLINK         = 0;
-$VERSION                = "1.44";
+$VERSION                = "1.46";
 $CHOWN                  = 1;
 $CHMOD                  = 1;
 $DO_NOT_USE_PREFIX      = 0;
@@ -68,8 +68,8 @@ Archive::Tar - module for manipulations of tar archives
     $tar->rename('oldname', 'new/file/name');
 
     $tar->write('files.tar');                   # plain tar
-    $tar->write('files.tgz', COMPRESSED_GZIP);  # gzip compressed
-    $tar->write('files.tbz', COMPRESSED_BZIP);  # bzip2 compressed
+    $tar->write('files.tgz', COMPRESS_GZIP);    # gzip compressed
+    $tar->write('files.tbz', COMPRESS_BZIP);    # bzip2 compressed
 
 =head1 DESCRIPTION
 
@@ -1073,10 +1073,10 @@ to be the C<gzip> compression level (between 1 and 9), but the use of
 constants is prefered:
 
   # write a gzip compressed file
-  $tar->write( 'out.tgz', COMPRESSION_GZIP );
+  $tar->write( 'out.tgz', COMPRESS_GZIP );
 
   # write a bzip compressed file
-  $tar->write( 'out.tbz', COMPRESSION_BZIP );
+  $tar->write( 'out.tbz', COMPRESS_BZIP );
 
 Note that when you pass in a filehandle, the compression argument
 is ignored, as all files are printed verbatim to your filehandle.
@@ -1503,10 +1503,10 @@ to be the C<gzip> compression level (between 1 and 9), but the use of
 constants is prefered:
 
   # write a gzip compressed file
-  Archive::Tar->create_archive( 'out.tgz', COMPRESSION_GZIP, @filelist );
+  Archive::Tar->create_archive( 'out.tgz', COMPRESS_GZIP, @filelist );
 
   # write a bzip compressed file
-  Archive::Tar->create_archive( 'out.tbz', COMPRESSION_BZIP, @filelist );
+  Archive::Tar->create_archive( 'out.tbz', COMPRESS_BZIP, @filelist );
 
 Note that when you pass in a filehandle, the compression argument
 is ignored, as all files are printed verbatim to your filehandle.
index ead236f..ee5e120 100644 (file)
@@ -492,7 +492,14 @@ sub validate {
 
     ### don't know why this one is different from the one we /write/ ###
     substr ($raw, 148, 8) = "        ";
-       return unpack ("%16C*", $raw) == $self->chksum ? 1 : 0;
+
+    ### bug #43513: [PATCH] Accept wrong checksums from SunOS and HP-UX tar
+    ### like GNU tar does. See here for details:
+    ### http://www.gnu.org/software/tar/manual/tar.html#SEC139
+    ### so we do both a signed AND unsigned validate. if one succeeds, that's
+    ### good enough
+       return (   (unpack ("%16C*", $raw) == $self->chksum)
+               or (unpack ("%16c*", $raw) == $self->chksum)) ? 1 : 0;
 }
 
 =head2 $bool = $file->has_content
index eba271f..89756cd 100644 (file)
@@ -149,6 +149,21 @@ use_ok( $FileClass );
         ### and clean up
         unless( $NO_UNLINK ) { 1 while unlink $out_file };
     }    
-    
+}
 
+### bug #43513: [PATCH] Accept wrong checksums from SunOS and HP-UX tar
+### like GNU tar does. See here for details:
+### http://www.gnu.org/software/tar/manual/tar.html#SEC139
+{   ok( 1,                      "Testing bug 43513" );
+    
+    my $src = File::Spec->catfile( qw[src header signed.tar] );
+    my $tar = $Class->new;
+    
+    isa_ok( $tar, $Class,       "   Object" );
+    ok( $tar->read( $src ),     "   Read non-Posix file with signed Checksum" );
+        
+    for my $file ( $tar->get_files ) {
+        ok( $file,              "       File object retrieved" );
+        ok( $file->validate,    "           File validates" );
+    }        
 }
diff --git a/lib/Archive/Tar/t/src/header/signed.tar.packed b/lib/Archive/Tar/t/src/header/signed.tar.packed
new file mode 100644 (file)
index 0000000..e8d5bc8
--- /dev/null
@@ -0,0 +1,243 @@
+#########################################################################
+This is a binary file that was packed with the 'uupacktool.pl' which
+is included in the Perl distribution.
+
+To unpack this file use the following command:
+
+     uupacktool.pl -u lib/Archive/Tar/t/src/header/signed.tar.packed lib/Archive/Tar/t/src/header/signed.tar
+
+To recreate it use the following command:
+
+     uupacktool.pl -p lib/Archive/Tar/t/src/header/signed.tar lib/Archive/Tar/t/src/header/signed.tar.packed
+
+Created at Thu Mar  5 17:07:54 2009
+#########################################################################
+__UU__
+MPZ3#I,.D````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````#`P,#8P,"``,3,S-#8W(``P,C,T,C`@`#`P,#`P,#`P,#`U
+M(#$Q,34P,S(V-#(R(#`Q,#0V,2``,```````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!U<W1A<@`P,&YT>6YI
+M````````````````````````````````````871K;W,`````````````````
+M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````!T97-T"@``````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+9````````````````````````````````````
index afaba77..2cd0987 100644 (file)
@@ -10,7 +10,7 @@ To recreate it use the following command:
 
      uupacktool.pl -p lib/Archive/Tar/t/src/linktest/linktest_missing_dir.tar lib/Archive/Tar/t/src/linktest/linktest_missing_dir.tar.packed
 
-Created at Tue Jan 20 14:58:16 2009
+Created at Thu Mar  5 17:07:54 2009
 #########################################################################
 __UU__
 M;&EN:W1E<W0O;&EN:P``````````````````````````````````````````
index 30cbed8..50ecaeb 100644 (file)
@@ -10,7 +10,7 @@ To recreate it use the following command:
 
      uupacktool.pl -p lib/Archive/Tar/t/src/linktest/linktest_with_dir.tar lib/Archive/Tar/t/src/linktest/linktest_with_dir.tar.packed
 
-Created at Tue Jan 20 14:58:16 2009
+Created at Thu Mar  5 17:07:54 2009
 #########################################################################
 __UU__
 M;&EN:W1E<W0O;W)I9R\`````````````````````````````````````````
index 7eed4f8..1379fee 100644 (file)
@@ -10,7 +10,7 @@ To recreate it use the following command:
 
      uupacktool.pl -p lib/Archive/Tar/t/src/long/bar.tar lib/Archive/Tar/t/src/long/bar.tar.packed
 
-Created at Tue Jan 20 14:58:17 2009
+Created at Thu Mar  5 17:07:54 2009
 #########################################################################
 __UU__
 M8P``````````````````````````````````````````````````````````
index 418c0bc..705f5bf 100644 (file)
@@ -10,7 +10,7 @@ To recreate it use the following command:
 
      uupacktool.pl -p lib/Archive/Tar/t/src/long/foo.tbz lib/Archive/Tar/t/src/long/foo.tbz.packed
 
-Created at Tue Jan 20 14:58:17 2009
+Created at Thu Mar  5 17:07:54 2009
 #########################################################################
 __UU__
 M0EIH.3%!62936=873NT``9C_A._0`DA``_^`0`0)`._OGJ```40(,`%X9`8`
index 05088ae..6de253c 100644 (file)
@@ -10,7 +10,7 @@ To recreate it use the following command:
 
      uupacktool.pl -p lib/Archive/Tar/t/src/long/foo.tgz lib/Archive/Tar/t/src/long/foo.tgz.packed
 
-Created at Tue Jan 20 14:58:17 2009
+Created at Thu Mar  5 17:07:54 2009
 #########################################################################
 __UU__
 M'XL(`````````^W72VZ#,!`&8*]S"BY`F,$/MCT`ET")25`<D"A1Q.UKR*M1
index 5cad235..18399eb 100644 (file)
@@ -10,7 +10,7 @@ To recreate it use the following command:
 
      uupacktool.pl -p lib/Archive/Tar/t/src/short/bar.tar lib/Archive/Tar/t/src/short/bar.tar.packed
 
-Created at Tue Jan 20 14:58:17 2009
+Created at Thu Mar  5 17:07:54 2009
 #########################################################################
 __UU__
 M8P``````````````````````````````````````````````````````````
index 3443d12..ff0f7e4 100644 (file)
@@ -10,7 +10,7 @@ To recreate it use the following command:
 
      uupacktool.pl -p lib/Archive/Tar/t/src/short/foo.tbz lib/Archive/Tar/t/src/short/foo.tbz.packed
 
-Created at Tue Jan 20 14:58:17 2009
+Created at Thu Mar  5 17:07:54 2009
 #########################################################################
 __UU__
 M0EIH.3%!62936>GH,8X``)O[A.90`D!``'^```#O*1X```%`""``E(*JGDA#
index ae190a7..67af0ed 100644 (file)
@@ -10,7 +10,7 @@ To recreate it use the following command:
 
      uupacktool.pl -p lib/Archive/Tar/t/src/short/foo.tgz lib/Archive/Tar/t/src/short/foo.tgz.packed
 
-Created at Tue Jan 20 14:58:17 2009
+Created at Thu Mar  5 17:07:54 2009
 #########################################################################
 __UU__
 M'XL(`````````^W300K",!"%X5GW%#G"3-JFYREJ080NJKU_A^A"$.RJ(\+_