ci-setup.sh (3705B)
1 #!/bin/sh 2 # mk/ci-setup.sh - the UNOS build toolchain, install and verify. 3 # 4 # ./mk/ci-setup.sh install, then verify the graph is satisfied 5 # ./mk/ci-setup.sh --check verify only, install nothing 6 # ./mk/ci-setup.sh --install-only install only; used to bake builder/Dockerfile 7 # 8 # builder/Dockerfile runs --install-only so the image and this list cannot 9 # drift. Pipeline tasks then run on that image and only --check, which is what 10 # catches a template that gained a hostmakedepends without a builder bump. 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 INSTALL_ONLY=0 27 case "${1:-}" in 28 --check) CHECK_ONLY=1 ;; 29 --install-only) INSTALL_ONLY=1 ;; 30 "") ;; 31 *) printf 'ci-setup.sh: unknown argument: %s\n' "$1" >&2; exit 1 ;; 32 esac 33 34 msg() { printf '==> %s\n' "$*"; } 35 die() { printf 'ci-setup.sh: error: %s\n' "$*" >&2; exit 1; } 36 37 # `dep` (https://github.com/finwo/dep) is not packaged by any distribution; 38 # linkd uses it to resolve its own C dependencies. Pinned deliberately. 39 DEP_VERSION="${DEP_VERSION:-0.1.0}" 40 41 if [ "${CHECK_ONLY}" = "0" ]; then 42 command -v apt-get >/dev/null 2>&1 \ 43 || die "no apt-get; this script targets the debian image the pipeline uses" 44 45 msg "installing build toolchain" 46 apt-get update -qq 47 apt-get install -y -qq --no-install-recommends \ 48 build-essential \ 49 pkg-config \ 50 ca-certificates \ 51 curl \ 52 wget \ 53 git \ 54 xz-utils \ 55 bzip2 \ 56 file \ 57 bc \ 58 bison \ 59 flex \ 60 gawk \ 61 make \ 62 mandoc \ 63 perl \ 64 python3 \ 65 sed \ 66 libssl-dev \ 67 zlib1g-dev \ 68 libzstd-dev \ 69 libelf-dev \ 70 kmod \ 71 rsync \ 72 >/dev/null 73 rm -rf /var/lib/apt/lists/* 74 75 if ! command -v dep >/dev/null 2>&1; then 76 msg "installing dep ${DEP_VERSION}" 77 curl -fsSL "https://github.com/finwo/dep/releases/download/${DEP_VERSION}/dep-linux-x64" \ 78 -o /usr/local/bin/dep || die "could not fetch dep ${DEP_VERSION}" 79 chmod 0755 /usr/local/bin/dep 80 fi 81 fi 82 83 # The image is built from mk/ alone; the channel tree it would verify against 84 # is not in the build context. 85 [ "${INSTALL_ONLY}" = "1" ] && { msg "toolchain installed"; exit 0; } 86 87 # Verify rather than assume: every hostmakedepends in the graph must now 88 # resolve. This is what stops the list above silently falling behind a 89 # template that gained a new build tool. 90 msg "verifying hostmakedepends are satisfied" 91 missing="" 92 # Every channel, not just the one this task builds: the apt list is shared, so 93 # a tool only edge needs must still be installed here. 94 for c in $("${ROOT}/mk/deps.sh" channels); do 95 "${ROOT}/mk/channel-assemble.sh" "$c" >/dev/null 96 for p in $("${ROOT}/mk/deps.sh" --channel "$c" list); do 97 for h in $("${ROOT}/mk/deps.sh" --channel "$c" vars "$p" | sed -n 's/^hostmakedepends: *//p'); do 98 # muon is built by bootstrap-host.sh, not installed from a distribution. 99 [ "${h}" = "muon" ] && continue 100 command -v "${h}" >/dev/null 2>&1 || case " ${missing} " in 101 *" ${h} "*) ;; 102 *) missing="${missing} ${h}" ;; 103 esac 104 done 105 done 106 done 107 if [ -n "${missing}" ]; then 108 die "hostmakedepends not satisfied:${missing} 109 Add them to the apt list in mk/ci-setup.sh." 110 fi 111 112 msg "toolchain ready"