r29018 - in /trunk/libarchive-tar-perl: CHANGES META.yml debian/changelog lib/Archive/Tar.pm lib/Archive/Tar/Constant.pm t/02_methods.t

gregoa at users.alioth.debian.org gregoa at users.alioth.debian.org
Thu Jan 1 16:47:36 UTC 2009


Author: gregoa
Date: Thu Jan  1 16:47:33 2009
New Revision: 29018

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=29018
Log:
New upstream release.

Modified:
    trunk/libarchive-tar-perl/CHANGES
    trunk/libarchive-tar-perl/META.yml
    trunk/libarchive-tar-perl/debian/changelog
    trunk/libarchive-tar-perl/lib/Archive/Tar.pm
    trunk/libarchive-tar-perl/lib/Archive/Tar/Constant.pm
    trunk/libarchive-tar-perl/t/02_methods.t

Modified: trunk/libarchive-tar-perl/CHANGES
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libarchive-tar-perl/CHANGES?rev=29018&op=diff
==============================================================================
--- trunk/libarchive-tar-perl/CHANGES (original)
+++ trunk/libarchive-tar-perl/CHANGES Thu Jan  1 16:47:33 2009
@@ -1,3 +1,12 @@
+* important changes in version 1.42 13/12/2008:
+- Address #40426: Archive Tar to support direct Archive::Tar::File adds
+  It is now possible to add Archive::Tar::File objects via $tar->add_files
+- Address #40016 (Archive::Tar assumes $> won't change): CAN_CHOWN is now a
+  dynamic check upon extraction. This allows scripts to drop privileges when
+  desired
+- Address take 2 of #39933: [PATCH] handle ../ directory name on VMS
+  John M. sent in a better way to do directory name translation.
+ 
 * important changes in version 1.40 13/10/2008:
 - Add $class->has_zlib_support and $class->has_bzip2_support to
   discern which A::T can support

Modified: trunk/libarchive-tar-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libarchive-tar-perl/META.yml?rev=29018&op=diff
==============================================================================
--- trunk/libarchive-tar-perl/META.yml (original)
+++ trunk/libarchive-tar-perl/META.yml Thu Jan  1 16:47:33 2009
@@ -1,7 +1,7 @@
 # http://module-build.sourceforge.net/META-spec.html
 #XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
 name:         Archive-Tar
-version:      1.40
+version:      1.42
 version_from: lib/Archive/Tar.pm
 installdirs:  site
 requires:

Modified: trunk/libarchive-tar-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libarchive-tar-perl/debian/changelog?rev=29018&op=diff
==============================================================================
--- trunk/libarchive-tar-perl/debian/changelog (original)
+++ trunk/libarchive-tar-perl/debian/changelog Thu Jan  1 16:47:33 2009
@@ -1,4 +1,4 @@
-libarchive-tar-perl (1.40-1) UNRELEASED; urgency=low
+libarchive-tar-perl (1.42-1) UNRELEASED; urgency=low
 
   [ gregor herrmann ]
   REMOVED from unstable and testing

Modified: trunk/libarchive-tar-perl/lib/Archive/Tar.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libarchive-tar-perl/lib/Archive/Tar.pm?rev=29018&op=diff
==============================================================================
--- trunk/libarchive-tar-perl/lib/Archive/Tar.pm (original)
+++ trunk/libarchive-tar-perl/lib/Archive/Tar.pm Thu Jan  1 16:47:33 2009
@@ -31,7 +31,7 @@
 $DEBUG                  = 0;
 $WARN                   = 1;
 $FOLLOW_SYMLINK         = 0;
-$VERSION                = "1.40";
+$VERSION                = "1.42";
 $CHOWN                  = 1;
 $CHMOD                  = 1;
 $DO_NOT_USE_PREFIX      = 0;
@@ -689,10 +689,11 @@
             }
         }
 
