version 1.102, 2021/12/22 04:43:41 |
version 1.108, 2021/12/23 03:45:46 |
|
|
} |
} |
|
|
add_firmware () { |
add_firmware () { |
local _f="${1##*/}" |
local _f="${1##*/}" _pkgname |
local _pkgdir="${DESTDIR}/var/db/pkg/${_f%.tgz}" |
local _tmpdir="$( tmpdir "${DESTDIR}/var/db/pkg/.firmware" )" |
local flags=-VM |
local flags=-VM |
"$VERBOSE" && flags=-vm |
"$VERBOSE" && flags=-vm |
ftp -D "Install" "$flags" -o- "file:${1}" | |
ftp -D "Install" "$flags" -o- "file:${1}" | |
tar -s ",^\+,${_pkgdir}/+," \ |
tar -s ",^\+,${_tmpdir}/+," \ |
-s ",^firmware,${DESTDIR}/etc/firmware," \ |
-s ",^firmware,${DESTDIR}/etc/firmware," \ |
-C / -zxphf - "+*" "firmware/*" |
-C / -zxphf - "+*" "firmware/*" |
|
|
|
_pkgname="$( sed -n '/^@name /{s///p;q;}' "${_tmpdir}/+CONTENTS" )" |
|
if [ ! "$_pkgname" ]; then |
|
echo "Failed to extract name from $1, partial install" 2>&1 |
|
rm -rf "$_tmpdir" |
|
return 1 |
|
fi |
|
|
# TODO: Should we mark these so real fw_update can -Drepair? |
# TODO: Should we mark these so real fw_update can -Drepair? |
ed -s "${_pkgdir}/+CONTENTS" <<EOL |
ed -s "${_tmpdir}/+CONTENTS" <<EOL |
/^@comment pkgpath/ -1a |
/^@comment pkgpath/ -1a |
@option manual-installation |
@option manual-installation |
@option firmware |
@option firmware |
|
|
. |
. |
w |
w |
EOL |
EOL |
|
|
|
chmod 755 "$_tmpdir" |
|
mv "$_tmpdir" "${DESTDIR}/var/db/pkg/${_pkgname}" |
} |
} |
|
|
delete_firmware() { |
delete_firmware() { |
|
|
"$VERBOSE" && echo "Uninstalling $_pkg" |
"$VERBOSE" && echo "Uninstalling $_pkg" |
_cwd="${_pkgdir}/$_pkg" |
_cwd="${_pkgdir}/$_pkg" |
|
|
|
if [ ! -e "$_cwd/+CONTENTS" ] || |
|
! grep -Fxq '@option firmware' "$_cwd/+CONTENTS"; then |
|
echo "${0##*/}: $_pkg does not appear to be firmware" >&2 |
|
return 2 |
|
fi |
|
|
set -A _remove -- "${_cwd}/+CONTENTS" "${_cwd}" |
set -A _remove -- "${_cwd}/+CONTENTS" "${_cwd}" |
|
|
while read -r c g; do |
while read -r c g; do |
|
|
} |
} |
|
|
usage() { |
usage() { |
echo "usage: ${0##*/} [-D | -L] [driver | file ...]" |
echo "usage: ${0##*/} [-D | -L] [-v] [driver | file ...]" |
exit 2 |
exit 2 |
} |
} |
|
|
|
|
|
|
CFILE="$LOCALSRC/$CFILE" |
CFILE="$LOCALSRC/$CFILE" |
|
|
if "$INSTALL" && [ -x /usr/bin/id ] && [ $(/usr/bin/id -u) != 0 ]; then |
if "$INSTALL" && [ -x /usr/bin/id ] && [ "$(/usr/bin/id -u)" != 0 ]; then |
echo "need root privileges" >&2 |
echo "need root privileges" >&2 |
exit 1 |
exit 1 |
fi |
fi |
|
|
echo "Signature check of SHA256.sig failed" >&2 && exit 1 |
echo "Signature check of SHA256.sig failed" >&2 && exit 1 |
fi |
fi |
|
|
|
added='' |
|
updated='' |
for f in "${devices[@]}"; do |
for f in "${devices[@]}"; do |
d="$( firmware_devicename "$f" )" |
d="$( firmware_devicename "$f" )" |
|
|
|
|
|
|
"$INSTALL" || continue |
"$INSTALL" || continue |
|
|
|
removed=false |
if [ "${installed[*]:-}" ]; then |
if [ "${installed[*]:-}" ]; then |
for i in "${installed[@]}"; do |
for i in "${installed[@]}"; do |
delete_firmware "$i" |
delete_firmware "$i" |
|
removed=true |
done |
done |
fi |
fi |
|
|
add_firmware "$f" |
add_firmware "$f" |
|
|
|
if "$removed"; then |
|
[ "$updated" ] && updated="$updated," |
|
updated="$updated$d" |
|
else |
|
[ "$added" ] && added="$added," |
|
added="$added$d" |
|
fi |
done |
done |
|
|
|
if ! $VERBOSE && { [ "$added" ] || [ "$updated" ]; }; then |
|
echo "${0##*/}: $( |
|
[ "$added" ] && echo -n "added ${added}" |
|
[ "$added" ] && [ "$updated" ] && echo -n "; " |
|
[ "$updated" ] && echo -n "updated ${updated}" |
|
)" |
|
fi |