diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2005-01-16 11:16:24 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2005-01-16 11:16:24 +0000 |
commit | cb414a18f7738fc2d2a41903019f370ee2e3e66a (patch) | |
tree | d798f51b8c47fb6d4042307076b6af44f49699dc /usr.sbin | |
parent | 75a02b58e8e5c9ebf697c1d103102247f359c4dd (diff) |
allow locking of database in quiet mode, where we don't display any
message.
Display the lock message on stderr anyways, so that we don't disturb
normal displays.
postpone locking after we know about -q in pkg_info's case.
Display command line if pkg_create fails, so that we can see what arguments
it found in bsd.port.mk.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageInfo.pm | 9 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_create | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_info | 8 |
3 files changed, 13 insertions, 8 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm index 49e7072dedd..f0873940f5a 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.16 2005/01/14 02:25:12 espie Exp $ +# $OpenBSD: PackageInfo.pm,v 1.17 2005/01/16 11:16:23 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -170,15 +170,16 @@ sub is_info_name($) my $dlock; -sub lock_db($) +sub lock_db($;$) { - my $shared = shift; + my ($shared, $quiet) = @_; my $mode = $shared ? LOCK_SH : LOCK_EX; open($dlock, '<', $pkg_db) or return; if (flock($dlock, $mode | LOCK_NB)) { return; } - print "Package database already locked... awaiting release\n"; + print STDERR "Package database already locked... awaiting release\n" + unless $quiet; while (!flock($dlock, $mode)) { } return; diff --git a/usr.sbin/pkg_add/pkg_create b/usr.sbin/pkg_add/pkg_create index 46c46c3b465..1e5456786ac 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.31 2004/12/12 11:26:16 espie Exp $ +# $OpenBSD: pkg_create,v 1.32 2005/01/16 11:16:23 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -309,7 +309,7 @@ try { if (@ARGV == 0) { $regen_package = 1; } elsif (@ARGV != 1) { - Usage "Exactly one single package name is required"; + Usage "Exactly one single package name is required: ", join(' ', @ARGV); } try { diff --git a/usr.sbin/pkg_add/pkg_info b/usr.sbin/pkg_add/pkg_info index 3ca83cb2f60..a9bbd4779cf 100644 --- a/usr.sbin/pkg_add/pkg_info +++ b/usr.sbin/pkg_add/pkg_info @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_info,v 1.27 2005/01/14 02:25:12 espie Exp $ +# $OpenBSD: pkg_info,v 1.28 2005/01/16 11:16:23 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -247,13 +247,15 @@ sub print_info set_usage('pkg_info [-cDdfIiKkLMpqRrsUv] [-E fname] [-e pkgname] [-l str] pkgname...', 'pkg_info [-Aa flags]'); -lock_db(1); +my $locked; try { getopts('cDdfhIikKLmpqRrsvhe:E:MU:l:aA', {'e' => sub { my $pat = shift; my @list; + lock_db(1, $opt_q); + $locked = 1; if ($pat =~ m/\//) { @list = find_by_path($pat); } else { @@ -278,6 +280,8 @@ try { Usage($_); }; +lock_db(1, $opt_q) unless $locked; + if ($opt_D) { $opt_M = 1; } |