[BACK]Return to fw_install.sh CVS log [TXT][DIR] Up to [local] / openbsd / fw_update

Diff for /openbsd/fw_update/fw_install.sh between version 1.95 and 1.102

version 1.95, 2021/12/21 02:16:47 version 1.102, 2021/12/22 04:43:41
Line 34 
Line 34 
 FWURL=http://firmware.openbsd.org/firmware/${HTTP_FWDIR}  FWURL=http://firmware.openbsd.org/firmware/${HTTP_FWDIR}
 FWPUB_KEY=${DESTDIR}/etc/signify/openbsd-${VERSION}-fw.pub  FWPUB_KEY=${DESTDIR}/etc/signify/openbsd-${VERSION}-fw.pub
   
   VERBOSE=false
 DOWNLOAD=true  DOWNLOAD=true
 INSTALL=true  INSTALL=true
 LOCALSRC=  LOCALSRC=
Line 61 
Line 62 
         # we have su(1) and doas(1) is unlikely to be configured.          # we have su(1) and doas(1) is unlikely to be configured.
         set -o monitor # make sure ftp gets its own process group          set -o monitor # make sure ftp gets its own process group
         (          (
           flags=-VM
           "$VERBOSE" && flags=-vm
         if [ -x /usr/bin/su ]; then          if [ -x /usr/bin/su ]; then
                 exec /usr/bin/su -s /bin/ksh "$_user" -c \                  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          else
                 exec /usr/bin/doas -u "$_user" \                  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          fi
         ) & _pid=$!          ) & _pid=$!
         set +o monitor          set +o monitor
   
         trap "kill -TERM '-$_pid'; exit 1" EXIT INT QUIT ABRT TERM          trap "kill -TERM '-$_pid' 2>/dev/null; exit 1" EXIT INT QUIT ABRT TERM
   
         SECONDS=0          SECONDS=0
         _last=0          _last=0
Line 150 
Line 153 
 installed_firmware() {  installed_firmware() {
         set +o noglob          set +o noglob
         for fw in "${DESTDIR}/var/db/pkg/$1-firmware"*; do          for fw in "${DESTDIR}/var/db/pkg/$1-firmware"*; do
                 [ -e "$fw" ] || continue                  [ -e "$fw/+CONTENTS" ] || continue
                 echo "${fw##*/}"                  echo "${fw##*/}"
         done          done
         set -o noglob          set -o noglob
Line 159 
Line 162 
 add_firmware () {  add_firmware () {
         local _f="${1##*/}"          local _f="${1##*/}"
         local _pkgdir="${DESTDIR}/var/db/pkg/${_f%.tgz}"          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}/+," \                  tar -s ",^\+,${_pkgdir}/+," \
                     -s ",^firmware,${DESTDIR}/etc/firmware," \                      -s ",^firmware,${DESTDIR}/etc/firmware," \
                     -C / -zxphf - "+*" "firmware/*"                      -C / -zxphf - "+*" "firmware/*"
Line 179 
Line 184 
         local _cwd _pkg="$1" _pkgdir="${DESTDIR}/var/db/pkg"          local _cwd _pkg="$1" _pkgdir="${DESTDIR}/var/db/pkg"
   
         # TODO: Check hash for files before deleting          # TODO: Check hash for files before deleting
         echo "Uninstalling $_pkg"          "$VERBOSE" && echo "Uninstalling $_pkg"
         _cwd="${_pkgdir}/$_pkg"          _cwd="${_pkgdir}/$_pkg"
   
         set -A _remove -- "${_cwd}/+CONTENTS" "${_cwd}"          set -A _remove -- "${_cwd}/+CONTENTS" "${_cwd}"
Line 217 
Line 222 
   
 OPT_D=  OPT_D=
 OPT_L=  OPT_L=
 while getopts DL name  while getopts :DLv name
 do  do
        case "$name" in         case "$name" in
        D) OPT_D=true ;;         D) OPT_D=true ;;
        L) OPT_L=true ;;         L) OPT_L=true ;;
        ?) usage 2 ;;         v) VERBOSE=true ;;
          ?) echo "${0##*/}: unknown option -- -$OPTARG"; usage 2 ;;
        esac         esac
 done  done
 shift $((OPTIND - 1))  shift $((OPTIND - 1))
Line 238 
Line 244 
         DOWNLOAD=false          DOWNLOAD=false
         LOCALSRC=.          LOCALSRC=.
 else  else
         LOCALSRC="$( tmpdir "${DESTDIR}/tmp/fw_install" )"          LOCALSRC="$( tmpdir "${DESTDIR}/tmp/${0##*/}" )"
 fi  fi
   
 CFILE="$LOCALSRC/$CFILE"  CFILE="$LOCALSRC/$CFILE"
Line 251 
Line 257 
 set -A devices -- "$@"  set -A devices -- "$@"
   
 if [ ! "${devices[*]:-}" ]; then  if [ ! "${devices[*]:-}" ]; then
         echo -n "Detecting firmware ..."          "$VERBOSE" && echo -n "Detecting firmware ..."
         set -A devices -- $( devices_needing_firmware )          set -A devices -- $( devices_needing_firmware )
         [ "${devices[*]:-}" ] && echo " found." || echo " done."          "$VERBOSE" &&
               { [ "${devices[*]:-}" ] && echo " found." || echo " done." ; }
 fi  fi
   
 [ "${devices[*]:-}" ] || exit  [ "${devices[*]:-}" ] || exit
Line 281 
Line 288 
         if "$INSTALL" && [ "${installed[*]:-}" ]; then          if "$INSTALL" && [ "${installed[*]:-}" ]; then
                 for i in "${installed[@]}"; do                  for i in "${installed[@]}"; do
                         if [ "${f##*/}" = "$i.tgz" ]; then                          if [ "${f##*/}" = "$i.tgz" ]; then
                                 echo "$i already installed"                                  "$VERBOSE" && echo "$i already installed"
                                 continue 2                                  continue 2
                         fi                          fi
                 done                  done
Line 289 
Line 296 
   
         if [ -e "$f" ]; then          if [ -e "$f" ]; then
                 if "$DOWNLOAD"; then                  if "$DOWNLOAD"; then
                         echo "Verify existing ${f##*/}"                          "$VERBOSE" && echo "Verify existing ${f##*/}"
                         verify "$f" || continue                          verify "$f" || continue
                 # else assume it was verified when downloaded                  # else assume it was verified when downloaded
                 fi                  fi

Legend:
Removed from v.1.95  
changed lines
  Added in v.1.102

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>