summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-04-30 12:39:32 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-04-30 12:39:32 +0000
commit7bc7e50f16228a42bd427ef960c4cbec62b2abf2 (patch)
tree329e10f2860ed252ce486c4b6f1c41fb9b5162ae
parentc481be70cd782b7e9f6cb6594b94921a12883461 (diff)
simplify regen mode logic: if we don't add anything to the packing-list,
we never have to check we added nothing. so, process -P/-W in two steps: stash we've seen them first, and add them later. As a benefit, sort/unify them once, so that we can stash them correctly directly.
-rw-r--r--usr.sbin/pkg_add/pkg_create24
1 files changed, 15 insertions, 9 deletions
diff --git a/usr.sbin/pkg_add/pkg_create b/usr.sbin/pkg_add/pkg_create
index 7a26c3d0a68..081f065a120 100644
--- a/usr.sbin/pkg_add/pkg_create
+++ b/usr.sbin/pkg_add/pkg_create
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg_create,v 1.81 2007/04/30 12:20:32 espie Exp $
+# $OpenBSD: pkg_create,v 1.82 2007/04/30 12:39:31 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -51,8 +51,6 @@ sub pretend_to_archive
sub archive {}
sub comment_create_package {}
-sub count_elements { ${$_[1]}++; }
-
sub print_file {}
sub avert_duplicates_and_other_checks
@@ -410,7 +408,8 @@ sub add_description
our $errors = 0;
-my @contents;
+my (@contents, %dependencies, %wantlib);
+
my $regen_package = 0;
@@ -439,10 +438,12 @@ try {
},
'h' => sub { Usage(); },
'P' => sub {
- OpenBSD::PackingElement::Dependency->add($plist, shift);
+ my $d = shift;
+ $dependencies{$d} = 1;
},
'W' => sub {
- OpenBSD::PackingElement::Wantlib->add($plist, shift);
+ my $w = shift;
+ $wantlib{$w} = 1;
}
});
} catchall {
@@ -475,9 +476,7 @@ if (!@contents) {
}
if ($regen_package) {
- my $v = 0;
- $plist->count_elements(\$v);
- if ($v != 1 or @contents != 1) {
+ if (@contents != 1) {
Usage "Exactly one single packing list is required";
}
if (-d $contents[0] && -f $contents[0].'/'.CONTENTS) {
@@ -501,6 +500,13 @@ if ($regen_package) {
} else {
Usage "Prefix required";
}
+ for my $d (sort keys %dependencies) {
+ OpenBSD::PackingElement::Dependency->add($plist, $d);
+ }
+
+ for my $w (sort keys %wantlib) {
+ OpenBSD::PackingElement::Wantlib->add($plist, $w);
+ }
if (defined $opt_A) {
OpenBSD::PackingElement::Arch->add($plist, $opt_A);