Compare commits

...
Author SHA1 Message Date
MickLesk 19233948aa update-apps: name the failure when the container leaves no .errinfo
Updates that fail before the engine's error handler (the update helper,
a script fetch, an explicit exit) left no .errinfo, so the report and
telemetry said only 'exit code: 1'. The container's output is now teed
to a temp file and its last error line is appended.
2026-12-05 13:53:51 +01:00
+15 -6
View File
@@ -625,19 +625,28 @@ for container in $CHOICE; do
# don't fail without a TTY — works for all shells incl. ash (no export -f)
SETUP_CMD="mkdir -p /tmp/.nc; printf '#!/bin/sh\n:\n' > /tmp/.nc/clear; chmod +x /tmp/.nc/clear; export PATH=/tmp/.nc:\$PATH; export TERM=dumb; "
case "$os" in
alpine) pct exec "$container" -- ash -c "${SETUP_CMD}${UPDATE_CMD}" ;;
archlinux) pct exec "$container" -- bash -c "${SETUP_CMD}${UPDATE_CMD}" ;;
fedora | rocky | centos | alma) pct exec "$container" -- bash -c "${SETUP_CMD}${UPDATE_CMD}" ;;
ubuntu | debian | devuan) pct exec "$container" -- bash -c "${SETUP_CMD}${UPDATE_CMD}" ;;
opensuse) pct exec "$container" -- bash -c "${SETUP_CMD}${UPDATE_CMD}" ;;
alpine) update_shell=ash ;;
archlinux | fedora | rocky | centos | alma | ubuntu | debian | devuan | opensuse) update_shell=bash ;;
*) update_shell="" ;;
esac
exit_code=$?
update_out=$(mktemp)
exit_code=0
if [[ -n "$update_shell" ]]; then
pct exec "$container" -- "$update_shell" -c "${SETUP_CMD}${UPDATE_CMD}" 2>&1 | tee "$update_out"
exit_code=${PIPESTATUS[0]}
fi
# The engine in the container leaves what failed in an .errinfo file; without it
# the report says only "exit code: 1".
update_detail=""
if [ $exit_code -ne 0 ]; then
update_detail=$(pct exec "$container" -- sh -c 'f=$(find /root /tmp -maxdepth 1 -name "*.errinfo" -newer /tmp/.cs-update-start 2>/dev/null | head -n1); [ -n "$f" ] || exit 0; m=$(sed -n "s/^MESSAGE=//p" "$f" | head -n1); [ -n "$m" ] || m=$(sed -n "s/^COMMAND=//p" "$f" | head -n1); printf "%s" "$m" | head -c 200' 2>/dev/null || true)
# Failures before the engine's error handler (the helper, a script fetch, an
# explicit exit) leave no .errinfo; the last error line printed says what broke.
if [[ -z "$update_detail" ]]; then
update_detail=$(sed -e 's/\x1b\[[0-9;?]*[a-zA-Z]//g' "$update_out" | tr '\r' '\n' | grep -E '✖|✘|\[ERROR\]|^E: |[Ee]rror' | tail -n1 | sed 's/^[[:space:]]*//' | head -c 200)
fi
fi
rm -f "$update_out"
#5) if build resources are different than run resources, then:
if [ "$UPDATE_BUILD_RESOURCES" -eq "1" ]; then