summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2003-10-19 18:42:56 +0000
committerMarc Espie <espie@cvs.openbsd.org>2003-10-19 18:42:56 +0000
commite380d718ff827092ee64d19268e9d643e0dd0f47 (patch)
tree17c1713570163b8904e80731c57f124cef951689
parent4d17b19c65526769e339f93939fb98ede968953f (diff)
plist's has/get methods for accessing elements: perl ->{} has quirks
that make it unusable for looking up constants correctly.
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingList.pm14
-rw-r--r--usr.sbin/pkg_add/pkg_add8
-rw-r--r--usr.sbin/pkg_add/pkg_delete12
3 files changed, 23 insertions, 11 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingList.pm b/usr.sbin/pkg_add/OpenBSD/PackingList.pm
index 24b3786a6e9..28b4e10851c 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackingList.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackingList.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: PackingList.pm,v 1.1 2003/10/16 17:43:34 espie Exp $
+# $OpenBSD: PackingList.pm,v 1.2 2003/10/19 18:42:55 espie Exp $
#
# Copyright (c) 2003 Marc Espie.
#
@@ -128,6 +128,18 @@ sub addunique
$plist->{$category} = $object;
}
+sub has
+{
+ my ($plist, $name) = @_;
+ return defined $plist->{$name};
+}
+
+sub get
+{
+ my ($plist, $name) = @_;
+ return $plist->{$name};
+}
+
sub pkgname($)
{
my $self = shift;
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index b784910efcb..f652b00e87a 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.1 2003/10/16 17:43:34 espie Exp $
+# $OpenBSD: pkg_add,v 1.2 2003/10/19 18:42:55 espie Exp $
#
# Copyright (c) 2003 Marc Espie.
#
@@ -166,14 +166,14 @@ sub reallyadd
}
}
die if $collisions;
- if ($plist->{OpenBSD::PackageInfo::REQUIRE}) {
+ if ($plist->has(REQUIRE)) {
print "Require script: $dir",REQUIRE," $pkgname INSTALL\n" if $opt_v or $opt_n;
unless ($opt_n) {
chmod 0755, $dir.REQUIRE;
system($dir.REQUIRE, $pkgname, "INSTALL") == 0 or die "require script borked";
}
}
- if ($plist->{OpenBSD::PackageInfo::INSTALL}) {
+ if ($plist->has(INSTALL)) {
print "Install script: $dir",INSTALL," $pkgname PRE-INSTALL\n" if $opt_v or $opt_n;
unless ($opt_n) {
chmod 0755, $dir.INSTALL;
@@ -187,7 +187,7 @@ sub reallyadd
}
$handle->close();
- if ($plist->{OpenBSD::PackageInfo::INSTALL}) {
+ if ($plist->has(INSTALL)) {
print "Install script: $dir",INSTALL ,"$pkgname POST-INSTALL\n" if $opt_v or $opt_n;
unless ($opt_n) {
system($dir.INSTALL, $pkgname, "POST-INSTALL") == 0 or die "install script borked";
diff --git a/usr.sbin/pkg_add/pkg_delete b/usr.sbin/pkg_add/pkg_delete
index d5d26295538..51ca34c28a6 100644
--- a/usr.sbin/pkg_add/pkg_delete
+++ b/usr.sbin/pkg_add/pkg_delete
@@ -1,6 +1,6 @@
#!/usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg_delete,v 1.1 2003/10/16 17:43:34 espie Exp $
+# $OpenBSD: pkg_delete,v 1.2 2003/10/19 18:42:55 espie Exp $
#
# Copyright (c) 2003 Marc Espie.
#
@@ -250,12 +250,12 @@ sub delete_package
die "Package $pkgname real name does not match";
}
- if ($plist->{OpenBSD::PackageInfo::REQUIRE}) {
- $plist->{OpenBSD::PackageInfo::REQUIRE}->delete($state);
- }
- if ($plist->{OpenBSD::PackageInfo::DEINSTALL}) {
- $plist->{OpenBSD::PackageInfo::DEINSTALL}->delete($state);
+ if ($plist->has(REQUIRE)) {
+ $plist->get(REQUIRE)->delete($state);
}
+ if ($plist->has(DEINSTALL)) {
+ $plist->get(DEINSTALL)->delete($state);
+ }
for my $item (@{$plist->{items}}) {
$item->delete($state);
}