summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorAndrew Fresh <afresh1@cvs.openbsd.org>2024-11-09 02:19:49 +0000
committerAndrew Fresh <afresh1@cvs.openbsd.org>2024-11-09 02:19:49 +0000
commit4db253e86581da9469b5fe3c7d1fda703631b5ba (patch)
treefb1f8d594150674aab24e795b29efdb61e79cf48 /usr.sbin
parent80ee43b12974ebdd793e7d3cc28a484082be67ba (diff)
Add a -l flag to list drivers or files
This provides a more easily machine readable list than the normal output.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/fw_update/fw_update.811
-rw-r--r--usr.sbin/fw_update/fw_update.sh39
2 files changed, 42 insertions, 8 deletions
diff --git a/usr.sbin/fw_update/fw_update.8 b/usr.sbin/fw_update/fw_update.8
index 94398898308..a5bab7cfa51 100644
--- a/usr.sbin/fw_update/fw_update.8
+++ b/usr.sbin/fw_update/fw_update.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: fw_update.8,v 1.5 2024/11/04 00:34:47 afresh1 Exp $
+.\" $OpenBSD: fw_update.8,v 1.6 2024/11/09 02:19:48 afresh1 Exp $
.\"
.\" Copyright (c) 2011 Alexander Hall <alexander@beard.se>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: November 4 2024 $
+.Dd $Mdocdate: November 9 2024 $
.Dt FW_UPDATE 8
.Os
.Sh NAME
@@ -22,7 +22,7 @@
.Nd install non-free firmware
.Sh SYNOPSIS
.Nm
-.Op Fl adFnv
+.Op Fl adFlnv
.Op Fl p Ar path
.Op Ar driver | file ...
.Sh DESCRIPTION
@@ -59,6 +59,11 @@ If used in conjunction with
delete firmware for all drivers.
.It Fl F
Download SHA256.sig and firmware .tgz to the current directory.
+.It Fl l
+List drivers without installing.
+With
+.Fl F
+lists the full path to the files that will be downloaded.
.It Fl n
Dry run.
Do not actually install or update any firmware;
diff --git a/usr.sbin/fw_update/fw_update.sh b/usr.sbin/fw_update/fw_update.sh
index 2dc1e2cdae5..87af486df23 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.59 2024/11/04 01:24:00 afresh1 Exp $
+# $OpenBSD: fw_update.sh,v 1.60 2024/11/09 02:19:48 afresh1 Exp $
#
# Copyright (c) 2021,2023 Andrew Hewus Fresh <afresh1@openbsd.org>
#
@@ -490,18 +490,20 @@ unregister_firmware() {
}
usage() {
- echo "usage: ${0##*/} [-adFnv] [-p path] [driver | file ...]"
+ echo "usage: ${0##*/} [-adFlnv] [-p path] [driver | file ...]"
exit 1
}
ALL=false
DOWNLOAD_ONLY=false
-while getopts :adFnp:v name
+LIST=false
+while getopts :adFlnp:v name
do
case "$name" in
a) ALL=true ;;
d) DELETE=true ;;
F) DOWNLOAD_ONLY=true ;;
+ l) LIST=true ;;
n) DRYRUN=true ;;
p) FWURL="$OPTARG" ;;
v) ((++VERBOSE)) ;;
@@ -517,6 +519,9 @@ do
done
shift $((OPTIND - 1))
+# When listing, provide a clean output
+"$LIST" && VERBOSE=1 ENABLE_SPINNER=false
+
# Progress bars, not spinner When VERBOSE > 1
((VERBOSE > 1)) && ENABLE_SPINNER=false
@@ -531,13 +536,13 @@ fi
# "Download only" means local dir and don't install
if "$DOWNLOAD_ONLY"; then
INSTALL=false
- LOCALSRC="${LOCALSRC:-.}"
+ "$LIST" || LOCALSRC="${LOCALSRC:-.}"
elif [ "$LOCALSRC" ]; then
DOWNLOAD=false
fi
if [ -x /usr/bin/id ] && [ "$(/usr/bin/id -u)" != 0 ]; then
- if "$DOWNLOAD_ONLY"; then
+ if "$DOWNLOAD_ONLY" || "$LIST"; then
# When we aren't in the installer,
# allow downloading as the current user.
DROP_PRIVS=false
@@ -602,6 +607,8 @@ if "$DELETE"; then
comma=,
if "$DRYRUN"; then
((VERBOSE)) && echo "Delete $fw"
+ elif "$LIST"; then
+ echo "$fw"
else
delete_firmware "$fw" || {
status " ($fw failed)"
@@ -613,6 +620,9 @@ if "$DELETE"; then
[ "$comma" ] || status none
+ # no status when listing
+ "$LIST" && rm -f "$FD_DIR/status"
+
exit
fi
@@ -640,11 +650,19 @@ set -A update ''
kept=''
unregister=''
+"$LIST" && "$DOWNLOAD_ONLY" &&
+ echo "$FWURL/${CFILE##*/}"
+
if [ "${devices[*]:-}" ]; then
lock_db
for f in "${devices[@]}"; do
d="$( firmware_devicename "$f" )"
+ if "$LIST" && ! "$DOWNLOAD_ONLY"; then
+ echo "$d"
+ continue
+ fi
+
verify_existing=true
if [ "$f" = "$d" ]; then
f=$( firmware_filename "$d" ) || {
@@ -675,6 +693,11 @@ if [ "${devices[*]:-}" ]; then
verify_existing=false
fi
+ if "$LIST"; then
+ echo "$FWURL/$f"
+ continue
+ fi
+
set -A installed
if "$INSTALL"; then
set -A installed -- \
@@ -732,6 +755,12 @@ if [ "${devices[*]:-}" ]; then
done
fi
+if "$LIST"; then
+ # No status when listing
+ rm -f "$FD_DIR/status"
+ exit
+fi
+
if "$INSTALL"; then
status " add "
action=Install