=================================================================== RCS file: /cvs/openbsd/fw_update/fw_install.sh,v retrieving revision 1.24 retrieving revision 1.33 diff -u -r1.24 -r1.33 --- openbsd/fw_update/fw_install.sh 2021/11/11 02:34:00 1.24 +++ openbsd/fw_update/fw_install.sh 2021/11/19 03:13:11 1.33 @@ -1,17 +1,10 @@ #!/bin/ksh set -e -scan_dmesg() { - # no bsort for now - sed -n "$1" /var/run/dmesg.boot -} - # Fake up some things from install.sub that we don't need to actually do prefetcharea_fs_list() { - echo "/mnt/tmp" + echo "${DESTDIR}/tmp" } -reset_watchdog() { -} # tmpdir, do_as, unpriv, and unpriv2 are from install.sub @@ -70,17 +63,11 @@ do_as _file "$@" } -# "fail" needs to be replaced with the "ask_yn" loop like in the installer. -_issue= -fail() { - echo $_issue >&2 - exit 1 -} +VNAME=${VNAME:-$(sysctl -n kern.osrelease)} +VERSION=${VERSION:"${VNAME%.*}${VNAME#*.}"} +FWDIR=${FWDIR:-$VNAME} +MODE=${MODE:-install} -VNAME=$(sysctl -n kern.osrelease) -VERSION="${VNAME%.*}${VNAME#*.}" -FWDIR="$VNAME" - # TODO: We need the firmware for the system we just installed # not the one we booted from. For example: # * booting from a snapshot bsd.rd that thinks it is the 7.0 release @@ -92,7 +79,7 @@ # Otherwise, the fw_update after first boot will fix it up for us. HTTP_FWDIR=$FWDIR -set -- $(scan_dmesg "/^OpenBSD $VNAME\([^ ]*\).*$/s//\1/p") +set -- sed -n "/^OpenBSD $VNAME\([^ ]*\).*$/s//\1/p" /var/run/dmesg.boot [[ $1 == -!(stable) ]] && HTTP_FWDIR=snapshots FWURL=http://firmware.openbsd.org/firmware/${HTTP_FWDIR} @@ -102,9 +89,11 @@ # TODO: support srclocal installation of firmware somehow fw_update() { local _src=$1 _tmpfs_list _tmpfs _tmpsrc \ - _t=Get _cfile="/tmp/SHA256" _pkgdir=/mnt/var/db/pkg \ - _f _r _remove _i _installed - local _srclocal=false _unpriv=unpriv + _t=Get _cfile="/tmp/SHA256" _pkgdir=${DESTDIR}/var/db/pkg \ + _f _r _remove _i _installed + local _srclocal=false _unpriv=unpriv + + echo "Let's $MODE firmware!" local _d _drivers=$( last='' $_unpriv ftp -D "Detecting" -Vmo- $FWPATTERNS | @@ -164,7 +153,6 @@ echo "Signature check of SHA256.sig failed" >&2 && return 1 for _d in $_drivers; do - $UU && reset_watchdog _f=$( sed -n "s/.*(\($_d-firmware-.*\.tgz\)).*/\1/p" "$_cfile" ) _installed=$( for fw in "${_pkgdir}/$_d-firmware"*; do @@ -212,7 +200,7 @@ while read c g; do case $c in - @cwd) cwd="/mnt/$g" + @cwd) cwd="${DESTDIR}/$g" ;; @*) continue ;; @@ -235,11 +223,10 @@ fi # TODO: Should we mark these so real fw_update can -Drepair? - $_unpriv ftp -D "Install" -Vmo- "file:$_tmpsrc/$_f" | - tar -s ",^\+,${_pkgdir}/${_f%.tgz}/+," \ - -s ",^firmware,mnt/etc/firmware," \ - -C / -zxphf - \ - "+*" "firmware/*" + ftp -D "Install" -Vmo- "file:$_tmpsrc/$_f" | + tar -s ",^\+,${_pkgdir}/${_f%.tgz}/+," \ + -s ",^firmware,${DESTDIR}/etc/firmware," \ + -C / -zxphf - "+*" "firmware/*" ed -s "${_pkgdir}/${_f%.tgz}/+CONTENTS" <