-        
-        ### '.' is the directory delimiter, of which the first one has to
-        ### be escaped/changed.
-        map tr/\./_/, @dirs if ON_VMS;        
+        ### '.' is the directory delimiter on VMS, which has to be escaped
+        ### or changed to '_' on vms.  vmsify is used, because older versions
+        ### of vmspath do not handle this properly.
+        ### Must not add a '/' to an empty directory though.
+        map { length() ? VMS::Filespec::vmsify($_.'/') : $_ } @dirs if ON_VMS;        
 
         my ($cwd_vol,$cwd_dir,$cwd_file) 
                     = File::Spec->splitpath( $cwd );
@@ -714,7 +715,8 @@
                             $cwd_vol, File::Spec->catdir( @cwd, @dirs ), '' 
                         );
 
-        ### catdir() returns undef if the path is longer than 255 chars on VMS
+        ### catdir() returns undef if the path is longer than 255 chars on 
+        ### older VMS systems.
         unless ( defined $dir ) {
             $^W && $self->_error( qq[Could not compose a path for '$dirs'\n] );
             return;
@@ -789,7 +791,7 @@
             $self->_error( qq[Could not update timestamp] );
     }
 
-    if( $CHOWN && CAN_CHOWN ) {
+    if( $CHOWN && CAN_CHOWN->() ) {
         chown $entry->uid, $entry->gid, $full or
             $self->_error( qq[Could not set uid/gid on '$full'] );
     }
@@ -1298,6 +1300,10 @@
 Be aware that the file's type/creator and resource fork will be lost,
 which is usually what you want in cross-platform archives.
 
+Instead of a filename, you can also pass it an existing C<Archive::Tar::File>
+object from, for example, another archive. The object will be clone, and
+effectively be a copy of the original, not an alias.
+
 Returns a list of C<Archive::Tar::File> objects that were just added.
 
 =cut
@@ -1308,6 +1314,15 @@
 
     my @rv;
     for my $file ( @files ) {
+
+        ### you passed an Archive::Tar::File object
+        ### clone it so we don't accidentally have a reference to
+        ### an object from another archive
+        if( UNIVERSAL::isa( $file,'Archive::Tar::File' ) ) {
+            push @rv, $file->clone; 
+            next;
+        }
+    
         unless( -e $file || -l $file ) {
             $self->_error( qq[No such file: '$file'] );
             next;

Modified: trunk/libarchive-tar-perl/lib/Archive/Tar/Constant.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libarchive-tar-perl/lib/Archive/Tar/Constant.pm?rev=29018&op=diff
==============================================================================
--- trunk/libarchive-tar-perl/lib/Archive/Tar/Constant.pm (original)
+++ trunk/libarchive-tar-perl/lib/Archive/Tar/Constant.pm Thu Jan  1 16:47:33 2009
@@ -78,7 +78,7 @@
 use constant GZIP_MAGIC_NUM => qr/^(?:\037\213|\037\235)/;
 use constant BZIP_MAGIC_NUM => qr/^BZh\d/;
 
-use constant CAN_CHOWN      => do { ($> == 0 and $^O ne "MacOS" and $^O ne "MSWin32") };
+use constant CAN_CHOWN      => sub { ($> == 0 and $^O ne "MacOS" and $^O ne "MSWin32") };
 use constant CAN_READLINK   => ($^O ne 'MSWin32' and $^O !~ /RISC(?:[ _])?OS/i and $^O ne 'VMS');
 use constant ON_UNIX        => ($^O ne 'MSWin32' and $^O ne 'MacOS' and $^O ne 'VMS');
 use constant ON_VMS         => $^O eq 'VMS'; 

Modified: trunk/libarchive-tar-perl/t/02_methods.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libarchive-tar-perl/t/02_methods.t?rev=29018&op=diff
==============================================================================
--- trunk/libarchive-tar-perl/t/02_methods.t (original)
+++ trunk/libarchive-tar-perl/t/02_methods.t Thu Jan  1 16:47:33 2009
@@ -25,6 +25,7 @@
 use Archive::Tar::Constant;
 
 my $Class   = 'Archive::Tar';
+my $FClass  = $Class . '::File';
 use_ok( $Class );
 
 
@@ -114,7 +115,7 @@
 {   my $tar     = $Class->new;
 
     ok( $tar,                       "Object created" );
-    isa_ok( $tar,                   'Archive::Tar');
+    isa_ok( $tar,                   $Class );
 
     local $Archive::Tar::WARN  = 0;
 
@@ -166,26 +167,26 @@
         my $tar             = $Class->new;
 
         ### check we got the object
-        ok( $tar,                       "Object created" );
-        isa_ok( $tar,                   'Archive::Tar');
+        ok( $tar,               "Object created" );
+        isa_ok( $tar,           $Class );
 
         ### ->read test
         my @list    = $tar->read( $type );
         my $cnt     = scalar @list;
         my $expect  = scalar __PACKAGE__->get_expect();
 
-        ok( $cnt,           "Reading '$type' using 'read()'" );
-        is( $cnt, $expect,  "   All files accounted for" );
+        ok( $cnt,               "Reading '$type' using 'read()'" );
+        is( $cnt, $expect,      "   All files accounted for" );
 
         for my $file ( @list ) {
-            ok( $file,      "Got File object" );
-            isa_ok( $file,  "Archive::Tar::File" );
+            ok( $file,          "       Got File object" );
+            isa_ok( $file,  $FClass );
 
             ### whitebox test -- make sure find_entry gets the
             ### right files
             for my $test ( $file->full_path, $file ) {
                 is( $tar->_find_entry( $test ), $file,
-                            "   Found proper object" );
+                                "           Found proper object" );
             }
             
             next unless $file->is_file;
@@ -195,10 +196,10 @@
                 get_expect_name_and_contents( $name, \@EXPECT_NORMAL );
 
             ### ->fullname!
-            ok($expect_name,"   Found expected file '$name'" );
+            ok($expect_name,    "           Found expected file '$name'" );
 
             like($tar->get_content($name), $expect_content,
-                            "   Content OK" );
+                                "           Content OK" );
         }
 
 
@@ -230,30 +231,30 @@
 
     ### check we got the object
     ok( $tar,                       "Object created" );
-    isa_ok( $tar,                   'Archive::Tar');
+    isa_ok( $tar,                   $Class );
 
     ### add the files
     {   my @files = $tar->add_files( @add );
 
         is( scalar @files, scalar @add,
-                                    "Adding files");
-        is( $files[0]->name, 'b',   "   Proper name" );
+                                    "   Adding files");
+        is( $files[0]->name,'b',    "      Proper name" );
 
         SKIP: {
             skip( "You are building perl using symlinks", 1)
                 if ($ENV{PERL_CORE} and $Config{config_args} =~/Dmksymlinks/);
 
             is( $files[0]->is_file, 1,  
-                                    "   Proper type" );
+                                    "       Proper type" );
         }
 
         like( $files[0]->get_content, qr/^bbbbbbbbbbb\s*$/,
-                                    "   Content OK" );
+                                    "       Content OK" );
 
         ### check if we have then in our tar object
         for my $file ( @addunix ) {
             ok( $tar->contains_file($file),
-                                    "   File found in archive" );
+                                    "       File found in archive" );
         }
     }
 
