diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-06-06 12:32:10 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-06-06 12:32:10 +0000 |
commit | 21a0793d20af8d6daf2db8fc4556777e53d48096 (patch) | |
tree | ad76fba17e8bd86b9bfc810183a48c69a0e655bd | |
parent | 83cd2085683762d985fbeb2474534b68820aec8a (diff) |
tweak how copies happen: rename make_copy into make_shallow_copy,
make_deep_copy.
tweak keep_old_files so that we set the pkgname later, when it won't
cause any error to have duplicates in there.
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Add.pm | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Delete.pm | 9 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 10 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingList.pm | 15 |
4 files changed, 24 insertions, 14 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm index 6a45b57cac3..b0558563006 100644 --- a/usr.sbin/pkg_add/OpenBSD/Add.pm +++ b/usr.sbin/pkg_add/OpenBSD/Add.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Add.pm,v 1.72 2007/06/04 18:55:47 espie Exp $ +# $OpenBSD: Add.pm,v 1.73 2007/06/06 12:32:09 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -72,7 +72,7 @@ sub record_partial_installation use OpenBSD::PackingElement; - my $n = $plist->make_copy($h); + my $n = $plist->make_shallow_copy($h); my $borked = borked_package($plist->pkgname); $n->set_pkgname($borked); diff --git a/usr.sbin/pkg_add/OpenBSD/Delete.pm b/usr.sbin/pkg_add/OpenBSD/Delete.pm index cda66a51459..dd5a8799fc3 100644 --- a/usr.sbin/pkg_add/OpenBSD/Delete.pm +++ b/usr.sbin/pkg_add/OpenBSD/Delete.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Delete.pm,v 1.62 2007/06/04 14:42:19 espie Exp $ +# $OpenBSD: Delete.pm,v 1.63 2007/06/06 12:32:09 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -50,11 +50,11 @@ sub keep_old_files my ($state, $plist) = @_; my $p = new OpenBSD::PackingList; my $borked = borked_package($plist->pkgname); - $p->set_pkgname($borked); $p->set_infodir(installed_info($borked)); mkdir($p->infodir); $plist->copy_old_stuff($p, $state); + $p->set_pkgname($borked); $p->to_installation; return $borked; } @@ -434,11 +434,6 @@ sub copy_old_stuff { } -package OpenBSD::PackingElement::Name; -sub copy_old_stuff -{ -} - package OpenBSD::PackingElement::Meta; sub copy_old_stuff { diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index 28ab7dcbbc5..fdf55b3e006 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingElement.pm,v 1.132 2007/06/04 18:52:02 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.133 2007/06/06 12:32:09 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -134,12 +134,18 @@ sub NoDuplicateNames() { 0 } sub signature {} -sub copy_if +sub copy_shallow_if { my ($self, $copy, $h) = @_; $self->add_object($copy) if defined $h->{$self}; } +sub copy_deep_if +{ + my ($self, $copy, $h) = @_; + $self->clone->add_object($copy) if defined $h->{$self}; +} + # Basic class hierarchy # various stuff that's only linked to objects before/after them diff --git a/usr.sbin/pkg_add/OpenBSD/PackingList.pm b/usr.sbin/pkg_add/OpenBSD/PackingList.pm index 57702e4043f..cde7c0be3db 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingList.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingList.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingList.pm,v 1.76 2007/06/04 14:40:39 espie Exp $ +# $OpenBSD: PackingList.pm,v 1.77 2007/06/06 12:32:09 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -66,16 +66,25 @@ sub set_infodir ${$self->{infodir}} = $dir; } -sub make_copy +sub make_shallow_copy { my ($plist, $h) = @_; my $copy = bless {state => OpenBSD::PackingList::State->new, infodir => \(my $d = ${$plist->{infodir}})}, ref($plist); - $plist->copy_if($copy, $h); + $plist->copy_shallow_if($copy, $h); return $copy; } +sub make_deep_copy +{ + my ($plist, $h) = @_; + + my $copy = bless {state => OpenBSD::PackingList::State->new, + infodir => \(my $d = ${$plist->{infodir}})}, ref($plist); + $plist->copy_deep_if($copy, $h); + return $copy; +} sub infodir { |