ci-setup.sh (2979B)
1 #!/bin/sh 2 # mk/ci-setup.sh - install the build toolchain into an ephemeral CI container. 3 # 4 # ./mk/ci-setup.sh install, then verify the graph is satisfied 5 # ./mk/ci-setup.sh --check verify only, install nothing 6 # 7 # Pipelines run in a stock debian image with no mounts, so every task starts 8 # from nothing and installs what it needs. Keeping that here rather than 9 # inlining apt lines in .conductor.yml means one place to change when a 10 # template gains a hostmakedepends, and it can verify itself afterwards. 11 # 12 # Two groups, for different reasons: 13 # 14 # toolchain what packages/*/template declare as hostmakedepends. The 15 # authority is mk/deps.sh, and the check at the end proves this 16 # list still covers it. 17 # host libs what mk/bootstrap-host.sh links the host `apk` against 18 # (openssl, zlib, zstd). Not hostmakedepends of any package -- 19 # they are needed before any package builds at all. 20 set -eu 21 22 HERE=$(cd "$(dirname "$0")" && pwd) 23 ROOT=$(cd "${HERE}/.." && pwd) 24 25 CHECK_ONLY=0 26 [ "${1:-}" = "--check" ] && CHECK_ONLY=1 27 28 msg() { printf '==> %s\n' "$*"; } 29 die() { printf 'ci-setup.sh: error: %s\n' "$*" >&2; exit 1; } 30 31 # `dep` (https://github.com/finwo/dep) is not packaged by any distribution; 32 # linkd uses it to resolve its own C dependencies. Pinned deliberately. 33 DEP_VERSION="${DEP_VERSION:-0.1.0}" 34 35 if [ "${CHECK_ONLY}" = "0" ]; then 36 command -v apt-get >/dev/null 2>&1 \ 37 || die "no apt-get; this script targets the debian image the pipeline uses" 38 39 msg "installing build toolchain" 40 apt-get update -qq 41 apt-get install -y -qq --no-install-recommends \ 42 build-essential \ 43 pkg-config \ 44 ca-certificates \ 45 curl \ 46 wget \ 47 git \ 48 xz-utils \ 49 bzip2 \ 50 file \ 51 bc \ 52 bison \ 53 flex \ 54 gawk \ 55 make \ 56 mandoc \ 57 perl \ 58 python3 \ 59 sed \ 60 libssl-dev \ 61 zlib1g-dev \ 62 libzstd-dev \ 63 >/dev/null 64 rm -rf /var/lib/apt/lists/* 65 66 if ! command -v dep >/dev/null 2>&1; then 67 msg "installing dep ${DEP_VERSION}" 68 curl -fsSL "https://github.com/finwo/dep/releases/download/${DEP_VERSION}/dep-linux-x64" \ 69 -o /usr/local/bin/dep || die "could not fetch dep ${DEP_VERSION}" 70 chmod 0755 /usr/local/bin/dep 71 fi 72 fi 73 74 # Verify rather than assume: every hostmakedepends in the graph must now 75 # resolve. This is what stops the list above silently falling behind a 76 # template that gained a new build tool. 77 msg "verifying hostmakedepends are satisfied" 78 missing="" 79 for p in $("${ROOT}/mk/deps.sh" list); do 80 for h in $("${ROOT}/mk/deps.sh" vars "$p" | sed -n 's/^hostmakedepends: *//p'); do 81 # muon is built by bootstrap-host.sh, not installed from a distribution. 82 [ "${h}" = "muon" ] && continue 83 command -v "${h}" >/dev/null 2>&1 || missing="${missing} ${h}" 84 done 85 done 86 if [ -n "${missing}" ]; then 87 die "hostmakedepends not satisfied:${missing} 88 Add them to the apt list in mk/ci-setup.sh." 89 fi 90 91 msg "toolchain ready"