=================================================================== RCS file: /cvs/openbsd/fw_update/fw_install.sh,v retrieving revision 1.130 retrieving revision 1.132 diff -u -r1.130 -r1.132 --- openbsd/fw_update/fw_install.sh 2021/12/25 18:22:38 1.130 +++ openbsd/fw_update/fw_install.sh 2021/12/25 19:08:52 1.132 @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: fw_install.sh,v 1.130 2021/12/25 18:22:38 afresh1 Exp $ +# $OpenBSD: fw_install.sh,v 1.132 2021/12/25 19:08:52 afresh1 Exp $ # # Copyright (c) 2021 Andrew Hewus Fresh # @@ -34,6 +34,7 @@ FWURL=http://firmware.openbsd.org/firmware/${HTTP_FWDIR} FWPUB_KEY=${DESTDIR}/etc/signify/openbsd-${VERSION}-fw.pub +DRYRUN=false VERBOSE=false DELETE=false DOWNLOAD=true @@ -131,8 +132,7 @@ # When we're not in the installer, the dmesg.boot can # contain multiple boots, so only look in the last one - _dmesgtail="$( echo ; sed -n 'H;/^OpenBSD/h;${g;p;}' /var/run/dmesg.boot | - grep -e "^[a-z][a-z]*[0-9]" -e " not configured " )" + _dmesgtail="$( echo ; sed -n 'H;/^OpenBSD/h;${g;p;}' /var/run/dmesg.boot ) grep -v '^[[:space:]]*#' "$FWPATTERNS" | while read -r _d _m; do @@ -276,12 +276,13 @@ ALL=false OPT_D= -while getopts :adDp:v name +while getopts :adDnp:v name do case "$name" in a) ALL=true ;; d) DELETE=true ;; D) OPT_D=true ;; + n) DRYRUN=true ;; p) LOCALSRC="$OPTARG" ;; v) VERBOSE=true ;; :) @@ -352,7 +353,11 @@ deleted='' if [ "${installed:-}" ]; then for fw in "${installed[@]}"; do - delete_firmware "$fw" || continue + if "$DRYRUN"; then + echo "Delete $fw" + else + delete_firmware "$fw" || continue + fi deleted="$deleted,$( firmware_devicename "$fw" )" done fi @@ -413,7 +418,7 @@ if "$INSTALL" && [ "${installed[*]:-}" ]; then for i in "${installed[@]}"; do if [ "${f##*/}" = "$i.tgz" ]; then - "$VERBOSE" && echo "$i already installed" + "$VERBOSE" && echo "Keep $i" kept="$kept,$d" continue 2 fi @@ -422,14 +427,23 @@ if [ -e "$f" ]; then if "$DOWNLOAD"; then - "$VERBOSE" && echo "Verify existing ${f##*/}" - verify "$f" || continue - "$INSTALL" || kept="$kept,$d" + if "$VERBOSE"; then + "$INSTALL" && + echo "Verify ${f##*/}" || + echo "Keep/Verify ${f##*/}" + echo "Verify ${f##*/}" + fi + "$DRYRUN" || verify "$f" || continue + "$INSTALL" || kept="$kept,$d" # else assume it was verified when downloaded fi elif "$DOWNLOAD"; then - fetch "$f" || continue - verify "$f" || continue + if "$DRYRUN"; then + "$VERBOSE" && echo "Get/Verify ${f##*/}" + else + fetch "$f" || continue + verify "$f" || continue + fi "$INSTALL" || added="$added,$d" elif "$INSTALL"; then echo "Cannot install ${f##*/}, not found" >&2 @@ -441,16 +455,20 @@ removed=false if [ "${installed[*]:-}" ]; then for i in "${installed[@]}"; do - delete_firmware "$i" + "$DRYRUN" || delete_firmware "$i" removed=true done fi - add_firmware "$f" + "$DRYRUN" || add_firmware "$f" + f="${f##*/}" + f="${f%.tgz}" if "$removed"; then + "$DRYRUN" && echo "Update $f" updated="$updated,$d" else + "$DRYRUN" && echo "Install $f" added="$added,$d" fi done