summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2009-10-15 18:32:12 +0000
committerMarc Espie <espie@cvs.openbsd.org>2009-10-15 18:32:12 +0000
commita8f4e0494367215058071983f9e4877eb47bfd8a (patch)
treedd7fe2c83689dbb5cce1a042bed1caf1ae5f5c41 /usr.sbin
parent28304259ca5315041425156cfcf7aea48374aee8 (diff)
move the installed check in Tracker, where they belong
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Tracker.pm14
-rw-r--r--usr.sbin/pkg_add/pkg_add25
2 files changed, 16 insertions, 23 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Tracker.pm b/usr.sbin/pkg_add/OpenBSD/Tracker.pm
index ebfc6c5b544..c4563356bda 100644
--- a/usr.sbin/pkg_add/OpenBSD/Tracker.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Tracker.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Tracker.pm,v 1.1 2009/10/15 18:17:18 espie Exp $
+# $OpenBSD: Tracker.pm,v 1.2 2009/10/15 18:32:11 espie Exp $
#
# Copyright (c) 2009 Marc Espie <espie@openbsd.org>
#
@@ -62,4 +62,16 @@ sub mark_installed
}
}
+sub is_installed
+{
+ my ($self, $pkg) = @_;
+ return $self->{installed}->{$pkg};
+}
+
+sub installed
+{
+ my $self = shift;
+ return keys %{$self->{installed}};
+}
+
1;
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 7f68e18bc2c..c42394172f5 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.354 2009/10/15 18:17:18 espie Exp $
+# $OpenBSD: pkg_add,v 1.355 2009/10/15 18:32:11 espie Exp $
#
# Copyright (c) 2003-2009 Marc Espie <espie@openbsd.org>
#
@@ -94,24 +94,6 @@ sub deptree_header
}
}
-sub mark_installed
-{
- my ($state, $pkg) = @_;
- $state->{installed}->{$pkg} = 1;
-}
-
-sub is_installed
-{
- my ($state, $pkg) = @_;
- return $state->{installed}->{$pkg};
-}
-
-sub installed
-{
- my $state = shift;
- return keys %{$state->{installed}};
-}
-
sub set_name_from_handle
{
my ($state, $h) = @_;
@@ -226,7 +208,7 @@ sub can_install
}
for my $toreplace (@conflicts) {
- if ($state->is_installed($toreplace)) {
+ if ($state->{tracker}->is_installed($toreplace)) {
Warn "Cannot replace $toreplace with $pkgname: just got installed\n";
$handle->set_error(OpenBSD::Handle::CANT_INSTALL);
return;
@@ -456,7 +438,7 @@ sub install_set
my ($set, $state, @todo) = @_;
my $handle = $set->handle;
- if ($state->is_installed($handle->pkgname)) {
+ if ($state->{tracker}->is_installed($handle->pkgname)) {
if (defined $handle->{location}) {
$handle->{location}->close_now;
}
@@ -528,7 +510,6 @@ sub install_set
$location->wipe_info;
delete $handle->{plist};
$state->{tracker}->mark_installed($set);
- $state->mark_installed($handle->pkgname);
return ();
}