diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2010-01-01 02:19:21 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2010-01-01 02:19:21 +0000 |
commit | dab9c89520cfe94f24d1c78afc2bbeec0134a60b (patch) | |
tree | f7b127fbef0f914665871b0e749fe04a4c3f1e77 | |
parent | e24f14b8a1dface5e78ba5f439bcf3dacab47de7 (diff) |
be slightly smarter about forward deps: check we have updates before
merging. Otherwise, fall back to updatedepends or asking.
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index 0c113e672fc..195ecf32671 100644 --- a/usr.sbin/pkg_add/pkg_add +++ b/usr.sbin/pkg_add/pkg_add @@ -1,9 +1,9 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_add,v 1.454 2009/12/31 13:48:52 espie Exp $ +# $OpenBSD: pkg_add,v 1.455 2010/01/01 02:19:20 espie Exp $ # -# Copyright (c) 2003-2009 Marc Espie <espie@openbsd.org> +# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -342,6 +342,24 @@ sub install_issues return 0; } +sub try_merging +{ + my ($set, $m, $state) = @_; + + my $s = $state->tracker->is_to_update($m); + if (!defined $s) { + $s = OpenBSD::UpdateSet->new->add_older( + OpenBSD::Handle->create_old($m, $state)); + } + if ($state->updater->process_set($s, $state)) { + $state->say("Merging ", $s->print, $state->ntogo); + $set->merge($state->tracker, $s); + return 1; + } else { + return 0; + } +} + sub check_forward_dependencies { my ($set, $state) = @_; @@ -352,18 +370,13 @@ sub check_forward_dependencies if (%$bad) { if ($state->{defines}->{mergeupdates}) { + my $okay = 1; for my $m (keys %$bad) { - my $s = $state->tracker->is_to_update($m); - if (defined $s) { - $set->merge($state->tracker, $s); - } else { - $set->add_older(OpenBSD::Handle->create_old( - $m, $state)); - } + $set->try_merging($m, $state) or $okay = 0; } - $state->say("Merging ", $set->print, $state->ntogo); - return 0; - } elsif ($state->{defines}->{updatedepends}) { + return 0 if $okay == 1; + } + if ($state->{defines}->{updatedepends}) { $state->errsay("Forcing update"); return 1; } elsif ($state->{interactive}) { |