summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorAndrew Fresh <afresh1@cvs.openbsd.org>2023-11-15 02:03:50 +0000
committerAndrew Fresh <afresh1@cvs.openbsd.org>2023-11-15 02:03:50 +0000
commitec9b5a3968d018ee417ac632e872eaf52d7d5041 (patch)
tree0c306c4edbbab55aa0f8b7adb6ea0049a9097bc3 /usr.sbin
parente1252d862b913bb47ed4a249eb5ef10b46125d40 (diff)
Improve output after waiting for package db lock
OpenBSD::PackageInfo::lock_db will send messages to STDERR if we ended up waiting for a lock, if that happens, it stomped over the "fw_update:" prefix on the status line so tidy up and print it out again.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/fw_update/fw_update.sh26
1 files changed, 22 insertions, 4 deletions
diff --git a/usr.sbin/fw_update/fw_update.sh b/usr.sbin/fw_update/fw_update.sh
index 38a65388d06..408f8ac2819 100644
--- a/usr.sbin/fw_update/fw_update.sh
+++ b/usr.sbin/fw_update/fw_update.sh
@@ -1,5 +1,5 @@
#!/bin/ksh
-# $OpenBSD: fw_update.sh,v 1.53 2023/11/15 02:00:02 afresh1 Exp $
+# $OpenBSD: fw_update.sh,v 1.54 2023/11/15 02:03:49 afresh1 Exp $
#
# Copyright (c) 2021,2023 Andrew Hewus Fresh <afresh1@openbsd.org>
#
@@ -278,6 +278,7 @@ firmware_devicename() {
}
lock_db() {
+ local _waited
[ "${LOCKPID:-}" ] && return 0
# The installer doesn't have perl, so we can't lock there
@@ -292,9 +293,22 @@ lock_db() {
$|=1;
$0 = "fw_update: lock_db";
- lock_db(0);
+ my $waited = 0;
+ package OpenBSD::FwUpdateState {
+ use parent 'OpenBSD::BaseState';
+ sub errprint ($self, @p) {
+ if ($p[0] && $p[0] =~ /already locked/) {
+ $waited++;
+ $p[0] = " " . $p[0]
+ if !$ENV{VERBOSE};
+ }
+ $self->SUPER::errprint(@p);
+ }
+
+ }
+ lock_db(0, 'OpenBSD::FwUpdateState');
- say $$;
+ say "$$ $waited";
# Wait for STDOUT to be readable, which won't happen
# but if our parent exits unexpectedly it will close.
@@ -304,7 +318,11 @@ lock_db() {
EOL
set +o monitor
- read -rp LOCKPID
+ read -rp LOCKPID _waited
+
+ if ((_waited)); then
+ ! ((VERBOSE)) && status "${0##*/}:"
+ fi
return 0
}