=================================================================== RCS file: /cvs/openbsd/fw_update/fw_install.sh,v retrieving revision 1.71 retrieving revision 1.79 diff -u -r1.71 -r1.79 --- openbsd/fw_update/fw_install.sh 2021/12/11 05:38:23 1.71 +++ openbsd/fw_update/fw_install.sh 2021/12/12 19:52:38 1.79 @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: fw_install.sh,v 1.71 2021/12/11 05:38:23 afresh1 Exp $ +# $OpenBSD: fw_install.sh,v 1.79 2021/12/12 19:52:38 afresh1 Exp $ # # Copyright (c) 2021 Andrew Hewus Fresh # @@ -16,6 +16,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. set -o errexit -o pipefail -o nounset +export PATH=/usr/bin:/bin:/usr/sbin:/sbin CFILE=SHA256.sig DESTDIR=${DESTDIR:-} @@ -38,7 +39,7 @@ local _i=1 _dir # If we're not in the installer, - # we have mktemp and a more hostile environment + # we have mktemp and a more hostile environment. if [ -x /usr/bin/mktemp ]; then _dir=$( mktemp -d "${1}-XXXXXXXXX" ) else @@ -53,8 +54,8 @@ fetch() { local _src="${FWURL}/${1##*/}" _dst=$1 _user=_file _exit - # If we're not in the installer, we have su(1) - # and doas(1) is unlikely to be configured. + # If we're not in the installer, + # we have su(1) and doas(1) is unlikely to be configured. if [ -x /usr/bin/su ]; then /usr/bin/su -s /bin/ksh "$_user" -c \ "/usr/bin/ftp -D 'Get/Verify' -Vm -o- '$_src'" > "$_dst" @@ -121,14 +122,15 @@ } add_firmware () { - local _f="${1##*/}" _pkgdir="${DESTDIR}/var/db/pkg" + local _f="${1##*/}" + local _pkgdir="${DESTDIR}/var/db/pkg/${_f%.tgz}" ftp -D "Install" -Vmo- "file:${1}" | - tar -s ",^\+,${_pkgdir}/${_f%.tgz}/+," \ + tar -s ",^\+,${_pkgdir}/+," \ -s ",^firmware,${DESTDIR}/etc/firmware," \ -C / -zxphf - "+*" "firmware/*" # TODO: Should we mark these so real fw_update can -Drepair? - ed -s "${_pkgdir}/${_f%.tgz}/+CONTENTS" <&2 exit 2 fi @@ -234,14 +238,18 @@ done fi - if [ ! -e "$f" ]; then - "$INSTALL" && ! "$DOWNLOAD" && - echo "Cannot install ${f##*/}, not found" >&2 && continue + if [ -e "$f" ]; then + if "$DOWNLOAD"; then + echo "Verify existing ${f##*/}" + verify "$f" || continue + # else assume it was verified when downloaded + fi + elif "$DOWNLOAD"; then fetch "$f" || continue verify "$f" || continue - elif $DOWNLOAD; then - echo "Already have $f" - verify "$f" || continue + elif "$INSTALL"; then + echo "Cannot install ${f##*/}, not found" >&2 + continue fi "$INSTALL" || continue