diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2005-06-26 16:41:09 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2005-06-26 16:41:09 +0000 |
commit | f258c7058507c33d1a8c660e9039ee3b04d0d987 (patch) | |
tree | 24c9a952a583803cb676c6fa827ad246194e03dc /usr.sbin | |
parent | e483bc9d7b9cf9cfc7c32103d055a8132da415ff (diff) |
Handle hard links correctly: the names need to be aliased correctly for
pkg_merging, and the names need to lose the prefix path when getting
extracted.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageLocator.pm | 5 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_merge | 22 |
2 files changed, 22 insertions, 5 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm index e06221691c4..9c224e6efd6 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageLocator.pm,v 1.13 2005/06/26 12:44:29 espie Exp $ +# $OpenBSD: PackageLocator.pm,v 1.14 2005/06/26 16:41:08 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -448,6 +448,9 @@ sub next return $self->next(); } $e->{name} = $name; + if ($e->isHardLink()) { + $e->{linkname} =~ s/^(.*?)\///; + } } } $self->{_current} = $e; diff --git a/usr.sbin/pkg_add/pkg_merge b/usr.sbin/pkg_add/pkg_merge index fcae7ea505f..5acfc60c0ac 100644 --- a/usr.sbin/pkg_add/pkg_merge +++ b/usr.sbin/pkg_add/pkg_merge @@ -28,6 +28,7 @@ sub copy_over {} sub mark_tocopy {} +sub make_alias {} package OpenBSD::PackingElement::FileBase; sub mark_tocopy { @@ -43,9 +44,18 @@ sub copy_over die "Names don't match: ", $e->{name}, " ", $self->{name}; } $e->{name} = $prefix."/".$e->{name}; - if (defined $wrarc) { - $e->copy($wrarc); + $e->copy($wrarc); +} + +sub make_alias +{ + my ($self, $wrarc, $prefix, $pkg, $alias) = @_; + my $e = $pkg->{pkg}->next(); + if ($e->{name} ne $self->{name}) { + die "Names don't match: ", $e->{name}, " ", $self->{name}; } + $e->{name} = $prefix."/".$e->{name}; + $e->alias($wrarc, "$prefix/$alias"); } package OpenBSD::PackingElement::SpecialFile; @@ -206,10 +216,10 @@ while(1) { my $copies = 0; my $currentprefix = $pkg->{prefix}; my @todo = (); + my @merged = (); for my $cmp (@mergeable) { if (defined $ref->{md5} && $cmp->{tocopy}->[0]->{md5} eq $ref->{md5}) { - my $i = shift @{$cmp->{tocopy}}; - $i->copy_over(undef, undef, $cmp); + push(@merged, $cmp); $currentprefix .= $cmp->{prefix}; $copies++; } else { @@ -221,6 +231,10 @@ while(1) { $ref->copy_over($wrarc, $currentprefix, $pkg); @mergeable = @todo; $all_copies += $copies; + for my $pkg2 (@merged) { + my $i = shift @{$pkg2->{tocopy}}; + $i->make_alias($wrarc, $currentprefix, $pkg2, $name); + } } if ($opt_v) { if ($all_copies) { |