diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2004-01-29 13:06:40 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2004-01-29 13:06:40 +0000 |
commit | 714673f9240f6c880f6895bf5e164d21de275464 (patch) | |
tree | 365d50312a8dc0da0b1bb8b1cd870a82d11d3bf3 | |
parent | 01bc758b999cfea0037b2752fe4fe9db38e47b37 (diff) |
destdir support
okay pvalchev.
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Ustar.pm | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Ustar.pm b/usr.sbin/pkg_add/OpenBSD/Ustar.pm index 6c4810c2d6b..83609e2d459 100644 --- a/usr.sbin/pkg_add/OpenBSD/Ustar.pm +++ b/usr.sbin/pkg_add/OpenBSD/Ustar.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Ustar.pm,v 1.5 2004/01/27 23:25:31 espie Exp $ +# $OpenBSD: Ustar.pm,v 1.6 2004/01/29 13:06:39 espie Exp $ # # Copyright (c) 2002 Marc Espie. # @@ -150,7 +150,8 @@ sub next gname => $gname, gid => $gid, size => $size, - archive => $self + archive => $self, + destdir => '' }; # adjust swallow $self->{swallow} = $size; @@ -175,15 +176,15 @@ package OpenBSD::Ustar::Object; sub set_modes { my $self = shift; - chown $self->{uid}, $self->{gid}, $self->{name}; - chmod $self->{mode}, $self->{name}; - utime $self->{mtime}, $self->{mtime}, $self->{name}; + chown $self->{uid}, $self->{gid}, $self->{destdir}.$self->{name}; + chmod $self->{mode}, $self->{destdir}.$self->{name}; + utime $self->{mtime}, $self->{mtime}, $self->{destdir}.$self->{name}; } sub make_basedir { my $self = shift; - my $dir = File::Basename::dirname($self->{name}); + my $dir = $self->{destdir}.File::Basename::dirname($self->{name}); File::Path::mkpath($dir) unless -d $dir; } @@ -199,7 +200,7 @@ our @ISA=qw(OpenBSD::Ustar::Object); sub create { my $self = shift; - File::Path::mkpath($self->{name}); + File::Path::mkpath($self->{destdir}.$self->{name}); $self->SUPER::set_modes(); } @@ -216,8 +217,8 @@ sub create if (defined $self->{cwd}) { $linkname=$self->{cwd}.'/'.$linkname; } - link $linkname, $self->{name} or - die "Can't link $linkname to $self->{name}: $!"; + link $self->{destdir}.$linkname, $self->{destdir}.$self->{name} or + die "Can't link $self->{destdir}.$linkname to $self->{destdir}.$self->{name}: $!"; } sub isLink() { 1 } @@ -230,8 +231,8 @@ sub create { my $self = shift; $self->make_basedir($self->{name}); - symlink $self->{linkname}, $self->{name} or - die "Can't symlink $self->{linkname} to $self->{name}: $!"; + symlink $self->{linkname}, $self->{destdir}.$self->{name} or + die "Can't symlink $self->{linkname} to $self->{destdir}.$self->{name}: $!"; } sub isLink() { 1 } @@ -244,9 +245,9 @@ sub create { my $self = shift; $self->make_basedir($self->{name}); - open (my $out, '>', $self->{name}); + open (my $out, '>', $self->{destdir}.$self->{name}); if (!defined $out) { - die "Can't write to $self->{name}: $!"; + die "Can't write to $self->{destdir}.$self->{name}: $!"; } my $buffer; my $toread = $self->{size}; @@ -258,12 +259,12 @@ sub create } $self->{archive}->{swallow} -= $maxread; unless (print $out $buffer) { - die "Error writing to $self->{name}: $!"; + die "Error writing to $self->{destdir}.$self->{name}: $!"; } $toread -= $maxread; } - $out->close() or die "Error closing $self->{name}: $!"; + $out->close() or die "Error closing $self->{destdir}.$self->{name}: $!"; $self->SUPER::set_modes(); } |