diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2009-11-30 15:49:53 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2009-11-30 15:49:53 +0000 |
commit | 13edd436d4838f91280f0491a9607a5a2f2e55fa (patch) | |
tree | 9827f6f4321e68fd4b5db3ca52c72edf9fd72c42 /usr.sbin | |
parent | 2edba4d3878014ce248ad7dd6bd280599b7d56fc (diff) |
better: have can_install return 0/1 as definitive answer, and return "undef"
for try again later.
Don't bother cleaning up set from can_install, since complete does it too.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index 7aeee330c8d..a9502be9e5f 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.404 2009/11/29 14:07:07 espie Exp $ +# $OpenBSD: pkg_add,v 1.405 2009/11/30 15:49:52 espie Exp $ # # Copyright (c) 2003-2009 Marc Espie <espie@openbsd.org> # @@ -160,12 +160,12 @@ sub complete return 1 if defined $set->{installable}; - my $r = $set->can_install($state); - return 0 if defined $r && $r == 0; - $set->{installable} = $r; + $set->{installable} = $set->can_install($state); + return 0 if !defined $set->{installable}; if (!$set->{installable}) { $set->cleanup(OpenBSD::Handle::CANT_INSTALL); + $set->{finished} = 1; } return 1; } @@ -246,16 +246,14 @@ sub can_install return 1 if @conflicts == 0; if (!$state->{allow_replacing}) { - $state->say("Can't install ", $set->short_print, + $state->errsay("Can't install ", $set->short_print, " because of conflicts (",join(',', @conflicts), ")"); - $set->cleanup(OpenBSD::Handle::CANT_INSTALL); - return; + return 0; } if (!$set->is_new_stuff_safe($state)) { - $set->cleanup(OpenBSD::Handle::CANT_INSTALL); - return; + return 0; } my $later = 0; @@ -263,8 +261,7 @@ sub can_install if ($state->tracker->is_installed($toreplace)) { $state->errsay("Cannot replace $toreplace in ", $set->short_print, ": just got installed"); - $set->cleanup(OpenBSD::Handle::CANT_INSTALL); - return; + return 0; } next if $set->{older}->{$toreplace}; @@ -279,7 +276,7 @@ sub can_install } } - return 0 if $later; + return if $later; my $manual_install = 0; @@ -296,10 +293,9 @@ sub can_install if (!OpenBSD::Replace::can_old_package_be_replaced($old->plist, $set, $state)) { - $state->say("Can't update $name into ", + $state->errsay("Can't update $name into ", $set->short_print); - $set->cleanup(OpenBSD::Handle::CANT_INSTALL); - return; + return 0; } if ($old->plist->has('manual-installation')) { |