summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2009-10-14 11:08:17 +0000
committerMarc Espie <espie@cvs.openbsd.org>2009-10-14 11:08:17 +0000
commit822f955d53820d205eb29f77c81993d8a978cd25 (patch)
tree8c714f52f6c0c3bdb86ea7b2a4a6d07597956395
parentc69bd1e7a9ad85db9fdb7c5afe575467890cef5f (diff)
use choose_location
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Update.pm24
-rw-r--r--usr.sbin/pkg_add/pkg_add40
2 files changed, 10 insertions, 54 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm
index 5ff19f64c7e..de00ae5d00a 100644
--- a/usr.sbin/pkg_add/OpenBSD/Update.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Update.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Update.pm,v 1.85 2009/10/13 21:21:07 espie Exp $
+# $OpenBSD: Update.pm,v 1.86 2009/10/14 11:08:16 espie Exp $
#
# Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org>
#
@@ -103,7 +103,6 @@ sub process_handle
push(@search, OpenBSD::Search::FilterLocation->keep_most_recent);
}
-
my $l = OpenBSD::PackageLocator->match_locations(@search);
if (@$l == 0) {
return undef;
@@ -124,25 +123,12 @@ sub process_handle
}
}
- $state->progress->clear;
- my %cnd = map {($_->name, $_)} @$l;
- print "Candidates for updating $pkgname -> ", join(' ', keys %cnd), "\n";
+ $state->progress->print("Candidates for updating $pkgname -> ", join(' ', map {$_->name} @$l), "\n");
- if (@$l == 1) {
- $self->add_updateset($set, $h, $l->[0]);
+ my $r = $state->choose_location($pkgname, $l);
+ if (defined $r) {
+ $self->add_updateset($set, $h, $r);
return 1;
- }
- my $result = OpenBSD::Interactive::choose1($pkgname,
- $state->{interactive}, sort keys %cnd);
- if (defined $result) {
- if (defined $found && $found eq $result &&
- !$plist->uses_old_libs) {
- print "No need to update $pkgname\n";
- return 0;
- } else {
- $self->add_updateset($set, $h, $cnd{$result});
- return 1;
- }
} else {
$state->{issues} = 1;
return undef;
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 7307781dca9..66839b9f13c 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.347 2009/10/14 11:06:41 espie Exp $
+# $OpenBSD: pkg_add,v 1.348 2009/10/14 11:08:16 espie Exp $
#
# Copyright (c) 2003-2009 Marc Espie <espie@openbsd.org>
#
@@ -626,23 +626,7 @@ sub stem2location
if (@$l > 1 && !$state->{defines}->{allversions}) {
$l = OpenBSD::Search::FilterLocation->keep_most_recent->filter_locations($l);
}
- if (@$l == 0) {
- print "Can't resolve $name\n";
- return undef;
- } elsif (@$l > 1) {
- my %h = map {($_->name, $_)} @$l;
- if ($state->{interactive}) {
- $h{'<None>'} = undef;
- my $result = OpenBSD::Interactive::ask_list("Ambiguous: choose package for $name", $state->{interactive}, sort keys %h);
- return $h{$result};
- } else {
- print "Ambiguous: $name could be ",
- join(' ', keys %h), "\n";
- return undef;
- }
- } elsif (@$l == 1) {
- return $l->[0];
- }
+ return $state->choose_location($name, $l);
}
@@ -770,7 +754,6 @@ lock_db($state->{not}) unless $state->{defines}->{nolock};
$state->setup_progressmeter($opt_x);
$state->check_root;
-my @todo = ();
my @todo2 = ();
if ($opt_l) {
@@ -796,23 +779,10 @@ if ($opt_l || $opt_z) {
$t =~ s/\-\d([^-]*)\-?/--/;
$l = OpenBSD::PackageLocator->match_locations(OpenBSD::Search::Stem->new($t), $k);
}
- if (@$l == 0) {
- $state->progress->clear;
- print "Can't find $_\n";
- } elsif (@$l > 1) {
- $state->progress->clear;
- if ($state->{interactive}) {
- my %cnd = map {($_->name, $_)} @$l;
- my $result = OpenBSD::Interactive::choose1($_,
- 1, sort keys %cnd);
- push @todo, $cnd{$result} if defined $result;
- } else {
- print "Ambiguous: $_\n";
- }
- } else {
- push(@todo, $l->[0]);
+ my $r = $state->choose_location($_, $l);
+ if (defined $r) {
+ push(@todo2, OpenBSD::UpdateSet->from_location($r));
}
- @todo2 = map { OpenBSD::UpdateSet->from_location($_) } @todo;
}
} elsif ($opt_u) {
require OpenBSD::Update;