summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernd Ahlers <bernd@cvs.openbsd.org>2006-08-01 10:23:39 +0000
committerBernd Ahlers <bernd@cvs.openbsd.org>2006-08-01 10:23:39 +0000
commitcf2136012b428300c1e5f1a0623ca6599cb9262b (patch)
treea73cf8dba758a25ec303972dd2a7010d0921d234
parent867def92381848455b644d9e0cbe4e3a9ae18ca4 (diff)
If pkg_delete is trying to remove more than one package at the same time and
is finding some dependency problems, explain which package depend on what. (with -v, -i or '-F verbosedeps') idea & ok espie@
-rw-r--r--usr.sbin/pkg_add/pkg_delete34
-rw-r--r--usr.sbin/pkg_add/pkg_delete.14
2 files changed, 29 insertions, 9 deletions
diff --git a/usr.sbin/pkg_add/pkg_delete b/usr.sbin/pkg_add/pkg_delete
index f107e43ffa1..bc594893338 100644
--- a/usr.sbin/pkg_add/pkg_delete
+++ b/usr.sbin/pkg_add/pkg_delete
@@ -1,6 +1,6 @@
#!/usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg_delete,v 1.93 2005/09/07 14:01:59 jmc Exp $
+# $OpenBSD: pkg_delete,v 1.94 2006/08/01 10:23:38 bernd Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -122,17 +122,35 @@ OpenBSD::PackageInfo::solve_installed_names(\@ARGV, \@realnames,
my @todo = OpenBSD::RequiredBy->compute_closure(@realnames);
if (@todo > @realnames) {
- my %extra_rm = map {($_,1)} @todo;
- for my $p (@realnames) {
- delete $extra_rm{$p};
+ my $details = $state->{very_verbose} || $forced{verbosedeps};
+ my $show = sub {
+ my ($p, $d) = @_;
+ print "Can't remove ".join(' ', @$p)." without also removing:\n"
+ .join(' ', @$d)."\n";
+ };
+ if ($state->{interactive} || !$details) {
+ my %deps = map {($_, 1)} @todo;
+ for my $p (@realnames) {
+ delete $deps{$p};
+ }
+ &$show([@ARGV], [keys %deps]);
+ if ((keys %deps) > 1 && OpenBSD::Interactive::confirm(
+ "Do you want details", $state->{interactive}, 1)) {
+ $details = 1;
+ }
+ }
+ if ($details) {
+ for my $pkg (@realnames) {
+ my @deps = OpenBSD::RequiredBy->compute_closure($pkg);
+ next unless @deps > 1;
+ @deps = grep {$_ ne $pkg} @deps;
+ &$show([$pkg], [@deps]);
+ }
}
- print "Can't remove ", join(' ', @ARGV), " without also removing:\n",
- join(' ', keys(%extra_rm)), "\n";
- my $them = keys(%extra_rm) > 1 ? 'them' : 'it';
+ my $them = @todo > 1 ? 'them' : 'it';
if ($forced{dependencies} or
OpenBSD::Interactive::confirm("Do you want to remove $them as well", $state->{interactive}, 0)) {
print "(removing $them as well)\n";
- push(@realnames, keys(%extra_rm));
} else {
$bad = 1;
}
diff --git a/usr.sbin/pkg_add/pkg_delete.1 b/usr.sbin/pkg_add/pkg_delete.1
index b70da722dde..0eaa8713dcc 100644
--- a/usr.sbin/pkg_add/pkg_delete.1
+++ b/usr.sbin/pkg_add/pkg_delete.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: pkg_delete.1,v 1.20 2005/09/07 14:01:59 jmc Exp $
+.\" $OpenBSD: pkg_delete.1,v 1.21 2006/08/01 10:23:38 bernd Exp $
.\"
.\" FreeBSD install - a package for the installation and maintenance
.\" of non-core utilities.
@@ -80,6 +80,8 @@ uninstall even if not running as root.
external scripts may fail.
.It Ar uninstalled
proceed even if some package names don't resolve to installed package names.
+.It Ar verbosedeps
+show detailed dependency information.
.El
.It Fl I
If scripts exist for a given package, do not execute them.