summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2009-11-08 12:16:24 +0000
committerMarc Espie <espie@cvs.openbsd.org>2009-11-08 12:16:24 +0000
commitb5ca2951bc85f080e2123027c50b0ea1c6a0704f (patch)
tree1d120a94d40b0f0b0011a9c55afcab91705bd956 /usr.sbin
parent88b8290f5cc4d63e03c502eb7695181eba8e4816 (diff)
let Handle display what went wrong.
Move stuff from being a fatal error to an error that displays at end, together with an error code.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Handle.pm19
-rw-r--r--usr.sbin/pkg_add/pkg_add13
2 files changed, 24 insertions, 8 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Handle.pm b/usr.sbin/pkg_add/OpenBSD/Handle.pm
index f7affacf1c2..e0b53db4fa4 100644
--- a/usr.sbin/pkg_add/OpenBSD/Handle.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Handle.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Handle.pm,v 1.8 2009/11/08 11:31:37 espie Exp $
+# $OpenBSD: Handle.pm,v 1.9 2009/11/08 12:16:23 espie Exp $
#
# Copyright (c) 2007-2009 Marc Espie <espie@openbsd.org>
#
@@ -97,6 +97,23 @@ sub has_error
return $self->{error};
}
+sub error_message
+{
+ my $self = shift;
+ my $error = $self->{error};
+ if ($error == BAD_PACKAGE) {
+ return "bad package";
+ } elsif ($error == CANT_INSTALL) {
+ return "can't install";
+ } elsif ($error == NOT_FOUND) {
+ return "not found";
+ } elsif ($error == ALREADY_INSTALLED) {
+ return "already installed";
+ } else {
+ return "no error";
+ }
+}
+
sub create_old
{
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index fa2db2e8016..8850525cc10 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.372 2009/11/08 11:18:41 espie Exp $
+# $OpenBSD: pkg_add,v 1.373 2009/11/08 12:16:23 espie Exp $
#
# Copyright (c) 2003-2009 Marc Espie <espie@openbsd.org>
#
@@ -476,12 +476,11 @@ sub install_set
return ();
}
if ($handle->has_error) {
- if (!$handle->{tweaked}) {
- $state->set_name_from_handle($handle);
- $state->fatal("Fatal error");
- } else {
- return ();
- }
+ $state->set_name_from_handle($handle);
+ $state->print("Can't install ", $handle->pkgname, ":",
+ $handle->error_message, "\n");
+ $bad++;
+ return ();
}
if ($handle->plist->has('arch')) {