summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2004-12-20 12:16:10 +0000
committerMarc Espie <espie@cvs.openbsd.org>2004-12-20 12:16:10 +0000
commite8de82031dd4aac483f836ffa154d34049cebf32 (patch)
treecab0880943ad7e0f564bfb37faa189cdcbfa7610
parent09f5ed9e32d7cb2df242438c6f9a3f6bee9dda59 (diff)
keep a hash of installed packages, so that we can refuse to replace a
package that just got installed. Also allows us to give a full tally of what reorder did in kitchensink.
-rw-r--r--usr.sbin/pkg_add/pkg_add17
1 files changed, 14 insertions, 3 deletions
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 6da3c84fbd4..ed2d6b291be 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.152 2004/12/19 14:47:33 espie Exp $
+# $OpenBSD: pkg_add,v 1.153 2004/12/20 12:16:09 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -85,6 +85,12 @@ sub can_install($$$)
return undef;
}
+ my $toreplace = $conflicts[0];
+ if (defined $state->{installed}->{$toreplace}) {
+ Warn "Cannot replace $toreplace with $pkgname: just got installed\n";
+ $errors++;
+ return undef;
+ }
require OpenBSD::Update;
if (!OpenBSD::Update::figure_out_libs($plist, $state, @libs)) {
@@ -570,7 +576,7 @@ sub install_package
return ();
}
}
- if (defined $handle->{finished}) {
+ if (defined $state->{installed}->{$plist->pkgname()}) {
return ();
}
if ($plist->has('arch')) {
@@ -621,7 +627,7 @@ sub install_package
}
really_add($handle, $state);
OpenBSD::PkgCfl::register($plist, $state);
- $handle->{finished} = 1;
+ $state->{installed}->{$plist->pkgname()} = 1;
return ();
}
@@ -661,6 +667,7 @@ $opt_L = '/usr/local' unless defined $opt_L;
my $state = new OpenBSD::Error;
$state->{cache} = {};
+$state->{installed} = {};
$state->{deptree} = {};
$state->{do_faked} = 0;
$state->{replace} = $opt_r;
@@ -725,6 +732,7 @@ if ($< && !$forced{nonroot}) {
my @todo = (@ARGV);
if (defined $state->{forced}->{kitchensink}) {
reorder(\@todo);
+ print "Adding in order ", join(', ', @todo), "\n";
}
eval {
@@ -750,6 +758,9 @@ if ($state->{beverbose}) {
OpenBSD::Vstat::tally();
}
$state->delayed_output();
+if (defined $state->{forced}->{kitchensink}) {
+ print "Added ", join(', ', sort keys %{$state->{installed}}), "\n";
+}
rethrow $dielater;
} catch {
print STDERR "$0: $_\n";