From 8bc5d4d28449afd4bca800c7b51a638c81221a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anna=20V=C3=ADtov=C3=A1?= Date: Mon, 20 Jul 2026 10:58:30 +0200 Subject: [PATCH] test: use image-builder instead of build cmd/build was recently removed from the image-builder repository. As a consequence, after we will update reference for the Shutzbot file, our build.sh will stop working. This commit uses the image-builder instead of cmd/build, and extracts blueprint from the config file. schutzfile: Update images library commit ref --- Schutzfile | 2 +- test/build.sh | 57 +++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/Schutzfile b/Schutzfile index 1631189..1fc8353 100644 --- a/Schutzfile +++ b/Schutzfile @@ -3,7 +3,7 @@ "last-forced-rebuild": "202607150713", "dependencies": { "images": { - "ref": "dac29a33b6d4b830baa6134bd9e4e7256e786d27" + "ref": "e061982be5ff85b9c81efe1fa356c16dceb0274c" } } } diff --git a/test/build.sh b/test/build.sh index 2197a54..c352552 100755 --- a/test/build.sh +++ b/test/build.sh @@ -13,6 +13,9 @@ IMAGES_DIR="${REPO_ROOT}/_images" BUILD_DIR="${REPO_ROOT}/build" CONFIG_FILE="${BUILD_DIR}/config.json" +BUILD_NAME="bootc_${ARCH//-/_}_${IMAGE_TYPE//-/_}_bootc_foundry" +BUILD_OUTPUT_DIR="${BUILD_DIR}/${BUILD_NAME}" + mkdir -p "${BUILD_DIR}" # Build the config JSON. Start with the base, optionally inject the payload ref. @@ -44,27 +47,51 @@ if [ -n "${PAYLOAD_CONTAINER_IMAGE}" ]; then echo " Payload container: ${PAYLOAD_CONTAINER_IMAGE}" fi -# Build the disk image using the images library's cmd/build. -# Run from the images directory so Go can find the module (go.mod). -# sudo is required because cmd/build uses 'podman mount' which needs root. -(cd "${IMAGES_DIR}" && sudo go run ./cmd/build \ - --bootc-ref "${CONTAINER_IMAGE}" \ - --arch "${ARCH}" \ - --type "${IMAGE_TYPE}" \ - --config "${CONFIG_FILE}" \ - --output "${BUILD_DIR}") - -# sudo go run produces root-owned output; reclaim ownership so the rest of the +# Extract blueprint for --blueprint (image-builder no longer takes --config). +BLUEPRINT_FILE=$(mktemp --suffix=.json) +trap 'rm -f "${BLUEPRINT_FILE}"' EXIT # Remove the temp file on exit. +jq '.blueprint // {}' "${CONFIG_FILE}" > "${BLUEPRINT_FILE}" + +# Compile first, then run as root — avoids a root-owned Go build cache from +# `sudo go run`. Run from the images directory so Go can find the module. +mkdir -p "${BUILD_OUTPUT_DIR}" +( + cd "${IMAGES_DIR}" + go build -o ./bin/image-builder ./cmd/image-builder + BUILD_ARGS=( + ./bin/image-builder build "${IMAGE_TYPE}" + --bootc-ref "${CONTAINER_IMAGE}" + --arch "${ARCH}" + --output-dir "${BUILD_OUTPUT_DIR}" + --output-name "${BUILD_NAME}" + --with-manifest + --ignore-warnings + --blueprint "${BLUEPRINT_FILE}" + ) + if [ -n "${PAYLOAD_CONTAINER_IMAGE}" ]; then + BUILD_ARGS+=(--bootc-installer-payload-ref "${PAYLOAD_CONTAINER_IMAGE}") + fi + # sudo is required because image-builder uses podman mount / osbuild as root. + sudo "${BUILD_ARGS[@]}" +) + +# sudo produces root-owned output; reclaim ownership so the rest of the # pipeline (and boot.sh) can access the artifacts without sudo. sudo chown -R "$(id -u):$(id -g)" "${BUILD_DIR}" -# Discover the build output directory (single subdirectory under build/) -BUILD_OUTPUT_DIR=$(find "${BUILD_DIR}" -mindepth 1 -maxdepth 1 -type d ! -name ".*" | head -1) +if [ ! -d "${BUILD_OUTPUT_DIR}" ]; then + echo "ERROR: No build output directory found: ${BUILD_OUTPUT_DIR}" + exit 1 +fi -if [ -z "${BUILD_OUTPUT_DIR}" ]; then - echo "ERROR: No build output directory found under ${BUILD_DIR}/" +# image-builder --with-manifest writes {name}.osbuild-manifest.json; boot-image +# expects manifest.json. +OSBUILD_MANIFEST="${BUILD_OUTPUT_DIR}/${BUILD_NAME}.osbuild-manifest.json" +if [ ! -f "${OSBUILD_MANIFEST}" ]; then + echo "ERROR: Expected osbuild manifest not found: ${OSBUILD_MANIFEST}" exit 1 fi +cp "${OSBUILD_MANIFEST}" "${BUILD_OUTPUT_DIR}/manifest.json" echo "Build output directory: ${BUILD_OUTPUT_DIR}"