Repository navigation
Expand file tree
/
Copy pathlinux-deps.sh
More file actions
55 lines (49 loc) · 1.83 KB
/
Copy pathlinux-deps.sh
File metadata and controls
55 lines (49 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
# Install only the missing Ubuntu packages for one hosted CI lane.
set -euo pipefail
usage() {
echo "usage: bash .github/scripts/linux-deps.sh [--list] build|test|voice|packaging" >&2
exit 2
}
list=false
if [[ ${1:-} == --list ]]; then
list=true
shift
fi
[[ $# == 1 ]] || usage
packages=(
pkg-config libxkbcommon-dev libwayland-dev libx11-dev libxcursor-dev
libxrandr-dev libxi-dev libgtk-3-dev libfontconfig1-dev libfreetype-dev
)
runtime=(libvulkan1 mesa-vulkan-drivers)
case "$1" in
build) ;;
test) packages+=("${runtime[@]}") ;;
voice) packages+=("${runtime[@]}" libasound2-dev) ;;
packaging) packages+=("${runtime[@]}" file flatpak flatpak-builder elfutils zstd) ;;
*) usage ;;
esac
if [[ "$list" == true ]]; then
printf '%s\n' "${packages[@]}"
exit 0
fi
missing=()
for package in "${packages[@]}"; do
status=$(dpkg-query -W -f='${db:Status-Status}' "$package" 2>/dev/null) || status=missing
if [[ "$status" != installed ]]; then
missing+=("$package")
fi
done
echo "Image: ${ImageOS:-unknown} ${ImageVersion:-unknown}"
echo "Linux dependencies ($1): ${#packages[@]} requested, ${#missing[@]} absent."
if (( ${#missing[@]} )); then
printf 'Installing %s\n' "${missing[*]}"
apt_options=(-o Acquire::Retries=2 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30)
sudo timeout --kill-after=20s 5m apt-get "${apt_options[@]}" update
# Cold runners can fetch over 100 packages even when the mirror keeps responding.
sudo timeout --kill-after=20s 20m apt-get "${apt_options[@]}" install -y --no-install-recommends "${missing[@]}"
fi
if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then
printf 'Linux setup (%s) on %s: %s/%s packages already installed, %ss elapsed.\n\n' \
"$1" "${ImageVersion:-unknown}" "$(( ${#packages[@]} - ${#missing[@]} ))" "${#packages[@]}" "$SECONDS" >> "$GITHUB_STEP_SUMMARY"
fi