summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-05-27 10:38:13 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-05-27 10:38:13 +0000
commit9665351e89f61f3ad378f1ca23435838e9dfd04a (patch)
tree4c874d76740e8067ea0ac169d4a2ed0ccc172421 /usr.sbin/pkg_add
parent7805df2b30f8de1d99751bd0e3a1506c3972904c (diff)
depend more stuff off handle.
Introduce UpdateSet, finally, with a main handle.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Vstat.pm13
-rw-r--r--usr.sbin/pkg_add/pkg_add29
2 files changed, 28 insertions, 14 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Vstat.pm b/usr.sbin/pkg_add/OpenBSD/Vstat.pm
index 3e1baf7e8fc..07b1f280377 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.22 2007/05/26 12:22:38 espie Exp $
+# $OpenBSD: Vstat.pm,v 1.23 2007/05/27 10:38:12 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -283,4 +283,15 @@ sub add_older
push(@{$self->{older}}, @handles);
}
+# temporary shortcut
+sub handle
+{
+ my $self = shift;
+ if (defined $self->{newer}) {
+ return $self->{newer}[0];
+ } else {
+ return undef;
+ }
+}
+
1;
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index e3c219ceb81..d7275ae4ee2 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.272 2007/05/27 09:59:41 espie Exp $
+# $OpenBSD: pkg_add,v 1.273 2007/05/27 10:38:12 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -100,7 +100,7 @@ sub can_install
{
my ($handle, $state) = @_;
my $plist = $handle->{plist};
- my $pkgname = $plist->pkgname;
+ my $pkgname = $handle->{pkgname};
$plist->{replacing} = [];
my @conflicts = OpenBSD::PkgCfl::find_all($plist, $state);
return 1 if @conflicts == 0;
@@ -197,33 +197,35 @@ sub prepare_to_add
{
my ($pkg, $state) = @_;
+ my $set = OpenBSD::UpdateSet->new;
my $handle = OpenBSD::Handle->new;
+ $set->add_newer($handle);
my $location = OpenBSD::PackageLocator->find($pkg, $state->{arch});
if (!$location) {
print $state->deptree_header($pkg);
print "Can't find $pkg\n";
$handle->set_error(OpenBSD::Handle::NOT_FOUND);
- return $handle;
+ return $set;
}
$handle->{location} = $location;
my $plist = $handle->{plist} = $location->plist;
unless (defined $plist) {
print "Can't find CONTENTS from $pkg\n";
$handle->set_error(OpenBSD::Handle::BAD_PACKAGE);
- return $handle;
+ return $set;
}
if ($plist->localbase ne $state->{localbase}) {
print "Localbase mismatch: package has: ", $plist->localbase, " , user wants: ", $state->{localbase}, "\n";
$handle->set_error(OpenBSD::Handle::BAD_PACKAGE);
- return $handle;
+ return $set;
}
- my $pkgname = $handle->{pkgname} = $location->{pkgname} = $plist->pkgname;
+ my $pkgname = $handle->{pkgname} = $plist->pkgname;
if ($pkg ne '-') {
if (!defined $pkgname or
OpenBSD::PackageName::url2pkgname($pkg) ne $pkgname) {
print "Package name is not consistent ???\n";
$handle->set_error(OpenBSD::Handle::BAD_PACKAGE);
- return $handle;
+ return $set;
}
}
if ($state->{verbose}) {
@@ -236,7 +238,7 @@ sub prepare_to_add
delete $handle->{plist};
$handle->set_error(OpenBSD::Handle::CANT_INSTALL);
}
- return $handle;
+ return $set;
}
@@ -265,7 +267,7 @@ sub failed_install
{
my ($handle, $not, $interrupted) = @_;
my $plist = $handle->{plist};
- my $pkgname = $plist->pkgname;
+ my $pkgname = $handle->{pkgname};
my $msg = "Installation of $pkgname failed";
if ($interrupted) {
$msg ="Caught SIG$interrupted. $msg";
@@ -281,7 +283,7 @@ sub really_add
my $destdir = $state->{destdir};
my $plist = $handle->{plist};
my $dir = $location->info;
- my $pkgname = $plist->pkgname;
+ my $pkgname = $handle->{pkgname};
$state->{archive} = $location;
$plist->{dir} = $dir;
$state->{dir} = $plist->{dir};
@@ -508,7 +510,8 @@ sub install_package
$cache->{$pkg} = prepare_to_add($pkg, $state);
}
- my $handle = $cache->{$pkg};
+ my $set = $cache->{$pkg};
+ my $handle = $set->handle;
if ($handle->has_error) {
if (!$state->{forced}->{kitchensink} ||
$handle->has_error(OpenBSD::Handle::BAD_PACKAGE)) {
@@ -527,10 +530,10 @@ sub install_package
my $plist = $handle->{plist};
- if (is_installed($plist->pkgname) && !$state->{forced}->{installed}) {
+ if (is_installed($handle->{pkgname}) && !$state->{forced}->{installed}) {
if ($state->{replace}) {
if (!$plist->has_new_sig($state) && !$plist->uses_old_libs) {
- $state->mark_as_already_installed($plist->pkgname);
+ $state->mark_as_already_installed($handle->{pkgname});
$location->close_now;
return ();
}