From f6ef6f9ad26cf7b687c6e1a12132a9e1c7650c9e Mon Sep 17 00:00:00 2001 From: Marc Espie <espie@cvs.openbsd.org> Date: Sat, 26 May 2007 12:22:39 +0000 Subject: base tests on $handle->has_error instead of $errors. --- usr.sbin/pkg_add/OpenBSD/Vstat.pm | 6 +++--- usr.sbin/pkg_add/pkg_add | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/usr.sbin/pkg_add/OpenBSD/Vstat.pm b/usr.sbin/pkg_add/OpenBSD/Vstat.pm index e50380a7364..3e1baf7e8fc 100644 --- a/usr.sbin/pkg_add/OpenBSD/Vstat.pm +++ b/usr.sbin/pkg_add/OpenBSD/Vstat.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Vstat.pm,v 1.21 2007/05/25 13:18:57 espie Exp $ +# $OpenBSD: Vstat.pm,v 1.22 2007/05/26 12:22:38 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -256,12 +256,12 @@ sub has_error { my ($self, $error) = @_; if (!defined $self->{error}) { - return 0; + return undef; } if (defined $error) { return $self->{error} eq $error; } - return 1; + return $self->{error}; } package OpenBSD::UpdateSet; diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index 40b1e49969a..5a7b92ab19a 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.266 2007/05/26 12:15:45 espie Exp $ +# $OpenBSD: pkg_add,v 1.267 2007/05/26 12:22:38 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -528,11 +528,20 @@ sub install_package } my $location = $cache->{$pkg}; - if ($errors > 0) { - $state->set_pkgname($pkg); - $state->fatal("Fatal error") unless defined $location; + if ($state->{forced}->{kitchensink}) { + if ($handle->has_error(OpenBSD::Handle::BAD_PACKAGE)) { + $state->set_pkgname($pkg); + $state->fatal("Fatal error") unless defined $location; + } else { + return () unless defined $location; + } } else { - return () unless defined $location; + if ($handle->has_error) { + $state->set_pkgname($pkg); + $state->fatal("Fatal error") unless defined $location; + } else { + return () unless defined $location; + } } if ($state->is_installed($location->{pkgname})) { -- cgit v1.2.3