summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2005-08-16 13:52:16 +0000
committerMarc Espie <espie@cvs.openbsd.org>2005-08-16 13:52:16 +0000
commit641b02e13937cacf033ab694d48b4699a2f9ff1d (patch)
tree08814c4f95cd8af9f411ec89982a9ed9b887b155 /usr.sbin
parentb6eda7ee68a136a728597f97a939aeacfef15a14 (diff)
In some cases, pkg_add -r will remove some extra packages while performing
replacement on dependencies. When we finally reach the package that triggered the dependencies, the package it's supposed to replace is no longer there, so do a quick sanity check to only replace packages that have not already been replaced...
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/pkg_add25
1 files changed, 18 insertions, 7 deletions
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 55dfddd2a38..2adec620675 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.182 2005/08/16 12:05:58 espie Exp $
+# $OpenBSD: pkg_add,v 1.183 2005/08/16 13:52:15 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -202,8 +202,19 @@ sub really_add($$)
$state->{archive} = $handle;
$plist->{dir} = $dir;
$state->set_pkgname($pkgname);
+
+ # XXX in `combined' updates, some dependencies may remove extra
+ # packages, so we do a double-take on the list of packages we
+ # are actually replacing.
+ my @toreplace = ();
+ for my $pl2 (@{$plist->{replacing}}) {
+ if (is_installed($pl2->pkgname())) {
+ push(@toreplace, $pl2);
+ }
+ }
+
my $replacing = 0;
- if (@{$plist->{replacing}}) {
+ if (@toreplace) {
$replacing = 1;
}
if (defined $plist->{old_libs}) {
@@ -216,8 +227,8 @@ sub really_add($$)
if (defined $state->{deptree}->{$pkgname}) {
$header = $state->{deptree}->{$pkgname}.":".$header;
}
- if (@{$plist->{replacing}}) {
- $header.=" (replacing ". join(', ', (map {$_->pkgname()}@{$plist->{replacing}})). ")";
+ if (@toreplace) {
+ $header.=" (replacing ". join(', ', (map {$_->pkgname()}@toreplace)). ")";
}
if (!OpenBSD::ProgressMeter::set_header($header)) {
print $state->{not} ? "Pretending to add " : "Adding ";
@@ -245,7 +256,7 @@ sub really_add($$)
OpenBSD::ProgressMeter::set_header("$pkgname (extracting)");
- if (@{$plist->{replacing}}) {
+ if (@toreplace) {
OpenBSD::Update::save_old_libraries($plist, $state);
}
@@ -271,7 +282,7 @@ sub really_add($$)
"Installation of $pkgname failed");
}
- for my $op (@{$plist->{replacing}}) {
+ for my $op (@toreplace) {
OpenBSD::ProgressMeter::set_header($op->pkgname()." (deleting)");
$state->set_pkgname($op->pkgname());
require OpenBSD::Delete;
@@ -376,7 +387,7 @@ sub really_add($$)
$plist->get(DISPLAY)->prepare($state);
}
# and add dependencies corresponding to the replacement
- for my $op (@{$plist->{replacing}}) {
+ for my $op (@toreplace) {
require OpenBSD::RequiredBy;
require OpenBSD::Update;
my $opkgname = $op->pkgname();