diff options
author | 2013-08-13 20:11:21 +0000 | |
---|---|---|
committer | 2013-08-13 20:11:21 +0000 | |
commit | ea2370adba063338118221862a535293381bcc0d (patch) | |
tree | 957d469fb41e01593ed0f7884119692d8089b0d6 | |
parent | Call drm_mtrr_add() directly instead adding a map. (diff) | |
download | wireguard-openbsd-ea2370adba063338118221862a535293381bcc0d.tar.xz wireguard-openbsd-ea2370adba063338118221862a535293381bcc0d.zip |
allow the user to specify which firmware to install, or install all of
them using the -a switch
ok rpe@
-rw-r--r-- | usr.sbin/fw_update/fw_update.1 | 20 | ||||
-rw-r--r-- | usr.sbin/fw_update/fw_update.sh | 51 |
2 files changed, 52 insertions, 19 deletions
diff --git a/usr.sbin/fw_update/fw_update.1 b/usr.sbin/fw_update/fw_update.1 index 4f35c122b13..c58eafd474c 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.10 2013/08/12 14:19:53 jmc Exp $ +.\" $OpenBSD: fw_update.1,v 1.11 2013/08/13 20:11:21 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: August 12 2013 $ +.Dd $Mdocdate: August 13 2013 $ .Dt FW_UPDATE 1 .Os .Sh NAME @@ -23,11 +23,13 @@ .Sh SYNOPSIS .Nm .Op Fl nv +.Op Ar driver ... +.Nm +.Op Fl anv .Sh DESCRIPTION The .Nm -utility checks which firmware are needed on the system and then -installs or updates the relevant packages from the Internet. +utility installs or updates firmware packages from the Internet. Since firmware with acceptable licenses are already present in .Ox , .Nm @@ -35,14 +37,22 @@ exists purely to install and update firmware that may not be freely distributed with .Ox . .Pp +If no +.Ar driver +is specified, the +.Nm +utility tries to determine which firmware are needed on the system. +.Pp The options are as follows: .Bl -tag -width Ds +.It Fl a +Install or update all available firmwares. .It Fl n Pass the .Fl n flag to .Xr pkg_add 1 , -causing it to not actually install any firmware packages, +causing it to not actually install or update any firmware packages, just report the steps that would be taken if it did. .It Fl v Turn on verbose output and pass the diff --git a/usr.sbin/fw_update/fw_update.sh b/usr.sbin/fw_update/fw_update.sh index 628fd9a84b1..54c9185a3af 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.12 2012/09/17 18:28:43 rpe Exp $ +# $OpenBSD: fw_update.sh,v 1.13 2013/08/13 20:11:21 halex Exp $ # Copyright (c) 2011 Alexander Hall <alexander@beard.se> # # Permission to use, copy, modify, and distribute this software for any @@ -22,7 +22,8 @@ DRIVERS="acx athn bwi ipw iwi iwn malo otus pgt rsu uath ueagle upgt urtwn PKG_ADD="pkg_add -I -D repair" usage() { - echo "usage: ${0##*/} [-nv]" >&2 + echo "usage: ${0##*/} [-anv]" >&2 + echo " ${0##*/} [-nv] [driver ...]" >&2 exit 1 } @@ -30,26 +31,36 @@ verbose() { [ "$verbose" ] && echo "${0##*/}: $@" } +setpath() { + set -- $(sysctl -n kern.version | + sed 's/^OpenBSD \([0-9]\.[0-9]\)\([^ ]*\).*/\1 \2/;q') + + local version=$1 tag=$2 + + [[ $tag == -!(stable) ]] && version=snapshots + export PKG_PATH=http://firmware.openbsd.org/firmware/$version/ +} + +all=false verbose= nop= -while getopts 'nv' s "$@" 2>/dev/null; do +while getopts 'anv' s "$@" 2>/dev/null; do case "$s" in + a) all=true;; v) verbose=${verbose:--}v ;; n) nop=-n ;; *) usage ;; esac done -# No additional arguments allowed -[ $# = $(($OPTIND-1)) ] || usage +shift $((OPTIND - 1)) -set -- $(sysctl -n kern.version | sed 's/^OpenBSD \([0-9]\.[0-9]\)\([^ ]*\).*/\1 \2/;q') - -version=$1 -tag=$2 +if $all; then + [ $# != 0 ] && usage + set -- $DRIVERS +fi -[[ $tag == -!(stable) ]] && version=snapshots -export PKG_PATH=http://firmware.openbsd.org/firmware/$version/ +setpath installed=$(pkg_info -q) dmesg=$(cat /var/run/dmesg.boot; echo; dmesg) @@ -58,12 +69,24 @@ install= update= extra= -for driver in $DRIVERS; do - if print -r -- "$installed" | grep -q "^${driver}-firmware-"; then +if [ $# = 0 ]; then + for driver in $DRIVERS; do + if print "$installed" | grep -q "^$driver-firmware-" || + print -r -- "$dmesg" | egrep -q "^$driver[0-9]+ at "; then + set -- "$@" $driver + fi + done +fi + +for driver; do + if print "$installed" | grep -q "^${driver}-firmware-"; then update="$update ${driver}-firmware" extra="$extra -Dupdate_${driver}-firmware" - elif print -r -- "$dmesg" | grep -q "^${driver}[0-9][0-9]* at "; then + elif printf "%s\n" $DRIVERS | fgrep -qx "$driver"; then install="$install ${driver}-firmware" + else + print -r "${0##*/}: $driver: unknown driver" >&2 + exit 1 fi done |