diff options
-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 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 6 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_delete | 8 |
7 files changed, 30 insertions, 51 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; diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index af1b76b4421..14e839e772c 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.388 2009/11/16 23:02:36 espie Exp $ +# $OpenBSD: pkg_add,v 1.389 2009/11/17 10:17:21 espie Exp $ # # Copyright (c) 2003-2009 Marc Espie <espie@openbsd.org> # @@ -29,7 +29,6 @@ use OpenBSD::PackageInfo; use OpenBSD::PackageLocator; use OpenBSD::PackageName; use OpenBSD::PkgCfl; -use OpenBSD::Interactive; use OpenBSD::Add; use OpenBSD::SharedLibs; use OpenBSD::UpdateSet; @@ -661,8 +660,7 @@ sub inform_user_of_pending_update $state->{full_update} && !$state->{interactive}) { print "Proceeding anyways\n"; } else { - if (!OpenBSD::Interactive::confirm("Proceed", - $state->{interactive}, 0)) { + if (!$state->confirm("Proceed", 0)) { exit(1); } } diff --git a/usr.sbin/pkg_add/pkg_delete b/usr.sbin/pkg_add/pkg_delete index fd54b922f23..703b36afd91 100644 --- a/usr.sbin/pkg_add/pkg_delete +++ b/usr.sbin/pkg_add/pkg_delete @@ -1,6 +1,6 @@ #!/usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_delete,v 1.124 2009/11/16 23:02:36 espie Exp $ +# $OpenBSD: pkg_delete,v 1.125 2009/11/17 10:17:21 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -29,7 +29,6 @@ our ($state, %defines, $bad, $opt_B); use OpenBSD::PackingList; use OpenBSD::RequiredBy; -use OpenBSD::Interactive; use OpenBSD::Delete; use OpenBSD::PackageInfo; use OpenBSD::UpdateSet; @@ -92,8 +91,7 @@ sub process_parameters } &$show([@realnames], [keys %deps]); if (@realnames > 1 && (keys %deps) > 1 && - OpenBSD::Interactive::confirm( - "Do you want details", $state->{interactive}, 1)) { + $state->confirm("Do you want details", 1)) { $details = 1; } } @@ -107,7 +105,7 @@ sub process_parameters } my $them = @todo > 1 ? 'them' : 'it'; if ($defines{dependencies} or - OpenBSD::Interactive::confirm("Do you want to remove $them as well", $state->{interactive}, 0)) { + $state->confirm("Do you want to remove $them as well", 0)) { $state->say("(removing $them as well)"); } else { $bad = 1; |