diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-06-11 09:23:21 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-06-11 09:23:21 +0000 |
commit | ed7bcc17fa6abb14c9e0cfc59ed9caaf3a9f4491 (patch) | |
tree | 90deee1cd061aa281250dec23fba0015f32a15d0 /usr.sbin | |
parent | e2b81bf38ffb64bd0d430a0f54079b16c15acfa8 (diff) |
prepare more stuff to be able to deal with UpdateSets directly
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index aae16a92060..af08c671865 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.321 2007/06/11 09:12:27 espie Exp $ +# $OpenBSD: pkg_add,v 1.322 2007/06/11 09:23:20 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -100,6 +100,7 @@ sub set_name_from_handle package OpenBSD::UpdateSet; use OpenBSD::PackageInfo; +use OpenBSD::Error; sub setup_header { @@ -121,7 +122,24 @@ sub setup_header } } -package main; +sub complete +{ + my ($set, $state) = @_; + + $set->handle->complete($state); + return if $set->handle->has_error; + return if defined $set->{installable}; + + $set->{installable} = $set->can_install($state); + + if (!$set->{installable}) { + $set->handle->{location}->close_with_client_error; + $set->handle->{location}->wipe_info; + delete $set->handle->{plist}; + $set->handle->set_error(OpenBSD::Handle::CANT_INSTALL); + } +} + sub can_install { my ($set, $state) = @_; @@ -190,21 +208,14 @@ sub can_install return 1; } +package main; + sub prepare_to_add { my ($pkg, $state) = @_; my $set = OpenBSD::UpdateSet->create_new($pkg); - $set->handle->complete($state); - if ($set->handle->has_error) { - return $set; - } - if (!can_install($set, $state)) { - $set->handle->{location}->close_with_client_error; - $set->handle->{location}->wipe_info; - delete $set->handle->{plist}; - $set->handle->set_error(OpenBSD::Handle::CANT_INSTALL); - } + $set->complete($state); return $set; } |