@@ -263,17 +264,33 @@
         my @added   = $tar2->add_files( $COMPRESS_FILE );
         my @count   = $tar2->list_files;
 
-        is( scalar @added, 1,       "Added files to secondary archive" );
+        is( scalar @added, 1,       "   Added files to secondary archive" );
         is( scalar @added, scalar @count,
-                                    "   Does not conflict with first archive" );
+                                    "       No conflict with first archive" );
 
         ### check the adding of directories
         my @add_dirs  = File::Spec->catfile( @ROOT );
         my @dirs      = $tar2->add_files( @add_dirs );
         is( scalar @dirs, scalar @add_dirs,
-                                    "Adding dirs");
-        ok( $dirs[0]->is_dir,       "   Proper type" );
-    }
+                                    "       Adding dirs");
+        ok( $dirs[0]->is_dir,       "           Proper type" );
+    }
+    
+    ### check if we can add a A::T::File object
+    {   my $tar2    = $Class->new;
+        my($added)  = $tar2->add_files( $add[0] );
+        
+        ok( $added,                 "   Added a file '$add[0]' to new object" );
+        isa_ok( $added, $FClass,    "       Object" );           
+
+        my($added2) = $tar2->add_files( $added );
+        ok( $added2,                "       Added an $FClass object" );
+        isa_ok( $added2, $FClass,   "           Object" );           
+        
+        is_deeply( [$added, $added2], [$tar2->get_files],
+                                    "       All files accounted for" );
+        isnt( $added, $added2,      "       Different memory allocations" );
+    }        
 }
 
 ### add data tests ###
