summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2004-12-21 01:43:59 +0000
committerMarc Espie <espie@cvs.openbsd.org>2004-12-21 01:43:59 +0000
commit89aa12cd2683c46b0b992cca78791b6ad1315d19 (patch)
tree43bb118db7a2d0b5c066eb3a0b34186dda6a20a0 /usr.sbin/pkg_add
parentc3eaabde2d2d2ec6f7d9e85e6123963a2e0d5162 (diff)
correct checks to allow for a package to replace several packages.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Update.pm5
-rw-r--r--usr.sbin/pkg_add/pkg_add33
2 files changed, 21 insertions, 17 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm
index cc2a1b889c1..6ee7bdf300e 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.46 2004/12/20 22:43:25 espie Exp $
+# $OpenBSD: Update.pm,v 1.47 2004/12/21 01:43:58 espie Exp $
#
# Copyright (c) 2004 Marc Espie <espie@openbsd.org>
#
@@ -234,7 +234,7 @@ use OpenBSD::Error;
sub can_do
{
- my ($toreplace, $replacement, $state) = @_;
+ my ($toreplace, $replacement, $state, $ignore) = @_;
$state->{okay} = 1;
$state->{libs_to_check} = [];
@@ -251,6 +251,7 @@ sub can_do
}
my @wantlist = OpenBSD::RequiredBy->new($toreplace)->list();
for my $wanting (@wantlist) {
+ next if defined $ignore->{$wanting};
print "Verifying dependencies still match for $wanting\n" if $state->{verbose};
my $p2 = OpenBSD::PackingList->from_installation($wanting,
\&OpenBSD::PackingList::DependOnly);
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 0fb2ff7971a..85c1598e973 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.159 2004/12/20 22:43:25 espie Exp $
+# $OpenBSD: pkg_add,v 1.160 2004/12/21 01:43:58 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -87,13 +87,13 @@ sub can_install($$$)
return undef;
}
- my $toreplace = $conflicts[0];
- if (defined $state->{installed}->{$toreplace}) {
- Warn "Cannot replace $toreplace with $pkgname: just got installed\n";
+ require OpenBSD::Update;
+
+ if (!OpenBSD::Update::is_safe($plist, $state)) {
+ print "Can't safely update to $pkgname\n";
$errors++;
return undef;
}
- require OpenBSD::Update;
if (!OpenBSD::Update::figure_out_libs($plist, $state, @libs)) {
print "Can't update to $pkgname because of collision with old libs\n";
@@ -101,21 +101,24 @@ sub can_install($$$)
return undef;
}
- my $rplist = OpenBSD::Update::can_do($conflicts[0], $pkgname, $state);
- if ($rplist) {
- if (!OpenBSD::Update::is_safe($plist, $state)) {
- print "Can't safely update $conflicts[0] to $pkgname\n";
+ for my $toreplace (@conflicts) {
+ if (defined $state->{installed}->{$toreplace}) {
+ Warn "Cannot replace $toreplace with $pkgname: just got installed\n";
+ $errors++;
+ return undef;
+ }
+
+ my $rplist = OpenBSD::Update::can_do($toreplace, $pkgname,
+ $state, \%conflicts);
+ if (!$rplist) {
+ print "Can't update $toreplace into $pkgname\n";
$errors++;
return undef;
}
- $rplist->{dir} = installed_info($conflicts[0]);
+ $rplist->{dir} = installed_info($toreplace);
push(@{$plist->{replacing}}, $rplist);
- return 1;
- } else {
- print "Can't update $conflicts[0] into $pkgname\n";
- $errors++;
- return undef;
}
+ return 1;
}