Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Schutzfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"last-forced-rebuild": "202607150713",
"dependencies": {
"images": {
"ref": "dac29a33b6d4b830baa6134bd9e4e7256e786d27"
"ref": "e061982be5ff85b9c81efe1fa356c16dceb0274c"
}
}
}
Expand Down
57 changes: 42 additions & 15 deletions test/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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}"

Expand Down
Loading