summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2019-10-13 16:22:59 +0000
committerMarc Espie <espie@cvs.openbsd.org>2019-10-13 16:22:59 +0000
commit56e806333c4b8581dfb2538ad2f33d4eb7629f86 (patch)
tree8ae1d9c8c1fd3f5ab52023d163e9f63eb72bf9c4 /usr.sbin/pkg_add/OpenBSD
parent5e5c36168c827b4bce6314744a732ce7fe8415da (diff)
name value to shorten code
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Dependencies.pm11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
index 534b8e1ef35..6dafcbb359e 100644
--- a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Dependencies.pm,v 1.172 2019/05/23 22:33:29 espie Exp $
+# $OpenBSD: Dependencies.pm,v 1.173 2019/10/13 16:22:58 espie Exp $
#
# Copyright (c) 2005-2010 Marc Espie <espie@openbsd.org>
#
@@ -192,6 +192,8 @@ sub find_dep_in_repositories
return unless $dep->spec->is_valid;
+ my $default = $dep->{def};
+
my $candidates = $self->{set}->match_locations($dep->spec);
if (!$state->defines('allversions')) {
require OpenBSD::Search;
@@ -200,19 +202,20 @@ sub find_dep_in_repositories
}
# XXX not really efficient, but hey
my %c = map {($_->name, $_)} @$candidates;
+
my @pkgs = keys %c;
if (@pkgs == 1) {
return $candidates->[0];
} elsif (@pkgs > 1) {
# unless -ii, we return the def if available
if ($state->is_interactive < 2) {
- if (defined(my $d = $c{$dep->{def}})) {
+ if (defined(my $d = $c{$default})) {
return $d;
}
}
# put default first if available
- @pkgs = ((grep {$_ eq $dep->{def}} @pkgs),
- (sort (grep {$_ ne $dep->{def}} @pkgs)));
+ @pkgs = ((grep {$_ eq $default} @pkgs),
+ (sort (grep {$_ ne $default} @pkgs)));
my $good = $state->ask_list(
'Ambiguous: choose dependency for '.$self->{set}->print.': ',
@pkgs);