diff options
author | Alexander Hall <halex@cvs.openbsd.org> | 2011-07-27 15:12:58 +0000 |
---|---|---|
committer | Alexander Hall <halex@cvs.openbsd.org> | 2011-07-27 15:12:58 +0000 |
commit | c84bd48df30e7cb1bdf906d35b7d68a7a6521a5e (patch) | |
tree | cf3f4067507d4b98681e10da1c4b289cfaee57d0 /usr.sbin | |
parent | 3ac0d258a6adcf86e7cb75b17d6180195544a195 (diff) |
a bunch of requested changes:
- pass same count of -v's to pkg_add as was passed to fw_update
- don't be all quiet if -v is specified
- add -n flag as per pkg_add
- prefix all verbose messages by 'fw_update: '
- look for devices in current dmesg as well as dmesg.boot
ok deraadt krw
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/fw_update/fw_update.1 | 16 | ||||
-rw-r--r-- | usr.sbin/fw_update/fw_update.sh | 37 |
2 files changed, 39 insertions, 14 deletions
diff --git a/usr.sbin/fw_update/fw_update.1 b/usr.sbin/fw_update/fw_update.1 index 96c0d0f9a60..2376b41f020 100644 --- a/usr.sbin/fw_update/fw_update.1 +++ b/usr.sbin/fw_update/fw_update.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: fw_update.1,v 1.4 2011/07/09 16:12:29 schwarze Exp $ +.\" $OpenBSD: fw_update.1,v 1.5 2011/07/27 15:12:57 halex 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: July 9 2011 $ +.Dd $Mdocdate: July 27 2011 $ .Dt FW_UPDATE 1 .Os .Sh NAME @@ -22,7 +22,7 @@ .Nd install and update non-free firmware packages .Sh SYNOPSIS .Nm -.Op Fl v +.Op Fl nv .Sh DESCRIPTION The .Nm @@ -34,11 +34,19 @@ firmware packages for the currently running kernel. .Pp The options are as follows: .Bl -tag -width Ds +.It Fl n +Pass the +.Fl n +flag to pkg_add, causing it to not actually install any firmware packages, +just report the steps that would be taken if it was. .It Fl v -Turn on verbose output by passing the +Turn on verbose output and passes the .Fl v flag to .Xr pkg_add 1 . +This flag can be specified multiple times for increased +.Xr pkg_add 1 +verbosity. .El .Sh SEE ALSO .Xr pkg_add 1 , diff --git a/usr.sbin/fw_update/fw_update.sh b/usr.sbin/fw_update/fw_update.sh index cff426e0cb4..3707671c8ef 100644 --- a/usr.sbin/fw_update/fw_update.sh +++ b/usr.sbin/fw_update/fw_update.sh @@ -1,6 +1,6 @@ #!/bin/sh -# $OpenBSD: fw_update.sh,v 1.6 2011/07/16 22:27:09 espie Exp $ +# $OpenBSD: fw_update.sh,v 1.7 2011/07/27 15:12:57 halex Exp $ # Copyright (c) 2011 Alexander Hall <alexander@beard.se> # # Permission to use, copy, modify, and distribute this software for any @@ -21,17 +21,21 @@ DRIVERS="acx athn bwi ipw iwi iwn malo otus pgt rsu uath ueagle upgt urtwn PKG_ADD="pkg_add -D repair" -[ 0 = $(id -u) ] || { echo "${0##*/} must be run as root" >&2; exit 1; } - usage() { - echo "usage: ${0##*/} [-v]" >&2 + echo "usage: ${0##*/} [-nv]" >&2 exit 1 } +verbose() { + [ "$verbose" ] && echo "${0##*/}: $@" +} + verbose= -while getopts 'v' s "$@" 2>&-; do +nop= +while getopts 'nv' s "$@" 2>&-; do case "$s" in - v) verbose=-v ;; + v) verbose=${verbose:--}v ;; + n) nop=-n ;; *) usage ;; esac done @@ -48,6 +52,7 @@ tag=$2 export PKG_PATH=http://firmware.openbsd.org/firmware/$version/ installed=$(pkg_info -q) +dmesg=$(cat /var/run/dmesg.boot; echo; dmesg) install= update= @@ -55,15 +60,27 @@ update= for driver in $DRIVERS; do if print -r -- "$installed" | grep -q "^${driver}-firmware-"; then update="$update ${driver}-firmware" - elif grep -q "^${driver}[0-9][0-9]* at " /var/run/dmesg.boot; then + elif print -r -- "$dmesg" | grep -q "^${driver}[0-9][0-9]* at "; then install="$install ${driver}-firmware" fi done -[ "$install$update" ] || exit 0 +if [ -z "$install$update" ]; then + verbose "No devices found which need firmwares to be downloaded." + exit 0 +fi + +[ "$nop" ] || [ 0 = $(id -u) ] || + { echo "${0##*/} must be run as root" >&2; exit 1; } # Install missing firmwares -[ "$install" ] && $PKG_ADD $verbose $install +if [ "$install" ]; then + verbose "Installing firmwares:$install." + $PKG_ADD $nop $verbose $install +fi # Update installed firmwares -[ "$update" ] && $PKG_ADD $verbose -u $update +if [ "$update" ]; then + verbose "Updating firmwares:$update." + $PKG_ADD $nop $verbose -u $update +fi |