Files
computer-playbook/scripts/install/apt.sh
kevinveenbirkenbachandClaude Opus 5 8284edeb20 fix(ci): skip apt when the packages are already there
The Azure Ubuntu mirror stalled during runs 32265854076 and 32265543004, apt-get update burned its 10m timeout and exited 124, and 40 deploy jobs died in the install step. Every package the wrapper is ever asked for ships with the ubuntu-24.04 runner image, so the network round trip bought nothing and cost 60s per job.

dpkg-query decides per package now; apt only runs for what is genuinely missing, which keeps the act image (no envsubst, no skopeo, no gh) working.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-19 19:30:04 +02:00

24 lines
609 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
if (($# == 0)); then
echo "Usage: $0 <package> [package ...]" >&2
exit 1
fi
missing=()
for pkg in "$@"; do
[[ "$(dpkg-query -W -f='${db:Status-Status}' "${pkg}" 2>/dev/null)" == installed ]] || missing+=("${pkg}")
done
if ((${#missing[@]} == 0)); then
echo "[apt] already installed: $*"
exit 0
fi
APT_TIMEOUT=10m
APT_OPTS=(-o Acquire::Retries=5 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30)
sudo timeout -k 30 "${APT_TIMEOUT}" apt-get "${APT_OPTS[@]}" update
sudo timeout -k 30 "${APT_TIMEOUT}" apt-get "${APT_OPTS[@]}" install -y "${missing[@]}"