@@ -284,16 +301,16 @@
 
         ### check we got the object
         ok( $tar,                   "Object created" );
-        isa_ok( $tar,               'Archive::Tar');
+        isa_ok( $tar,               $Class );
 
         ### add a new file item as data
         my $obj = $tar->add_data( @to_add );
 
-        ok( $obj,                   "Adding data" );
-        is( $obj->name, $to_add[0], "   Proper name" );
-        is( $obj->is_file, 1,       "   Proper type" );
+        ok( $obj,                   "   Adding data" );
+        is( $obj->name, $to_add[0], "       Proper name" );
+        is( $obj->is_file, 1,       "       Proper type" );
         like( $obj->get_content, qr/^$to_add[1]\s*$/,
-                                    "   Content OK" );
+                                    "       Content OK" );
     }
 
     {   ### binary data +
@@ -313,12 +330,12 @@
 
                 my $obj = $tar->add_data( $path, $data );
 
-                ok( $obj,               "Adding data '$file'" );
+                ok( $obj,               "   Adding data '$file'" );
                 is( $obj->full_path, $path,
-                                        "   Proper name" );
-                ok( $obj->is_file,      "   Proper type" );
+                                        "       Proper name" );
+                ok( $obj->is_file,      "       Proper type" );
                 is( $obj->get_content, $data,
-                                        "   Content OK" );
+                                        "       Content OK" );
             }
         }
     }
@@ -363,7 +380,7 @@
 
     ### remove returns the files left, which should be equal to list_files
     is( scalar($tar->remove($remove)), scalar($tar->list_files),
-                                    "Removing file '$remove'" );
+                                    "   Removing file '$remove'" );
 
     ### so what's left should be all expected files minus 1
     is( scalar($tar->list_files), scalar(__PACKAGE__->get_expect) - 1,
@@ -389,9 +406,9 @@
 
         ### check if we stringify it ok
         {   my $string = $obj->write;
-            ok( $string,           "Stringified tar file has size" );
+            ok( $string,           "    Stringified tar file has size" );
             cmp_ok( length($string) % BLOCK, '==', 0,
-                                    "Tar archive stringified" );
+                                    "       Tar archive stringified" );
         }
 
         ### write tar tests
@@ -399,18 +416,18 @@
 
             {   ### write()
                 ok( $obj->write($out),
-                                    "Wrote tarfile using 'write'" );
+                                    "       Wrote tarfile using 'write'" );
                 check_tar_file( $out );
                 check_tar_object( $obj, $struct );
 
                 ### now read it in again
                 ok( $new->read( $out ),
-                                    "Read '$out' in again" );
+                                    "       Read '$out' in again" );
 
                 check_tar_object( $new, $struct );
 
                 ### now extract it again
-                ok( $new->extract,  "Extracted '$out' with 'extract'" );
+                ok( $new->extract,  "       Extracted '$out' with 'extract'" );
                 check_tar_extract( $new, $struct );
 
                 rm( $out ) unless $NO_UNLINK;
@@ -419,12 +436,12 @@
 
             {   ### create_archive()
                 ok( $Class->create_archive( $out, 0, $COMPRESS_FILE ),
-                                    "Wrote tarfile using 'create_archive'" );
+                                    "       Wrote tarfile using 'create_archive'" );
                 check_tar_file( $out );
 
                 ### now extract it again
                 ok( $Class->extract_archive( $out ),
-                                    "Extracted file using 'extract_archive'");
+                                    "       Extracted file using 'extract_archive'");
                 rm( $out ) unless $NO_UNLINK;
             }
         }
