fix(ci): run apt deadlines inside sudo sessions

This commit is contained in:
Neil
2026-11-11 07:46:29 -08:00
parent b3c808ea96
commit 252bf5a86a
3 changed files with 12 additions and 11 deletions
@@ -9,7 +9,8 @@ fi
bash "$(dirname "${BASH_SOURCE[0]}")/prepare-ubuntu-apt.sh"
# Eight minutes of command allowances leave room for tests within the job deadline.
if timeout 45 sudo apt-get update -o Acquire::Languages=none && timeout 120 sudo apt-get install -y "$@"; then
# Run deadlines as root so sudo cannot leave apt in a separate session.
if sudo timeout --kill-after=10s 45 apt-get update -o Acquire::Languages=none && sudo timeout --kill-after=10s 120 apt-get install -y "$@"; then
exit 0
fi
@@ -21,7 +22,7 @@ done
bash "$(dirname "${BASH_SOURCE[0]}")/use-ubuntu-apt-mirror.sh"
bash "$(dirname "${BASH_SOURCE[0]}")/recover-ubuntu-dpkg.sh" || true
# Unrelated repositories may fail refresh; apt still verifies the requested packages.
if ! timeout 120 sudo apt-get update -o Acquire::Languages=none; then
if ! sudo timeout --kill-after=10s 120 apt-get update -o Acquire::Languages=none; then
echo 'Index refresh incomplete; attempting the requested packages with available authenticated indexes.' >&2
fi
timeout 150 sudo apt-get install -y "$@"
sudo timeout --kill-after=10s 150 apt-get install -y "$@"
+1 -1
View File
@@ -2,7 +2,7 @@
set -euo pipefail
# A timed-out apt frontend can leave dpkg running in a separate session.
timeout 30 sudo bash -euo pipefail -c '
sudo timeout --kill-after=10s 30 bash -euo pipefail -c '
while lslocks --noheadings --raw --notruncate --output PATH | grep -E "^/var/lib/dpkg/lock(-frontend)?$" >/dev/null; do
sleep 1
done