diff options
author | Olivier Thauvin <nanardon@mandriva.org> | 2004-12-06 16:42:29 +0000 |
---|---|---|
committer | Olivier Thauvin <nanardon@mandriva.org> | 2004-12-06 16:42:29 +0000 |
commit | dcd615a5ac5759ce82db71f8aac058768e2d8ce3 (patch) | |
tree | 62159ef989cd9baaee2d4a46253a0031278301a5 /Packdrakeng.pm | |
parent | 749363943850d341a730ac739e086ea837f28ea3 (diff) | |
download | rpmtools-dcd615a5ac5759ce82db71f8aac058768e2d8ce3.tar rpmtools-dcd615a5ac5759ce82db71f8aac058768e2d8ce3.tar.gz rpmtools-dcd615a5ac5759ce82db71f8aac058768e2d8ce3.tar.bz2 rpmtools-dcd615a5ac5759ce82db71f8aac058768e2d8ce3.tar.xz rpmtools-dcd615a5ac5759ce82db71f8aac058768e2d8ce3.zip |
- fix dir / symlink creation
- add test
Diffstat (limited to 'Packdrakeng.pm')
-rw-r--r-- | Packdrakeng.pm | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/Packdrakeng.pm b/Packdrakeng.pm index 6986a39..0504ec4 100644 --- a/Packdrakeng.pm +++ b/Packdrakeng.pm @@ -605,25 +605,31 @@ sub extract_virtual { } sub extract { - my ($pack, $dir, @file) = @_; + my ($pack, $destdir, @file) = @_; foreach my $f (@file) { - my $dest = $dir ? "$dir/$f" : "$f"; + my $dest = $destdir ? "$destdir/$f" : "$f"; my ($dir) = $dest =~ m!(.*)/.*!; if (exists($pack->{dir}{$f})) { -d $dest || mkpath($dest) - or warn "Unable to create dir $dest"; + or warn "Unable to create dir $dest: $!"; next; } elsif (exists($pack->{'symlink'}{$f})) { - -d $dir || mkpath($dir) or do { - warn "Unable to create dir $dir"; - }; - symlink($dest, $pack->{'symlink'}{$f}) - or warn "Unable to extract symlink $f"; + -d $dir || mkpath($dir) or + warn "Unable to create dir $dest: $!"; + -l $dest and unlink $dest; + symlink($pack->{'symlink'}{$f}, $dest) + or warn "Unable to extract symlink $f: $!"; next; } elsif (exists($pack->{files}{$f})) { -d $dir || mkpath($dir) or do { warn "Unable to create dir $dir"; }; + if (-l $dest) { + unlink($dest) or do { + warn "Can't remove link $dest: $!"; + next; # Don't overwrite a file because where the symlink point to + }; + } sysopen(my $destfh, $dest, O_CREAT | O_TRUNC | O_WRONLY) or do { warn "Unable to extract $dest"; @@ -664,7 +670,7 @@ sub list { } # Print toc info -sub dump { +sub dumptoc { my ($pack) = @_; foreach my $file (keys %{$pack->{dir}}) { printf "d %13c %s\n", ' ', $file; |