=================================================================== RCS file: /cvs/openbsd/fw_update/fw_install.sh,v retrieving revision 1.100 retrieving revision 1.102 diff -u -r1.100 -r1.102 --- openbsd/fw_update/fw_install.sh 2021/12/22 04:29:18 1.100 +++ openbsd/fw_update/fw_install.sh 2021/12/22 04:43:41 1.102 @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: fw_install.sh,v 1.100 2021/12/22 04:29:18 afresh1 Exp $ +# $OpenBSD: fw_install.sh,v 1.102 2021/12/22 04:43:41 afresh1 Exp $ # # Copyright (c) 2021 Andrew Hewus Fresh # @@ -62,12 +62,14 @@ # we have su(1) and doas(1) is unlikely to be configured. set -o monitor # make sure ftp gets its own process group ( + flags=-VM + "$VERBOSE" && flags=-vm if [ -x /usr/bin/su ]; then exec /usr/bin/su -s /bin/ksh "$_user" -c \ - "/usr/bin/ftp -D 'Get/Verify' -Vm -o- '$_src'" > "$_dst" + "/usr/bin/ftp -D 'Get/Verify' $flags -o- '$_src'" > "$_dst" else exec /usr/bin/doas -u "$_user" \ - /usr/bin/ftp -D 'Get/Verify' -Vm -o- "$_src" > "$_dst" + /usr/bin/ftp -D 'Get/Verify' $flags -o- "$_src" > "$_dst" fi ) & _pid=$! set +o monitor @@ -160,7 +162,9 @@ add_firmware () { local _f="${1##*/}" local _pkgdir="${DESTDIR}/var/db/pkg/${_f%.tgz}" - ftp -D "Install" -Vmo- "file:${1}" | + local flags=-VM + "$VERBOSE" && flags=-vm + ftp -D "Install" "$flags" -o- "file:${1}" | tar -s ",^\+,${_pkgdir}/+," \ -s ",^firmware,${DESTDIR}/etc/firmware," \ -C / -zxphf - "+*" "firmware/*" @@ -180,7 +184,7 @@ local _cwd _pkg="$1" _pkgdir="${DESTDIR}/var/db/pkg" # TODO: Check hash for files before deleting - echo "Uninstalling $_pkg" + "$VERBOSE" && echo "Uninstalling $_pkg" _cwd="${_pkgdir}/$_pkg" set -A _remove -- "${_cwd}/+CONTENTS" "${_cwd}" @@ -240,7 +244,7 @@ DOWNLOAD=false LOCALSRC=. else - LOCALSRC="$( tmpdir "${DESTDIR}/tmp/fw_install" )" + LOCALSRC="$( tmpdir "${DESTDIR}/tmp/${0##*/}" )" fi CFILE="$LOCALSRC/$CFILE" @@ -253,9 +257,10 @@ set -A devices -- "$@" if [ ! "${devices[*]:-}" ]; then - echo -n "Detecting firmware ..." + "$VERBOSE" && echo -n "Detecting firmware ..." set -A devices -- $( devices_needing_firmware ) - [ "${devices[*]:-}" ] && echo " found." || echo " done." + "$VERBOSE" && + { [ "${devices[*]:-}" ] && echo " found." || echo " done." ; } fi [ "${devices[*]:-}" ] || exit @@ -283,7 +288,7 @@ if "$INSTALL" && [ "${installed[*]:-}" ]; then for i in "${installed[@]}"; do if [ "${f##*/}" = "$i.tgz" ]; then - echo "$i already installed" + "$VERBOSE" && echo "$i already installed" continue 2 fi done @@ -291,7 +296,7 @@ if [ -e "$f" ]; then if "$DOWNLOAD"; then - echo "Verify existing ${f##*/}" + "$VERBOSE" && echo "Verify existing ${f##*/}" verify "$f" || continue # else assume it was verified when downloaded fi