| version 1.100, 2021/12/22 04:29:18 |
version 1.101, 2021/12/22 04:30:07 |
|
|
| # 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 |
|
|
| 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/*" |
|
|
| 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}" |
|
|
| 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 |
|
|
| 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 |
|
|
| |
|
| 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 |