diff --git a/ci/ci-setup.sh b/ci/ci-setup.sh index c09ab5d6..71c4e80c 100755 --- a/ci/ci-setup.sh +++ b/ci/ci-setup.sh @@ -56,7 +56,6 @@ _classify_failure() { } trap _classify_failure EXIT -PDFIO_VER=1.6.4 LIBCUPSFILTERS_URL="${LIBCUPSFILTERS_URL:-https://github.com/OpenPrinting/libcupsfilters.git}" LIBCUPSFILTERS_REF="${LIBCUPSFILTERS_REF:-master}" @@ -112,6 +111,38 @@ build_autoconf() { $SUDO ldconfig || true } +prepare_libcupsfilters_source() { + cache_root="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/libppd-libcupsfilters" + src="$cache_root/source" + if [ ! -d "$src/.git" ]; then + mkdir -p "$src" + git -C "$src" init -q + git -C "$src" remote add origin "$LIBCUPSFILTERS_URL" + git -C "$src" fetch -q --depth 1 origin "$LIBCUPSFILTERS_REF" + git -C "$src" checkout -q --detach FETCH_HEAD + printf '%s\n' "$LIBCUPSFILTERS_REF" > "$cache_root/requested-ref" + fi + + [ "$(git -C "$src" remote get-url origin)" = "$LIBCUPSFILTERS_URL" ] || { + echo "ci-setup: cached libcupsfilters URL does not match" >&2; exit 2; + } + [ "$(cat "$cache_root/requested-ref")" = "$LIBCUPSFILTERS_REF" ] || { + echo "ci-setup: cached libcupsfilters ref does not match" >&2; exit 2; + } + printf '%s\n' "$src" +} + +build_libcupsfilters() { + src="$(prepare_libcupsfilters_source)" + echo "ci-setup: building $LIBCUPSFILTERS_URL @ $(git -C "$src" rev-parse HEAD)" + ( cd "$src" + [ -x ./configure ] || ./autogen.sh + ./configure --prefix=/usr + make -j"$(nproc)" + $SUDO make install ) + $SUDO ldconfig || true +} + cmd_cups() { kind="$1" case "$kind" in @@ -141,6 +172,11 @@ cmd_cups() { } cmd_pdfio() { + libcupsfilters_src="$(prepare_libcupsfilters_source)" + # shellcheck disable=SC1091 + . "$libcupsfilters_src/dependency-versions" + PDFIO_VER="$PDFIO_MIN_VERSION" + [ -n "$PDFIO_VER" ] || { echo "ci-setup: missing PDFIO_MIN_VERSION" >&2; exit 2; } echo "ci-setup: building pdfio $PDFIO_VER" src="$(mktemp -d)" ( cd "$src" @@ -163,7 +199,7 @@ cmd_libcupsfilters() { # Build libcupsfilters against the CUPS already installed above. # Its configure auto-detects CUPS via pkg-config (cups3 / cups / # cups-config), so the same source matches every CUPS release. - build_autoconf "$LIBCUPSFILTERS_URL" "$LIBCUPSFILTERS_REF" "" + build_libcupsfilters ;; *) echo "ci-setup: unknown libcupsfilters kind: $kind" >&2; exit 2 ;;