diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2011-07-12 10:51:29 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2011-07-12 10:51:29 +0000 |
commit | 0dad2c99e31bd1d9fd89b37492c8dda5d8daabf2 (patch) | |
tree | e4f687eb4727997c4229aa1e2e669b667e475d89 /usr.sbin | |
parent | db1f139aa305c531e5ad6489f7ad5eeeb53b3864 (diff) |
put back options -Dbaddepend -Ddependencies
uninstalled and verbosedeps are now always on.
ambiguous will die ?
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgDelete.pm | 51 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_delete.1 | 8 |
2 files changed, 47 insertions, 12 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm b/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm index db600a43544..22cad904007 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm @@ -1,6 +1,6 @@ #!/usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgDelete.pm,v 1.12 2011/07/12 10:30:29 espie Exp $ +# $OpenBSD: PkgDelete.pm,v 1.13 2011/07/12 10:51:28 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org> # @@ -221,6 +221,32 @@ sub really_remove $state->progress->next($state->ntogo); } +sub delete_dependencies +{ + my $state = shift; + + if ($state->defines("dependencies")) { + return 1; + } + if ($state->{interactive}) { + return $state->confirm("Delete them as well", 0); + } + return 0; +} + +sub fix_bad_dependencies +{ + my $state = shift; + + if ($state->defines("baddepend")) { + return 1; + } + if ($state->{interactive}) { + return $state->confirm("Delete anyways", 0); + } + return 0; +} + sub remove_set { my ($set, $state) = @_; @@ -251,12 +277,27 @@ sub remove_set } } if (keys %$bad > 0) { + my $bad2 = {}; + for my $pkg (keys %$bad) { + if (!is_installed($pkg)) { + $bad2->{$pkg} = 1; + } + } + if (keys %$bad2 > 0) { + $state->errsay("#1 depends on non-existant #2", + $set->delete_print, join(' ', sort keys %$bad2)); + if (fix_bad_dependencies($state)) { + for my $pkg (keys %$bad2) { + delete $bad->{$pkg}; + } + } + } + } + if (keys %$bad > 0) { if (!$state->{automatic}) { $state->errsay("can't delete #1 without deleting #2", - join(' ', $set->older_names), - join(' ', sort keys %$bad)); - if ($state->{interactive} && - $state->confirm("Delete them as well", 0)) { + $set->delete_print, join(' ', sort keys %$bad)); + if (delete_dependencies($state)) { my $l = create_locations($state, keys %$bad); $state->tracker->todo($l); return (@$l, $set); diff --git a/usr.sbin/pkg_add/pkg_delete.1 b/usr.sbin/pkg_add/pkg_delete.1 index 6aceee5e92d..d283ef6302d 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.38 2011/07/12 10:34:09 espie Exp $ +.\" $OpenBSD: pkg_delete.1,v 1.39 2011/07/12 10:51:28 espie Exp $ .\" .\" Documentation and design originally from FreeBSD. All the code has .\" been rewritten since. We keep the documentation's notice: @@ -75,8 +75,6 @@ is a keyword that states what failsafe should be waived. Recognized keywords include: .Bl -tag -width "dependenciesXX" -.It Ar ambiguous -delete all packages matching ambiguous package specifications. .It Ar baddepend force the deletion of packages even if they reference inexistent dependencies. .It Ar dependencies @@ -85,10 +83,6 @@ also delete the whole set of packages that depends upon the requested packages. uninstall even if not running as root. .It Ar scripts 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. |