diff options
author | Steve Peters <steve@fisharerojo.org> | 2006-01-28 16:43:43 +0000 |
---|---|---|
committer | Steve Peters <steve@fisharerojo.org> | 2006-01-28 16:43:43 +0000 |
commit | b3200c5dd5a8045b8a8a1386ac9dfeaf534ff25f (patch) | |
tree | 48d0c710d322a4da6a247485d4e4e0783c1b63f2 /lib | |
parent | 5c1737d116a34c9fc2f84dad1ca8ff52ccdaaa64 (diff) | |
download | perl-b3200c5dd5a8045b8a8a1386ac9dfeaf534ff25f.tar.gz |
Upgrade to Archive-Tar-1.28
p4raw-id: //depot/perl@26985
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Archive/Tar.pm | 64 | ||||
-rw-r--r-- | lib/Archive/Tar/bin/ptardiff | 39 | ||||
-rw-r--r-- | lib/Archive/Tar/t/02_methods.t | 11 | ||||
-rw-r--r-- | lib/Archive/Tar/t/04_resolved_issues.t | 40 |
4 files changed, 149 insertions, 5 deletions
diff --git a/lib/Archive/Tar.pm b/lib/Archive/Tar.pm index 28338df2f7..044d9e8003 100644 --- a/lib/Archive/Tar.pm +++ b/lib/Archive/Tar.pm @@ -14,7 +14,7 @@ use vars qw[$DEBUG $error $VERSION $WARN $FOLLOW_SYMLINK $CHOWN $CHMOD $DEBUG = 0; $WARN = 1; $FOLLOW_SYMLINK = 0; -$VERSION = "1.26_01"; +$VERSION = "1.28"; $CHOWN = 1; $CHMOD = 1; $DO_NOT_USE_PREFIX = 0; @@ -134,6 +134,12 @@ installed, since it will transparently Do The Right Thing. Archive::Tar will warn if you try to pass a compressed file if IO::Zlib is not available and simply return. +Note that you can currently B<not> pass a C<gzip> compressed +filehandle, which is not opened with C<IO::Zlib>, nor a string +containing the full archive information (either compressed or +uncompressed). These are worth while features, but not currently +implemented. See the C<TODO> section. + The third argument can be a hash reference with options. Note that all options are case-sensitive. @@ -1100,9 +1106,45 @@ Will add a file to the in-memory archive, with name C<$filename> and content C<$data>. Specific properties can be set using C<$opthashref>. The following list of properties is supported: name, size, mtime (last modified date), mode, uid, gid, linkname, uname, gname, -devmajor, devminor, prefix. (On MacOS, the file's path and +devmajor, devminor, prefix, type. (On MacOS, the file's path and modification times are converted to Unix equivalents.) +Valid values for the file type are the following constants defined in +Archive::Tar::Constants: + +=over 4 + +=item FILE + +Regular file. + +=item HARDLINK + +=item SYMLINK + +Hard and symbolic ("soft") links; linkname should specify target. + +=item CHARDEV + +=item BLOCKDEV + +Character and block devices. devmajor and devminor should specify the major +and minor device numbers. + +=item DIR + +Directory. + +=item FIFO + +FIFO (named pipe). + +=item SOCKET + +Socket. + +=back + Returns the C<Archive::Tar::File> object that was just added, or C<undef> on failure. @@ -1250,8 +1292,10 @@ reference to an open file handle (e.g. a GLOB reference). If C<list_archive()> is passed an array reference as its third argument it returns a list of hash references containing the requested properties of each file. The following list of properties is -supported: name, size, mtime (last modified date), mode, uid, gid, -linkname, uname, gname, devmajor, devminor, prefix. +supported: full_path, name, size, mtime (last modified date), mode, +uid, gid, linkname, uname, gname, devmajor, devminor, prefix. + +See C<Archive::Tar::File> for details about supported properties. Passing an array reference containing only one element, 'name', is special cased to return a list of names rather than a list of hash @@ -1509,6 +1553,18 @@ write a C<.tar.Z> file Currently I don't know of any portable pure perl way to do this. Suggestions welcome. +=item Allow archives to be passed in as string + +Currently, we only allow opened filehandles or filenames, but +not strings. The internals would need some reworking to facilitate +stringified archives. + +=item Facilitate processing an opened filehandle of a compressed archive + +Currently, we only support this if the filehandle is an IO::Zlib object. +Environments, like apache, will present you with an opened filehandle +to an uploaded file, which might be a compressed archive. + =back =head1 AUTHOR diff --git a/lib/Archive/Tar/bin/ptardiff b/lib/Archive/Tar/bin/ptardiff index 19c9b90d2a..21e7d6cce5 100644 --- a/lib/Archive/Tar/bin/ptardiff +++ b/lib/Archive/Tar/bin/ptardiff @@ -71,3 +71,42 @@ See Also: ] . $/; } + + + +=head1 NAME + +ptardiff - program that diffs an extracted archive against an unextracted one + +=head1 DESCRIPTION + + ptardiff is a small program that diffs an extracted archive + against an unextracted one, using the perl module Archive::Tar. + + This effectively lets you view changes made to an archives contents. + + Provide the progam with an ARCHIVE_FILE and it will look up all + the files with in the archive, scan the current working directory + for a file with the name and diff it against the contents of the + archive. + +=head1 SYNOPSIS + + ptardiff ARCHIVE_FILE + ptardiff -h + + $ tar -xzf Acme-Buffy-1.3.tar.gz + $ vi Acme-Buffy-1.3/README + [...] + $ ptardiff Acme-Buffy-1.3.tar.gz > README.patch + + +=head1 OPTIONS + + h Prints this help message + +=head1 SEE ALSO + +tar(1), L<Archive::Tar>. + +=cut diff --git a/lib/Archive/Tar/t/02_methods.t b/lib/Archive/Tar/t/02_methods.t index c898a25524..be73ed8334 100644 --- a/lib/Archive/Tar/t/02_methods.t +++ b/lib/Archive/Tar/t/02_methods.t @@ -220,7 +220,16 @@ chmod 0644, $COMPRESS_FILE; is( scalar @files, scalar @add, "Adding files"); is( $files[0]->name, 'b', " Proper name" ); - is( $files[0]->is_file, 1, " Proper type" ); + + + use Config; + if ($ENV{PERL_CORE} and $Config{config_args} =~/Dmksymlinks/) { + ok( !$files[0]->is_file," Proper type" ); + } else { + is( $files[0]->is_file, 1, + " Proper type" ); + } + like( $files[0]->get_content, qr/^bbbbbbbbbbb\s*$/, " Content OK" ); diff --git a/lib/Archive/Tar/t/04_resolved_issues.t b/lib/Archive/Tar/t/04_resolved_issues.t index 9ebaa1609f..e733cc6707 100644 --- a/lib/Archive/Tar/t/04_resolved_issues.t +++ b/lib/Archive/Tar/t/04_resolved_issues.t @@ -57,3 +57,43 @@ use_ok( $Class ); ### remove the file unless( $NO_UNLINK ) { 1 while unlink $out } } + +### bug #14922 +### There's a bug in Archive::Tar that causes a file like: foo/foo.txt +### to be stored in the tar file as: foo/.txt +### XXX could not be reproduced in 1.26 -- leave test to be sure +{ my $dir = $$ . '/'; + my $file = $$ . '.txt'; + my $out = $$ . '.tar'; + + ### first create the file + { my $tar = $Class->new; + + isa_ok( $tar, $Class ); + ok( $tar->add_data( $dir.$file => $$ ), + " Added long file" ); + + ok( $tar->write($out), " File written to $out" ); + } + + ### then read it back in + { my $tar = $Class->new; + isa_ok( $tar, $Class ); + ok( $tar->read( $out ), " Read in $out again" ); + + my @files = $tar->get_files; + is( scalar(@files), 1, " Only 1 entry found" ); + + my $entry = shift @files; + ok( $entry->is_file, " Entry is a file" ); + is( $entry->full_path, $dir.$file, + " With the proper name" ); + } + + ### remove the file + unless( $NO_UNLINK ) { 1 while unlink $out } +} + + + + |