summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2005-06-13 12:46:48 +0000
committerMarc Espie <espie@cvs.openbsd.org>2005-06-13 12:46:48 +0000
commit1ad4af8dc3ae49fa8a13a6e359a8fdabab36d3f5 (patch)
tree3bec03597bf90541a284e51d89cc9ef24348b0b4 /usr.sbin
parent5c905322a3f109c9ea032a555c24cc231322e8b9 (diff)
we can determine if an entry will be stored as a HardLink at prepare() time,
so do it...
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Ustar.pm30
1 files changed, 8 insertions, 22 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Ustar.pm b/usr.sbin/pkg_add/OpenBSD/Ustar.pm
index a3cd7e6e810..0f4bfc98536 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.17 2005/06/13 12:22:37 espie Exp $
+# $OpenBSD: Ustar.pm,v 1.18 2005/06/13 12:46:47 espie Exp $
#
# Copyright (c) 2002-2004 Marc Espie <espie@openbsd.org>
#
@@ -205,8 +205,11 @@ sub prepare
archive => $self,
destdir => $self->{destdir}
};
-
- if (-l $_) {
+ my $k = $entry->{key};
+ if (defined $self->{key}->{$k}) {
+ $entry->{linkname} = $self->{key}->{$k};
+ bless "OpenBSD::Ustar::HardLink", $entry;
+ } elsif (-l $_) {
$entry->{linkname} = readlink("$destdir/$filename");
bless "OpenBSD::Ustar::SoftLink", $entry;
} elsif (-d _) {
@@ -238,7 +241,8 @@ sub write
my $self = shift;
my $arc = $self->{archive};
- $self->write_header($arc);
+ my $header = OpenBSD::Ustar::mkheader($self, $self->type());
+ syswrite($arc->{fh}, $header, 512);
$self->write_contents($arc);
my $k = $self->{key};
if (!defined $arc->{key}->{$k}) {
@@ -251,13 +255,6 @@ sub write_contents
# only files have anything to write
}
-sub write_header
-{
- my ($self, $arc) = @_;
- my $header = OpenBSD::Ustar::mkheader($self, $self->type());
- syswrite($arc->{fh}, $header, 512);
-}
-
sub isDir() { 0 }
sub isFile() { 0 }
sub isLink() { 0 }
@@ -409,17 +406,6 @@ sub create
$self->SUPER::set_modes();
}
-sub write_header
-{
- my ($self, $arc) = @_;
- my $k = $self->{key};
- if (defined $arc->{key}->{$k}) {
- $self->{linkname} = $arc->{key}->{$k};
- bless "OpenBSD::Ustar::HardLink", $self;
- }
- $self->SUPER::write_header($arc);
-}
-
sub write_contents
{
my ($self, $arc) = @_;