summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-05-30 16:32:15 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-05-30 16:32:15 +0000
commit3f253f61eca131987f384f2f3b77b6ac8a2262b2 (patch)
treec8d8c7773fefe2637903c688c7991eeb5f0d1a2d /usr.sbin/pkg_add
parentd6d5b8a14834bcf7c886975434ca4e9a7df71b6c (diff)
simplify script handling a bit (they're going to disappear probably anyways).
Remove two passes visitors, we don't use them.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Add.pm16
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Delete.pm24
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageInfo.pm3
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingList.pm25
-rw-r--r--usr.sbin/pkg_add/pkg_add20
5 files changed, 34 insertions, 54 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm
index 98075c365b9..0e042c12e98 100644
--- a/usr.sbin/pkg_add/OpenBSD/Add.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Add.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Add.pm,v 1.65 2007/05/30 14:04:51 espie Exp $
+# $OpenBSD: Add.pm,v 1.66 2007/05/30 16:32:14 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -625,6 +625,20 @@ sub copy_info
File::Copy::move($self->fullname, $dest);
}
+package OpenBSD::PackingElement::FREQUIRE;
+sub install
+{
+ my ($self, $state) = @_;
+ $self->run($state, 'INSTALL');
+}
+
+package OpenBSD::PackingElement::FINSTALL;
+sub install
+{
+ my ($self, $state) = @_;
+ $self->run($state, 'PRE-INSTALL');
+}
+
package OpenBSD::PackingElement::FCONTENTS;
sub copy_info
{
diff --git a/usr.sbin/pkg_add/OpenBSD/Delete.pm b/usr.sbin/pkg_add/OpenBSD/Delete.pm
index 378b525dc87..e7e122ce25b 100644
--- a/usr.sbin/pkg_add/OpenBSD/Delete.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Delete.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Delete.pm,v 1.53 2007/05/30 14:04:51 espie Exp $
+# $OpenBSD: Delete.pm,v 1.54 2007/05/30 16:32:14 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -131,27 +131,18 @@ sub delete_plist
my ($plist, $state) = @_;
my $totsize = $plist->{totsize};
+ my $donesize = 0;
my $pkgname = $plist->pkgname;
$state->{pkgname} = $pkgname;
$ENV{'PKG_PREFIX'} = $plist->localbase;
- if ($plist->has(REQUIRE)) {
- $plist->get(REQUIRE)->delete($state);
- }
- if ($plist->has(DEINSTALL)) {
- $plist->get(DEINSTALL)->delete($state);
- }
$plist->register_manpage($state);
manpages_unindex($state);
- my $donesize = 0;
- for my $item (@{$plist->{groups}}, @{$plist->{users}}, @{$plist->{items}}) {
- $item->delete($state);
- $item->mark_progress(\$donesize, $totsize);
- }
-
+ $plist->delete_and_progress($state, \$donesize, $totsize);
OpenBSD::ProgressMeter::next();
if ($plist->has(UNDISPLAY)) {
$plist->get(UNDISPLAY)->prepare($state);
}
+
for my $name (OpenBSD::Requiring->new($pkgname)->list) {
print "remove dependency on $name\n"
@@ -185,6 +176,13 @@ sub delete
{
}
+sub delete_and_progress
+{
+ my ($self, $state, $donesize, $totsize) = @_;
+ $self->delete($state);
+ $self->mark_progress($donesize, $totsize);
+}
+
sub record_shared
{
}
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm
index be15a669e9f..e997f254022 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackageInfo.pm,v 1.29 2007/05/18 12:40:35 espie Exp $
+# $OpenBSD: PackageInfo.pm,v 1.30 2007/05/30 16:32:14 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -44,6 +44,7 @@ my $pkg_db = $ENV{"PKG_DBDIR"} || '/var/db/pkg';
my ($list, $stemlist);
+# XXX note that REQUIRE occurs before INSTALL/DESINSTALL.
our @info = (CONTENTS, COMMENT, DESC, REQUIRE, INSTALL, DEINSTALL, REQUIRED_BY, REQUIRING, DISPLAY, UNDISPLAY, MTREE_DIRS, MODULE);
our %info = ();
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingList.pm b/usr.sbin/pkg_add/OpenBSD/PackingList.pm
index 2a8e5f919e7..110f0ad9c0f 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackingList.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackingList.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackingList.pm,v 1.71 2007/05/30 12:29:19 espie Exp $
+# $OpenBSD: PackingList.pm,v 1.72 2007/05/30 16:32:14 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -361,21 +361,6 @@ sub is_signed
return 0;
}
-{
- package OpenBSD::PackingList::Visitor;
- sub new
- {
- my $class = shift;
- bless {list=>[], pass=>1}, $class;
- }
-
- sub revisit
- {
- my ($self, $item) = @_;
- push(@{$self->{list}}, $item);
- }
-}
-
our @unique_categories =
(qw(name no-default-conflict manual-installation extrainfo localbase arch));
@@ -390,10 +375,6 @@ sub visit
{
my ($self, $method, @l) = @_;
- my $visitor = new OpenBSD::PackingList::Visitor;
-
- push(@l, $visitor);
-
if (defined $self->{cvstags}) {
for my $item (@{$self->{cvstags}}) {
$item->$method(@l);
@@ -415,10 +396,6 @@ sub visit
}
}
}
- $visitor->{pass} = 2;
- while (my $item = shift @{$visitor->{list}}) {
- $item->$method(@l);
- }
}
my $plist_cache = {};
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 8ba7a2fc2e3..8c5a89edaf1 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.294 2007/05/30 14:10:08 espie Exp $
+# $OpenBSD: pkg_add,v 1.295 2007/05/30 16:32:14 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -281,13 +281,6 @@ sub prepare_to_add
}
-sub do_script
-{
- my ($plist, $name, $state, $args) = @_;
- return unless $plist->has($name);
- $plist->get($name)->run($state, $args);
-}
-
sub thunderbird_special_case
{
my $plist = shift;
@@ -430,13 +423,10 @@ sub really_add
}
try {
- do_script($plist, REQUIRE, $state, "INSTALL");
- do_script($plist, INSTALL, $state, "PRE-INSTALL")
- unless $state->{interrupted};
- OpenBSD::Add::perform_installation($handle, $state)
- unless $state->{interrupted};
- do_script($plist, INSTALL, $state, "POST-INSTALL")
- unless $state->{interrupted};
+ OpenBSD::Add::perform_installation($handle, $state);
+ if (!$state->{interrupted} && $plist->has(INSTALL)) {
+ $plist->get(INSTALL)->run($state, 'POST-INSTALL');
+ }
} catchall {
unless ($state->{interrupted}) {
Warn $_;