diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2004-10-31 12:40:02 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2004-10-31 12:40:02 +0000 |
commit | fa2211d64232a823ca1391ac5c4d146d305fd31f (patch) | |
tree | 36498f39d09fdda390c2c1b94fe60766b3271b84 | |
parent | e2e5d8abe0771599452882568b06ad60b9d4f59f (diff) |
fix logic error: we will be able to fully validate the new packing-list
in pkg_add -r mode, it's just a question of removing the old package
from the virtual filesystem early, so that we can still check for collisions.
Help getting OpenBSD::Delete self-contained while we're there...
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Delete.pm | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Update.pm | 12 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 12 |
3 files changed, 19 insertions, 9 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Delete.pm b/usr.sbin/pkg_add/OpenBSD/Delete.pm index 31a76267a7a..f659813fcd2 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.1 2004/10/31 10:26:17 espie Exp $ +# $OpenBSD: Delete.pm,v 1.2 2004/10/31 12:40:01 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -138,6 +138,8 @@ sub delete_package } package OpenBSD::PackingElement; +use OpenBSD::Logger; + sub delete { } diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm index a5f73772b7d..df6c2dcaa19 100644 --- a/usr.sbin/pkg_add/OpenBSD/Update.pm +++ b/usr.sbin/pkg_add/OpenBSD/Update.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Update.pm,v 1.1 2004/10/23 11:09:23 espie Exp $ +# $OpenBSD: Update.pm,v 1.2 2004/10/31 12:40:01 espie Exp $ # # Copyright (c) 2004 Marc Espie <espie@openbsd.org> # @@ -18,6 +18,8 @@ use strict; use warnings; +use OpenBSD::Delete; + package OpenBSD::PackingElement; sub can_update { @@ -72,7 +74,7 @@ use OpenBSD::PackageInfo; sub can_do { - my ($toreplace, $replacement) = @_; + my ($toreplace, $replacement, $state) = @_; my $r = OpenBSD::RequiredBy->new($toreplace); my $okay = 1; @@ -91,6 +93,12 @@ sub can_do my $plist = OpenBSD::PackingList->fromfile(installed_info($toreplace).CONTENTS); $plist->visit('can_update', \$okay); + eval { + OpenBSD::Delete::validate_plist($plist, $state->{destdir}); + }; + if ($@) { + $okay = 0; + } return $okay; } diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index ab7b541684f..4d43e2e393e 100644 --- a/usr.sbin/pkg_add/pkg_add +++ b/usr.sbin/pkg_add/pkg_add @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_add,v 1.86 2004/10/31 11:33:50 espie Exp $ +# $OpenBSD: pkg_add,v 1.87 2004/10/31 12:40:00 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -476,7 +476,7 @@ sub can_install($$) require OpenBSD::Update; my $toreplace = $l[0]; - if (OpenBSD::Update::can_do($toreplace, $pkgname)) { + if (OpenBSD::Update::can_do($toreplace, $pkgname, $state)) { print "Will be able to update $toreplace once we're done\n"; } else { print "Can't update $toreplace into $pkgname\n"; @@ -723,9 +723,9 @@ sub collision_report($) } } -sub validate_plist($$$) +sub validate_plist($$) { - my ($plist, $destdir, $replace) = @_; + my ($plist, $destdir) = @_; my $problems = 0; my $pkgname = $plist->pkgname(); @@ -746,7 +746,7 @@ sub validate_plist($$$) for my $item (@{$plist->{items}}) { next unless $item->IsFile(); my $fname = $destdir.$item->fullname(); - if (OpenBSD::Vstat::vexists($fname) && !$replace) { + if (OpenBSD::Vstat::vexists($fname)) { push(@$colliding, $fname); $problems++; } @@ -818,7 +818,7 @@ sub really_add($$) } print "\n"; } - my $totsize = validate_plist($plist, $destdir, $state->{replace}); + my $totsize = validate_plist($plist, $destdir); if (!defined $handle) { Fatal "Archive in $pkgname broken"; |