summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-06-11 09:12:28 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-06-11 09:12:28 +0000
commite691562c2ceaccc44196bbe09aeab511385114ea (patch)
treed2c2f8b7dd4da258f56e781dbbd6dba6153672b0 /usr.sbin/pkg_add
parent8478e815b5e07f4d232e157183ac57b808e2f331 (diff)
keep on extracting stuff
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Vstat.pm21
-rw-r--r--usr.sbin/pkg_add/pkg_add27
2 files changed, 28 insertions, 20 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Vstat.pm b/usr.sbin/pkg_add/OpenBSD/Vstat.pm
index a951f971b6d..9e94cfc3f05 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.39 2007/06/10 16:05:49 espie Exp $
+# $OpenBSD: Vstat.pm,v 1.40 2007/06/11 09:12:27 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -369,6 +369,16 @@ sub create_old
}
return $self;
}
+
+sub create_new
+{
+ my ($class, $pkg) = @_;
+ my $handle = $class->new;
+ $handle->{pkgname} = $pkg;
+ $handle->{tweaked} = 0;
+ return $handle;
+}
+
package OpenBSD::UpdateSet;
sub new
{
@@ -477,6 +487,15 @@ sub handle
}
}
+# temporary creator
+sub create_new
+{
+ my ($class, $pkgname) = @_;
+ my $set = $class->new;
+ $set->add_newer(OpenBSD::Handle->create_new($pkgname));
+ return $set;
+}
+
package OpenBSD::PackingList;
sub compute_size
{
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index de8828f7f04..aae16a92060 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.320 2007/06/10 16:05:49 espie Exp $
+# $OpenBSD: pkg_add,v 1.321 2007/06/11 09:12:27 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -190,31 +190,20 @@ sub can_install
return 1;
}
-sub create_handle
-{
- my $pkg = shift;
- my $handle = OpenBSD::Handle->new;
- $handle->{pkgname} = $pkg;
- $handle->{tweaked} = 0;
- return $handle;
-}
-
sub prepare_to_add
{
my ($pkg, $state) = @_;
- my $set = OpenBSD::UpdateSet->new;
- my $handle = create_handle($pkg);
- $set->add_newer($handle);
- $handle->complete($state);
- if ($handle->has_error) {
+ my $set = OpenBSD::UpdateSet->create_new($pkg);
+ $set->handle->complete($state);
+ if ($set->handle->has_error) {
return $set;
}
if (!can_install($set, $state)) {
- $handle->{location}->close_with_client_error;
- $handle->{location}->wipe_info;
- delete $handle->{plist};
- $handle->set_error(OpenBSD::Handle::CANT_INSTALL);
+ $set->handle->{location}->close_with_client_error;
+ $set->handle->{location}->wipe_info;
+ delete $set->handle->{plist};
+ $set->handle->set_error(OpenBSD::Handle::CANT_INSTALL);
}
return $set;
}