diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2005-06-18 13:17:12 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2005-06-18 13:17:12 +0000 |
commit | 3082708bb92c9b5a6ab11c44aaa464f490ba02f3 (patch) | |
tree | d5bb9b317a9864522a46f6777edde10769d94110 /usr.sbin | |
parent | 0343ba98b3c6d1cfcfc827ef8a3464dbf508b62c (diff) |
maintain correspondence between original archive file names and rewritten
names. Allows transparent rename & copy of hard links.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Ustar.pm | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Ustar.pm b/usr.sbin/pkg_add/OpenBSD/Ustar.pm index b4d24410ba6..2d7ce0bd46f 100644 --- a/usr.sbin/pkg_add/OpenBSD/Ustar.pm +++ b/usr.sbin/pkg_add/OpenBSD/Ustar.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Ustar.pm,v 1.25 2005/06/18 12:52:29 espie Exp $ +# $OpenBSD: Ustar.pm,v 1.26 2005/06/18 13:17:11 espie Exp $ # # Copyright (c) 2002-2004 Marc Espie <espie@openbsd.org> # @@ -152,6 +152,7 @@ sub next if ($size % 512) { $self->{swallow} += 512 - $size % 512; } + $self->{cachename} = $name; return $result; } @@ -302,6 +303,11 @@ sub write_contents # only files have anything to write } +sub resolve_links +{ + # only hard links must cheat +} + sub copy_contents { # only files need copying @@ -311,6 +317,7 @@ sub copy { my ($self, $wrarc) = @_; my $out = $wrarc->{fh}; + $self->resolve_links($wrarc); my $header = OpenBSD::Ustar::mkheader($self, $self->type()); print $out $header; @@ -352,6 +359,18 @@ sub create die "Can't link $self->{destdir}$linkname to $self->{destdir}$self->{name}: $!"; } +sub resolve_links +{ + my ($self, $arc) = @_; + + my $k = $self->{archive}.":".$self->{linkname}; + if (defined $arc->{key}->{$k}) { + $self->{linkname} = $arc->{key}->{$k}; + } else { + die "Can't copy link over: original NOT available\n"; + } +} + sub isLink() { 1 } sub isHardLink() { 1 } @@ -518,6 +537,10 @@ sub copy_contents if ($size % 512) { print $out "\0" x (512 - $size % 512); } + my $k = $self->{archive}.":".$self->{archive}->{cachename}; + if (!defined $arc->{key}->{$k}) { + $arc->{key}->{$k} = $self->{name}; + } } sub isFile() { 1 } |