/usr/share/perl5/Archive/Tar/Wrapper.pm is in libarchive-tar-wrapper-perl 0.21-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 | ###########################################
package Archive::Tar::Wrapper;
###########################################
use strict;
use warnings;
use File::Temp qw(tempdir);
use Log::Log4perl qw(:easy);
use File::Spec::Functions;
use File::Spec;
use File::Path;
use File::Copy;
use File::Find;
use File::Basename;
use File::Which qw(which);
use IPC::Run qw(run);
use Cwd;
our $VERSION = "0.21";
###########################################
sub new {
###########################################
my($class, %options) = @_;
my $self = {
tar => undef,
tmpdir => undef,
tar_read_options => '',
tar_write_options => '',
tar_gnu_read_options => [],
dirs => 0,
max_cmd_line_args => 512,
ramdisk => undef,
%options,
};
bless $self, $class;
$self->{tar} = which("tar") unless defined $self->{tar};
$self->{tar} = which("gtar") unless defined $self->{tar};
if( ! defined $self->{tar} ) {
LOGDIE "tar not found in PATH, please specify location";
}
if(defined $self->{ramdisk}) {
my $rc = $self->ramdisk_mount( %{ $self->{ramdisk} } );
if(!$rc) {
LOGDIE "Mounting ramdisk failed";
}
$self->{tmpdir} = $self->{ramdisk}->{tmpdir};
} else {
$self->{tmpdir} = tempdir($self->{tmpdir} ?
(DIR => $self->{tmpdir}) : ());
}
$self->{tardir} = File::Spec->catfile($self->{tmpdir}, "tar");
mkpath [$self->{tardir}], 0, 0755 or
LOGDIE "Cannot mkpath $self->{tardir} ($!)";
$self->{objdir} = tempdir();
return $self;
}
###########################################
sub tardir {
###########################################
my($self) = @_;
return $self->{tardir};
}
###########################################
sub read {
###########################################
my($self, $tarfile, @files) = @_;
my $cwd = getcwd();
unless(File::Spec::Functions::file_name_is_absolute($tarfile)) {
$tarfile = File::Spec::Functions::rel2abs($tarfile, $cwd);
}
chdir $self->{tardir} or
LOGDIE "Cannot chdir to $self->{tardir}";
my $compr_opt = "";
$compr_opt = $self->is_compressed($tarfile);
my $cmd = [$self->{tar}, "${compr_opt}x$self->{tar_read_options}",
@{$self->{tar_gnu_read_options}},
"-f", $tarfile, @files];
DEBUG "Running @$cmd";
my $rc = run($cmd, \my($in, $out, $err));
if(!$rc) {
ERROR "@$cmd failed: $err";
chdir $cwd or LOGDIE "Cannot chdir to $cwd";
return undef;
}
WARN $err if $err;
chdir $cwd or LOGDIE "Cannot chdir to $cwd";
return 1;
}
###########################################
sub is_compressed {
###########################################
my($self, $tarfile) = @_;
return 'z' if $tarfile =~ /\.t?gz$/i;
return 'j' if $tarfile =~ /\.bz2$/i;
# Sloppy check for gzip files
open FILE, "<$tarfile" or die "Cannot open $tarfile";
binmode FILE;
my $read = sysread(FILE, my $two, 2, 0) or die "Cannot sysread";
close FILE;
return 'z' if
ord(substr($two, 0, 1)) eq 0x1F and
ord(substr($two, 1, 1)) eq 0x8B;
return q{};
}
###########################################
sub locate {
###########################################
my($self, $rel_path) = @_;
my $real_path = File::Spec->catfile($self->{tardir}, $rel_path);
if(-e $real_path) {
DEBUG "$real_path exists";
return $real_path;
}
DEBUG "$real_path doesn't exist";
WARN "$rel_path not found in tarball";
return undef;
}
###########################################
sub add {
###########################################
my($self, $rel_path, $path_or_stringref, $opts) = @_;
if($opts) {
if(!ref($opts) or ref($opts) ne 'HASH') {
LOGDIE "Option parameter given to add() not a hashref.";
}
}
my $perm = $opts->{perm} if defined $opts->{perm};
my $uid = $opts->{uid} if defined $opts->{uid};
my $gid = $opts->{gid} if defined $opts->{gid};
my $binmode = $opts->{binmode} if defined $opts->{binmode};
my $target = File::Spec->catfile($self->{tardir}, $rel_path);
my $target_dir = dirname($target);
if( ! -d $target_dir ) {
if( ref($path_or_stringref) ) {
$self->add( dirname( $rel_path ), dirname( $target_dir ) );
} else {
$self->add( dirname( $rel_path ), dirname( $path_or_stringref ) );
}
}
if(ref($path_or_stringref)) {
open FILE, ">$target" or LOGDIE "Can't open $target ($!)";
if(defined $binmode) {
binmode FILE, $binmode;
}
print FILE $$path_or_stringref;
close FILE;
} elsif( -d $path_or_stringref ) {
# perms will be fixed further down
mkpath($target, 0, 0755) unless -d $target;
} else {
copy $path_or_stringref, $target or
LOGDIE "Can't copy $path_or_stringref to $target ($!)";
}
if(defined $uid) {
chown $uid, -1, $target or
LOGDIE "Can't chown $target uid to $uid ($!)";
}
if(defined $gid) {
chown -1, $gid, $target or
LOGDIE "Can't chown $target gid to $gid ($!)";
}
if(defined $perm) {
chmod $perm, $target or
LOGDIE "Can't chmod $target to $perm ($!)";
}
if(!defined $uid and
!defined $gid and
!defined $perm and
!ref($path_or_stringref)) {
perm_cp($path_or_stringref, $target) or
LOGDIE "Can't perm_cp $path_or_stringref to $target ($!)";
}
1;
}
######################################
sub perm_cp {
######################################
my($source, $target) = @_;
# Lifted from Ben Okopnik's
# http://www.linuxgazette.com/issue87/misc/tips/cpmod.pl.txt
my $perms = perm_get($source);
perm_set($target, $perms);
}
######################################
sub perm_get {
######################################
my($filename) = @_;
my @stats = (stat $filename)[2,4,5] or
LOGDIE "Cannot stat $filename ($!)";
return \@stats;
}
######################################
sub perm_set {
######################################
my($filename, $perms) = @_;
# ignore errors here, as we can't change uid/gid unless we're
# the superuser (see LIMITATIONS section)
chown($perms->[1], $perms->[2], $filename);
chmod($perms->[0] & 07777, $filename) or
LOGDIE "Cannot chmod $filename ($!)";
}
###########################################
sub remove {
###########################################
my($self, $rel_path) = @_;
my $target = File::Spec->catfile($self->{tardir}, $rel_path);
rmtree($target) or LOGDIE "Can't rmtree $target ($!)";
}
###########################################
sub list_all {
###########################################
my($self) = @_;
my @entries = ();
$self->list_reset();
while(my $entry = $self->list_next()) {
push @entries, $entry;
}
return \@entries;
}
###########################################
sub list_reset {
###########################################
my($self) = @_;
my $list_file = File::Spec->catfile($self->{objdir}, "list");
open FILE, ">$list_file" or LOGDIE "Can't open $list_file";
my $cwd = getcwd();
chdir $self->{tardir} or LOGDIE "Can't chdir to $self->{tardir} ($!)";
find(sub {
my $entry = $File::Find::name;
$entry =~ s#^\./##;
my $type = (-d $_ ? "d" :
-l $_ ? "l" :
"f"
);
print FILE "$type $entry\n";
}, ".");
chdir $cwd or LOGDIE "Can't chdir to $cwd ($!)";
close FILE;
$self->offset(0);
}
###########################################
sub list_next {
###########################################
my($self) = @_;
my $offset = $self->offset();
my $list_file = File::Spec->catfile($self->{objdir}, "list");
open FILE, "<$list_file" or LOGDIE "Can't open $list_file";
seek FILE, $offset, 0;
{ my $line = <FILE>;
return undef unless defined $line;
chomp $line;
my($type, $entry) = split / /, $line, 2;
redo if $type eq "d" and ! $self->{dirs};
$self->offset(tell FILE);
return [$entry, File::Spec->catfile($self->{tardir}, $entry),
$type];
}
}
###########################################
sub offset {
###########################################
my($self, $new_offset) = @_;
my $offset_file = File::Spec->catfile($self->{objdir}, "offset");
if(defined $new_offset) {
open FILE, ">$offset_file" or LOGDIE "Can't open $offset_file";
print FILE "$new_offset\n";
close FILE;
}
open FILE, "<$offset_file" or LOGDIE "Can't open $offset_file (Did you call list_next() without a previous list_reset()?)";
my $offset = <FILE>;
chomp $offset;
return $offset;
close FILE;
}
###########################################
sub write {
###########################################
my($self, $tarfile, $compress) = @_;
my $cwd = getcwd();
chdir $self->{tardir} or LOGDIE "Can't chdir to $self->{tardir} ($!)";
unless(File::Spec::Functions::file_name_is_absolute($tarfile)) {
$tarfile = File::Spec::Functions::rel2abs($tarfile, $cwd);
}
my $compr_opt = "";
$compr_opt = "z" if $compress;
opendir DIR, "." or LOGDIE "Cannot open $self->{tardir}";
my @top_entries = grep { $_ !~ /^\.\.?$/ } readdir DIR;
closedir DIR;
my $cmd;
if(@top_entries > $self->{max_cmd_line_args}) {
my $filelist_file = $self->{tmpdir}."/file-list";
open FLIST, ">$filelist_file" or
LOGDIE "Cannot open $filelist_file ($!)";
for(@top_entries) {
print FLIST "$_\n";
}
close FLIST;
$cmd = [$self->{tar}, "${compr_opt}cf$self->{tar_write_options}",
$tarfile, "-T", $filelist_file];
} else {
$cmd = [$self->{tar}, "${compr_opt}cf$self->{tar_write_options}",
$tarfile, @top_entries];
}
DEBUG "Running @$cmd";
my $rc = run($cmd, \my($in, $out, $err));
if(!$rc) {
ERROR "@$cmd failed: $err";
chdir $cwd or LOGDIE "Cannot chdir to $cwd";
return undef;
}
WARN $err if $err;
chdir $cwd or LOGDIE "Cannot chdir to $cwd";
return 1;
}
###########################################
sub DESTROY {
###########################################
my($self) = @_;
$self->ramdisk_unmount() if defined $self->{ramdisk};
rmtree($self->{objdir}) if defined $self->{objdir};
rmtree($self->{tmpdir}) if defined $self->{tmpdir};
}
###########################################
sub is_gnu {
###########################################
my($self) = @_;
open PIPE, "$self->{tar} --version |" or
return 0;
my $output = join "\n", <PIPE>;
close PIPE;
return $output =~ /GNU/;
}
###########################################
sub ramdisk_mount {
###########################################
my($self, %options) = @_;
# mkdir -p /mnt/myramdisk
# mount -t tmpfs -o size=20m tmpfs /mnt/myramdisk
$self->{mount} = which("mount") unless $self->{mount};
$self->{umount} = which("umount") unless $self->{umount};
for (qw(mount umount)) {
if(!defined $self->{$_}) {
LOGWARN "No $_ command found in PATH";
return undef;
}
}
$self->{ramdisk} = { %options };
$self->{ramdisk}->{size} = "100m" unless
defined $self->{ramdisk}->{size};
if(! defined $self->{ramdisk}->{tmpdir}) {
$self->{ramdisk}->{tmpdir} = tempdir( CLEANUP => 1 );
}
my @cmd = ($self->{mount},
"-t", "tmpfs", "-o", "size=$self->{ramdisk}->{size}",
"tmpfs", $self->{ramdisk}->{tmpdir});
INFO "Mounting ramdisk: @cmd";
my $rc = system( @cmd );
if($rc) {
LOGWARN "Mount command '@cmd' failed: $?";
LOGWARN "Note that this only works on Linux and as root";
return;
}
$self->{ramdisk}->{mounted} = 1;
return 1;
}
###########################################
sub ramdisk_unmount {
###########################################
my($self) = @_;
return if !exists $self->{ramdisk}->{mounted};
my @cmd = ($self->{umount}, $self->{ramdisk}->{tmpdir});
INFO "Unmounting ramdisk: @cmd";
my $rc = system( @cmd );
if($rc) {
LOGWARN "Unmount command '@cmd' failed: $?";
return;
}
delete $self->{ramdisk};
return 1;
}
1;
__END__
=head1 NAME
Archive::Tar::Wrapper - API wrapper around the 'tar' utility
=head1 SYNOPSIS
use Archive::Tar::Wrapper;
my $arch = Archive::Tar::Wrapper->new();
# Open a tarball, expand it into a temporary directory
$arch->read("archive.tgz");
# Iterate over all entries in the archive
$arch->list_reset(); # Reset Iterator
# Iterate through archive
while(my $entry = $arch->list_next()) {
my($tar_path, $phys_path) = @$entry;
print "$tar_path\n";
}
# Get a huge list with all entries
for my $entry (@{$arch->list_all()}) {
my($tar_path, $real_path) = @$entry;
print "Tarpath: $tar_path Tempfile: $real_path\n";
}
# Add a new entry
$arch->add($logic_path, $file_or_stringref);
# Remove an entry
$arch->remove($logic_path);
# Find the physical location of a temporary file
my($tmp_path) = $arch->locate($tar_path);
# Create a tarball
$arch->write($tarfile, $compress);
=head1 DESCRIPTION
Archive::Tar::Wrapper is an API wrapper around the 'tar' command line
utility. It never stores anything in memory, but works on temporary
directory structures on disk instead. It provides a mapping between
the logical paths in the tarball and the 'real' files in the temporary
directory on disk.
It differs from Archive::Tar in two ways:
=over 4
=item *
Archive::Tar::Wrapper doesn't hold anything in memory. Everything is
stored on disk.
=item *
Archive::Tar::Wrapper is 100% compliant with the platform's C<tar>
utility, because it uses it internally.
=back
=head1 METHODS
=over 4
=item B<my $arch = Archive::Tar::Wrapper-E<gt>new()>
Constructor for the tar wrapper class. Finds the C<tar> executable
by searching C<PATH> and returning the first hit. In case you want
to use a different tar executable, you can specify it as a parameter:
my $arch = Archive::Tar::Wrapper->new(tar => '/path/to/tar');
Since C<Archive::Tar::Wrapper> creates temporary directories to store
tar data, the location of the temporary directory can be specified:
my $arch = Archive::Tar::Wrapper->new(tmpdir => '/path/to/tmpdir');
Tremendous performance increases can be achieved if the temporary
directory is located on a ram disk. Check the "Using RAM Disks"
section below for details.
Additional options can be passed to the C<tar> command by using the
C<tar_read_options> and C<tar_write_options> parameters. Example:
my $arch = Archive::Tar::Wrapper->new(
tar_read_options => "p"
);
will use C<tar xfp archive.tgz> to extract the tarball instead of just
C<tar xf archive.tgz>. Gnu tar supports even more options, these can
be passed in via
my $arch = Archive::Tar::Wrapper->new(
tar_gnu_read_options => ["--numeric-owner"],
);
By default, the C<list_*()> functions will return only file entries.
Directories will be suppressed. To have C<list_*()>
return directories as well, use
my $arch = Archive::Tar::Wrapper->new(
dirs => 1
);
If more files are added to a tarball than the command line can handle,
C<Archive::Tar::Wrapper> will switch from using the command
tar cfv tarfile file1 file2 file3 ...
to
tar cfv tarfile -T filelist
where C<filelist> is a file containing all file to be added. The default
for this switch is 512, but it can be changed by setting the parameter
C<max_cmd_line_args>:
my $arch = Archive::Tar::Wrapper->new(
max_cmd_line_args => 1024
);
=item B<$arch-E<gt>read("archive.tgz")>
C<read()> opens the given tarball, expands it into a temporary directory
and returns 1 on success und C<undef> on failure.
The temporary directory holding the tar data gets cleaned up when C<$arch>
goes out of scope.
C<read> handles both compressed and uncompressed files. To find out if
a file is compressed or uncompressed, it tries to guess by extension,
then by checking the first couple of bytes in the tarfile.
If only a limited number of files is needed from a tarball, they
can be specified after the tarball name:
$arch->read("archive.tgz", "path/file.dat", "path/sub/another.txt");
The file names are passed unmodified to the C<tar> command, make sure
that the file paths match exactly what's in the tarball, otherwise
C<read()> will fail.
=item B<$arch-E<gt>list_reset()>
Resets the list iterator. To be used before the first call to
B<$arch->list_next()>.
=item B<my($tar_path, $phys_path, $type) = $arch-E<gt>list_next()>
Returns the next item in the tarfile. It returns a list of three scalars:
the relative path of the item in the tarfile, the physical path
to the unpacked file or directory on disk, and the type of the entry
(f=file, d=directory, l=symlink). Note that by default,
Archive::Tar::Wrapper won't display directories, unless the C<dirs>
parameter is set when running the constructor.
=item B<my $items = $arch-E<gt>list_all()>
Returns a reference to a (possibly huge) array of items in the
tarfile. Each item is a reference to an array, containing two
elements: the relative path of the item in the tarfile and the
physical path to the unpacked file or directory on disk.
To iterate over the list, the following construct can be used:
# Get a huge list with all entries
for my $entry (@{$arch->list_all()}) {
my($tar_path, $real_path) = @$entry;
print "Tarpath: $tar_path Tempfile: $real_path\n";
}
If the list of items in the tarfile is big, use C<list_reset()> and
C<list_next()> instead of C<list_all>.
=item B<$arch-E<gt>add($logic_path, $file_or_stringref, [$options])>
Add a new file to the tarball. C<$logic_path> is the virtual path
of the file within the tarball. C<$file_or_stringref> is either
a scalar, in which case it holds the physical path of a file
on disk to be transferred (i.e. copied) to the tarball. Or it is
a reference to a scalar, in which case its content is interpreted
to be the data of the file.
If no additional parameters are given, permissions and user/group
id settings of a file to be added are copied. If you want different
settings, specify them in the options hash:
$arch->add($logic_path, $stringref,
{ perm => 0755, uid => 123, gid => 10 });
If $file_or_stringref is a reference to a Unicode string, the C<binmode>
option has to be set to make sure the string gets written as proper UTF-8
into the tarfile:
$arch->add($logic_path, $stringref, { binmode => ":utf8" });
=item B<$arch-E<gt>remove($logic_path)>
Removes a file from the tarball. C<$logic_path> is the virtual path
of the file within the tarball.
=item B<$arch-E<gt>locate($logic_path)>
Finds the physical location of a file, specified by C<$logic_path>, which
is the virtual path of the file within the tarball. Returns a path to
the temporary file C<Archive::Tar::Wrapper> created to manipulate the
tarball on disk.
=item B<$arch-E<gt>write($tarfile, $compress)>
Write out the tarball by tarring up all temporary files and directories
and store it in C<$tarfile> on disk. If C<$compress> holds a true value,
compression is used.
=item B<$arch-E<gt>tardir()>
Return the directory the tarball was unpacked in. This is sometimes useful
to play dirty tricks on C<Archive::Tar::Wrapper> by mass-manipulating
unpacked files before wrapping them back up into the tarball.
=item B<$arch-E<gt>is_gnu()>
Checks if the tar executable is a GNU tar by running 'tar --version'
and parsing the output for "GNU".
=back
=head1 Using RAM Disks
On Linux, it's quite easy to create a RAM disk and achieve tremendous
speedups while untarring or modifying a tarball. You can either
create the RAM disk by hand by running
# mkdir -p /mnt/myramdisk
# mount -t tmpfs -o size=20m tmpfs /mnt/myramdisk
and then feeding the ramdisk as a temporary directory to
Archive::Tar::Wrapper, like
my $tar = Archive::Tar::Wrapper->new( tmpdir => '/mnt/myramdisk' );
or using Archive::Tar::Wrapper's built-in option 'ramdisk':
my $tar = Archive::Tar::Wrapper->new(
ramdisk => {
type => 'tmpfs',
size => '20m', # 20 MB
},
);
Only drawback with the latter option is that creating the RAM disk needs
to be performed as root, which often isn't desirable for security reasons.
For this reason, Archive::Tar::Wrapper offers a utility functions that
mounts the ramdisk and returns the temporary directory it's located in:
# Create new ramdisk (as root):
my $tmpdir = Archive::Tar::Wrapper->ramdisk_mount(
type => 'tmpfs',
size => '20m', # 20 MB
);
# Delete a ramdisk (as root):
Archive::Tar::Wrapper->ramdisk_unmount();
Optionally, the C<ramdisk_mount()> command accepts a C<tmpdir> parameter
pointing to a temporary directory for the ramdisk if you wish to set it
yourself instead of letting Archive::Tar::Wrapper create it automatically.
=head1 KNOWN LIMITATIONS
=over 4
=item *
Currently, only C<tar> programs supporting the C<z> option (for
compressing/decompressing) are supported. Future version will use
C<gzip> alternatively.
=item *
Currently, you can't add empty directories to a tarball directly.
You could add a temporary file within a directory, and then
C<remove()> the file.
=item *
If you delete a file, the empty directories it was located in
stay in the tarball. You could try to C<locate()> them and delete
them. This will be fixed, though.
=item *
Filenames containing newlines are causing problems with the list
iterators. To be fixed.
=item *
If you ask Archive::Tar::Wrapper to add a file to a tarball, it copies it into
a temporary directory and then calls the system tar to wrap up that directory
into a tarball.
This approach has limitations when it comes to file permissions: If the file to
be added belongs to a different user/group, Archive::Tar::Wrapper will adjust
the uid/gid/permissions of the target file in the temporary directory to
reflect the original file's settings, to make sure the system tar will add it
like that to the tarball, just like a regular tar run on the original file
would. But this will fail of course if the original file's uid is different
from the current user's, unless the script is running with superuser rights.
The tar program by itself (without Archive::Tar::Wrapper) works differently:
It'll just make a note of a file's uid/gid/permissions in the tarball (which it
can do without superuser rights) and upon extraction, it'll adjust the
permissions of newly generated files if the -p option is given (default for
superuser).
=back
=head1 BUGS
Archive::Tar::Wrapper doesn't currently handle filenames with embedded
newlines.
=head1 LEGALESE
Copyright 2005 by Mike Schilli, all rights reserved.
This program is free software, you can redistribute it and/or
modify it under the same terms as Perl itself.
=head1 AUTHOR
2005, Mike Schilli <cpan@perlmeister.com>
|