summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2009-12-28 12:51:27 +0000
committerMarc Espie <espie@cvs.openbsd.org>2009-12-28 12:51:27 +0000
commit3eb56ed12b79d02ae89d6f9b5e4c82acfedeef91 (patch)
tree6eb9707882e2c34dcbc9a4de323832d12f29e035 /usr.sbin
parentdf21489bc4a8c527014cd466bc237d7c7ad3a507 (diff)
move code around a bit, more functions. Especially do the exec check
ways later, when we're certain we're not going to change the set any longer, so we don't need to go back.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Replace.pm6
-rw-r--r--usr.sbin/pkg_add/pkg_add99
2 files changed, 62 insertions, 43 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Replace.pm b/usr.sbin/pkg_add/OpenBSD/Replace.pm
index 372134586ae..36bd8b3733c 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.64 2009/12/27 15:32:20 espie Exp $
+# $OpenBSD: Replace.pm,v 1.65 2009/12/28 12:51:26 espie Exp $
#
# Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org>
#
@@ -309,14 +309,10 @@ sub is_set_safe
my $ok = 1;
for my $pkg ($set->older) {
- next if defined $pkg->{exec_checked};
$ok = 0 unless can_old_package_be_replaced($pkg->plist, $state);
- $pkg->{exec_checked} = 1;
}
for my $pkg ($set->newer) {
- next if defined $pkg->{exec_checked};
$ok = 0 unless is_new_package_safe($pkg->plist, $state);
- $pkg->{exec_checked} = 1;
}
return 1 if $ok;
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 9da16743b9a..adf2342a5d6 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.440 2009/12/28 10:42:02 espie Exp $
+# $OpenBSD: pkg_add,v 1.441 2009/12/28 12:51:26 espie Exp $
#
# Copyright (c) 2003-2009 Marc Espie <espie@openbsd.org>
#
@@ -297,9 +297,7 @@ sub can_install
$set->mark_as_manual_install if $manual_install;
- require OpenBSD::Replace;
-
- return OpenBSD::Replace::is_set_safe($set, $state);
+ return 1;
}
sub recheck_conflicts
@@ -400,17 +398,9 @@ sub iterate
}
}
-sub really_add
+sub check_x509_signature
{
my ($set, $state) = @_;
-
- for my $h ($set->newer) {
- $h->plist->set_infodir($h->location->info);
- }
-
- $set->validate_plists($state);
-
- my $errors = 0;
for my $handle ($set->newer) {
$state->set_name_from_handle($handle, '+');
my $plist = $handle->plist;
@@ -434,6 +424,21 @@ sub really_add
$state->{check_digest} = 0;
}
}
+}
+
+sub really_add
+{
+ my ($set, $state) = @_;
+
+ for my $h ($set->newer) {
+ $h->plist->set_infodir($h->location->info);
+ }
+
+ $set->validate_plists($state);
+
+ my $errors = 0;
+
+ check_x509_signature($set, $state);
if ($state->{not}) {
$state->status->what("Pretending to add");
@@ -578,35 +583,14 @@ sub really_add
}
}
-sub install_set
+sub newer_has_errors
{
my ($set, $state) = @_;
- $set = $set->real_set;
-
- if ($set->{finished}) {
- return ();
- }
-
- if (!$state->updater->process_set($set, $state)) {
- return ();
- }
-
- for my $handle ($set->newer) {
- if ($state->tracker->is_installed($handle->pkgname)) {
- $set->cleanup(OpenBSD::Handle::ALREADY_INSTALLED);
- return ();
- }
- }
-
- if (!$set->complete($state)) {
- return $set;
- }
-
for my $handle ($set->newer) {
if ($handle->has_error(OpenBSD::Handle::ALREADY_INSTALLED)) {
$set->cleanup(OpenBSD::Handle::ALREADY_INSTALLED);
- return ();
+ return 1;
}
if ($handle->has_error) {
$state->set_name_from_handle($handle);
@@ -615,7 +599,7 @@ sub install_set
$bad++;
$set->cleanup($handle->has_error);
$state->tracker->cant($set);
- return ();
+ return 1;
}
if ($handle->plist->has('arch')) {
@@ -625,11 +609,42 @@ sub install_set
if (!$defines{arch}) {
$set->cleanup(OpenBSD::Handle::CANT_INSTALL);
$state->tracker->cant($set);
- return ();
+ return 1;
}
}
}
}
+ return 0;
+}
+
+sub install_set
+{
+ my ($set, $state) = @_;
+
+ $set = $set->real_set;
+
+ if ($set->{finished}) {
+ return ();
+ }
+
+ if (!$state->updater->process_set($set, $state)) {
+ return ();
+ }
+
+ for my $handle ($set->newer) {
+ if ($state->tracker->is_installed($handle->pkgname)) {
+ $set->cleanup(OpenBSD::Handle::ALREADY_INSTALLED);
+ return ();
+ }
+ }
+
+ if (!$set->complete($state)) {
+ return $set;
+ }
+
+ if (newer_has_errors($set, $state)) {
+ return ();
+ }
if (!defined $set->{solver} || $set->{solver}->{not_ready}) {
delete $set->{solver};
@@ -684,6 +699,14 @@ sub install_set
$state->tracker->cant($set);
return ();
}
+ if ($set->older_to_do) {
+ require OpenBSD::Replace;
+ if (!OpenBSD::Replace::is_set_safe($set, $state)) {
+ $set->cleanup(OpenBSD::Handle::CANT_INSTALL);
+ $state->tracker->cant($set);
+ return ();
+ }
+ }
really_add($set, $state);
$set->cleanup;
$state->tracker->done($set);