version 1.142, 2022/01/07 00:38:06 |
version 1.145, 2022/01/07 02:18:52 |
|
|
fi |
fi |
} |
} |
|
|
|
fetch_cfile() { |
|
if "$DOWNLOAD"; then |
|
set +o noclobber # we want to get the latest CFILE |
|
fetch "$CFILE" || return 1 |
|
set -o noclobber |
|
! signify -qVep "$FWPUB_KEY" -x "$CFILE" -m "$CFILE" && |
|
echo "Signature check of SHA256.sig failed" >&2 && return 1 |
|
elif [ ! -e "$CFILE" ]; then |
|
echo "${0##*/}: $CFILE: No such file or directory" >&2 |
|
return 2 |
|
fi |
|
} |
|
|
verify() { |
verify() { |
|
[ -e "$CFILE" ] || fetch_cfile |
# On the installer we don't get sha256 -C, so fake it. |
# On the installer we don't get sha256 -C, so fake it. |
if ! fgrep -qx "SHA256 (${1##*/}) = $( /bin/sha256 -qb "$1" )" "$CFILE"; then |
if ! fgrep -qx "SHA256 (${1##*/}) = $( /bin/sha256 -qb "$1" )" "$CFILE"; then |
echo "Checksum test for ${1##*/} failed." >&2 |
echo "Checksum test for ${1##*/} failed." >&2 |
|
|
|
|
firmware_filename() { |
firmware_filename() { |
local _f |
local _f |
|
[ -e "$CFILE" ] || fetch_cfile |
_f="$( sed -n "s/.*(\($1-firmware-.*\.tgz\)).*/\1/p" "$CFILE" | sed '$!d' )" |
_f="$( sed -n "s/.*(\($1-firmware-.*\.tgz\)).*/\1/p" "$CFILE" | sed '$!d' )" |
! [ "$_f" ] && echo "Unable to find firmware for $1" >&2 && return 1 |
! [ "$_f" ] && echo "Unable to find firmware for $1" >&2 && return 1 |
echo "$_f" |
echo "$_f" |
|
|
OPT_F= |
OPT_F= |
while getopts :adFnp:v name |
while getopts :adFnp:v name |
do |
do |
case "$name" in |
case "$name" in |
a) ALL=true ;; |
a) ALL=true ;; |
d) DELETE=true ;; |
d) DELETE=true ;; |
F) OPT_F=true ;; |
F) OPT_F=true ;; |
n) DRYRUN=true ;; |
n) DRYRUN=true ;; |
p) LOCALSRC="$OPTARG" ;; |
p) LOCALSRC="$OPTARG" ;; |
v) VERBOSE=$(( VERBOSE + 1 )) ;; |
v) VERBOSE=$(( VERBOSE + 1 )) ;; |
:) |
:) |
echo "${0##*/}: option requires an argument -- -$OPTARG" >&2 |
echo "${0##*/}: option requires an argument -- -$OPTARG" >&2 |
usage 2 |
usage 2 |
;; |
;; |
?) |
?) |
echo "${0##*/}: unknown option -- -$OPTARG" >&2 |
echo "${0##*/}: unknown option -- -$OPTARG" >&2 |
usage 2 |
usage 2 |
;; |
;; |
esac |
esac |
done |
done |
shift $((OPTIND - 1)) |
shift $((OPTIND - 1)) |
|
|
|
|
if [ "$OPT_F" ]; then |
if [ "$OPT_F" ]; then |
INSTALL=false |
INSTALL=false |
LOCALSRC="${LOCALSRC:-.}" |
LOCALSRC="${LOCALSRC:-.}" |
|
|
|
# Always check for latest CFILE and so latest firmware |
|
if [ -e "$LOCALSRC/$CFILE" ]; then |
|
mv "$LOCALSRC/$CFILE" "$LOCALSRC/$CFILE-OLD" |
|
if fetch_cfile; then |
|
rm -f "$LOCALSRC/$CFILE-OLD" |
|
else |
|
mv "$LOCALSRC/$CFILE-OLD" "$LOCALSRC/$CFILE" |
|
echo "Using existing $CFILE" >&2 |
|
fi |
|
fi |
elif [ "$LOCALSRC" ]; then |
elif [ "$LOCALSRC" ]; then |
DOWNLOAD=false |
DOWNLOAD=false |
fi |
fi |
|
|
fi |
fi |
|
|
if [ ! "$LOCALSRC" ]; then |
if [ ! "$LOCALSRC" ]; then |
LOCALSRC="$( tmpdir "${DESTDIR}/tmp/${0##*/}" )" |
LOCALSRC="$( tmpdir "${DESTDIR}/tmp/${0##*/}" )" |
REMOVE_LOCALSRC=true |
REMOVE_LOCALSRC=true |
fi |
fi |
|
|
CFILE="$LOCALSRC/$CFILE" |
CFILE="$LOCALSRC/$CFILE" |
|
|
fi |
fi |
|
|
[ "${devices[*]:-}" ] || exit |
[ "${devices[*]:-}" ] || exit |
|
|
if "$DOWNLOAD"; then |
|
set +o noclobber # we want to get the latest CFILE |
|
fetch "$CFILE" |
|
set -o noclobber |
|
! signify -qVep "$FWPUB_KEY" -x "$CFILE" -m "$CFILE" && |
|
echo "Signature check of SHA256.sig failed" >&2 && exit 1 |
|
elif [ ! -e "$CFILE" ]; then |
|
# TODO: We shouldn't need a CFILE if all arguments are files. |
|
echo "${0##*/}: $CFILE: No such file or directory" >&2 |
|
exit 2 |
|
fi |
|
|
|
added='' |
added='' |
updated='' |
updated='' |