diff options
author | Alexander Hall <halex@cvs.openbsd.org> | 2011-07-09 01:16:58 +0000 |
---|---|---|
committer | Alexander Hall <halex@cvs.openbsd.org> | 2011-07-09 01:16:58 +0000 |
commit | b17b8f3e9d955448a7c956804f6213a552e1f293 (patch) | |
tree | 89c8bf6fc4cd458435dc31f1dcc75391f83b8c3a | |
parent | b39e8c0c98081790ce8599896c6186e353554b93 (diff) |
welcome fw_update, which installs and/or updates non-free firmware for
detected and previously installed devices that needs it
"go ahead and commit it" deraadt@
-rw-r--r-- | usr.sbin/Makefile | 6 | ||||
-rw-r--r-- | usr.sbin/fw_update/Makefile | 9 | ||||
-rw-r--r-- | usr.sbin/fw_update/fw_update.sh | 65 |
3 files changed, 77 insertions, 3 deletions
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index 0b35c43e68c..42d374f8801 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -1,12 +1,12 @@ -# $OpenBSD: Makefile,v 1.158 2011/07/07 21:00:59 deraadt Exp $ +# $OpenBSD: Makefile,v 1.159 2011/07/09 01:16:57 halex Exp $ .include <bsd.own.mk> SUBDIR= ac accton acpidump adduser amd apm apmd arp \ authpf bgpctl bgpd bind chroot config cron crunchgen dev_mkdb \ dhcpd dhcrelay dvmrpctl dvmrpd edquota eeprom faithd fdformat \ - ftp-proxy gpioctl hostapd hotplugd httpd ifstated ikectl inetd iostat \ - iscsictl iscsid \ + ftp-proxy fw_update gpioctl hostapd hotplugd httpd ifstated ikectl \ + inetd iostat iscsictl iscsid \ kgmon kvm_mkdb ldapd ldapctl ldpd ldpctl lpr mailwrapper map-mbone \ memconfig mksuncd mopd mrinfo mrouted mtrace mtree ndp netgroup_mkdb \ nsd ntpd openssl ospfctl ospfd ospf6d ospf6ctl pcidump pkg_add popa3d \ diff --git a/usr.sbin/fw_update/Makefile b/usr.sbin/fw_update/Makefile new file mode 100644 index 00000000000..00a8b8712db --- /dev/null +++ b/usr.sbin/fw_update/Makefile @@ -0,0 +1,9 @@ +# $OpenBSD: Makefile,v 1.1 2011/07/09 01:16:57 halex Exp $ + +#MAN= fw_update.1 + +beforeinstall: + ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ + ${.CURDIR}/fw_update.sh ${DESTDIR}${BINDIR}/fw_update + +.include <bsd.prog.mk> diff --git a/usr.sbin/fw_update/fw_update.sh b/usr.sbin/fw_update/fw_update.sh new file mode 100644 index 00000000000..d96b3f81e7c --- /dev/null +++ b/usr.sbin/fw_update/fw_update.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +# Copyright (c) 2011 Alexander Hall <alexander@beard.se> +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +[ 0 = $(id -u) ] || { echo "${0##*/} must be run as root"; exit 1; } + +usage() { + echo "usage: ${0##*/} [-v]" + exit 1 +} + +verbose= +while getopts 'v' s "$@" 2>&-; do + case "$s" in + v) verbose=-v ;; + *) usage ;; + esac +done + +# No additional arguments allowed +[ $# = $(($OPTIND-1)) ] || usage + +set -- $(sysctl -n kern.version | sed 's/^OpenBSD \([0-9]\.[0-9]\)\([^ ]*\).*/\1 \2/;q') + +version=$1 +tag=$2 + +[ -n "$tag" -a X"$tag" != X"-stable" ] && version=snapshots + +export PKG_PATH=http://firmware.openbsd.org/firmware/$version/ + +DRIVERS="acx athn bwi ipw iwi iwn malo otus pgt rsu uath ueagle upgt urtwn uvideo wpi" + +install= +update= + +for driver in $DRIVERS; do + if test -d /var/db/pkg/${driver}-*; then + update="$update ${driver}-firmware" + elif grep -q "^${driver}[0-9][0-9]* at " /var/run/dmesg.boot; then + install="$install ${driver}-firmware" + fi +done + +[ "$install$update" ] || exit 0 + +echo 'updating firmwares' + +# Install missing firmwares +[ "$install" ] && pkg_add $verbose $install + +# Update installed firmwares +[ "$update" ] && pkg_add $verbose -u $update |