| version 1.109, 2021/12/23 19:32:59 |
version 1.113, 2021/12/23 21:34:12 |
|
|
| FWPUB_KEY=${DESTDIR}/etc/signify/openbsd-${VERSION}-fw.pub |
FWPUB_KEY=${DESTDIR}/etc/signify/openbsd-${VERSION}-fw.pub |
| |
|
| VERBOSE=false |
VERBOSE=false |
| |
DELETE=false |
| DOWNLOAD=true |
DOWNLOAD=true |
| INSTALL=true |
INSTALL=true |
| LOCALSRC= |
LOCALSRC= |
|
|
| } |
} |
| |
|
| installed_firmware() { |
installed_firmware() { |
| local _pattern="$1" _firmware |
local _pre="$1" _match="$2" _post="$3" _firmware |
| set -A _firmware -- $( |
set -A _firmware -- $( |
| set +o noglob |
set +o noglob |
| grep -Fxl '@option firmware' \ |
grep -Fxl '@option firmware' \ |
| "${DESTDIR}/var/db/pkg/"$_pattern"/+CONTENTS" \ |
"${DESTDIR}/var/db/pkg/"$_pre"$_match"$_post"/+CONTENTS" \ |
| 2>/dev/null || true |
2>/dev/null || true |
| set -o noglob |
set -o noglob |
| ) |
) |
|
|
| } |
} |
| |
|
| usage() { |
usage() { |
| echo "usage: ${0##*/} [-D | -L] [-v] [driver | file ...]" |
echo "usage: ${0##*/} [-d | -D | -L] [-av] [driver | file ...]" |
| exit 2 |
exit 2 |
| } |
} |
| |
|
| |
ALL=false |
| OPT_D= |
OPT_D= |
| OPT_L= |
OPT_L= |
| while getopts :DLv name |
while getopts :adDLv name |
| do |
do |
| case "$name" in |
case "$name" in |
| |
a) ALL=true ;; |
| |
d) DELETE=true ;; |
| D) OPT_D=true ;; |
D) OPT_D=true ;; |
| L) OPT_L=true ;; |
L) OPT_L=true ;; |
| v) VERBOSE=true ;; |
v) VERBOSE=true ;; |
|
|
| |
|
| CFILE="$LOCALSRC/$CFILE" |
CFILE="$LOCALSRC/$CFILE" |
| |
|
| if "$INSTALL" && [ -x /usr/bin/id ] && [ "$(/usr/bin/id -u)" != 0 ]; then |
if "$INSTALL" || "$DELETE"; then |
| echo "need root privileges" >&2 |
if [ -x /usr/bin/id ] && [ "$(/usr/bin/id -u)" != 0 ]; then |
| exit 1 |
echo "need root privileges" >&2 |
| |
exit 1 |
| |
fi |
| fi |
fi |
| |
|
| set -A devices -- "$@" |
set -A devices -- "$@" |
| |
|
| if [ ! "${devices[*]:-}" ]; then |
if "$DELETE"; then |
| |
[ "$OPT_D" ] || [ "$OPT_L" ] && usage 22 |
| |
|
| |
set -A installed |
| |
if [ "${devices[*]:-}" ]; then |
| |
"$ALL" && usage 22 |
| |
|
| |
set -A installed -- $( |
| |
for d in "${devices[@]}"; do |
| |
f="${d##*/}" # only care about the name |
| |
f="${f%.tgz}" # allow specifying the package name |
| |
[ "$( firmware_devicename "$f" )" = "$f" ] && f="$f-firmware" |
| |
|
| |
set -A i -- $( installed_firmware '' "$f-" '*' ) |
| |
|
| |
if [ "${i[*]:-}" ]; then |
| |
echo "${i[@]}" |
| |
else |
| |
echo "No firmware found for '$d'" >&2 |
| |
fi |
| |
done |
| |
) |
| |
elif "$ALL"; then |
| |
set -A installed -- $( installed_firmware '*' '-firmware-' '*' ) |
| |
fi |
| |
|
| |
deleted='' |
| |
if [ "${installed:-}" ]; then |
| |
for fw in "${installed[@]}"; do |
| |
delete_firmware "$fw" || continue |
| |
deleted="$deleted,$( firmware_devicename "$fw" )" |
| |
done |
| |
fi |
| |
|
| |
deleted="${deleted:+${deleted#,}}" |
| |
echo "${0:##*/}: deleted ${deleted:-none}"; |
| |
|
| |
exit |
| |
fi |
| |
|
| |
if [ "${devices[*]:-}" ]; then |
| |
"$ALL" && usage 22 |
| |
else |
| "$VERBOSE" && echo -n "Detecting firmware ..." |
"$VERBOSE" && echo -n "Detecting firmware ..." |
| set -A devices -- $( devices_needing_firmware ) |
set -A devices -- $( devices_needing_firmware ) |
| "$VERBOSE" && |
"$VERBOSE" && |
|
|
| exit 2 |
exit 2 |
| fi |
fi |
| |
|
| set -A installed -- $( installed_firmware "$d-firmware-*" ) |
set -A installed -- $( installed_firmware '' "$d-firmware-" '*' ) |
| |
|
| if "$INSTALL" && [ "${installed[*]:-}" ]; then |
if "$INSTALL" && [ "${installed[*]:-}" ]; then |
| for i in "${installed[@]}"; do |
for i in "${installed[@]}"; do |