diff options
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/AddDelete.pm | 11 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/CollisionReport.pm | 6 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Interactive.pm | 37 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Replace.pm | 10 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Update.pm | 3 |
5 files changed, 25 insertions, 42 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/AddDelete.pm b/usr.sbin/pkg_add/OpenBSD/AddDelete.pm index 48d3e1c8d66..046f5b7de1c 100644 --- a/usr.sbin/pkg_add/OpenBSD/AddDelete.pm +++ b/usr.sbin/pkg_add/OpenBSD/AddDelete.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: AddDelete.pm,v 1.3 2009/11/16 14:42:18 espie Exp $ +# $OpenBSD: AddDelete.pm,v 1.4 2009/11/17 10:17:21 espie Exp $ # # Copyright (c) 2007-2009 Marc Espie <espie@openbsd.org> # @@ -330,6 +330,15 @@ sub choose_location } } +sub confirm +{ + my ($state, $prompt, $default) = @_; + + return 0 if !$state->{interactive}; + require OpenBSD::Interactive; + return OpenBSD::Interactive::confirm($prompt, $default); +} + # stub class when no actual progressmeter that still prints out. package OpenBSD::StubProgress; sub clear {} diff --git a/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm b/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm index 8ae0d943845..0413b8ec696 100644 --- a/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm +++ b/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: CollisionReport.pm,v 1.27 2009/11/16 14:42:18 espie Exp $ +# $OpenBSD: CollisionReport.pm,v 1.28 2009/11/17 10:17:21 espie Exp $ # # Copyright (c) 2003-2006 Marc Espie <espie@openbsd.org> # @@ -124,9 +124,7 @@ sub collision_report($$) if ($state->{defines}->{repair}) { $dorepair = 1; } elsif ($state->{interactive}) { - require OpenBSD::Interactive; - if (OpenBSD::Interactive::confirm( - "It seems to be a missing package registration\nRepair", 1, 0)) { + if ($state->confirm("It seems to be a missing package registration\nRepair", 0)) { $dorepair = 1; } } diff --git a/usr.sbin/pkg_add/OpenBSD/Interactive.pm b/usr.sbin/pkg_add/OpenBSD/Interactive.pm index cf533397f27..85d9e7fd957 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.10 2009/11/10 11:36:56 espie Exp $ +# $OpenBSD: Interactive.pm,v 1.11 2009/11/17 10:17:21 espie Exp $ # # Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org> # @@ -57,20 +57,19 @@ LOOP: } } -my $always = {}; +my $always = 0; sub confirm { - my ($prompt, $interactive, $default, $key) = @_; - if (!$interactive || !-t STDIN) { + my ($prompt, $default) = @_; + if (!-t STDIN) { return 0; } - if (defined $key && $always->{$key}) { + if ($always) { return 1; } LOOP2: - my $a = defined $key ? '/a' : ''; - print STDERR $prompt, $default ? "? [Y/n$a] " : "? [y/N$a] "; + print STDERR $prompt, $default ? "? [Y/n/a] " : "? [y/N/a] "; my $result = <STDIN>; unless(defined $result) { @@ -86,8 +85,8 @@ LOOP2: if ($result eq 'no' or $result eq 'n') { return 0; } - if (defined $key && $result eq 'a') { - $always->{$key} = 1; + if ($result eq 'a') { + $always = 1; return 1; } if ($result eq '') { @@ -97,24 +96,4 @@ LOOP2: goto LOOP2; } -sub choose1 -{ - my ($pkgname, $interactive, @l) = @_; - if (@l == 0) { - print "Can't resolve $pkgname\n"; - } elsif (@l == 1) { - return $l[0]; - } elsif (@l != 0) { - if ($interactive) { - my $result = ask_list("Ambiguous: choose package for $pkgname", 1, ("<None>", @l)); - if ($result ne '<None>') { - return $result; - } - } else { - print "Ambiguous: $pkgname could be ", join(' ', @l),"\n"; - } - } - return; -} - 1; diff --git a/usr.sbin/pkg_add/OpenBSD/Replace.pm b/usr.sbin/pkg_add/OpenBSD/Replace.pm index b87f9c52192..f22b5c73957 100644 --- a/usr.sbin/pkg_add/OpenBSD/Replace.pm +++ b/usr.sbin/pkg_add/OpenBSD/Replace.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Replace.pm,v 1.54 2009/11/11 12:32:03 espie Exp $ +# $OpenBSD: Replace.pm,v 1.55 2009/11/17 10:17:21 espie Exp $ # # Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org> # @@ -18,7 +18,6 @@ use strict; use warnings; use OpenBSD::Delete; -use OpenBSD::Interactive; package OpenBSD::PackingElement; sub can_update @@ -239,7 +238,7 @@ sub validate_depend $state->{forcedupdates}->{$wanting} = 1; } elsif ($state->{interactive}) { - if (OpenBSD::Interactive::confirm("Forward dependency of $wanting on $toreplace doesn't match $replacement, proceed with update anyways", 1, 0, 'updatedepends')) { + if ($state->confirm("Forward dependency of $wanting on $toreplace doesn't match $replacement, proceed with update anyways", 0)) { $state->{forcedupdates} = {} unless defined $state->{forcedupdates}; $state->{forcedupdates}->{$wanting} = 1; } else { @@ -293,7 +292,6 @@ use OpenBSD::RequiredBy; use OpenBSD::PackingList; use OpenBSD::PackageInfo; use OpenBSD::Error; -use OpenBSD::Interactive; sub perform_extraction { @@ -326,7 +324,7 @@ sub can_old_package_be_replaced $state->{okay} = 1; } elsif ($state->{interactive}) { - if (OpenBSD::Interactive::confirm("proceed with update anyways", 1, 0, 'update')) { + if ($state->confirm("proceed with update anyways", 0)) { $state->{okay} = 1; } } @@ -369,7 +367,7 @@ sub is_new_package_safe $state->errsay("(forcing update)"); $state->{okay} = 1; } elsif ($state->{interactive}) { - if (OpenBSD::Interactive::confirm("proceed with update anyways", 1, 0, 'update')) { + if ($state->confirm("proceed with update anyways", 0)) { $state->{okay} = 1; } } diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm index c6821e387b7..52b12c78777 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.98 2009/11/16 17:30:43 espie Exp $ +# $OpenBSD: Update.pm,v 1.99 2009/11/17 10:17:21 espie Exp $ # # Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org> # @@ -18,7 +18,6 @@ use strict; use warnings; package OpenBSD::Update; -use OpenBSD::Interactive; use OpenBSD::PackageInfo; use OpenBSD::PackageLocator; use OpenBSD::PackageName; |