=================================================================== RCS file: /cvs/openbsd/fw_update/fw_install.sh,v retrieving revision 1.130 retrieving revision 1.131 diff -u -r1.130 -r1.131 --- openbsd/fw_update/fw_install.sh 2021/12/25 18:22:38 1.130 +++ openbsd/fw_update/fw_install.sh 2021/12/25 19:03:56 1.131 @@ -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.131 2021/12/25 19:03:56 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 @@ -276,12 +277,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 +354,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 +419,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 +428,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 +456,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