@@ -440,19 +457,19 @@
 
                 {   ### write()
                     ok($obj->write($out, $compression),
-                                    "Writing compressed file '$out' using 'write'" );
+                                    "       Writing compressed file '$out' using 'write'" );
                     check_compressed_file( $out );
 
                     check_tar_object( $obj, $struct );
 
                     ### now read it in again
                     ok( $new->read( $out ),
-                                    "Read '$out' in again" );
+                                    "       Read '$out' in again" );
                     check_tar_object( $new, $struct );
 
                     ### now extract it again
                     ok( $new->extract,
-                                    "Extracted '$out' again" );
+                                    "       Extracted '$out' again" );
                     check_tar_extract( $new, $struct );
 
                     rm( $out ) unless $NO_UNLINK;
@@ -460,12 +477,12 @@
 
                 {   ### create_archive()
                     ok( $Class->create_archive( $out, $compression, $COMPRESS_FILE ),
-                                    "Wrote '$out' using 'create_archive'" );
+                                    "       Wrote '$out' using 'create_archive'" );
                     check_compressed_file( $out );
 
                     ### now extract it again
                     ok( $Class->extract_archive( $out, $compression ),
-                                    "Extracted file using 'extract_archive'");
+                                    "       Extracted file using 'extract_archive'");
                     rm( $out ) unless $NO_UNLINK;
                 }
             }
@@ -494,8 +511,8 @@
         for my $arg ( $obj, $obj->full_path ) {
 
             ok( $tar->$meth( $arg ),
-                                    "Extracted '$name' to cwd() with $meth" );
-            ok( -e $obj->full_path, "   Extracted file exists" );
+                                    "   Extract '$name' to cwd() with $meth" );
+            ok( -e $obj->full_path, "       Extracted file exists" );
             rm( $obj->full_path ) unless $NO_UNLINK;
         }
     }
@@ -507,8 +524,8 @@
         my $outfile = File::Spec->catfile( $outpath, $$ ); #$obj->full_path );
 
         ok( $tar->$meth( $obj->full_path, $outfile ),
-                                    "Extracted file '$name' to $outpath with $meth" );
-        ok( -e $outfile,            "   Extracted file '$outfile' exists" );
+                                    "   Extract file '$name' to $outpath with $meth" );
+        ok( -e $outfile,            "       Extracted file '$outfile' exists" );
         rm( $outfile ) unless $NO_UNLINK;
     }
 
@@ -537,7 +554,7 @@
         my $file    = File::Basename::basename( $COMPRESS_FILE );
 
         ok( $obj,                   "File added" );
-        isa_ok( $obj,               "Archive::Tar::File" );
+        isa_ok( $obj,               $FClass );
 
         ### internal storage ###
         is( $obj->name, $file,      "   Name set to '$file'" );
@@ -557,18 +574,18 @@
 
     ### now read it back in, there should be no prefix
     {   ok( $tar->read( $OUT_TAR_FILE ),
-                                    "Tar file read in again" );
+                                    "   Tar file read in again" );
 
         my ($obj) = $tar->get_files;
-        ok( $obj,                   "   File retrieved" );
-        isa_ok( $obj,               "Archive::Tar::File" );
+        ok( $obj,                   "       File retrieved" );
+        isa_ok( $obj, $FClass,      "       Object" );
 
         is( $obj->name, $COMPRESS_FILE,
-                                    "   Name now set to '$COMPRESS_FILE'" );
-        is( $obj->prefix, '',       "   Prefix now empty" );
+                                    "       Name now set to '$COMPRESS_FILE'" );
+        is( $obj->prefix, '',       "       Prefix now empty" );
 
         my $re = quotemeta $COMPRESS_FILE;
-        like( $obj->raw, qr/^$re/,  "   Prefix + name in name slot of header" );
+        like( $obj->raw, qr/^$re/,  "       Prefix + name in name slot of header" );
     }
 
     rm( $OUT_TAR_FILE ) unless $NO_UNLINK;




More information about the Pkg-perl-cvs-commits mailing list