summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2010-12-05 09:41:55 +0000
committerespie <espie@openbsd.org>2010-12-05 09:41:55 +0000
commit138429bfda0acdbccfeb1f25fb955de36f93ab9d (patch)
tree4f217e36dcd6737ca729a2ceb15d487222f3865d
parentcorrect constant name (diff)
downloadwireguard-openbsd-138429bfda0acdbccfeb1f25fb955de36f93ab9d.tar.xz
wireguard-openbsd-138429bfda0acdbccfeb1f25fb955de36f93ab9d.zip
tweak the framework so that individual modules don't exist and return
the exit code upstream instead. this simplifies the task of people who want to reuse it, as noted by landry@
-rw-r--r--usr.sbin/pkg_add/OpenBSD/AddDelete.pm10
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgCheck.pm3
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgCreate.pm15
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgInfo.pm6
-rw-r--r--usr.sbin/pkg_add/pkg5
5 files changed, 19 insertions, 20 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/AddDelete.pm b/usr.sbin/pkg_add/OpenBSD/AddDelete.pm
index 44a5428edef..82296804be1 100644
--- a/usr.sbin/pkg_add/OpenBSD/AddDelete.pm
+++ b/usr.sbin/pkg_add/OpenBSD/AddDelete.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: AddDelete.pm,v 1.39 2010/10/27 14:35:56 espie Exp $
+# $OpenBSD: AddDelete.pm,v 1.40 2010/12/05 09:41:55 espie Exp $
#
# Copyright (c) 2007-2010 Marc Espie <espie@openbsd.org>
#
@@ -34,7 +34,7 @@ sub do_the_main_work
my ($self, $state) = @_;
if ($state->{bad}) {
- exit(1);
+ return;
}
my $handler = sub { $state->fatal("Caught SIG#1", shift); };
@@ -87,13 +87,10 @@ sub framework
if ($_ =~ m/^Caught SIG(\w+)/o) {
kill $1, $$;
}
- exit(1);
+ $state->{bad}++;
};
}
- if ($state->{bad}) {
- exit(1);
- }
}
sub parse_and_run
@@ -105,6 +102,7 @@ sub parse_and_run
local $SIG{'INFO'} = sub { $state->status->print($state); };
$self->framework($state);
+ return $state->{bad} != 0;
}
package OpenBSD::SharedItemsRecorder;
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCheck.pm b/usr.sbin/pkg_add/OpenBSD/PkgCheck.pm
index c6df515f12f..9466ae41d8f 100644
--- a/usr.sbin/pkg_add/OpenBSD/PkgCheck.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PkgCheck.pm
@@ -1,7 +1,7 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgCheck.pm,v 1.24 2010/10/02 13:33:43 espie Exp $
+# $OpenBSD: PkgCheck.pm,v 1.25 2010/12/05 09:41:55 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
@@ -632,6 +632,7 @@ sub parse_and_run
}
lock_db(0) unless $state->{subst}->value('nolock');
$self->run($state);
+ return 0;
}
1;
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
index 9bc7de8dc97..ac7eb566dfb 100644
--- a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgCreate.pm,v 1.28 2010/11/27 11:54:25 espie Exp $
+# $OpenBSD: PkgCreate.pm,v 1.29 2010/12/05 09:41:55 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
@@ -920,7 +920,7 @@ sub parse_and_run
for my $pkgname (@ARGV) {
$self->sign_existing($state, $pkgname, $cert, $privkey);
}
- exit(0);
+ return 0;
} else {
$plist = $self->create_plist($state, $ARGV[0], \@contents,
\%dependencies, \%wantlib);
@@ -950,7 +950,7 @@ sub parse_and_run
if (!defined $plist->pkgname) {
$state->error("can't write unnamed packing-list");
- exit 1;
+ return 1;
}
if (defined $state->opt('q')) {
@@ -959,19 +959,19 @@ sub parse_and_run
} else {
$plist->write(\*STDOUT);
}
- exit 0 if defined $state->opt('n');
+ return 0 if defined $state->opt('n');
}
if ($plist->{deprecated}) {
$state->error("found obsolete constructs");
- exit 1;
+ return 1;
}
$plist->avert_duplicates_and_other_checks($state);
$state->{stash} = {};
if ($state->{bad} && $state->{subst}->empty('REGRESSION_TESTING')) {
- exit 1;
+ return 1;
}
$state->{bad} = 0;
@@ -997,8 +997,9 @@ sub parse_and_run
}
}catch {
print STDERR "$0: $_\n";
- exit(1);
+ return 1;
};
+ return 0;
}
1;
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgInfo.pm b/usr.sbin/pkg_add/OpenBSD/PkgInfo.pm
index 4e091a888d0..7ccf2fe3fc3 100644
--- a/usr.sbin/pkg_add/OpenBSD/PkgInfo.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PkgInfo.pm
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgInfo.pm,v 1.15 2010/10/27 14:35:56 espie Exp $
+# $OpenBSD: PkgInfo.pm,v 1.16 2010/12/05 09:41:55 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
@@ -515,7 +515,7 @@ sub parse_and_run
is_installed($p) ? "#1 (installed)" : "#1", $p);
}
- exit 0;
+ return 0;
}
if ($state->verbose) {
@@ -582,7 +582,7 @@ sub parse_and_run
if ($pkgs > 1) {
$state->say("Total size: #1", $total_size);
}
- exit($exit_code);
+ return $exit_code;
}
1;
diff --git a/usr.sbin/pkg_add/pkg b/usr.sbin/pkg_add/pkg
index e16274ba182..f9354b6f8a2 100644
--- a/usr.sbin/pkg_add/pkg
+++ b/usr.sbin/pkg_add/pkg
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg,v 1.18 2010/06/10 23:39:50 espie Exp $
+# $OpenBSD: pkg,v 1.19 2010/12/05 09:41:55 espie Exp $
#
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
#
@@ -27,8 +27,7 @@ sub run
if ($@) {
die $@;
}
- $module->parse_and_run($name);
- exit(0);
+ exit($module->parse_and_run($name));
}
my @l = qw(add check create delete info);