From 05226e388853cbb0ae97c2cc7bedefc7ca55a93e Mon Sep 17 00:00:00 2001 From: kylerankin Date: Wed, 16 Sep 2026 03:33:18 +0000 Subject: [PATCH 1/3] build: add os-base option to build-ddi for FSDK/Flatcar parity harness projectbluefin/server#129 wants an os-base: fsdk | flatcar-reference option so the FSDK-composed payload and the imported Flatcar reference can be built from one tree and diffed. build-ddi now takes an OS_BASE parameter (default fsdk) and routes to the matching element: fsdk -> oci/bluefin-server-ddi.bst (shipped payload) flatcar-reference -> oci/bluefin-server-ddi-flatcar-reference.bst, added alongside the #126 imported Flatcar tree The flatcar-reference route refuses with a pointer to #126 until that element exists, and an unknown base is rejected. The default path is unchanged, so CI's 'just build-ddi' keeps building the FSDK payload. Adds a bats test covering the routing and guards. Assisted-by: lemonade/Ornith-1.5-35B-A3B-GGUF via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: kylerankin --- Justfile | 31 +++++- tests/unit/build_ddi_os_base_test.bats | 143 +++++++++++++++++++++++++ 2 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 tests/unit/build_ddi_os_base_test.bats diff --git a/Justfile b/Justfile index f2dc1b23..3d9fc437 100644 --- a/Justfile +++ b/Justfile @@ -84,9 +84,36 @@ build: # Build the OS DDI payload filesystem image (implicit dep of build-installer; # useful when you need the standalone artifact for release publishing). +# +# os-base selects the payload base for the FSDK-vs-Flatcar parity harness +# (projectbluefin/server#129): +# fsdk FSDK-composed payload, the shipped base (default). +# flatcar-reference Imported Flatcar reference tree, the known-good control. +# Routes to bluefin-server-ddi-flatcar-reference.bst, added +# alongside the #126 imported Flatcar reference tree. [group('installer')] -build-ddi: - just bst build oci/bluefin-server-ddi.bst +build-ddi OS_BASE="fsdk": + #!/usr/bin/env bash + set -euo pipefail + case "{{OS_BASE}}" in + fsdk) + DDI_ELEMENT="oci/bluefin-server-ddi.bst" + ;; + flatcar-reference) + if [ ! -f "oci/bluefin-server-ddi-flatcar-reference.bst" ]; then + echo "ERROR: os-base=flatcar-reference requires the imported Flatcar reference tree" >&2 + echo " (projectbluefin/server#126); element oci/bluefin-server-ddi-flatcar-reference.bst" >&2 + echo " does not exist yet. Add it alongside the #126 tree, then re-run." >&2 + exit 1 + fi + DDI_ELEMENT="oci/bluefin-server-ddi-flatcar-reference.bst" + ;; + *) + echo "ERROR: unknown os-base '{{OS_BASE}}' (expected 'fsdk' or 'flatcar-reference')" >&2 + exit 1 + ;; + esac + just bst build "${DDI_ELEMENT}" # Export the OS DDI payload + SHA256SUMS to dist/ddi/. [group('installer')] diff --git a/tests/unit/build_ddi_os_base_test.bats b/tests/unit/build_ddi_os_base_test.bats new file mode 100644 index 00000000..9485b5c7 --- /dev/null +++ b/tests/unit/build_ddi_os_base_test.bats @@ -0,0 +1,143 @@ +#!/usr/bin/env bats +# +# Unit tests for the `os-base` option in the `build-ddi` recipe of the +# top-level Justfile (projectbluefin/server#129). +# +# `build-ddi` composes the shipped Bluefin Server OS payload. The `os-base` +# option selects the payload base for the FSDK-vs-Flatcar parity harness: +# `fsdk` (default) builds the FSDK-composed payload, and `flatcar-reference` +# builds the imported Flatcar reference tree once the #126 element lands. +# +# The recipe never builds a real payload in the test. It delegates to the +# `bst` recipe, which runs `podman`. `podman` is replaced by a logging stub on +# PATH that records its arguments and exits 0, so the recipe that routes +# `os-base` to the right element runs to completion and the chosen element is +# recorded in the call log instead of being composed. + +setup() { + if ! command -v just >/dev/null 2>&1; then + skip "just is not installed" + fi + + REPO_ROOT="$(cd "${BATS_TEST_DIRNAME}/../.." && pwd)" + JUSTFILE="${REPO_ROOT}/Justfile" + SANDBOX="${BATS_TEST_TMPDIR}/sandbox" + BIN_DIR="${BATS_TEST_TMPDIR}/bin" + ELEMENTS="${SANDBOX}/elements" + OCI="${SANDBOX}/oci" + LOG="${BATS_TEST_TMPDIR}/podman.log" + REF_ELEMENT="oci/bluefin-server-ddi-flatcar-reference.bst" + + mkdir -p "$BIN_DIR" "$ELEMENTS" "$OCI" + : > "$LOG" + + # The Justfile's top-level backtick assignments inspect + # elements/freedesktop-sdk.bst. Copy it so loading the sandbox Justfile + # behaves exactly like the real one. + cp "${REPO_ROOT}/elements/freedesktop-sdk.bst" "${ELEMENTS}/" + + make_stub podman 0 +} + +# make_stub +make_stub() { + cat > "${BIN_DIR}/$1" <> "${LOG}" +exit $2 +EOF + chmod +x "${BIN_DIR}/$1" +} + +# run_build [os-base] -- invoke `just build-ddi` with the given base. +run_build() { + local base="${1:-}" + if [ -n "${base}" ]; then + run env PATH="${BIN_DIR}:${PATH}" \ + just --justfile "${JUSTFILE}" \ + --working-directory "${REPO_ROOT}" \ + build-ddi "${base}" + else + run env PATH="${BIN_DIR}:${PATH}" \ + just --justfile "${JUSTFILE}" \ + --working-directory "${REPO_ROOT}" \ + build-ddi + fi +} + +# The fsdk element is the shipped base; the flatcar-reference route must never +# select it, and vice versa. +assert_builds() { + local element="$1" + if ! grep -qF "${element}" "${LOG}"; then + echo "expected podman call to build ${element}" >&2 + echo "---- podman log ----" >&2 + cat "${LOG}" >&2 + return 1 + fi +} + +assert_does_not_build() { + local element="$1" + if grep -qF "${element}" "${LOG}"; then + echo "expected podman call NOT to build ${element}" >&2 + cat "${LOG}" >&2 + return 1 + fi +} + +assert_no_build() { + refute_log "bst" +} + +refute_log() { + if grep -qF -- "$1" "${LOG}" 2>/dev/null; then + echo "expected log NOT to contain: $1" >&2 + cat "${LOG}" >&2 + return 1 + fi +} + +# --- guard shape ------------------------------------------------------------ + +@test "build-ddi still declares the OS_BASE parameter defaulting to fsdk" { + grep -qF 'build-ddi OS_BASE="fsdk"' "${JUSTFILE}" +} + +@test "build-ddi still validates os-base against fsdk and flatcar-reference" { + grep -qF "expected 'fsdk' or 'flatcar-reference'" "${JUSTFILE}" +} + +@test "build-ddi still guards the flatcar-reference element's existence" { + grep -qF "os-base=flatcar-reference requires the imported Flatcar reference tree" "${JUSTFILE}" +} + +# --- routing ---------------------------------------------------------------- + +@test "build-ddi with no argument builds the fsdk payload" { + run_build + [ "$status" -eq 0 ] + assert_builds "oci/bluefin-server-ddi.bst" + assert_does_not_build "${REF_ELEMENT}" +} + +@test "build-ddi os-base=fsdk builds the fsdk payload" { + run_build "fsdk" + [ "$status" -eq 0 ] + assert_builds "oci/bluefin-server-ddi.bst" + assert_does_not_build "${REF_ELEMENT}" +} + +@test "build-ddi os-base=flatcar-reference refuses before the element exists" { + run_build "flatcar-reference" + [ "$status" -ne 0 ] + [[ "$output" == *"projectbluefin/server#126"* ]] + assert_no_build +} + +@test "build-ddi rejects an unknown os-base" { + run_build "not-a-base" + [ "$status" -ne 0 ] + [[ "$output" == *"unknown os-base"* ]] + assert_no_build +} From a062fc73ee43196431e42e8fd5bf3f4f9e5fabb3 Mon Sep 17 00:00:00 2001 From: castrojo Date: Fri, 18 Sep 2026 13:11:21 -0400 Subject: [PATCH 2/3] fix: resolve flatcar-reference element against elements/ in build-ddi The build-ddi os-base=flatcar-reference guard tested `-f "oci/bluefin-server-ddi-flatcar-reference.bst"`, but project.conf declares `element-path: elements`, so the element file lives at `elements/oci/bluefin-server-ddi-flatcar-reference.bst`. The guard could therefore never be satisfied and the flatcar-reference route was permanently unreachable, matching the Justfile's existing convention of referencing element files as `elements/...` on disk. The bats test asserting the refusal passed for the wrong reason: it ran against the repo root where no `oci/` directory exists at all. It now runs against a sandbox that holds a decoy at the bare `oci/` path and nothing under `elements/oci/`, so it fails if the guard resolves the wrong path and stays a genuine refusal test once the #126 element lands. Assisted-by: Claude Opus 4.6 via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Justfile | 2 +- tests/unit/build_ddi_os_base_test.bats | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Justfile b/Justfile index 3d9fc437..37d48581 100644 --- a/Justfile +++ b/Justfile @@ -100,7 +100,7 @@ build-ddi OS_BASE="fsdk": DDI_ELEMENT="oci/bluefin-server-ddi.bst" ;; flatcar-reference) - if [ ! -f "oci/bluefin-server-ddi-flatcar-reference.bst" ]; then + if [ ! -f "elements/oci/bluefin-server-ddi-flatcar-reference.bst" ]; then echo "ERROR: os-base=flatcar-reference requires the imported Flatcar reference tree" >&2 echo " (projectbluefin/server#126); element oci/bluefin-server-ddi-flatcar-reference.bst" >&2 echo " does not exist yet. Add it alongside the #126 tree, then re-run." >&2 diff --git a/tests/unit/build_ddi_os_base_test.bats b/tests/unit/build_ddi_os_base_test.bats index 9485b5c7..51c47f39 100644 --- a/tests/unit/build_ddi_os_base_test.bats +++ b/tests/unit/build_ddi_os_base_test.bats @@ -129,7 +129,16 @@ refute_log() { } @test "build-ddi os-base=flatcar-reference refuses before the element exists" { - run_build "flatcar-reference" + # The guard must resolve the element against the project's element-path + # (project.conf: element-path: elements), so a stray copy at a bare + # oci/ path must not satisfy it. Run against a sandbox that has the + # decoy but not elements/oci/, so this stays a refusal test after the + # #126 element lands in the repo. + touch "${OCI}/bluefin-server-ddi-flatcar-reference.bst" + run env PATH="${BIN_DIR}:${PATH}" \ + just --justfile "${JUSTFILE}" \ + --working-directory "${SANDBOX}" \ + build-ddi flatcar-reference [ "$status" -ne 0 ] [[ "$output" == *"projectbluefin/server#126"* ]] assert_no_build From b1be581e98a978588eaf711dd4ad275cdd34063a Mon Sep 17 00:00:00 2001 From: "sec-check[bot]" Date: Sun, 20 Sep 2026 07:05:29 -0400 Subject: [PATCH 3/3] fix(build): stop interpolating os-base into the build-ddi recipe body just substitutes {{...}} textually into the recipe body before bash parses it, so `case "{{OS_BASE}}"` made the argument executable: $ just build-ddi '$(echo PWNED >&2)' PWNED PWNED ERROR: unknown os-base '' (expected 'fsdk' or 'flatcar-reference') It ran twice -- once at the case, once in the error echo -- so even the rejection path executed it, and the message that was supposed to name the bad value printed empty because the substitution had consumed it. Exporting the parameter (`build-ddi $OS_BASE="fsdk"`) hands it to the recipe as an environment variable, so bash only ever sees "$OS_BASE" and never expands the caller's text. Same invocation now prints the payload verbatim and exits 1. Only the local invoker could reach this, and it matches the existing {{ARGS}} pattern in the bst recipe, but os-base is a fixed enum of two values and has no reason to be interpolated at all. Adds two regression tests: one asserts no {{OS_BASE}} remains in the recipe body, the other passes $(touch ) and asserts the marker is absent. The marker matters -- the payload's own text necessarily appears in the rejection message, so a string assertion could not distinguish echoed from executed. Both fail against the previous Justfile, along with the parameter-shape guard. Also documents os-base in docs/skills/ddi-installer-build.md, which still showed a bare `just build-ddi` and is what operators drive the #129 parity harness from: a Payload base section covering both values, the #126 refusal before the reference element exists, and the fact that export-ddi does not forward os-base, so the reference tree stays a comparison input and never becomes a release artifact. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: sec-check[bot] --- Justfile | 6 +++--- docs/skills/ddi-installer-build.md | 27 ++++++++++++++++++++++++-- tests/unit/build_ddi_os_base_test.bats | 26 ++++++++++++++++++++++++- 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/Justfile b/Justfile index 37d48581..3beb0e63 100644 --- a/Justfile +++ b/Justfile @@ -92,10 +92,10 @@ build: # Routes to bluefin-server-ddi-flatcar-reference.bst, added # alongside the #126 imported Flatcar reference tree. [group('installer')] -build-ddi OS_BASE="fsdk": +build-ddi $OS_BASE="fsdk": #!/usr/bin/env bash set -euo pipefail - case "{{OS_BASE}}" in + case "$OS_BASE" in fsdk) DDI_ELEMENT="oci/bluefin-server-ddi.bst" ;; @@ -109,7 +109,7 @@ build-ddi OS_BASE="fsdk": DDI_ELEMENT="oci/bluefin-server-ddi-flatcar-reference.bst" ;; *) - echo "ERROR: unknown os-base '{{OS_BASE}}' (expected 'fsdk' or 'flatcar-reference')" >&2 + echo "ERROR: unknown os-base '${OS_BASE}' (expected 'fsdk' or 'flatcar-reference')" >&2 exit 1 ;; esac diff --git a/docs/skills/ddi-installer-build.md b/docs/skills/ddi-installer-build.md index 0916d10f..468fa7a1 100644 --- a/docs/skills/ddi-installer-build.md +++ b/docs/skills/ddi-installer-build.md @@ -24,7 +24,7 @@ just cluster-build # submit an Argo workflow to build/publish just build-installer # build the installer locally just export-installer # export installer + UKI + SHA256SUMS to dist/ just export-pxe # export standalone PXE vmlinuz/initrd to dist/ -just build-ddi # build the OS DDI payload +just build-ddi # build the OS DDI payload (see "Payload base" below) just export-ddi # export DDI + SHA256SUMS to dist/ddi/ just build-sysext # build the k0s sysext just export-sysext # export sysext artifacts to dist/sysext/ @@ -34,6 +34,28 @@ just test-installer-artifact # test already-exported artifacts in QEMU without r just tags # show FSDK-derived version tags ``` +### Payload base + +`build-ddi` takes an optional `os-base` argument selecting which payload it +composes. It backs the FSDK-vs-Flatcar parity harness +(projectbluefin/server#129), where the two bases are built and compared: + +```bash +just build-ddi # os-base=fsdk (default) +just build-ddi fsdk # FSDK-composed payload -- the shipped base +just build-ddi flatcar-reference # imported Flatcar reference tree -- the control +``` + +`flatcar-reference` routes to `oci/bluefin-server-ddi-flatcar-reference.bst`. +That element arrives with the imported Flatcar reference tree +(projectbluefin/server#126); until it does, `build-ddi flatcar-reference` +refuses with a message naming #126 rather than building anything. Anything +other than these two values is rejected. + +`export-ddi` always exports the default `fsdk` payload -- it does not forward +`os-base`, so the reference tree is a comparison input, never a release +artifact. + ## Mandatory build path: ghost cluster This project MUST always build on the ghost cluster using distributed BuildStream: @@ -58,7 +80,8 @@ projects: push: true ``` -Then run `just build-installer` or `just build-ddi`. +Then run `just build-installer` or `just build-ddi` (add `flatcar-reference` to +build the parity-harness control instead of the shipped payload). ## Flashing the installer media diff --git a/tests/unit/build_ddi_os_base_test.bats b/tests/unit/build_ddi_os_base_test.bats index 51c47f39..8b8dc84b 100644 --- a/tests/unit/build_ddi_os_base_test.bats +++ b/tests/unit/build_ddi_os_base_test.bats @@ -101,7 +101,17 @@ refute_log() { # --- guard shape ------------------------------------------------------------ @test "build-ddi still declares the OS_BASE parameter defaulting to fsdk" { - grep -qF 'build-ddi OS_BASE="fsdk"' "${JUSTFILE}" + grep -qF 'build-ddi $OS_BASE="fsdk"' "${JUSTFILE}" +} + +# `just` substitutes {{...}} textually into the recipe body before bash parses +# it, so `case "{{OS_BASE}}"` makes `just build-ddi '$(cmd)'` run cmd -- on the +# rejection path too, because the error message interpolates it a second time. +# The `$` on the parameter exports it as an environment variable instead, so +# bash only ever sees "$OS_BASE" and never expands the caller's text. +@test "build-ddi never interpolates os-base into the recipe body" { + run awk '/^build-ddi /{f=1} f&&/\{\{OS_BASE\}\}/{print} f&&/^$/{f=0}' "${JUSTFILE}" + [ -z "${output}" ] } @test "build-ddi still validates os-base against fsdk and flatcar-reference" { @@ -150,3 +160,17 @@ refute_log() { [[ "$output" == *"unknown os-base"* ]] assert_no_build } + +@test "build-ddi does not execute command substitution in os-base" { + # The marker proves execution rather than mere appearance: the payload's + # own text necessarily shows up in the rejection message, so a string + # assertion could not tell "echoed" from "ran". + local marker="${BATS_TEST_TMPDIR}/injected" + run_build "\$(touch ${marker})" + [ "$status" -ne 0 ] + [ ! -e "${marker}" ] + # The payload is reported verbatim instead. Before the `$OS_BASE` export + # the substitution ran here too, so the name was empty in this message. + [[ "$output" == *"touch ${marker}"* ]] + assert_no_build +}