summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm18
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Dependencies.pm8
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Interactive.pm7
3 files changed, 19 insertions, 14 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm b/usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm
index 99724c92866..376714f8965 100644
--- a/usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm
+++ b/usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: AddCreateDelete.pm,v 1.29 2015/01/04 14:20:04 espie Exp $
+# $OpenBSD: AddCreateDelete.pm,v 1.30 2015/01/30 11:42:55 espie Exp $
#
# Copyright (c) 2007-2014 Marc Espie <espie@openbsd.org>
#
@@ -59,24 +59,22 @@ sub handle_options
{
my ($state, $opt_string, @usage) = @_;
+ my $i;
+ $state->{opt}{i} = sub {
+ $i++;
+ };
$state->SUPER::handle_options($opt_string.'IiL:mnx', @usage);
$state->progress->setup($state->opt('x'), $state->opt('m'), $state);
$state->{not} = $state->opt('n');
- if ($state->opt('i') && $state->opt('I')) {
- $state->usage("-i and -I are reverse options, make up your mind");
- }
- my $i;
- if ($state->opt('i')) {
- $i = 1;
- } elsif ($state->opt('I')) {
+ if ($state->opt('I')) {
$i = 0;
- } else {
+ } elsif (!defined $i) {
$i = -t STDIN;
}
if ($i) {
require OpenBSD::Interactive;
- $state->{interactive} = OpenBSD::Interactive->new($state);
+ $state->{interactive} = OpenBSD::Interactive->new($state, $i);
} else {
$state->{interactive} = OpenBSD::InteractiveStub->new($state);
}
diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
index 062ff005af9..70bb7684972 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.154 2014/11/30 15:56:34 espie Exp $
+# $OpenBSD: Dependencies.pm,v 1.155 2015/01/30 11:42:55 espie Exp $
#
# Copyright (c) 2005-2010 Marc Espie <espie@openbsd.org>
#
@@ -572,6 +572,12 @@ sub find_dep_in_repositories
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}})) {
+ return $d;
+ }
+ }
# put default first if available
@pkgs = ((grep {$_ eq $dep->{def}} @pkgs),
(sort (grep {$_ ne $dep->{def}} @pkgs)));
diff --git a/usr.sbin/pkg_add/OpenBSD/Interactive.pm b/usr.sbin/pkg_add/OpenBSD/Interactive.pm
index 432f2aab692..0f8fcfe9e08 100644
--- a/usr.sbin/pkg_add/OpenBSD/Interactive.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Interactive.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Interactive.pm,v 1.19 2014/12/29 07:37:27 jasper Exp $
+# $OpenBSD: Interactive.pm,v 1.20 2015/01/30 11:42:55 espie Exp $
#
# Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org>
#
@@ -21,10 +21,11 @@ package OpenBSD::Interactive;
sub new
{
- my ($class, $state) = @_;
+ my ($class, $state, $level) = @_;
bless {
state => $state,
always => 0,
+ level => $level,
}, $class;
}
@@ -109,7 +110,7 @@ LOOP2:
sub is_interactive
{
- return 1;
+ return shift->{level};
}
1;