diff --git a/.github/scripts/configure_podman_storage.sh b/.github/scripts/configure_podman_storage.sh deleted file mode 100755 index d565bd0..0000000 --- a/.github/scripts/configure_podman_storage.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: Apache-2.0 -# Configure podman storage driver intelligently based on available filesystem -# Clears existing podman storage to avoid database mismatch errors - -set -eo pipefail - -# Stop podman if running -sudo podman rm -fa 2>/dev/null || true -sudo podman rmi -a 2>/dev/null || true - -# Clear existing podman storage database to avoid driver mismatch -# This is safe in CI where we start fresh each run -echo "Clearing podman storage database..." -if command -v podman &> /dev/null; then - sudo podman system reset -f 2>/dev/null || { - # Fallback if podman system reset isn't available - sudo rm -rf /var/lib/containers/storage.lock 2>/dev/null || true - sudo rm -rf /run/containers/storage.lock 2>/dev/null || true - echo "Warning: podman system reset not available, tried lock file cleanup as fallback" - } -else - echo "Podman not installed, skipping reset" -fi - -# Detect filesystem type at /var/lib/containers (where BTRFS loopback is mounted) -# Use findmnt to reliably detect filesystem (stat --file-system returns "ext2/ext3" for ext4) -if [ -d /var/lib/containers ]; then - FS_TYPE=$(findmnt -n -o FSTYPE -T /var/lib/containers 2>/dev/null || echo "unknown") -else - FS_TYPE=$(findmnt -n -o FSTYPE -T /var/lib 2>/dev/null || echo "unknown") -fi - -echo "Detected filesystem for /var/lib/containers: $FS_TYPE" - -# Choose driver based on filesystem (native drivers preferred for COW efficiency) -case "$FS_TYPE" in - btrfs) - DRIVER="btrfs" - echo "Using btrfs driver (native COW support on BTRFS filesystem)" - ;; - zfs) - DRIVER="zfs" - echo "Using zfs driver (native COW support on ZFS filesystem)" - ;; - ext4|ext3|ext2|xfs) - DRIVER="overlay" - echo "Using overlay driver (space-efficient on ext4/xfs)" - ;; - *) - DRIVER="vfs" - echo "Using vfs driver (fallback for $FS_TYPE)" - ;; -esac - -# Write storage.conf -echo "Configuring podman storage driver: $DRIVER" -GRAPHROOT="/var/lib/containers/storage" - -sudo bash -c "cat > /etc/containers/storage.conf" << CONF -[storage] -driver = "$DRIVER" -graphroot = "$GRAPHROOT" -runroot = "/run/containers/storage" -CONF - -# Verify configuration -echo "" -echo "=== Podman storage configuration ===" -sudo podman info | grep -A 5 "storage:" || sudo podman info | head -20 diff --git a/.github/workflows/build-iso-all.yml b/.github/workflows/build-iso-all.yml new file mode 100644 index 0000000..e5412c0 --- /dev/null +++ b/.github/workflows/build-iso-all.yml @@ -0,0 +1,56 @@ +--- +name: Build All ISOs +# Orchestrator workflow that calls ALL individual ISO build workflows +# Builds ALL production ISOs with production tags only +# +# For testing tags (-testing), use the dedicated testing workflow: +# - build-iso-lts-hwe-testing.yml (the ONLY authorized workflow for testing tags) +# +# Total: 8 production ISOs across all variants: +# - build-iso-stable → 2 Stable ISOs (amd64 × main, amd64 × nvidia-open) +# - build-iso-lts → 4 LTS ISOs (amd64/arm64 × main, amd64/arm64 × gdx) +# - build-iso-lts-hwe → 2 LTS-HWE ISOs (amd64/arm64 × main) +on: + workflow_dispatch: + inputs: + upload_artifacts: + description: 'Upload ISOs as job artifacts' + type: boolean + default: false + upload_r2: + description: 'Upload ISOs to Cloudflare R2' + type: boolean + default: true + schedule: + - cron: "0 3 1 * *" # Push to testing bucket on the first of the month at 03:00 UTC - 2h after Bluefin publishes monthly builds. + +jobs: + build-iso-lts: + name: Build LTS ISOs + uses: ./.github/workflows/reusable-build-iso-anaconda.yml + secrets: inherit + with: + image_version: lts # Strictly LTS only + image_tag: lts # Hardcoded: build-iso-all.yml only builds production tags + upload_artifacts: ${{ github.event_name == 'workflow_dispatch' && inputs.upload_artifacts || false }} + upload_r2: ${{ github.event_name != 'workflow_dispatch' || inputs.upload_r2 }} + + build-iso-lts-hwe: + name: Build LTS-HWE ISOs + uses: ./.github/workflows/reusable-build-iso-anaconda.yml + secrets: inherit + with: + image_version: lts-hwe # Strictly LTS-HWE only + image_tag: lts-hwe + upload_artifacts: ${{ github.event_name == 'workflow_dispatch' && inputs.upload_artifacts || false }} + upload_r2: ${{ github.event_name != 'workflow_dispatch' || inputs.upload_r2 }} + + build-iso-stable: + name: Build Stable ISOs + uses: ./.github/workflows/reusable-build-iso-anaconda.yml + secrets: inherit + with: + image_version: stable # Strictly Stable only + image_tag: stable + upload_artifacts: ${{ github.event_name == 'workflow_dispatch' && inputs.upload_artifacts || false }} + upload_r2: ${{ github.event_name != 'workflow_dispatch' || inputs.upload_r2 }} diff --git a/.github/workflows/build-iso-lts-hwe-testing.yml b/.github/workflows/build-iso-lts-hwe-testing.yml new file mode 100644 index 0000000..35f0793 --- /dev/null +++ b/.github/workflows/build-iso-lts-hwe-testing.yml @@ -0,0 +1,34 @@ +--- +name: Build LTS-HWE Testing ISOs +# This is the ONLY authorized workflow for building lts-hwe-testing ISOs. +# Testing tags (lts-hwe-testing) must NOT be used in build-iso-lts-hwe.yml or +# build-iso-all.yml — those workflows are for production tags only. +# Note: choice-input removal enforces this at the UI/CLI level; direct API +# callers must follow this policy by convention. +# Builds: 2 LTS-HWE testing ISOs +# - amd64 x main +# - arm64 x main +on: + workflow_dispatch: + inputs: + upload_artifacts: + description: 'Upload ISOs as job artifacts' + type: boolean + default: false + upload_r2: + description: 'Upload ISOs to Cloudflare R2' + type: boolean + default: true + schedule: + - cron: '17 6 * * 1' # Every Monday at 06:17 UTC + +jobs: + build-iso-lts-hwe-testing: + name: Build LTS-HWE Testing ISOs + uses: ./.github/workflows/reusable-build-iso-anaconda.yml + secrets: inherit + with: + image_version: lts-hwe + image_tag: lts-hwe-testing + upload_artifacts: ${{ github.event_name == 'workflow_dispatch' && inputs.upload_artifacts || false }} + upload_r2: ${{ github.event_name != 'workflow_dispatch' || inputs.upload_r2 }} diff --git a/.github/workflows/build-iso-lts-hwe.yml b/.github/workflows/build-iso-lts-hwe.yml new file mode 100644 index 0000000..94e1ef3 --- /dev/null +++ b/.github/workflows/build-iso-lts-hwe.yml @@ -0,0 +1,36 @@ +--- +name: Build LTS-HWE ISOs +# This workflow ONLY builds LTS-HWE ISOs (not GTS, Stable, or LTS) +# Builds: 2 LTS-HWE ISOs +# - amd64 × main +# - arm64 × main +on: + workflow_dispatch: + inputs: + image_tag: + description: 'Image tag to build from (production only; for lts-hwe-testing use build-iso-lts-hwe-testing.yml)' + type: choice + options: + - lts-hwe + default: lts-hwe + upload_artifacts: + description: 'Upload ISOs as job artifacts' + type: boolean + default: false + upload_r2: + description: 'Upload ISOs to Cloudflare R2' + type: boolean + default: true + schedule: + - cron: '0 2 1 * *' # 2am UTC on the 1st of every month + +jobs: + build-iso-lts-hwe: + name: Build LTS-HWE ISOs + uses: ./.github/workflows/reusable-build-iso-anaconda.yml + secrets: inherit + with: + image_version: lts-hwe # Strictly builds LTS-HWE ISOs only + image_tag: ${{ github.event_name == 'workflow_dispatch' && inputs.image_tag || 'lts-hwe' }} + upload_artifacts: ${{ github.event_name == 'workflow_dispatch' && inputs.upload_artifacts || false }} + upload_r2: ${{ github.event_name != 'workflow_dispatch' || inputs.upload_r2 }} diff --git a/.github/workflows/build-iso-lts.yml b/.github/workflows/build-iso-lts.yml new file mode 100644 index 0000000..687f6ba --- /dev/null +++ b/.github/workflows/build-iso-lts.yml @@ -0,0 +1,38 @@ +--- +name: Build LTS ISOs +# This workflow ONLY builds LTS ISOs (not GTS, Stable, or LTS-HWE) +# Builds: 4 LTS ISOs +# - amd64 × main +# - amd64 × gdx +# - arm64 × main +# - arm64 × gdx +on: + workflow_dispatch: + inputs: + image_tag: + description: 'Image tag to build from (production only; no authorized workflow exists for lts-testing)' + type: choice + options: + - lts + default: lts + upload_artifacts: + description: 'Upload ISOs as job artifacts' + type: boolean + default: false + upload_r2: + description: 'Upload ISOs to Cloudflare R2' + type: boolean + default: true + schedule: + - cron: '0 2 1 * *' # 2am UTC on the 1st of every month + +jobs: + build-iso-lts: + name: Build LTS ISOs + uses: ./.github/workflows/reusable-build-iso-anaconda.yml + secrets: inherit + with: + image_version: lts # Strictly builds LTS ISOs only + image_tag: ${{ github.event_name == 'workflow_dispatch' && inputs.image_tag || 'lts' }} + upload_artifacts: ${{ github.event_name == 'workflow_dispatch' && inputs.upload_artifacts || false }} + upload_r2: ${{ github.event_name != 'workflow_dispatch' || inputs.upload_r2 }} diff --git a/.github/workflows/build-iso-stable.yml b/.github/workflows/build-iso-stable.yml new file mode 100644 index 0000000..151e05e --- /dev/null +++ b/.github/workflows/build-iso-stable.yml @@ -0,0 +1,30 @@ +--- +name: Build Stable ISOs +# This workflow ONLY builds Stable ISOs (not LTS, LTS-HWE, or GTS) +# Builds: 2 Stable ISOs +# - amd64 × main +# - amd64 × nvidia-open +on: + workflow_dispatch: + inputs: + upload_artifacts: + description: 'Upload ISOs as job artifacts' + type: boolean + default: false + upload_r2: + description: 'Upload ISOs to Cloudflare R2' + type: boolean + default: true + schedule: + - cron: '0 2 1 * *' # 2am UTC on the 1st of every month + +jobs: + build-iso-stable: + name: Build Stable ISOs + uses: ./.github/workflows/reusable-build-iso-anaconda.yml + secrets: inherit + with: + image_version: stable # Strictly builds Stable ISOs only + image_tag: stable + upload_artifacts: ${{ github.event_name == 'workflow_dispatch' && inputs.upload_artifacts || false }} + upload_r2: ${{ github.event_name == 'workflow_dispatch' && inputs.upload_r2 || true }} diff --git a/.github/workflows/build-iso.yml b/.github/workflows/build-iso.yml deleted file mode 100644 index cd56b8c..0000000 --- a/.github/workflows/build-iso.yml +++ /dev/null @@ -1,251 +0,0 @@ -name: Build and Publish Bluefin Live ISO - -on: - push: - branches: [main] - paths: - - 'Containerfile' - - 'Containerfile.builder' - - 'justfile' - - 'src/**' - - 'bluefin/**' - - 'bluefin-lts/**' - - '.github/workflows/build-iso.yml' - schedule: - # Rebuild daily at 03:00 UTC to pick up Bluefin image updates - - cron: '0 3 * * *' - workflow_dispatch: - inputs: - skip_upload: - description: 'Build ISO but skip uploading to R2 (dry run)' - required: false - default: false - type: boolean - -jobs: - build-and-publish: - name: Build ${{ matrix.target }} Live ISO - runs-on: ubuntu-24.04 - strategy: - fail-fast: false - matrix: - target: [bluefin, bluefin-lts] - permissions: - contents: read - packages: read - pull-requests: write - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Free disk space - uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be - with: - tool-cache: true - - - name: Disk space after free - run: | - echo "=== Disk space after free-disk-space ===" - df -h / - df -i / - echo "=== Podman info ===" - sudo podman info --format 'Driver: {{.Store.GraphDriverName}} GraphRoot: {{.Store.GraphRoot}}' 2>/dev/null || true - - - name: Install dependencies - run: | - sudo apt-get update -qq - sudo apt-get install -y just podman buildah rclone mtools xorriso - - - name: Log in to GHCR - run: | - echo "${{ secrets.GITHUB_TOKEN }}" | \ - sudo podman login ghcr.io -u ${{ github.actor }} --password-stdin - - - name: Build Live ISO - run: | - echo "=== Disk space before build ===" - df -h / - sudo mkdir -p /var/iso-build - sudo $(command -v just) installer_channel=stable output_dir=/var/iso-build iso-sd-boot ${{ matrix.target }} - mkdir -p output - sudo cp /var/iso-build/*.iso output/ 2>/dev/null || true - sudo chown -R "$USER:$(id -gn)" output/ - - - name: Disk space after build - run: | - echo "=== Disk space after ISO build ===" - df -h / - echo "=== Podman images ===" - sudo podman images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}" - echo "=== Podman system df ===" - sudo podman system df -v 2>/dev/null || sudo podman system df - echo "=== Output directory ===" - du -sh output/* 2>/dev/null || true - - - name: Clean up podman images - run: | - echo "=== Removing podman images to free space ===" - sudo podman rmi localhost/${{ matrix.target }}-installer 2>/dev/null || true - sudo podman system prune -af --volumes 2>/dev/null || true - echo "=== Disk space after cleanup ===" - df -h / - sudo podman images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}" 2>/dev/null || true - - - name: Fix output directory ownership - run: sudo chown -R "$USER:$(id -gn)" output/ 2>/dev/null || true - - - name: Compute ISO name - id: iso - run: | - DATE=$(date -u +%Y%m%d) - SHA=$(echo "${{ github.sha }}" | cut -c1-7) - echo "dated=${{ matrix.target }}-live-${DATE}-${SHA}.iso" >> "$GITHUB_OUTPUT" - echo "path=output/${{ matrix.target }}-live.iso" >> "$GITHUB_OUTPUT" - - - name: Generate SHA256 checksum - id: checksum - run: | - ISO="${{ steps.iso.outputs.path }}" - DATED="${{ steps.iso.outputs.dated }}" - CHECKSUM_PATH="output/${DATED}-CHECKSUM" - LATEST="${{ matrix.target }}-live-latest.iso" - LATEST_CHECKSUM_PATH="output/${LATEST}-CHECKSUM" - sha256sum "$ISO" | sed "s|${ISO}|${DATED}|" | tee "$CHECKSUM_PATH" - sha256sum "$ISO" | sed "s|${ISO}|${LATEST}|" > "$LATEST_CHECKSUM_PATH" - echo "path=${CHECKSUM_PATH}" >> "$GITHUB_OUTPUT" - echo "name=${DATED}-CHECKSUM" >> "$GITHUB_OUTPUT" - echo "latest_path=${LATEST_CHECKSUM_PATH}" >> "$GITHUB_OUTPUT" - echo "latest=${LATEST}" >> "$GITHUB_OUTPUT" - - - name: Upload ISO to Cloudflare R2 - if: ${{ inputs.skip_upload != true && github.event_name != 'pull_request' }} - env: - RCLONE_CONFIG_R2_TYPE: s3 - RCLONE_CONFIG_R2_PROVIDER: Cloudflare - RCLONE_CONFIG_R2_REGION: auto - RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.RCLONE_CONFIG_R2_ACCESS_KEY_ID }} - RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.RCLONE_CONFIG_R2_SECRET_ACCESS_KEY }} - RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.RCLONE_CONFIG_R2_ENDPOINT }} - run: | - ISO="${{ steps.iso.outputs.path }}" - DATED="${{ steps.iso.outputs.dated }}" - LATEST="${{ steps.checksum.outputs.latest }}" - - echo "==> Uploading as $DATED ..." - rclone copyto --log-level INFO --checksum --s3-no-check-bucket \ - "$ISO" "R2:testing/${DATED}" - - echo "==> Updating ${LATEST} ..." - rclone copyto --log-level INFO --s3-no-check-bucket \ - "$ISO" "R2:testing/${LATEST}" - - echo "==> Uploading checksum as ${{ steps.checksum.outputs.name }} ..." - rclone copyto --log-level INFO --s3-no-check-bucket \ - "${{ steps.checksum.outputs.path }}" \ - "R2:testing/${{ steps.checksum.outputs.name }}" - - echo "==> Updating ${LATEST}-CHECKSUM ..." - rclone copyto --log-level INFO --s3-no-check-bucket \ - "${{ steps.checksum.outputs.latest_path }}" \ - "R2:testing/${LATEST}-CHECKSUM" - - echo "==> Done. Public URLs:" - echo " https://projectbluefin.dev/${LATEST}" - echo " https://projectbluefin.dev/${LATEST}-CHECKSUM" - - - name: Boot verification (UEFI + serial) - timeout-minutes: 10 - run: | - ISO="${{ steps.iso.outputs.path }}" - - sudo apt-get install -y qemu-system-x86 ovmf socat imagemagick -qq - - echo "==> Booting $ISO ..." - - EFI_CODE=""; EFI_VARS="" - for f in /usr/share/OVMF/OVMF_CODE_4M.fd \ - /usr/share/OVMF/OVMF_CODE.fd \ - /usr/share/edk2/ovmf/OVMF_CODE.fd; do - [ -f "$f" ] && EFI_CODE="$f" && break - done - for f in /usr/share/OVMF/OVMF_VARS_4M.fd \ - /usr/share/OVMF/OVMF_VARS.fd \ - /usr/share/edk2/ovmf/OVMF_VARS.fd; do - if [ -f "$f" ]; then - cp "$f" /tmp/EFI_VARS.fd - EFI_VARS="/tmp/EFI_VARS.fd" - break - fi - done - - PFLASH=() - if [ -n "$EFI_CODE" ] && [ -n "$EFI_VARS" ]; then - echo "==> UEFI firmware: $EFI_CODE" - PFLASH+=(-drive "if=pflash,format=raw,readonly=on,file=$EFI_CODE") - PFLASH+=(-drive "if=pflash,format=raw,file=$EFI_VARS") - fi - - sudo qemu-system-x86_64 \ - -machine type=q35,accel=kvm \ - -cpu host -m 4G -smp 2 \ - "${PFLASH[@]}" \ - -cdrom "$ISO" -boot d \ - -monitor unix:/tmp/qemu-monitor.sock,server,nowait \ - -serial file:/tmp/serial.log \ - -display none \ - -daemonize - - for i in $(seq 1 30); do - [ -S /tmp/qemu-monitor.sock ] && break - sleep 2 - done - - echo "==> Waiting up to 5 minutes for live environment to be ready..." - for i in $(seq 1 60); do - if sudo grep -q "BLUEFIN_LIVE_READY" /tmp/serial.log 2>/dev/null; then - echo "==> Live environment ready after $((i * 5))s" - break - fi - [ "$i" -eq 60 ] && echo "WARNING: BLUEFIN_LIVE_READY not seen in serial log after 5m" || true - sleep 5 - done - - echo "screendump /tmp/screenshot.ppm" | \ - sudo socat - UNIX-CONNECT:/tmp/qemu-monitor.sock || true - sleep 2 - if sudo test -f /tmp/screenshot.ppm; then - sudo convert /tmp/screenshot.ppm screenshot.png 2>/dev/null || \ - sudo cp /tmp/screenshot.ppm screenshot.png - echo "==> Screenshot saved" - fi - - echo "quit" | sudo socat - UNIX-CONNECT:/tmp/qemu-monitor.sock || true - - sudo grep -qE "BLUEFIN_LIVE_READY|Finished live-ready\.service" /tmp/serial.log || \ - { echo "ERROR: Live environment did not reach ready state"; sudo tail -50 /tmp/serial.log; exit 1; } - - - name: Upload ISO as artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ steps.iso.outputs.dated }} - path: ${{ steps.iso.outputs.path }} - if-no-files-found: error - retention-days: 7 - - - name: Upload SHA256 checksum as artifact - uses: actions/upload-artifact@v4 - if: steps.checksum.outputs.path != '' - with: - name: checksum-${{ steps.iso.outputs.dated }} - path: ${{ steps.checksum.outputs.path }} - if-no-files-found: warn - retention-days: 7 - - - name: Upload boot screenshot as artifact - uses: actions/upload-artifact@v4 - if: always() - with: - name: boot-screenshot-${{ matrix.target }} - path: screenshot.png - if-no-files-found: warn diff --git a/.github/workflows/promote-iso.yml b/.github/workflows/promote-iso.yml new file mode 100644 index 0000000..09d8f9a --- /dev/null +++ b/.github/workflows/promote-iso.yml @@ -0,0 +1,394 @@ +--- +name: Promote ISOs to Production +on: + workflow_dispatch: + inputs: + variant: + description: 'Which ISOs to promote' + required: true + type: choice + default: 'stable' + options: + - stable + - lts + - lts-hwe + release_tag: + description: 'GitHub release tag to promote (e.g., 26.02.1). Leave empty to auto-detect latest prerelease.' + type: string + required: false + allow_unsafe_lts: + description: 'UNSAFE: allow promoting LTS (non-HWE) ISOs. Requires explicit acknowledgment.' + required: false + type: boolean + default: false + dry_run: + description: 'Run in dry-run mode (preview changes without copying)' + required: false + type: boolean + default: true + +jobs: + promote: + name: Promote ${{ inputs.variant }} ISOs to Production + runs-on: ubuntu-latest + outputs: + source_tag: ${{ steps.preflight.outputs.source_tag }} + source_release_id: ${{ steps.preflight.outputs.source_release_id }} + candidate_count: ${{ steps.preflight.outputs.candidate_count }} + filter_file: ${{ steps.preflight.outputs.filter_file }} + permissions: + contents: read + env: + # Test Bucket Config (Source) - using R2 2025 credentials + RCLONE_CONFIG_R2_TEST_TYPE: s3 + RCLONE_CONFIG_R2_TEST_PROVIDER: Cloudflare + RCLONE_CONFIG_R2_TEST_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID_2025 }} + RCLONE_CONFIG_R2_TEST_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY_2025 }} + RCLONE_CONFIG_R2_TEST_REGION: auto + RCLONE_CONFIG_R2_TEST_ENDPOINT: ${{ secrets.R2_ENDPOINT_2025 }} + + # Production Bucket Config (Destination) - using dedicated production credentials + RCLONE_CONFIG_R2_PROD_TYPE: s3 + RCLONE_CONFIG_R2_PROD_PROVIDER: Cloudflare + RCLONE_CONFIG_R2_PROD_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_PRODUCTION }} + RCLONE_CONFIG_R2_PROD_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_PRODUCTION }} + RCLONE_CONFIG_R2_PROD_REGION: auto + RCLONE_CONFIG_R2_PROD_ENDPOINT: ${{ secrets.R2_ENDPOINT_PRODUCTION }} + + steps: + - name: Set up Homebrew + uses: Homebrew/actions/setup-homebrew@8f52032f943acddc1c5670f437b94e031e78afc0 # master + + - name: Install rclone + run: brew install rclone + + - name: Preflight checks + id: preflight + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + run: | + set -euo pipefail + + if [ "${{ inputs.variant }}" = "lts" ] && [ "${{ inputs.allow_unsafe_lts }}" != "true" ]; then + echo "Refusing to promote variant 'lts' without inputs.allow_unsafe_lts=true" + exit 1 + fi + + if [ -n "${{ inputs.release_tag }}" ]; then + SOURCE_TAG="${{ inputs.release_tag }}" + else + SOURCE_TAG=$(gh release list --limit 50 --json tagName,isPrerelease --jq '.[] | select(.isPrerelease == true) | .tagName' | sed -n '1p') + if [ -z "${SOURCE_TAG}" ]; then + echo "No prerelease found to promote" + exit 1 + fi + fi + + RELEASE_JSON=$(gh api "repos/${GITHUB_REPOSITORY}/releases/tags/${SOURCE_TAG}" 2>/dev/null || true) + if [ -z "${RELEASE_JSON}" ]; then + echo "Source release tag '${SOURCE_TAG}' not found" + exit 1 + fi + + IS_PRERELEASE=$(printf '%s' "${RELEASE_JSON}" | jq -r '.prerelease') + RELEASE_ID=$(printf '%s' "${RELEASE_JSON}" | jq -r '.id') + + if [ "${IS_PRERELEASE}" != "true" ]; then + echo "Source release '${SOURCE_TAG}' exists but is not a prerelease" + exit 1 + fi + + RELEASE_ASSET_LIST="${RUNNER_TEMP}/source-release-assets-${SOURCE_TAG}.txt" + printf '%s\n' "${RELEASE_JSON}" | jq -r '.assets[]?.name' > "${RELEASE_ASSET_LIST}" + + RELEASE_ASSET_COUNT=$(wc -l < "${RELEASE_ASSET_LIST}" | tr -d '[:space:]') + if [ "${RELEASE_ASSET_COUNT}" -eq 0 ]; then + echo "Source prerelease '${SOURCE_TAG}' has no assets" + exit 1 + fi + + # Build an rclone filter file for this variant. + # + # WHY the '- *-testing-*' rule is first in every variant block: + # Testing ISOs (e.g. bluefin-lts-hwe-testing-x86_64.iso) share a naming + # prefix with their production counterparts. Without an explicit exclusion, + # the production include rules below would match them: + # '+ *-lts-hwe-*.iso*' matches both lts-hwe AND lts-hwe-testing files. + # Placing '- *-testing-*' first ensures rclone discards testing artifacts + # before evaluating the production include rules, regardless of what files + # happen to be present in the testing bucket. + FILTER_FILE="${RUNNER_TEMP}/rclone-filter-${{ inputs.variant }}.txt" + case "${{ inputs.variant }}" in + stable) + printf '%s\n' \ + '- *-testing-*' \ + '+ *-stable-*.iso*' \ + '- *' > "${FILTER_FILE}" + ;; + lts) + printf '%s\n' \ + '- *-testing-*' \ + '- *-lts-hwe-*.iso*' \ + '+ *-dx-lts-*.iso*' \ + '+ *-lts-*.iso*' \ + '- *' > "${FILTER_FILE}" + ;; + lts-hwe) + printf '%s\n' \ + '- *-testing-*' \ + '+ *-lts-hwe-*.iso*' \ + '- *' > "${FILTER_FILE}" + ;; + *) + echo "Unsupported variant '${{ inputs.variant }}'" + exit 1 + ;; + esac + + CANDIDATE_LIST="${RUNNER_TEMP}/candidate-files-${{ inputs.variant }}.txt" + rclone lsf R2_TEST:testing --filter-from "${FILTER_FILE}" > "${CANDIDATE_LIST}" + CANDIDATE_COUNT=$(wc -l < "${CANDIDATE_LIST}" | tr -d '[:space:]') + + SOURCE_VARIANT_ASSET_COUNT=0 + while IFS= read -r asset_name; do + # Exclude testing artifacts from the production asset count. + # A prerelease may contain both production and testing torrents + # (e.g. from a mixed build run). Only production assets count + # toward the minimum required for a valid promotion. + case "${asset_name}" in + *-testing-*) continue ;; + esac + case "${{ inputs.variant }}" in + stable) + case "${asset_name}" in + *-stable-*.iso.torrent|*-stable-*.iso.torrent-CHECKSUM) + SOURCE_VARIANT_ASSET_COUNT=$((SOURCE_VARIANT_ASSET_COUNT + 1)) + ;; + esac + ;; + lts) + case "${asset_name}" in + *-lts-hwe-*.iso.torrent|*-lts-hwe-*.iso.torrent-CHECKSUM) + ;; + *-dx-lts-*.iso.torrent|*-dx-lts-*.iso.torrent-CHECKSUM|*-lts-*.iso.torrent|*-lts-*.iso.torrent-CHECKSUM) + SOURCE_VARIANT_ASSET_COUNT=$((SOURCE_VARIANT_ASSET_COUNT + 1)) + ;; + esac + ;; + lts-hwe) + case "${asset_name}" in + *-lts-hwe-*.iso.torrent|*-lts-hwe-*.iso.torrent-CHECKSUM) + SOURCE_VARIANT_ASSET_COUNT=$((SOURCE_VARIANT_ASSET_COUNT + 1)) + ;; + esac + ;; + esac + done < "${RELEASE_ASSET_LIST}" + + echo "Source prerelease: ${SOURCE_TAG} (id=${RELEASE_ID})" + echo "Candidate files in testing bucket (${CANDIDATE_COUNT}):" + cat "${CANDIDATE_LIST}" + + if [ "${CANDIDATE_COUNT}" -eq 0 ]; then + echo "No candidate files matched for variant '${{ inputs.variant }}' in R2_TEST:testing" + exit 1 + fi + + if [ "${SOURCE_VARIANT_ASSET_COUNT}" -eq 0 ]; then + echo "Source prerelease '${SOURCE_TAG}' has no assets for variant '${{ inputs.variant }}'" + exit 1 + fi + + echo "source_tag=${SOURCE_TAG}" >> "$GITHUB_OUTPUT" + echo "source_release_id=${RELEASE_ID}" >> "$GITHUB_OUTPUT" + echo "candidate_count=${CANDIDATE_COUNT}" >> "$GITHUB_OUTPUT" + echo "filter_file=${FILTER_FILE}" >> "$GITHUB_OUTPUT" + + - name: List files in Test bucket + run: | + set -euo pipefail + echo "Files in Test bucket matching variant '${{ inputs.variant }}':" + rclone ls R2_TEST:testing --filter-from "${{ steps.preflight.outputs.filter_file }}" + + - name: Promote ISOs (Dry Run) + if: ${{ inputs.dry_run == true }} + run: | + set -euo pipefail + echo "Running in DRY RUN mode - no files will be copied" + rclone copy R2_TEST:testing R2_PROD:bluefin \ + --filter-from "${{ steps.preflight.outputs.filter_file }}" \ + --dry-run \ + --verbose + + - name: Promote ISOs (Production) + if: ${{ inputs.dry_run == false }} + run: | + set -euo pipefail + echo "Promoting ISOs from Test to Production" + rclone copy R2_TEST:testing R2_PROD:bluefin \ + --filter-from "${{ steps.preflight.outputs.filter_file }}" \ + --verbose \ + --progress + + - name: Verify promotion + if: ${{ inputs.dry_run == false }} + run: | + set -euo pipefail + echo "Files in Production bucket after promotion:" + rclone ls R2_PROD:bluefin --filter-from "${{ steps.preflight.outputs.filter_file }}" + + promote-release: + name: Promote GitHub Release + needs: promote + if: ${{ inputs.dry_run == false }} + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + + - name: Determine production release tag + id: prod-tag + env: + GH_TOKEN: ${{ github.token }} + SOURCE_TAG: ${{ needs.promote.outputs.source_tag }} + run: | + set -euo pipefail + + if [ -z "${SOURCE_TAG}" ]; then + echo "Missing source tag from preflight outputs" + exit 1 + fi + + BASE_TAG="${SOURCE_TAG}-${{ inputs.variant }}" + TARGET_TAG="${BASE_TAG}" + COUNTER=1 + while gh release view "${TARGET_TAG}" >/dev/null 2>&1; do + TARGET_TAG="${BASE_TAG}.${COUNTER}" + COUNTER=$((COUNTER + 1)) + done + + echo "target_tag=${TARGET_TAG}" >> "$GITHUB_OUTPUT" + echo "source_tag=${SOURCE_TAG}" >> "$GITHUB_OUTPUT" + echo "Source prerelease: ${SOURCE_TAG}" + echo "Target production tag: ${TARGET_TAG}" + + - name: Download and select torrent assets from source prerelease + id: assets + env: + GH_TOKEN: ${{ github.token }} + SOURCE_TAG: ${{ steps.prod-tag.outputs.source_tag }} + run: | + set -euo pipefail + shopt -s nullglob + + RAW_DIR="${RUNNER_TEMP}/release-assets-raw" + SELECTED_DIR="${RUNNER_TEMP}/release-assets-selected" + mkdir -p "${RAW_DIR}" "${SELECTED_DIR}" + + gh release download "${SOURCE_TAG}" --dir "${RAW_DIR}" --pattern "*.iso.torrent" + gh release download "${SOURCE_TAG}" --dir "${RAW_DIR}" --pattern "*.iso.torrent-CHECKSUM" + + for file in "${RAW_DIR}"/*; do + name=$(basename "${file}") + # Exclude testing artifacts from the production GitHub release. + # A prerelease may contain both production and testing torrents + # (e.g. lts-hwe and lts-hwe-testing from the same build window). + # The production include rules below would otherwise match testing + # filenames by prefix — this guard is the last line of defense. + case "${name}" in + *-testing-*) continue ;; + esac + case "${{ inputs.variant }}" in + stable) + case "${name}" in + *-stable-*.iso.torrent|*-stable-*.iso.torrent-CHECKSUM) + cp "${file}" "${SELECTED_DIR}/" + ;; + esac + ;; + lts) + case "${name}" in + *-lts-hwe-*.iso.torrent|*-lts-hwe-*.iso.torrent-CHECKSUM) + ;; + *-dx-lts-*.iso.torrent|*-dx-lts-*.iso.torrent-CHECKSUM|*-lts-*.iso.torrent|*-lts-*.iso.torrent-CHECKSUM) + cp "${file}" "${SELECTED_DIR}/" + ;; + esac + ;; + lts-hwe) + case "${name}" in + *-lts-hwe-*.iso.torrent|*-lts-hwe-*.iso.torrent-CHECKSUM) + cp "${file}" "${SELECTED_DIR}/" + ;; + esac + ;; + esac + done + + selected=("${SELECTED_DIR}"/*) + if [ ${#selected[@]} -eq 0 ]; then + echo "No variant-matching torrent assets found on source prerelease '${SOURCE_TAG}'" + exit 1 + fi + + printf '%s\n' "${selected[@]}" > "${RUNNER_TEMP}/selected-assets.txt" + echo "selected_assets_file=${RUNNER_TEMP}/selected-assets.txt" >> "$GITHUB_OUTPUT" + echo "Selected ${#selected[@]} assets for release" + + - name: Create production release + env: + GH_TOKEN: ${{ github.token }} + SOURCE_TAG: ${{ steps.prod-tag.outputs.source_tag }} + TARGET_TAG: ${{ steps.prod-tag.outputs.target_tag }} + SELECTED_ASSETS_FILE: ${{ steps.assets.outputs.selected_assets_file }} + run: | + set -euo pipefail + mapfile -t assets < "${SELECTED_ASSETS_FILE}" + + if [ ${#assets[@]} -eq 0 ]; then + echo "No selected assets available to publish for target tag '${TARGET_TAG}'" + exit 1 + fi + + release_notes=$(cat <.torrent-CHECKSUM + EOF + ) + + if [ "${{ inputs.variant }}" = "stable" ]; then + gh release create "${TARGET_TAG}" "${assets[@]}" \ + --title "Bluefin ISOs ${SOURCE_TAG} (${{ inputs.variant }})" \ + --notes "${release_notes}" \ + --latest + elif [ "${{ inputs.variant }}" = "lts-hwe" ]; then + gh release create "${TARGET_TAG}" "${assets[@]}" \ + --title "Bluefin ISOs ${SOURCE_TAG} (${{ inputs.variant }})" \ + --notes "${release_notes}" + else + gh release create "${TARGET_TAG}" "${assets[@]}" \ + --title "Bluefin ISOs ${SOURCE_TAG} (${{ inputs.variant }})" \ + --notes "${release_notes}" + fi + + echo "Created production release ${TARGET_TAG} from source prerelease ${SOURCE_TAG}" diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..4e0840c --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,28 @@ +name: ISO Build PR Check +on: + pull_request: + branches: + - main + paths-ignore: + - '**.md' + - '.gitignore' + +jobs: + build-iso-lts: + name: Build LTS ISOs + uses: ./.github/workflows/reusable-build-iso-anaconda.yml + with: + image_version: lts + upload_r2: false + upload_artifacts: false + secrets: inherit + + build-iso-stable: + name: Build Stable ISOs + uses: ./.github/workflows/reusable-build-iso-anaconda.yml + with: + image_version: stable + image_tag: stable + upload_r2: false + upload_artifacts: false + secrets: inherit diff --git a/.github/workflows/reusable-build-iso-anaconda.yml b/.github/workflows/reusable-build-iso-anaconda.yml new file mode 100644 index 0000000..787a5bb --- /dev/null +++ b/.github/workflows/reusable-build-iso-anaconda.yml @@ -0,0 +1,464 @@ +--- +name: Reusable Build +"on": + workflow_call: + inputs: + image_version: + description: 'Which image version to build' + type: string + required: true + image_tag: + description: 'Image tag to build from' + type: string + default: lts + upload_artifacts: + description: 'Upload ISOs as job artifacts' + type: boolean + default: false + upload_r2: + description: 'Upload ISOs to Cloudflare R2' + type: boolean + default: true + secrets: + R2_ACCESS_KEY_ID_2025: + required: false + R2_SECRET_ACCESS_KEY_2025: + required: false + R2_ENDPOINT_2025: + required: false + pull_request: + paths: + - ".github/workflows/reusable-build-iso-anaconda.yml" + - "iso_files/configure_iso_anaconda.sh" + +env: + IMAGE_REGISTRY: "ghcr.io/ublue-os" + IMAGE_NAME: "bluefin" + +jobs: + # Define which variants to build based on input + # This job ensures strict separation: each image_version builds ONLY its own ISOs + determine-matrix: + name: Determine Build Matrix + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: Set Matrix + id: set-matrix + run: | + # Define the matrix based on the input selection + # When called via workflow_call, the image_version input determines which ISOs to build + # Each variant builds ONLY its own specific ISOs - no cross-contamination + # NOTE: Check if inputs.image_version is provided (indicates workflow_call) + # rather than checking github.event_name, which may not be reliable + if [[ -n "${{ inputs.image_version }}" ]]; then + case "${{ inputs.image_version }}" in + "lts") + # LTS variant: builds ONLY LTS ISOs (4 total) + matrix='{"include":[ + {"platform":"amd64","flavor":"main","image_version":"lts"}, + {"platform":"arm64","flavor":"main","image_version":"lts"}, + {"platform":"amd64","flavor":"gdx","image_version":"lts"}, + {"platform":"arm64","flavor":"gdx","image_version":"lts"} + ]}' + ;; + "lts-hwe") + # LTS-HWE variant: builds ONLY LTS-HWE ISOs (2 total) + matrix='{"include":[ + {"platform":"amd64","flavor":"main","image_version":"lts-hwe"}, + {"platform":"arm64","flavor":"main","image_version":"lts-hwe"} + ]}' + ;; + "stable") + # Stable variant: builds ONLY Stable ISOs (2 total) + matrix='{"include":[ + {"platform":"amd64","flavor":"main","image_version":"stable"}, + {"platform":"amd64","flavor":"nvidia-open","image_version":"stable"} + ]}' + ;; + "all") + # "all" is reserved for testing - builds all variants + matrix='{"include":[ + {"platform":"amd64","flavor":"main","image_version":"stable"}, + {"platform":"amd64","flavor":"nvidia-open","image_version":"stable"}, + {"platform":"amd64","flavor":"main","image_version":"lts"}, + {"platform":"arm64","flavor":"main","image_version":"lts"}, + {"platform":"amd64","flavor":"gdx","image_version":"lts"}, + {"platform":"arm64","flavor":"gdx","image_version":"lts"}, + {"platform":"amd64","flavor":"main","image_version":"lts-hwe"}, + {"platform":"arm64","flavor":"main","image_version":"lts-hwe"} + ]}' + ;; + esac + else + # Default for when image_version is not provided (e.g., pull_request triggers) + # Build Stable only for faster PR validation + matrix='{"include":[ + {"platform":"amd64","flavor":"main","image_version":"stable"}, + {"platform":"amd64","flavor":"nvidia-open","image_version":"stable"} + ]}' + fi + + # Compact the JSON and output it + compact_matrix=$(echo "$matrix" | jq -c .) + echo "matrix=$compact_matrix" >> $GITHUB_OUTPUT + echo "Generated matrix:" + echo "$matrix" | jq . + + build: + name: Build ISOs + runs-on: ${{ matrix.platform == 'amd64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }} + needs: determine-matrix + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.determine-matrix.outputs.matrix) }} + permissions: + contents: read + packages: read + id-token: write + + steps: + - name: Install dependencies + if: matrix.platform == 'arm64' + run: | + set -x + sudo apt update -y + sudo apt install -y \ + podman + + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + submodules: recursive + + - name: Setup Just + uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4 + + - name: Check Just Syntax + shell: bash + run: | + just check + + - name: Format image ref + id: image_ref + env: + FLAVOR: ${{ matrix.flavor }} + run: | + set -eoux pipefail + # Standard variants use the Just recipe to determine image name + image_name=$(just image_name "bluefin" "${{ matrix.image_version}}" "${{ matrix.flavor}}") + image_ref="${IMAGE_REGISTRY}/${image_name}" + effective_tag="${{ inputs.image_tag || matrix.image_version }}" + artifact_format="$image_name-${effective_tag}-$(uname -m)" + KARGS="NONE" + echo "image_ref=$image_ref" >> "${GITHUB_OUTPUT}" + echo "artifact_format=$artifact_format" >> "${GITHUB_OUTPUT}" + echo "kargs=$KARGS" >> "${GITHUB_OUTPUT}" + + - name: Generate titanoboa-compatible file list + id: flatpak_list + run: | + set -eoux pipefail + FILE_LIST="$(mktemp)" + git clone https://github.com/projectbluefin/common.git common + find common -iname "*system-flatpaks.Brewfile" -exec cat '{}' ';' | grep -v '#' | grep -F -e "flatpak" | sed 's/flatpak //' | tr -d '"' | tee "${FILE_LIST}" + echo "file_list_path=${FILE_LIST}" | tee "${GITHUB_OUTPUT}" + + - name: Build ISO + id: build + uses: ublue-os/titanoboa@main + with: + image-ref: ${{ steps.image_ref.outputs.image_ref }}:${{ inputs.image_tag || matrix.image_version }} + flatpaks-list: ${{ steps.flatpak_list.outputs.file_list_path }} + hook-post-rootfs: ${{ (matrix.image_version == 'lts' || matrix.image_version == 'lts-hwe') && format('{0}/iso_files/configure_lts_iso_anaconda.sh', github.workspace) || format('{0}/iso_files/configure_iso_anaconda.sh', github.workspace) }} + kargs: ${{ steps.image_ref.outputs.kargs }} + builder-distro: ${{ (matrix.image_version == 'lts' || matrix.image_version == 'lts-hwe') && 'centos' || 'fedora' }} + + - name: Rename ISO + id: rename + env: + OUTPUT_PATH: ${{ steps.build.outputs.iso-dest }} + FLAVOR: ${{ matrix.flavor }} + OUTPUT_NAME: ${{ steps.image_ref.outputs.artifact_format }} + IMAGE_VERSION: ${{ matrix.image_version }} + run: | + set -x + mkdir -p output + OUTPUT_DIRECTORY="$(realpath output)" + mv "${OUTPUT_PATH}" "${OUTPUT_DIRECTORY}/${OUTPUT_NAME}.iso" + (cd "${OUTPUT_DIRECTORY}" && sha256sum "${OUTPUT_NAME}.iso" | tee "${OUTPUT_NAME}.iso-CHECKSUM") + echo "output_directory=$OUTPUT_DIRECTORY" >> "${GITHUB_OUTPUT}" + + - name: Generate Torrent File + env: + OUTPUT_DIRECTORY: ${{ steps.rename.outputs.output_directory }} + OUTPUT_NAME: ${{ steps.image_ref.outputs.artifact_format }} + IMAGE_VERSION: ${{ matrix.image_version }} + FLAVOR: ${{ matrix.flavor }} + PLATFORM: ${{ matrix.platform }} + run: | + set -eoux pipefail + + sudo apt-get install -y mktorrent + + BUILD_DATE=$(date -u +%Y-%m-%d) + + cd "${OUTPUT_DIRECTORY}" + mktorrent \ + -a udp://tracker.opentrackr.org:1337/announce \ + -a udp://open.tracker.cl:1337/announce \ + -a udp://open.demonii.com:1337/announce \ + -a udp://tracker.openbittorrent.com:6969/announce \ + -a udp://exodus.desync.com:6969/announce \ + -a udp://tracker.torrent.eu.org:451/announce \ + -a udp://tracker.moeking.me:6969/announce \ + -a https://tracker.gbitt.info:443/announce \ + -a https://tracker.tamersunion.org:443/announce \ + -a wss://tracker.btorrent.xyz \ + -a wss://tracker.openwebtorrent.com \ + -w "https://projectbluefin.dev/${OUTPUT_NAME}.iso" \ + -w "https://download.projectbluefin.io/${OUTPUT_NAME}.iso" \ + -c "Bluefin ${IMAGE_VERSION} ${FLAVOR} (${PLATFORM}) - ${BUILD_DATE}" \ + -o "${OUTPUT_NAME}.iso.torrent" \ + "${OUTPUT_NAME}.iso" + + sha256sum "${OUTPUT_NAME}.iso.torrent" | tee "${OUTPUT_NAME}.iso.torrent-CHECKSUM" + + - name: Upload Run Torrent Artifacts + if: inputs.upload_r2 && github.event_name != 'pull_request' + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 + with: + name: torrent-${{ github.run_id }}-${{ matrix.image_version }}-${{ matrix.flavor }}-${{ matrix.platform }} + if-no-files-found: error + path: | + ${{ steps.rename.outputs.output_directory }}/${{ steps.image_ref.outputs.artifact_format }}.iso.torrent + ${{ steps.rename.outputs.output_directory }}/${{ steps.image_ref.outputs.artifact_format }}.iso.torrent-CHECKSUM + + - name: Upload Run CHECKSUM Artifacts + if: inputs.upload_r2 && github.event_name != 'pull_request' + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 + with: + name: checksum-${{ github.run_id }}-${{ matrix.image_version }}-${{ matrix.flavor }}-${{ matrix.platform }} + if-no-files-found: error + path: | + ${{ steps.rename.outputs.output_directory }}/${{ steps.image_ref.outputs.artifact_format }}.iso-CHECKSUM + + - name: Upload to Job Artifacts + if: inputs.upload_artifacts + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 + with: + name: ${{ steps.image_ref.outputs.artifact_format }} + if-no-files-found: error + path: ${{ steps.rename.outputs.output_directory }} + + - name: Set up Homebrew + if: inputs.upload_r2 && github.event_name != 'pull_request' + uses: Homebrew/actions/setup-homebrew@8f52032f943acddc1c5670f437b94e031e78afc0 # master + + - name: Install rclone + if: inputs.upload_r2 && github.event_name != 'pull_request' + run: brew install rclone + + - name: Upload to CloudFlare + if: inputs.upload_r2 && github.event_name != 'pull_request' + shell: bash + env: + RCLONE_CONFIG_R2_TYPE: s3 + RCLONE_CONFIG_R2_PROVIDER: Cloudflare + RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID_2025 }} + RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY_2025 }} + RCLONE_CONFIG_R2_REGION: auto + RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.R2_ENDPOINT_2025 }} + SOURCE_DIR: ${{ steps.rename.outputs.output_directory }} + run: | + rclone copy --log-level INFO --checksum "${SOURCE_DIR}" R2:testing + + create-prerelease: + name: Create GitHub Prerelease + needs: build + # Run when builds complete (success or partial failure) — skip only on cancellation. + # This ensures a prerelease is published even when arm64 builds fail, so + # the amd64 ISOs that succeeded are still available on the releases page. + if: >- + inputs.upload_r2 && + github.event_name != 'pull_request' && + needs.build.result != 'cancelled' + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + + - name: Download Current Run Torrent Artifacts + env: + GH_TOKEN: ${{ github.token }} + run: | + set -eoux pipefail + mkdir -p torrents + gh run download "${{ github.run_id }}" \ + --pattern "torrent-${{ github.run_id }}-*" \ + --dir torrents + + echo "Downloaded torrent files:" + ls -lah torrents/ + + shopt -s globstar nullglob + torrent_files=(torrents/**/*.torrent) + if [ ${#torrent_files[@]} -eq 0 ]; then + echo "No torrent files found for current run" + exit 1 + fi + + - name: Download Current Run CHECKSUM Artifacts + env: + GH_TOKEN: ${{ github.token }} + run: | + set -eoux pipefail + mkdir -p checksums + gh run download "${{ github.run_id }}" \ + --pattern "checksum-${{ github.run_id }}-*" \ + --dir checksums + + echo "Downloaded checksum files:" + ls -lah checksums/ + + shopt -s globstar nullglob + checksum_files=(checksums/**/*.iso-CHECKSUM) + if [ ${#checksum_files[@]} -eq 0 ]; then + echo "No ISO checksum files found for current run" + exit 1 + fi + + - name: Determine Release Version + id: version + env: + GH_TOKEN: ${{ github.token }} + run: | + set -eoux pipefail + YEAR_MONTH=$(date -u +%y.%m) + + if gh release view "${YEAR_MONTH}" >/dev/null 2>&1; then + PATCH=1 + while gh release view "${YEAR_MONTH}.${PATCH}" >/dev/null 2>&1; do + PATCH=$((PATCH + 1)) + done + VERSION="${YEAR_MONTH}.${PATCH}" + else + VERSION="${YEAR_MONTH}" + fi + + echo "version=${VERSION}" >> $GITHUB_OUTPUT + + - name: Build Platform Status + id: build_status + env: + GH_TOKEN: ${{ github.token }} + run: | + set -eoux pipefail + STATUS_FILE="${RUNNER_TEMP}/build-status.md" + + # Fetch all jobs for this run and filter to the build matrix jobs + gh api "repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" \ + --paginate \ + --jq '.jobs[]' > /tmp/all-jobs.json + + { + printf '%s\n' '### Build Status' + printf '\n' + printf '%s\n' '| Platform | Variant | Flavor | Result |' + printf '%s\n' '|----------|---------|--------|--------|' + + # Extract build matrix jobs — name pattern: "Build ISOs (platform, flavor, variant)" + jq -r 'select(.name | test("Build ISOs \\(")) | + [ + (.name | capture("Build ISOs \\((?P[^,]+), (?P[^,]+), (?P[^)]+)\\)") | .platform, .variant, .flavor), + .conclusion + ] | @tsv' /tmp/all-jobs.json | sort | \ + while IFS=$'\t' read -r platform variant flavor conclusion; do + case "$conclusion" in + success) icon="✅" ;; + failure) icon="❌" ;; + skipped) icon="⏭️" ;; + *) icon="⏳" ;; + esac + printf '| %s | %s | %s | %s %s |\n' "$platform" "$variant" "$flavor" "$icon" "$conclusion" + done + + printf '\n' + # Warn if any builds failed so readers know some ISOs may be missing + if jq -e 'select(.name | test("Build ISOs \\(")) | select(.conclusion == "failure")' /tmp/all-jobs.json > /dev/null 2>&1; then + printf '%s\n' '> **Note**: Some platform builds failed. Only ISOs from successful builds are attached.' + printf '\n' + fi + } > "${STATUS_FILE}" + + echo "status_file=${STATUS_FILE}" >> "${GITHUB_OUTPUT}" + + - name: Create GitHub Prerelease + env: + GH_TOKEN: ${{ github.token }} + VERSION: ${{ steps.version.outputs.version }} + BUILD_STATUS_FILE: ${{ steps.build_status.outputs.status_file }} + run: | + set -eoux pipefail + + shopt -s globstar nullglob + TORRENT_FILES=(torrents/**/*.torrent torrents/**/*.torrent-CHECKSUM) + CHECKSUM_FILES=(checksums/**/*.iso-CHECKSUM) + + if [ ${#TORRENT_FILES[@]} -eq 0 ]; then + echo "No torrent assets available for prerelease" + exit 1 + fi + + if [ ${#CHECKSUM_FILES[@]} -eq 0 ]; then + echo "No ISO checksum assets available for prerelease" + exit 1 + fi + + NOTES_FILE="${RUNNER_TEMP}/prerelease-notes.md" + { + printf '%s\n' '## ⚠️ Prerelease - Testing Builds' + printf '\n' + printf '%s\n' 'These ISOs are automatically generated from successful builds and uploaded to the **testing** bucket.' + printf '\n' + printf '%s\n' '**Status**: Not yet promoted to production' + printf '%s\n' '**For**: Testing and validation only' + printf '\n' + printf '%s\n' 'Once validated, these builds can be promoted to production using the promotion workflow.' + printf '\n' + cat "${BUILD_STATUS_FILE}" + printf '%s\n' '### How to Download' + printf '\n' + printf '%s\n' '1. Download a `.torrent` file below' + printf '%s\n' '2. Open with a BitTorrent client (qBittorrent, Transmission, etc.)' + printf '%s\n' '3. Torrents include web seeds -- downloads work immediately' + printf '\n' + printf '%s\n' '### Direct Downloads' + printf '\n' + printf '%s\n' 'ISOs are also available at https://docs.projectbluefin.io/downloads-testing' + printf '\n' + printf '%s\n' '### Verify' + printf '\n' + printf '%s\n' 'Verify your ISO download using the `.iso-CHECKSUM` files attached to this release:' + printf '\n' + printf '%s\n' '```bash' + printf '%s\n' 'sha256sum -c .iso-CHECKSUM' + printf '%s\n' '```' + printf '\n' + printf '%s\n' 'Verify a downloaded torrent file using the `.torrent-CHECKSUM` files:' + printf '\n' + printf '%s\n' '```bash' + printf '%s\n' 'sha256sum -c .iso.torrent-CHECKSUM' + printf '%s\n' '```' + } > "${NOTES_FILE}" + + gh release create "${VERSION}" \ + --prerelease \ + --title "Bluefin ISOs ${VERSION} (Prerelease, run ${GITHUB_RUN_ID})" \ + --notes-file "${NOTES_FILE}" \ + "${TORRENT_FILES[@]}" \ + "${CHECKSUM_FILES[@]}" diff --git a/.github/workflows/test-luks-install.yml b/.github/workflows/test-luks-install.yml deleted file mode 100644 index 3c05574..0000000 --- a/.github/workflows/test-luks-install.yml +++ /dev/null @@ -1,245 +0,0 @@ -name: LUKS Install End-to-End Test - -on: - pull_request: - branches: - - main - workflow_dispatch: - schedule: - - cron: '0 4 * * 1' - -permissions: - issues: write - pull-requests: write - contents: write - actions: read - -jobs: - luks-e2e: - name: LUKS E2E (${{ matrix.target }}, ${{ matrix.installer_channel }}) - runs-on: ubuntu-24.04 - timeout-minutes: 90 - strategy: - fail-fast: false - matrix: - installer_channel: [dev, stable] - target: [bluefin, bluefin-lts] - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Ensure screenshots branch exists - continue-on-error: true - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - REPO: ${{ github.repository }} - run: | - if gh api "/repos/${REPO}/git/refs/heads/ci-screenshots" &>/dev/null; then - echo "ci-screenshots branch already exists" - else - echo "Creating ci-screenshots branch..." - DEFAULT=$(gh api "/repos/${REPO}" --jq '.default_branch') - SHA=$(gh api "/repos/${REPO}/git/refs/heads/${DEFAULT}" --jq '.object.sha') - gh api --method POST "/repos/${REPO}/git/refs" \ - -f "ref=refs/heads/ci-screenshots" \ - -f "sha=${SHA}" - echo "ci-screenshots branch created from ${DEFAULT}" - fi - - - name: Free disk space - uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be - with: - tool-cache: true - - - name: Install dependencies - run: | - sudo apt-get update -qq - sudo apt-get install -y \ - just podman buildah mtools xorriso \ - qemu-system-x86 ovmf socat sshpass \ - imagemagick -qq - - - name: Log in to GHCR - run: | - echo "${{ secrets.GITHUB_TOKEN }}" | \ - sudo podman login ghcr.io -u ${{ github.actor }} --password-stdin - - - name: Configure podman storage (intelligent driver selection) - run: bash .github/scripts/configure_podman_storage.sh - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.23' - - - name: Clone patched fisherman - run: | - git clone https://github.com/projectbluefin/fisherman.git \ - --branch fix/overlay-driver-for-ostree-bootc-install \ - --depth 1 \ - /tmp/fisherman - - - name: Build debug ISO - id: build - run: | - START=$(date +%s) - sudo mkdir -p /var/iso-build - sudo $(command -v just) debug=1 installer_channel=${{ matrix.installer_channel }} output_dir=/var/iso-build iso-sd-boot ${{ matrix.target }} - mkdir -p output - sudo cp /var/iso-build/*.iso output/ 2>/dev/null || true - sudo chown -R "$USER:$(id -gn)" output/ - echo "duration=$(( $(date +%s) - START ))" >> "$GITHUB_OUTPUT" - ISO=$(ls output/*.iso 2>/dev/null | head -1) - echo "iso_size=$(stat -c%s "$ISO" 2>/dev/null || echo 0)" >> "$GITHUB_OUTPUT" - - - name: Fix output directory ownership - run: sudo chown -R "$USER:$(id -gn)" output/ 2>/dev/null || true - - - name: Run LUKS end-to-end test - id: luks_test - env: - FISHER_REPO: /tmp/fisherman/fisherman - run: | - START=$(date +%s) - just luks-test-qemu ${{ matrix.target }} - echo "duration=$(( $(date +%s) - START ))" >> "$GITHUB_OUTPUT" - continue-on-error: true - - - name: Convert and publish screenshots - if: always() - continue-on-error: true - id: screenshots - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - REPO: ${{ github.repository }} - RUN_ID: ${{ github.run_id }} - run: | - sudo chmod a+r /tmp/luks-screenshot-*.ppm /tmp/luks-unlock-snap.ppm 2>/dev/null || true - - commit_png() { - local src_ppm="$1" label="$2" out_var="$3" - local png="/tmp/${label}.png" - - convert "$src_ppm" "$png" 2>/dev/null || return 0 - [[ -f "$png" ]] || return 0 - - local path_in_repo="luks-e2e/${RUN_ID}/${{ matrix.target }}/${{ matrix.installer_channel }}/${label}.png" - local existing_sha - existing_sha=$(gh api "/repos/${REPO}/contents/${path_in_repo}?ref=ci-screenshots" \ - --jq '.sha' 2>/dev/null || echo "") - - local b64_file - b64_file=$(mktemp) - base64 -w0 "$png" > "$b64_file" - - jq -n \ - --arg msg "LUKS E2E screenshot: ${label} (run ${RUN_ID})" \ - --rawfile content "$b64_file" \ - --arg branch "ci-screenshots" \ - --arg sha "$existing_sha" \ - 'if $sha != "" then - {message: $msg, content: ($content | rtrimstr("\n")), branch: $branch, sha: $sha} - else - {message: $msg, content: ($content | rtrimstr("\n")), branch: $branch} - end' | \ - gh api --method PUT "/repos/${REPO}/contents/${path_in_repo}" --input - > /dev/null - - rm "$b64_file" - local url="https://raw.githubusercontent.com/${REPO}/ci-screenshots/${path_in_repo}" - echo "${out_var}=${url}" >> "$GITHUB_OUTPUT" - echo "Published ${label} → ${url}" - } - - commit_png /tmp/luks-screenshot-live.ppm "live-boot" "live_url" - commit_png /tmp/luks-screenshot-plymouth.ppm "plymouth" "plymouth_url" - commit_png /tmp/luks-screenshot-final.ppm "final-boot" "final_url" - - - name: Post PR comment - if: always() && github.event_name == 'pull_request' - continue-on-error: true - uses: actions/github-script@v7 - env: - LIVE_URL: ${{ steps.screenshots.outputs.live_url }} - PLYMOUTH_URL: ${{ steps.screenshots.outputs.plymouth_url }} - FINAL_URL: ${{ steps.screenshots.outputs.final_url }} - BUILD_S: ${{ steps.build.outputs.duration }} - LUKS_S: ${{ steps.luks_test.outputs.duration }} - ISO_BYTES: ${{ steps.build.outputs.iso_size }} - TEST_RESULT: ${{ steps.luks_test.outcome }} - INSTALLER_CHANNEL: ${{ matrix.installer_channel }} - TARGET: ${{ matrix.target }} - with: - script: | - const result = process.env.TEST_RESULT || 'unknown'; - const channel = process.env.INSTALLER_CHANNEL || 'unknown'; - const target = process.env.TARGET || 'unknown'; - const pass = result === 'success'; - const icon = pass ? '✅' : '❌'; - const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; - - const fmtDur = s => s ? `${Math.floor(s/60)}m ${s%60}s` : 'N/A'; - const fmtMiB = b => b ? `${(b/1024/1024).toFixed(0)} MiB` : 'N/A'; - - const img = (url, alt) => url ? `**${alt}**\n![${alt}](${url})\n` : ''; - - const body = [ - `## ${icon} LUKS End-to-End Test (${target}, ${channel}) — ${pass ? 'PASSED' : 'FAILED'}`, - '', - '| Step | Details |', - '|------|---------|', - `| ISO build | ${fmtMiB(process.env.ISO_BYTES)} · ${fmtDur(process.env.BUILD_S)} |`, - `| LUKS E2E | ${fmtDur(process.env.LUKS_S)} |`, - `| Result | ${icon} ${result} |`, - '', - img(process.env.LIVE_URL, 'Live boot'), - img(process.env.PLYMOUTH_URL, 'Plymouth passphrase prompt'), - img(process.env.FINAL_URL, 'Installed system (post-LUKS unlock)'), - `[Workflow run](${runUrl})`, - ].join('\n'); - - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.payload.pull_request.number, - body, - }); - - - name: Write job summary - if: always() - run: | - RESULT="${{ steps.luks_test.outcome }}" - CHANNEL="${{ matrix.installer_channel }}" - TARGET="${{ matrix.target }}" - ICON=$( [ "$RESULT" = "success" ] && echo "✅" || echo "❌" ) - { - echo "## ${ICON} LUKS End-to-End Test (${TARGET}, ${CHANNEL}) — ${RESULT}" - echo "" - echo "| Step | Value |" - echo "|------|-------|" - echo "| ISO size | $(numfmt --to=iec ${{ steps.build.outputs.iso_size }} 2>/dev/null || echo N/A) |" - echo "| Build time | ${{ steps.build.outputs.duration }}s |" - echo "| LUKS test time | ${{ steps.luks_test.outputs.duration }}s |" - } >> "$GITHUB_STEP_SUMMARY" - - - name: Upload serial logs - if: always() - run: | - sudo chmod a+r /tmp/bluefin-qemu-*.log 2>/dev/null || true - - - name: Upload serial logs artifact - if: always() - uses: actions/upload-artifact@v4 - with: - name: luks-e2e-serial-logs-${{ matrix.target }}-${{ matrix.installer_channel }} - path: | - /tmp/bluefin-qemu-live-serial.log - /tmp/bluefin-qemu-installed-serial.log - if-no-files-found: warn - retention-days: 14 - - - name: Fail if LUKS test failed - if: steps.luks_test.outcome == 'failure' - run: | - echo "::error::LUKS end-to-end test failed — see serial logs and screenshots above" - exit 1 diff --git a/.gitignore b/.gitignore index 5add728..147cd2b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,11 +8,9 @@ previous.manifest.json changelog.md output.env -output/ -*.sfs -*.tar # Generated files +iso_files/bluefin.repo # Temporary files *.tmp diff --git a/AGENTS.md b/AGENTS.md index df8a3bd..4f7a507 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,155 +1,302 @@ # Bluefin ISO Builder — Agent Instructions -This repo builds bootable Bluefin and Bluefin LTS live ISOs using the -[bootc-installer](https://github.com/projectbluefin/bootc-installer) Flatpak -and the ostree backend. +This repo builds bootable Bluefin installation ISOs using +[Titanoboa](https://github.com/ublue-os/titanoboa) and the Anaconda installer. +It pulls pre-built container images from `ghcr.io/ublue-os`, wraps them in ISOs, +generates torrents, and manages a testing → production release pipeline via +CloudFlare R2. -**Working model**: maintainers commit directly to `projectbluefin/iso`. +**Working model**: maintainers commit directly to `projectbluefin/iso` — no fork +workflow. This repo is designed to be forked by other projects; see +"Adapting for Downstream Forks" below. --- -## Quick reference +## ⚠️ LTS ISO Status: DISABLED — DO NOT TOUCH PRODUCTION -```bash -just iso-sd-boot bluefin # full build -just debug=1 installer_channel=dev iso-sd-boot bluefin # debug build with SSH -just boot-iso-serial bluefin # boot + validate via QEMU serial -just e2e bluefin # build ISO + LUKS end-to-end test -``` +**LTS (non-HWE) ISOs are currently broken.** Anaconda does not work correctly on +the LTS base image. The `build-iso-lts.yml` workflow is intentionally left without +a schedule so it does not fire automatically. + +**Production impact**: There are working LTS ISOs in the production R2 bucket from +before this breakage. They must not be overwritten. + +### What agents and maintainers MUST NOT do: +- Do NOT re-enable the `build-iso-lts.yml` schedule +- Do NOT run `promote-iso.yml` with `variant: lts` or `variant: all` — both match + `*-lts-*.iso*` files and would overwrite production with broken builds +- Do NOT trigger `build-iso-all.yml` expecting it to promote LTS to production +- Do NOT remove or alter the inline warning comments in `build-iso-lts.yml` + +### What is safe: +- Building LTS ISOs with `upload_r2: false` (artifacts only) to test if the + breakage has been resolved +- Running `promote-iso.yml` with `variant: stable` only + +### When LTS is fixed: +1. Verify the build succeeds end-to-end with `upload_r2: false` +2. Inspect the ISO manually before any promotion +3. Add back the `schedule:` block to `build-iso-lts.yml` +4. Remove this warning from AGENTS.md and README.md --- -## Repository structure +## Repository Structure ``` -bluefin/payload_ref → ghcr.io/ublue-os/bluefin:stable -bluefin-lts/payload_ref → ghcr.io/ublue-os/bluefin-lts:latest -Containerfile → 3-stage build (bluefin-ref, initramfs-builder, final) -Containerfile.builder → Debian ISO toolchain (xorriso, mksquashfs, etc.) -src/ - build-iso.sh → ISO assembly (BLUEFIN_LIVE label, El Torito EFI) - configure-live.sh → Live env setup (user, GDM, installer autostart, polkit) - install-flatpaks.sh → Flatpak pre-installation from Flathub - flatpaks → List of Flatpak apps to pre-install - luks-unlock.py → Automated LUKS passphrase injection via PTY - show-screenshot.sh → Terminal screenshot display (Kitty/iTerm2) - dracut/95bluefin-isofile/ → Ventoy/file-backed ISO boot support - etc/bootc-installer/ - images.json → Catalog lock: Bluefin, grub2, btrfs, ostree - recipe.json → Branding, tour slides, install steps - icons/hicolor/*/apps/ → Bluefin icon (PNG, all sizes) - images/bluefin.png → Installer tour image -justfile → Build + test automation .github/workflows/ - build-iso.yml → Daily ISO builds (bluefin + bluefin-lts matrix) - test-luks-install.yml → Weekly LUKS E2E test + build-iso-stable.yml # Caller: 2 Stable ISOs (amd64 × main, nvidia-open) + build-iso-lts.yml # Caller: 4 LTS ISOs — DISABLED (see above) + build-iso-lts-hwe.yml # Caller: 2 LTS-HWE ISOs (amd64/arm64 × main) + build-iso-lts-hwe-testing.yml # Caller: 2 LTS-HWE testing ISOs — weekly schedule (ONLY authorized testing workflow) + build-iso-all.yml # Orchestrator: calls stable + lts-hwe in parallel + reusable-build-iso-anaconda.yml # Core build logic (matrix, build, prerelease) + promote-iso.yml # Promotes testing → production R2 + GitHub release + pull-request.yml # PR check: builds LTS + Stable, no upload + validate-renovate.yml # Validates Renovate config on PRs/pushes +iso_files/ + configure_iso_anaconda.sh # Hook for Stable ISOs + configure_lts_iso_anaconda.sh # Hook for LTS and LTS-HWE ISOs +hack/ + local-iso-build.sh # Local development ISO build script +just/ + bluefin-apps.just # Application management recipes + bluefin-system.just # System management recipes +Justfile # Build automation (local-iso-bluefin, local-iso-lts, check, fix) ``` --- -## Architecture +## Build Pipeline -### Two-container build pipeline +``` +Caller workflows (stable, lts-hwe) + │ + ▼ +reusable-build-iso-anaconda.yml + ├─ determine-matrix job + ├─ build job (parallel matrix) + │ ├─ Fetch flatpaks from projectbluefin/common + │ ├─ Run Titanoboa + │ ├─ Generate torrent files + │ └─ Upload to R2:testing + └─ create-prerelease job + └─ Creates GitHub prerelease with torrent files + │ + ▼ (manual: promote-iso.yml) +R2_PROD:bluefin + GitHub Release (full, marked latest) +``` -1. **`-installer`** — built by `Containerfile` (3 stages): - - Stage 1 `bluefin-ref`: original Bluefin image (kernel modules) - - Stage 2 `initramfs-builder`: Debian; builds dmsquash-live initramfs against Bluefin's kernel - - Stage 3 (final): Bluefin + systemd-boot + rebuilt initramfs + Flatpaks + live-env config +Promotion is always manual and always has a dry-run mode (enabled by default). -2. **`-iso-builder`** — built by `Containerfile.builder` (Debian with xorriso, - mksquashfs, dosfstools, mtools). Runs `build-iso.sh`. +--- -### ISO layout +## Workflow Architecture -``` -EFI/efi.img — FAT32 ESP: systemd-boot + kernel + initramfs -EFI/BOOT/BOOTX64.EFI — EFI fallback path -LiveOS/squashfs.img — squashfs of the full live rootfs (+ embedded OCI) -boot/grub/loopback.cfg — Ventoy/GRUB loopback metadata -images/pxeboot/* — kernel/initramfs copies for loopback ISO boot -``` +### Caller Workflows + +All callers share the same structure: +- Triggers: `workflow_dispatch` + optional `schedule` +- Calls `reusable-build-iso-anaconda.yml` via `uses:` +- `secrets: inherit` — no `permissions:` block in caller +- Inputs: `image_version`, `image_tag`, `upload_artifacts`, `upload_r2` + +**`build-iso-lts.yml`** has an `image_tag` choice input: `lts` or `lts-testing`. + +**`build-iso-lts-hwe.yml`** has a single `image_tag` choice: `lts-hwe` (production +only). The `lts-hwe-testing` option was removed from this workflow — use +`build-iso-lts-hwe-testing.yml` for testing tags. + +**`build-iso-lts-hwe-testing.yml`** is the ONLY authorized workflow for +`lts-hwe-testing` ISOs. It hardcodes `image_tag: lts-hwe-testing` and runs on a +weekly schedule (every Monday at 06:17 UTC). Do not use testing tags in any other +workflow. -### Live boot flow +**Stable** hardcodes `image_tag: stable`. No testing tag variant exists for Stable. +**`build-iso-all.yml`** calls the reusable workflow directly (not the caller +workflows), hardcoding the correct tag for each variant. The monthly cron +`"0 3 1 * *"` is valid 5-field syntax and fires correctly. Known latent bug: +- The LTS job references `inputs.image_tag` which is not a defined input; it always + resolves to `'lts'` (correct behavior, but latent bug). + +### Reusable Workflow + +Three jobs: + +**1. `determine-matrix`** — sets the build matrix from `image_version`: + +| `image_version` | ISOs | Platforms | Flavors | +|-----------------|------|---------------|-------------------| +| `stable` | 2 | amd64 | main, nvidia-open | +| `lts` | 4 | amd64, arm64 | main, gdx | +| `lts-hwe` | 2 | amd64, arm64 | main | +| `all` | 8 | all above | all above | + +**2. `build`** — parallel matrix. Runner, hook script, and builder distro by variant: + +| Variant | Runner | `builder-distro` | Hook script | +|---------------|---------------------|------------------|----------------------------------| +| stable | ubuntu-24.04 | fedora | configure_iso_anaconda.sh | +| lts, lts-hwe | ubuntu-24.04[-arm] | centos | configure_lts_iso_anaconda.sh | + +**3. `create-prerelease`** — runs after all build jobs succeed. Downloads torrent +files from R2:testing and creates a versioned GitHub prerelease (`YY.MM[.N]`). + +### Image Reference + +```yaml +env: + IMAGE_REGISTRY: "ghcr.io/ublue-os" + IMAGE_NAME: "bluefin" ``` -UEFI → El Torito → FAT ESP → systemd-boot → kernel (initramfs: dmsquash-live) -dmsquash-live: scans for CDLABEL=BLUEFIN_LIVE → mounts ISO → squashfs → overlayfs + +Image names are resolved by the `just image_name` recipe. Full ref at build time: +`${IMAGE_REGISTRY}/${image_name}:${image_tag}`. + +### Flatpak Sourcing + +Flatpaks are **not stored in this repo**. The build job clones +`projectbluefin/common` at runtime and parses all `*system-flatpaks.Brewfile` files: + +```bash +git clone https://github.com/projectbluefin/common.git common +find common -iname "*system-flatpaks.Brewfile" -exec cat '{}' ';' \ + | grep -v '#' | grep -F -e "flatpak" | sed 's/flatpak //' | tr -d '"' ``` -### Key differences from dakota-iso +--- + +## Promote Workflow + +`promote-iso.yml` is manual-only (`workflow_dispatch`). Uses `rclone sync` to copy +from the testing bucket to the production bucket (`R2_PROD:bluefin`), then converts +the GitHub prerelease to a full release. + +Inputs: +- `variant`: `stable`, `lts`, or `lts-hwe` +- `release_tag`: specific tag to promote, or auto-detects latest prerelease +- `dry_run`: default `true` — always preview before running live + +Filter patterns per variant: -| Aspect | dakota-iso | bluefin-bootc-iso | -|--------|-----------|-------------------| -| Base image | `ghcr.io/projectbluefin/dakota:latest` | `ghcr.io/ublue-os/bluefin:stable` | -| Filesystem backend | composefs | ostree | -| Installed bootloader | systemd-boot | grub2 | -| Live ISO bootloader | systemd-boot (from image) | systemd-boot (installed via rpm-ostree) | -| User creation | skipped (GNOME Initial Setup) | required (`needs_user_creation: true`) | -| Containerfile path | `dakota/Containerfile` | `Containerfile` (repo root) | -| src path | `dakota/src/` | `src/` | -| ISO label | `DAKOTA_LIVE` | `BLUEFIN_LIVE` | -| Live ready marker | `DAKOTA_LIVE_READY` | `BLUEFIN_LIVE_READY` | -| Build targets | `dakota`, `dakota-nvidia` | `bluefin`, `bluefin-lts` | -| VM name | `dakota-debug` | `bluefin-debug` | +| Variant | Files matched | +|-----------|----------------------------------------------------------------------------| +| `stable` | `*-stable-*.iso*` | +| `lts` | `*-lts-*.iso*`, `*-lts-hwe-*.iso*`, `*-dx-lts-*.iso*` | +| `lts-hwe` | `*-lts-hwe-*.iso*` (excludes `*-lts-hwe-testing-*`) | -### Installer configuration +> ⚠️ Do NOT run with `variant: lts` or `variant: all` while LTS builds are broken. +> Both patterns match LTS filenames and will overwrite production ISOs. -- **`images.json`**: `bootloader: "grub2"`, `filesystem: "btrfs"`, no `composefs` key, `needs_user_creation: true` -- **`recipe.json`**: `composeFsBackend: false`, `bootloader: "grub2"`, `distro_name: "Bluefin"`, includes user creation step -- **LUKS recipe** (in justfile): `"composeFsBackend": false, "bootloader": "grub2"` +--- + +## Required Secrets -### VFS containers-storage +| Secret | Used by | +|-----------------------------|--------------------------------------| +| `R2_ACCESS_KEY_ID_2025` | Build workflows (testing bucket) | +| `R2_SECRET_ACCESS_KEY_2025` | Build workflows (testing bucket) | +| `R2_ENDPOINT_2025` | Build workflows (testing bucket) | +| `R2_ACCESS_KEY_PRODUCTION` | promote-iso.yml (production bucket) | +| `R2_SECRET_PRODUCTION` | promote-iso.yml (production bucket) | +| `R2_ENDPOINT_PRODUCTION` | promote-iso.yml (production bucket) | -The squashfs embeds the Bluefin OCI image as VFS containers-storage for offline installation. -`/etc/containers/storage.conf` is set to `driver = "vfs"` by `configure-live.sh`. +R2 secrets are declared `required: false` in the reusable workflow — builds succeed +without them; only R2 upload fails. --- -## CI workflows +## Local Development -### `build-iso.yml` +```bash +# Local ISO build (wraps hack/local-iso-build.sh) +just local-iso-bluefin # Fedora-based Stable ISO +just local-iso-lts # LTS ISO (requires centos builder) -- **Trigger**: push to main (matching paths), daily 03:00 UTC, workflow_dispatch -- **Matrix**: `[bluefin, bluefin-lts]` (fail-fast: false) -- **Build path**: `/var/iso-build` -- **Upload**: ISOs to Cloudflare R2 `testing` bucket as `-live-latest.iso` + dated -- **Smoke test**: boots ISO in QEMU, waits for `BLUEFIN_LIVE_READY` on serial +# Validation (always run before committing) +pre-commit run --all-files +just check -### `test-luks-install.yml` +# Fix formatting +just fix -- **Trigger**: PRs to main, weekly Monday 04:00 UTC, workflow_dispatch -- **Matrix**: `installer_channel: [dev, stable]` -- **Flow**: build debug ISO → boot live QEMU → SSH fisherman LUKS install → reboot → unlock → verify boot -- **Screenshots**: saved to `ci-screenshots` branch, posted to PR comments +# Shell script syntax check +bash -n iso_files/configure_iso_anaconda.sh +``` --- -## LUKS E2E test +## Standard vs LTS Differences -```bash -# Libvirt (interactive): -just debug=1 installer_channel=dev iso-sd-boot bluefin -just debug=1 boot-libvirt-debug bluefin -just luks-install bluefin -just luks-unlock bluefin - -# QEMU (automated, CI-equivalent): -just debug=1 installer_channel=dev e2e bluefin +| Aspect | Stable | LTS / LTS-HWE | +|----------------|------------------------------|-----------------------------------------| +| Base OS | Fedora | CentOS Stream | +| Builder distro | `fedora` | `centos` | +| Hook script | `configure_iso_anaconda.sh` | `configure_lts_iso_anaconda.sh` | +| Filesystem | BTRFS | XFS | +| Secure boot | Enabled | Disabled (commented out in hook) | +| EFI dir | `fedora` | `centos` | +| Testing tag | None | `-testing` suffix (`lts-testing`, etc.) | + +--- + +## Adapting for Downstream Forks + +To build ISOs for a different image (e.g., `ghcr.io/myorg/myimage`): + +### 1. Image registry and name + +In `reusable-build-iso-anaconda.yml`, update the top-level env: + +```yaml +env: + IMAGE_REGISTRY: "ghcr.io/myorg" + IMAGE_NAME: "myimage" ``` +### 2. Flatpak source + +In the "Generate titanoboa-compatible file list" step, change the git clone URL to +your own config repo, or replace the step entirely with a local file read. + +### 3. Variants and matrix + +Edit the `determine-matrix` case statement. Each case outputs a JSON array of +`{platform, flavor, image_version}` objects. Add, remove, or rename variants to +match what your image actually builds and publishes. + +### 4. Hook scripts + +Copy and modify `iso_files/configure_iso_anaconda.sh` for your image. Update the +`hook-post-rootfs` value in the `Build ISO` step of the reusable workflow. + +### 5. Storage buckets + +The bucket names `testing` (build upload) and `bluefin` (production) are hardcoded +in the workflows. Update both `reusable-build-iso-anaconda.yml` and +`promote-iso.yml` to match your bucket names. + +### 6. Promotion filters + +Update the `determine filter pattern` step in `promote-iso.yml` so the `stable` and +`lts` patterns match your ISO naming scheme. + --- -## Variants +## Commit Conventions -| Variant | `payload_ref` | ISO output | -|---|---|---| -| `bluefin` | `ghcr.io/ublue-os/bluefin:stable` | `bluefin-live.iso` | -| `bluefin-lts` | `ghcr.io/ublue-os/bluefin-lts:latest` | `bluefin-lts-live.iso` | +Format: `(): ` -To add a new variant: +Types: `feat`, `fix`, `docs`, `ci`, `chore`, `refactor` -```bash -mkdir my-variant -echo 'ghcr.io/ublue-os/my-image:latest' > my-variant/payload_ref -just iso-sd-boot my-variant +Examples: +- `ci(workflow): fix LTS-HWE default image tag` +- `fix(iso): correct secure boot enrollment path` +- `docs(agents): update flatpak sourcing documentation` + +AI attribution footer required on every commit: + +``` +Assisted-by: via ``` diff --git a/Containerfile b/Containerfile deleted file mode 100644 index 9c16be8..0000000 --- a/Containerfile +++ /dev/null @@ -1,104 +0,0 @@ -# Bluefin live ISO installer image -# -# Build with: -# just container bluefin -# -# Three-stage build: -# 1. bluefin-ref — original Bluefin image (provides kernel modules) -# 2. initramfs-builder — Debian: builds a dmsquash-live initramfs against -# Bluefin's kernel modules in its native glibc environment -# 3. final — Bluefin: receives the rebuilt initramfs + live-env setup -# -# Bluefin is Fedora/ostree-based using GRUB2 for the installed system. -# The live ISO uses systemd-boot for ESP boot (installed in the final stage). -# The installed system's bootloader is controlled by fisherman/bootc-installer -# via images.json (grub2). -# -# The initramfs is built in a separate Debian stage so no cross-distro binary -# grafting is needed; only the initramfs.img output crosses the stage boundary. - -# Base image — override to build bluefin-lts or other variants. -# Example: podman build --build-arg BASE_IMAGE=ghcr.io/ublue-os/bluefin-lts:latest ... -ARG BASE_IMAGE=ghcr.io/ublue-os/bluefin:stable - -# ── Stage 1: Bluefin reference (kernel modules source) ─────────────────────── -FROM ${BASE_IMAGE} AS bluefin-ref - -# ── Stage 2: Debian — builds the dmsquash-live initramfs ───────────────────── -# Dracut runs natively in Debian against Bluefin's kernel modules. -# Only /tmp/initramfs.img crosses into the final stage. -FROM debian:sid AS initramfs-builder - -RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - dracut \ - dmsetup \ - && rm -rf /var/lib/apt/lists/* - -# Import Bluefin's kernel module tree so dracut targets the correct kernel -COPY --from=bluefin-ref /usr/lib/modules /usr/lib/modules - -# Add Bluefin-specific initramfs support for Ventoy/file-backed ISO boot. -COPY src/dracut/95bluefin-isofile /usr/lib/dracut/modules.d/95bluefin-isofile - -RUN set -ex; \ - kernel=$(ls /usr/lib/modules | sort -V | tail -1); \ - echo "Building dmsquash-live initramfs for kernel ${kernel}"; \ - # Check which optional drivers are available (el10 kernel may lack ntfs3). - NTFS3=""; test -f "/usr/lib/modules/${kernel}/kernel/fs/ntfs3/ntfs3.ko" && NTFS3="ntfs3"; \ - DRACUT_NO_XATTR=1 dracut -v --force --zstd --reproducible --no-hostonly \ - --add "dmsquash-live bluefin-isofile" \ - --add-drivers "squashfs overlay loop iso9660 sr_mod cdrom sd_mod usb-storage xhci-pci exfat vfat fat ${NTFS3} ext4" \ - /tmp/initramfs.img "${kernel}"; \ - ls -lh /tmp/initramfs.img - -# ── Stage 3: Final Bluefin live image ──────────────────────────────────────── -ARG BASE_IMAGE -FROM ${BASE_IMAGE} - -# Set to "dev" to pull the tuna-installer dev build (continuous-dev release) -# instead of the stable continuous build. -ARG INSTALLER_CHANNEL=stable -ENV INSTALLER_CHANNEL=${INSTALLER_CHANNEL} - -# DEBUG=1 builds a debug ISO (installer only, SSH enabled). -ARG DEBUG=0 -ENV DEBUG=${DEBUG} - -# Filesystem for the installed system: btrfs (Bluefin stable) or xfs (Bluefin LTS). -# Override via: --build-arg FILESYSTEM=xfs -ARG FILESYSTEM=btrfs - -# Install systemd-boot for the live ISO ESP (Bluefin ships GRUB2 for the -# installed system, but the live ISO needs a UEFI bootloader on the ESP image). -# systemd-boot-unsigned is the Fedora package; use rpm-ostree to layer it. -# fuse-overlayfs provides overlay-on-overlay for kernels without native support -# (e.g. CentOS Stream 10 in bluefin-lts — containers/storage needs it on -# overlayfs-based rootfs). -RUN rpm-ostree install --apply-live --allow-inactive systemd-boot-unsigned fuse-overlayfs \ - && rm -rf /var/cache/rpm-ostree - -# Replace the OCI-mode initramfs with the dmsquash-live initramfs from stage 2 -COPY --from=initramfs-builder /tmp/initramfs.img /tmp/initramfs.img -RUN kernel=$(ls /usr/lib/modules | sort -V | tail -1) && \ - mv /tmp/initramfs.img "/usr/lib/modules/${kernel}/initramfs.img" && \ - echo "Replaced initramfs for kernel ${kernel}" - -# ── Flatpak install layer ───────────────────────────────────────────────────── -COPY src/flatpaks /tmp/flatpaks-list -RUN --mount=type=bind,source=src,target=/src \ - --mount=type=cache,target=/var/cache/flatpak-dl,id=bluefin-flatpak \ - /src/install-flatpaks.sh - -# ── Live-environment configure layer ───────────────────────────────────────── -COPY src/ /tmp/src/ -RUN chmod +x /tmp/src/configure-live.sh && /tmp/src/configure-live.sh - -ARG BASE_IMAGE -ARG FILESYSTEM -# Patch installer configs to reference the actual base image + filesystem for this variant. -RUN sed -i "s|ghcr.io/ublue-os/bluefin:stable|${BASE_IMAGE}|g" \ - /etc/bootc-installer/images.json \ - /etc/bootc-installer/recipe.json && \ - sed -i 's|"filesystem": "btrfs"|"filesystem": "${FILESYSTEM}"|g' \ - /etc/bootc-installer/images.json diff --git a/Containerfile.builder b/Containerfile.builder deleted file mode 100644 index 161d701..0000000 --- a/Containerfile.builder +++ /dev/null @@ -1,28 +0,0 @@ -# ISO assembly builder image (Debian-based) -# -# Used by: just iso-sd-boot -# -# This container has all the tools needed to assemble a UEFI live ISO: -# xorriso — ISO-9660 creation with El Torito EFI boot entry -# mksquashfs — compress the live rootfs into a squashfs image -# mkfs.fat — create the FAT ESP image for systemd-boot -# mtools — populate the FAT image without requiring a loop mount -# implantisomd5 — embed MD5 checksum for ISO integrity verification -# -# All tools run in their native Debian environment; no cross-distro binary -# grafting required. -FROM debian:sid - -RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - xorriso \ - isomd5sum \ - squashfs-tools \ - dosfstools \ - mtools \ - && rm -rf /var/lib/apt/lists/* - -COPY src/build-iso.sh /build-iso.sh -RUN chmod +x /build-iso.sh - -ENTRYPOINT ["/build-iso.sh"] diff --git a/HANDOFF.md b/HANDOFF.md deleted file mode 100644 index 88ce0cb..0000000 --- a/HANDOFF.md +++ /dev/null @@ -1,172 +0,0 @@ -# Bluefin bootc-ISO — Handoff - -This document captures the current state of the Bluefin bootc-ISO effort for -another agent or maintainer to pick up, including the architectural differences -from dakota-iso (which works) and the remaining blocker. - -## What this branch does - -PR #61 (`feat/bluefin-bootc-iso`) adds a full ISO builder for Bluefin and -Bluefin LTS using the bootc-installer Flatpak (fisherman) with an ostree -backend. The ISO is live-bootable, supports LUKS-encrypted installation via -fisherman, and is built in CI via GitHub Actions. - -Dakota-ISO exists as a working reference: same toolchain (fisherman, -bootc-installer), same VM-based LUKS E2E test, same QEMU/KVM harness. -The differences are the root cause of the remaining issues. - -## Architectural comparison: bluefin-iso vs dakota-iso - -### 1. Image backend (UNCHANGEABLE) - -| Aspect | Dakota-ISO | Bluefin-ISO | -|--------|------------|-------------| -| Base image | `ghcr.io/projectbluefin/dakota:latest` | `ghcr.io/ublue-os/bluefin:stable` / `...bluefin:lts` | -| Backend | composefs-native | ostree | -| Installed bootloader | systemd-boot | GRUB2 | -| `images.json` `composefs` | `true` | absent | -| `images.json` `needs_user_creation` | `false` | `true` | -| Filesystem | btrfs | btrfs (bluefin), xfs (bluefin-lts) | - -Bluefin IS ostree — this cannot change. All the memory and deployment -differences flow from this. - -### 2. Install flow (CURRENT / TRIED) - -Dakota uses `"image": "containers-storage:..."` in the fisherman recipe with -`composeFsBackend: true`. Fisherman's composefs path: -1. Exports the image to an OCI layout via skopeo -2. Runs `podman --root --storage-driver overlay --tmpfs /var/tmp ... oci: bootc install --composefs-backend ...` -3. Works reliably at 8 GB VM RAM - -Bluefin has tried several approaches: - -| Approach | Result | Why | -|----------|--------|-----| -| `containers-storage:` recipe + VFS (original) | OOM | VFS copies every layer | -| Registry pull + VFS (be4f757) | OOM | Same VFS issue | -| Registry + overlay redirect + OCI layout (1b70f55..266b4fb) | OOM at podman run | Podman container setup ate 14.9 GB virtual | -| Empty image → bootcDirect (58c8ed2) | `bootc install` fails | Needs `--source-imgref` | -| bootcDirect + `--source-imgref docker://` (625ab3b) | untested | Would require network pull (offline VM) | -| bootcDirect + `--source-imgref containers-storage:` (24d15db) | **PENDING CI** | Most promising — no podman, no network | - -### 3. Justfile recipe differences (luks-install-qemu) - -```json -// Dakota recipe (WORKS): -{"image": "containers-storage:ghcr.io/projectbluefin/dakota:latest", - "composeFsBackend": true, - "bootloader": "systemd"} - -// Bluefin recipe (CURRENT — awaiting CI): -{"image": "", - "targetImgref": "ghcr.io/ublue-os/bluefin:stable", - "composeFsBackend": false, - "bootloader": "grub2"} -``` - -### 4. QEMU VM RAM - -| | Dakota | Bluefin (currently) | -|---|---|---| -| Live ISO QEMU | 8 GB | 8 GB (was bumped to 12 GB, reverted) | -| Installed disk QEMU | 8 GB | 8 GB | -| Second disk (cs-disk) | No | Removed | - -Dakota passes at 8 GB. Bluefin's ostree deployment needs more headroom. -12 GB has been tested but not with the `containers-storage:` transport + -bootcDirect approach. - -### 5. Fisherman fork - -Bluefin needs a forked fisherman -(`projectbluefin/fisherman#fix/overlay-driver-for-ostree-bootc-install`) -because the upstream tuna-os/fisherman doesn't support the `--source-imgref` -flag for the direct (bootcDirect) mode. The fork adds: - -1. `BuildBootcArgs` emits `--source-imgref containers-storage:` for - direct-mode installs (when SourceImgref is empty, TargetImgref is set). -2. `bareImageRef()` is called on target-imgref to strip transport prefixes. -3. The `selectStorageDriver` composefs guard is removed (unused in direct - mode but needed for the container-mode fallback). - -If the `containers-storage:` transport + bootcDirect approach works, these -changes should be upstreamed to tuna-os/fisherman and the forked build step -removed from CI. - -## Current status - -**✅ NEW: offline-capable path working** — run `27702412035`: bluefin + bluefin-stable PASSED -with `--source-imgref containers-storage:ghcr.io/ublue-os/bluefin:stable` (containers-storage -transport) + bootcDirect at 8 GB VM RAM. No squash, no second disk, no podman container, -no network pull. The image is read from the embedded squashfs at `/usr/lib/containers/storage`. - -**Bluefin-lts:** pre-existing dracut build failure (kernel `6.12.0-228.el10` in Debian -initramfs-builder) — unrelated to LUKS test changes. - -**Key insight that made it work:** removing the `podman commit -s` squashing step. -The squashing was added for VFS memory pressure (commit `3b8322b`), but the -containers-storage import now uses overlay driver. Without squashing, ostree -annotations (`ostree.final-diffid`) survive into the embedded store, and bootc -resolves them correctly. - -**Fisherman fork needed:** upstream tuna-os/fisherman lacks the `--source-imgref` -emission for direct mode. The essential patch is ~10 lines in `BuildBootcArgs`. -See PR to upstream. - -**Previous failure chain (resolved):** - -| CI Run | ISO Commit | Fisherman Commit | Failure | -|--------|-----------|-----------------|---------| -| 27684346872 | e4a6039 | d5c3b3e | `Unknown transport 'ostree-unverified-registry'` | -| 27682666045 | 94e2473 | d5c3b3e | `Either --source-imgref must be defined...` | -| 27681019431 | ba3ec5f | d5c3b3e | Same as above | -| 27679316314 | 58c8ed2 | d5c3b3e | Same as above | -| 27677273567 | 50df7d8 | 266b4fb | OOM (12 GB, podman run) | -| 27674960446 | 136ae7d | 266b4fb | OOM (10 GB, podman run) | -| 27673343778 | a9e081b | 266b4fb | OOM (8 GB, podman run) | -| 27670315536 | 8dec7d5 | 266b4fb | OOM (8 GB, podman pull) | - -## Files changed - -### `projectbluefin/iso` (PR #61, branch `feat/bluefin-bootc-iso`) - -| File | Change | -|------|--------| -| `justfile` | Added `fisher_repo` var, rebuilt `luks-install-qemu` for bootcDirect, removed second disk and cs-setup.sh | -| `.github/workflows/test-luks-install.yml` | Added Go setup, fisherman clone, FISHER_REPO env var | -| `bluefin/` | payload_ref, images.json, recipe.json (new variant files) | -| `bluefin-lts/` | Same (bluefin-lts variant) | -| `Containerfile` | 3-stage ISO build (Bluefin + Debian initramfs + final) | -| `src/` | configure-live.sh, build-iso.sh, dracut module, branding assets | - -### `projectbluefin/fisherman` (branch `fix/overlay-driver-for-ostree-bootc-install`) - -| File | Change | -|------|--------| -| `internal/install/bootc.go` | `BuildBootcArgs`: emits `--source-imgref containers-storage:` for direct mode; `bareImageRef` on target-imgref | -| `internal/install/storage_driver.go` | Removed composefs-only guard from `selectStorageDriver`; removed btrfs from unsafeFS list | -| `internal/install/bootc_test.go` | New tests for direct-mode args, OCI export guards | -| `internal/install/storage_driver_test.go` | Updated for new `selectStorageDriver` sig | -| `internal/install/storage_driver_loopback_test.go` | Same | - -## Open questions - -1. ~~Does `--source-imgref containers-storage:ghcr.io/ublue-os/bluefin:stable` work~~ - **RESOLVED** — works with bootcDirect at 8 GB when squashing is removed. - -2. ~~Is 8 GB enough for ostree bootcDirect?~~ **RESOLVED** — 8 GB is sufficient. - bootcDirect avoids podman's container runtime overhead entirely. - -3. **Cleanup dead patches** — commits `1b70f55` through `ea7987b` in the fisherman - fork (overlay/OCI container-mode patches) should be removed from the branch. - Only the direct-mode `--source-imgref` change + `bareImageRef` fix + tests are - needed. - -4. **Upstream fisherman fix** — the ~10-line `--source-imgref` change in - `BuildBootcArgs` should be submitted as a PR to tuna-os/fisherman. - Once merged, the forked binary build step can be removed from CI. - -5. **bluefin-lts dracut failure** — kernel `6.12.0-228.el10` in the Debian - initramfs-builder causes dracut to fail. Unrelated to LUKS test changes. - Needs a separate Containerfile fix (different dracut version or kernel path). diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..63affa1 --- /dev/null +++ b/Justfile @@ -0,0 +1,905 @@ +repo_organization := "ublue-os" +rechunker_image := "ghcr.io/hhd-dev/rechunk:v1.2.4@sha256:8a84bd5a029681aa8db523f927b7c53b5aded9b078b81605ac0a2fedc969f528" +images := '( + [bluefin]=bluefin + [bluefin-dx]=bluefin-dx +)' +flavors := '( + [main]=main + [nvidia-open]=nvidia-open + + # Temporary for LTS to anaconda build-iso + [gdx]=gdx +)' +tags := '( + [stable]=stable + [latest]=latest + [beta]=beta + + # Temporary for LTS to anaconda build-iso + [lts]=lts + [lts-hwe]=lts-hwe +)' +export SUDO_DISPLAY := if `if [ -n "${DISPLAY:-}" ] || [ -n "${WAYLAND_DISPLAY:-}" ]; then echo true; fi` == "true" { "true" } else { "false" } +export SUDOIF := if `id -u` == "0" { "" } else if SUDO_DISPLAY == "true" { "sudo --askpass" } else { "sudo" } +export PODMAN := if path_exists("/usr/bin/podman") == "true" { env("PODMAN", "/usr/bin/podman") } else if path_exists("/usr/bin/docker") == "true" { env("PODMAN", "docker") } else { env("PODMAN", "exit 1 ; ") } +export PULL_POLICY := if PODMAN =~ "docker" { "missing" } else { "newer" } +just := just_executable() + +[private] +default: + @{{ just }} --list + +# Check Just Syntax +[group('Just')] +check: + #!/usr/bin/bash + find . -type f -name "*.just" | while read -r file; do + echo "Checking syntax: $file" + {{ just }} --unstable --fmt --check -f $file + done + echo "Checking syntax: Justfile" + {{ just }} --unstable --fmt --check -f Justfile + +# Fix Just Syntax +[group('Just')] +fix: + #!/usr/bin/bash + find . -type f -name "*.just" | while read -r file; do + echo "Checking syntax: $file" + {{ just }} --unstable --fmt -f $file + done + echo "Checking syntax: Justfile" + {{ just }} --unstable --fmt -f Justfile || { exit 1; } + +# Clean Repo +[group('Utility')] +clean: + #!/usr/bin/bash + set -eoux pipefail + touch _build + find *_build* -exec rm -rf {} \; + rm -f previous.manifest.json + rm -f changelog.md + rm -f output.env + +# Check if valid combo +[group('Utility')] +[private] +validate $image $tag $flavor: + #!/usr/bin/bash + set -eou pipefail + declare -A images={{ images }} + declare -A tags={{ tags }} + declare -A flavors={{ flavors }} + + # Handle Stable Daily + if [[ "${tag}" == "stable-daily" ]]; then + tag="stable" + fi + + checkimage="${images[${image}]-}" + checktag="${tags[${tag}]-}" + checkflavor="${flavors[${flavor}]-}" + + # Validity Checks + if [[ -z "$checkimage" ]]; then + echo "Invalid Image..." + exit 1 + fi + if [[ -z "$checktag" ]]; then + echo "Invalid tag..." + exit 1 + fi + if [[ -z "$checkflavor" ]]; then + echo "Invalid flavor..." + exit 1 + fi + +# Build Image +[group('Image')] +build $image="bluefin" $tag="latest" $flavor="main" rechunk="0" ghcr="0" pipeline="0" $kernel_pin="": + #!/usr/bin/bash + + echo "::group:: Build Prep" + set -eoux pipefail + + # Validate + {{ just }} validate "${image}" "${tag}" "${flavor}" + + # Image Name + image_name=$({{ just }} image_name {{ image }} {{ tag }} {{ flavor }}) + + # Base Image + base_image_name="silverblue" + + + # AKMODS Flavor and Kernel Version + if [[ "${flavor}" =~ hwe ]]; then + akmods_flavor="bazzite" + elif [[ "${tag}" =~ stable ]]; then + akmods_flavor="coreos-stable" + elif [[ "${tag}" =~ beta ]]; then + akmods_flavor="main" + else + akmods_flavor="main" + fi + + # Fedora Version + if [[ {{ ghcr }} == "0" ]]; then + rm -f /tmp/manifest.json + fi + fedora_version=$({{ just }} fedora_version '{{ image }}' '{{ tag }}' '{{ flavor }}' '{{ kernel_pin }}') + + # Verify Base Image with cosign + {{ just }} verify-container "${base_image_name}-main:${fedora_version}" + + # Kernel Release/Pin + if [[ -z "${kernel_pin:-}" ]]; then + kernel_release=$(skopeo inspect --retry-times 3 docker://ghcr.io/ublue-os/akmods:"${akmods_flavor}"-"${fedora_version}" | jq -r '.Labels["ostree.linux"]') + else + kernel_release="${kernel_pin}" + fi + + # Verify Containers with Cosign + {{ just }} verify-container "akmods:${akmods_flavor}-${fedora_version}-${kernel_release}" + if [[ "${akmods_flavor}" =~ coreos ]]; then + {{ just }} verify-container "akmods-zfs:${akmods_flavor}-${fedora_version}-${kernel_release}" + fi + if [[ "${flavor}" =~ nvidia-open ]]; then + {{ just }} verify-container "akmods-nvidia-open:${akmods_flavor}-${fedora_version}-${kernel_release}" + fi + + # Get Version + if [[ "${tag}" =~ stable ]]; then + ver="${fedora_version}.$(date +%Y%m%d)" + else + ver="${tag}-${fedora_version}.$(date +%Y%m%d)" + fi + skopeo list-tags docker://ghcr.io/{{ repo_organization }}/${image_name} > /tmp/repotags.json + if [[ $(jq "any(.Tags[]; contains(\"$ver\"))" < /tmp/repotags.json) == "true" ]]; then + POINT="1" + while $(jq -e "any(.Tags[]; contains(\"$ver.$POINT\"))" < /tmp/repotags.json) + do + (( POINT++ )) + done + fi + if [[ -n "${POINT:-}" ]]; then + ver="${ver}.$POINT" + fi + + # Build Arguments + BUILD_ARGS=() + # Target + if [[ "${image}" =~ dx ]]; then + BUILD_ARGS+=("--build-arg" "IMAGE_FLAVOR=dx") + target="dx" + fi + BUILD_ARGS+=("--build-arg" "AKMODS_FLAVOR=${akmods_flavor}") + BUILD_ARGS+=("--build-arg" "BASE_IMAGE_NAME=${base_image_name}") + BUILD_ARGS+=("--build-arg" "FEDORA_MAJOR_VERSION=${fedora_version}") + BUILD_ARGS+=("--build-arg" "IMAGE_NAME=${image_name}") + BUILD_ARGS+=("--build-arg" "IMAGE_VENDOR={{ repo_organization }}") + BUILD_ARGS+=("--build-arg" "KERNEL=${kernel_release}") + BUILD_ARGS+=("--build-arg" "VERSION=${ver}") + if [[ -z "$(git status -s)" ]]; then + BUILD_ARGS+=("--build-arg" "SHA_HEAD_SHORT=$(git rev-parse --short HEAD)") + fi + BUILD_ARGS+=("--build-arg" "UBLUE_IMAGE_TAG=${tag}") + if [[ "${PODMAN}" =~ docker && "${TERM}" == "dumb" ]]; then + BUILD_ARGS+=("--progress" "plain") + fi + + # Labels + LABELS=() + LABELS+=("--label" "org.opencontainers.image.title=${image_name}") + LABELS+=("--label" "org.opencontainers.image.version=${ver}") + LABELS+=("--label" "ostree.linux=${kernel_release}") + LABELS+=("--label" "io.artifacthub.package.readme-url=https://raw.githubusercontent.com/ublue-os/bluefin/refs/heads/main/README.md") + LABELS+=("--label" "io.artifacthub.package.logo-url=https://avatars.githubusercontent.com/u/120078124?s=200&v=4") + LABELS+=("--label" "org.opencontainers.image.description=The next generation Linux workstation, designed for reliability, performance, and sustainability.") + LABELS+=("--label" "containers.bootc=1") + LABELS+=("--label" "org.opencontainers.image.created=$(date -u +%Y\-%m\-%d\T%H\:%M\:%S\Z)") + LABELS+=("--label" "org.opencontainers.image.source=https://raw.githubusercontent.com/ublue-os/bluefin/refs/heads/main/Containerfile") + LABELS+=("--label" "org.opencontainers.image.url=https://projectbluefin.io") + LABELS+=("--label" "org.opencontainers.image.vendor={{ repo_organization }}") + LABELS+=("--label" "io.artifacthub.package.deprecated=false") + LABELS+=("--label" "io.artifacthub.package.keywords=bootc,bluefin,ublue,universal-blue") + LABELS+=("--label" "io.artifacthub.package.maintainers=[{\"name\": \"castrojo\", \"email\": \"jorge.castro@gmail.com\"}]") + + echo "::endgroup::" + echo "::group:: Build Container" + + # Build Image + PODMAN_BUILD_ARGS=("${BUILD_ARGS[@]}" "${LABELS[@]}" --tag localhost/"${image_name}:${tag}" --file Containerfile) + + # Add GitHub token secret if available (for CI/CD) + if [[ -n "${GITHUB_TOKEN:-}" ]]; then + echo "Adding GitHub token as build secret" + PODMAN_BUILD_ARGS+=(--secret "id=GITHUB_TOKEN,env=GITHUB_TOKEN") + else + echo "No GitHub token found - build may hit rate limit" + fi + + ${PODMAN} build "${PODMAN_BUILD_ARGS[@]}" . + echo "::endgroup::" + + # Rechunk + if [[ "{{ rechunk }}" == "1" && "{{ ghcr }}" == "1" && "{{ pipeline }}" == "1" ]]; then + ${SUDOIF} {{ just }} rechunk "${image}" "${tag}" "${flavor}" 1 1 + elif [[ "{{ rechunk }}" == "1" && "{{ ghcr }}" == "1" ]]; then + ${SUDOIF} {{ just }} rechunk "${image}" "${tag}" "${flavor}" 1 + elif [[ "{{ rechunk }}" == "1" ]]; then + ${SUDOIF} {{ just }} rechunk "${image}" "${tag}" "${flavor}" + fi + +# Build Image and Rechunk +[group('Image')] +build-rechunk image="bluefin" tag="latest" flavor="main" kernel_pin="": + @{{ just }} build {{ image }} {{ tag }} {{ flavor }} 1 0 0 {{ kernel_pin }} + +# Build Image with GHCR Flag +[group('Image')] +build-ghcr image="bluefin" tag="latest" flavor="main" kernel_pin="": + #!/usr/bin/bash + if [[ "${UID}" -gt "0" ]]; then + echo "Must Run with sudo or as root..." + exit 1 + fi + {{ just }} build {{ image }} {{ tag }} {{ flavor }} 0 1 0 {{ kernel_pin }} + +# Build Image for Pipeline: +[group('Image')] +build-pipeline image="bluefin" tag="latest" flavor="main" kernel_pin="": + #!/usr/bin/bash + ${SUDOIF} {{ just }} build {{ image }} {{ tag }} {{ flavor }} 1 1 1 {{ kernel_pin }} + +# Rechunk Image +[group('Image')] +[private] +rechunk $image="bluefin" $tag="latest" $flavor="main" ghcr="0" pipeline="0": + #!/usr/bin/bash + + echo "::group:: Rechunk Prep" + set -eoux pipefail + + # Validate + {{ just }} validate "${image}" "${tag}" "${flavor}" + + # Image Name + image_name=$({{ just }} image_name {{ image }} {{ tag }} {{ flavor }}) + + # Check if image is already built + ID=$(${PODMAN} images --filter reference=localhost/"${image_name}":"${tag}" --format "'{{ '{{.ID}}' }}'") + if [[ -z "$ID" ]]; then + {{ just }} build "${image}" "${tag}" "${flavor}" + fi + + # Load into Rootful Podman + ID=$(${SUDOIF} ${PODMAN} images --filter reference=localhost/"${image_name}":"${tag}" --format "'{{ '{{.ID}}' }}'") + if [[ -z "$ID" && ! ${PODMAN} =~ docker ]]; then + COPYTMP=$(mktemp -p "${PWD}" -d -t podman_scp.XXXXXXXXXX) + ${SUDOIF} TMPDIR=${COPYTMP} ${PODMAN} image scp ${UID}@localhost::localhost/"${image_name}":"${tag}" root@localhost::localhost/"${image_name}":"${tag}" + rm -rf "${COPYTMP}" + fi + + # Prep Container + CREF=$(${SUDOIF} ${PODMAN} create localhost/"${image_name}":"${tag}" bash) + OLD_IMAGE=$(${SUDOIF} ${PODMAN} inspect $CREF | jq -r '.[].Image') + OUT_NAME="${image_name}_build" + MOUNT=$(${SUDOIF} ${PODMAN} mount "${CREF}") + + # Fedora Version + fedora_version=$(${SUDOIF} ${PODMAN} inspect $CREF | jq -r '.[].Config.Labels["ostree.linux"]' | grep -oP 'fc\K[0-9]+') + + # Label Version + VERSION=$(${SUDOIF} ${PODMAN} inspect $CREF | jq -r '.[].Config.Labels["org.opencontainers.image.version"]') + + # Git SHA + SHA="dedbeef" + if [[ -z "$(git status -s)" ]]; then + SHA=$(git rev-parse HEAD) + fi + + # Rest of Labels + LABELS=" + io.artifacthub.package.deprecated=false + io.artifacthub.package.keywords=bootc,fedora,bluefin,ublue,universal-blue + io.artifacthub.package.logo-url=https://avatars.githubusercontent.com/u/120078124?s=200&v=4 + io.artifacthub.package.maintainers=[{\"name\": \"castrojo\", \"email\": \"jorge.castro@gmail.com\"}] + io.artifacthub.package.readme-url=https://raw.githubusercontent.com/ublue-os/bluefin/refs/heads/main/README.md + org.opencontainers.image.created=$(date -u +%Y\-%m\-%d\T%H\:%M\:%S\Z) + org.opencontainers.image.license=Apache-2.0 + org.opencontainers.image.source=https://raw.githubusercontent.com/ublue-os/bluefin/refs/heads/main/Containerfile + org.opencontainers.image.title=${image_name} + org.opencontainers.image.url=https://projectbluefin.io + org.opencontainers.image.vendor={{ repo_organization }} + ostree.linux=$(${SUDOIF} ${PODMAN} inspect $CREF | jq -r '.[].Config.Labels["ostree.linux"]') + containers.bootc=1 + " + + # Cleanup Space during Github Action + if [[ "{{ ghcr }}" == "1" ]]; then + base_image_name=silverblue-main + if [[ "${tag}" =~ stable ]]; then + tag="stable-daily" + fi + ID=$(${SUDOIF} ${PODMAN} images --filter reference=ghcr.io/{{ repo_organization }}/"${base_image_name}":${fedora_version} --format "{{ '{{.ID}}' }}") + if [[ -n "$ID" ]]; then + ${PODMAN} rmi "$ID" + fi + fi + + # Rechunk Container + rechunker="{{ rechunker_image }}" + + echo "::endgroup::" + echo "::group:: Prune" + + # Run Rechunker's Prune + ${SUDOIF} ${PODMAN} run --rm \ + --pull=${PULL_POLICY} \ + --security-opt label=disable \ + --volume "$MOUNT":/var/tree \ + --env TREE=/var/tree \ + --user 0:0 \ + "${rechunker}" \ + /sources/rechunk/1_prune.sh + + echo "::endgroup::" + echo "::group:: Create ostree tree" + + # Run Rechunker's Create + ${SUDOIF} ${PODMAN} run --rm \ + --security-opt label=disable \ + --volume "$MOUNT":/var/tree \ + --volume "cache_ostree:/var/ostree" \ + --env TREE=/var/tree \ + --env REPO=/var/ostree/repo \ + --env RESET_TIMESTAMP=1 \ + --user 0:0 \ + "${rechunker}" \ + /sources/rechunk/2_create.sh + + # Cleanup Temp Container Reference + ${SUDOIF} ${PODMAN} unmount "$CREF" + ${SUDOIF} ${PODMAN} rm "$CREF" + ${SUDOIF} ${PODMAN} rmi "$OLD_IMAGE" + + echo "::endgroup::" + echo "::group:: Rechunker" + + # Run Rechunker + ${SUDOIF} ${PODMAN} run --rm \ + --pull=${PULL_POLICY} \ + --security-opt label=disable \ + --volume "$PWD:/workspace" \ + --volume "$PWD:/var/git" \ + --volume cache_ostree:/var/ostree \ + --env REPO=/var/ostree/repo \ + --env PREV_REF=ghcr.io/ublue-os/"${image_name}":"${tag}" \ + --env OUT_NAME="$OUT_NAME" \ + --env LABELS="${LABELS}" \ + --env "DESCRIPTION='An interpretation of the Ubuntu spirit built on Fedora technology'" \ + --env "VERSION=${VERSION}" \ + --env VERSION_FN=/workspace/version.txt \ + --env OUT_REF="oci:$OUT_NAME" \ + --env GIT_DIR="/var/git" \ + --env REVISION="$SHA" \ + --user 0:0 \ + "${rechunker}" \ + /sources/rechunk/3_chunk.sh + + # Fix Permissions of OCI + ${SUDOIF} find ${OUT_NAME} -type d -exec chmod 0755 {} \; || true + ${SUDOIF} find ${OUT_NAME}* -type f -exec chmod 0644 {} \; || true + + if [[ "${UID}" -gt "0" ]]; then + ${SUDOIF} chown "${UID}:${GROUPS}" -R "${PWD}" + elif [[ -n "${SUDO_UID:-}" ]]; then + chown "${SUDO_UID}":"${SUDO_GID}" -R "${PWD}" + fi + + # Remove cache_ostree + ${SUDOIF} ${PODMAN} volume rm cache_ostree + + echo "::endgroup::" + + # Pipeline Checks + if [[ {{ pipeline }} == "1" && -n "${SUDO_USER:-}" ]]; then + sudo -u "${SUDO_USER}" {{ just }} load-rechunk "${image}" "${tag}" "${flavor}" + sudo -u "${SUDO_USER}" {{ just }} secureboot "${image}" "${tag}" "${flavor}" + fi + +# Load OCI into Podman Store +[group('Image')] +load-rechunk image="bluefin" tag="latest" flavor="main": + #!/usr/bin/bash + set -eou pipefail + + # Validate + {{ just }} validate {{ image }} {{ tag }} {{ flavor }} + + # Image Name + image_name=$({{ just }} image_name {{ image }} {{ tag }} {{ flavor }}) + + # Load Image + OUT_NAME="${image_name}_build" + IMAGE=$(${PODMAN} pull oci:"${PWD}"/"${OUT_NAME}") + ${PODMAN} tag ${IMAGE} localhost/"${image_name}":{{ tag }} + + # Cleanup + rm -rf "${OUT_NAME}*" + rm -f previous.manifest.json + +# Run Container +[group('Image')] +run $image="bluefin" $tag="latest" $flavor="main": + #!/usr/bin/bash + set -eoux pipefail + + # Validate + {{ just }} validate "${image}" "${tag}" "${flavor}" + + # Image Name + image_name=$({{ just }} image_name {{ image }} {{ tag }} {{ flavor }}) + + # Check if image exists + ID=$(${PODMAN} images --filter reference=localhost/"${image_name}":"${tag}" --format "'{{ '{{.ID}}' }}'") + if [[ -z "$ID" ]]; then + {{ just }} build "$image" "$tag" "$flavor" + fi + + # Run Container + ${PODMAN} run -it --rm localhost/"${image_name}":"${tag}" bash + +# Build ISO +[group('ISO')] +build-iso $image="bluefin" $tag="latest" $flavor="main" ghcr="0" pipeline="0": + #!/usr/bin/bash + set -eoux pipefail + + # Validate + {{ just }} validate "${image}" "${tag}" "${flavor}" + + # Image Name + image_name=$({{ just }} image_name {{ image }} {{ tag }} {{ flavor }}) + + build_dir="${image_name}_build" + mkdir -p "$build_dir" + + if [[ -f "${build_dir}/${image_name}-${tag}-$(uname -m).iso" || -f "${build_dir}/${image_name}-${tag}-$(uname -m).iso-CHECKSUM" ]]; then + echo "ERROR - ISO or Checksum already exist. Please mv or rm to build new ISO" + exit 1 + fi + + # Local or Github Build + if [[ "{{ ghcr }}" == "1" ]]; then + IMAGE_FULL=ghcr.io/ublue-os/"${image_name}":"${tag}" + IMAGE_REPO=ghcr.io/ublue-os + ${PODMAN} pull "${IMAGE_FULL}" + else + IMAGE_FULL=localhost/"${image_name}":"${tag}" + IMAGE_REPO=localhost + ID=$(${PODMAN} images --filter reference=localhost/"${image_name}":"${tag}" --format "'{{ '{{.ID}}' }}'") + if [[ -z "$ID" ]]; then + {{ just }} build "$image" "$tag" "$flavor" + fi + fi + + # Fedora Version + # if [[ "$tag" != lts ]]; then + # FEDORA_VERSION=$(${PODMAN} inspect ${IMAGE_FULL} | jq -r '.[]["Config"]["Labels"]["ostree.linux"]' | grep -oP 'fc\K[0-9]+') + # else + FEDORA_VERSION=42 + # fi + + # Load Image into rootful podman + if [[ "${UID}" -gt 0 && {{ ghcr }} == "0" && ! "${PODMAN}" =~ docker ]]; then + COPYTMP=$(mktemp -p "${PWD}" -d -t podman_scp.XXXXXXXXXX) + ${SUDOIF} TMPDIR=${COPYTMP} ${PODMAN} image scp "${UID}"@localhost::"${IMAGE_FULL}" root@localhost::"${IMAGE_FULL}" + rm -rf "${COPYTMP}" + fi + + FLATPAK_DIR_SHORTNAME="flatpaks" + + # Generate Flatpak List + TEMP_FLATPAK_INSTALL_DIR="$(mktemp -d -p /tmp flatpak-XXXXX)" + flatpak_refs=() + while IFS= read -r line; do + flatpak_refs+=("$line") + done < "${FLATPAK_DIR_SHORTNAME}/system-flatpaks.list" + + # Add DX Flatpaks if needed + if [[ "${image_name}" =~ dx ]]; then + while IFS= read -r line; do + flatpak_refs+=("$line") + done < "flatpaks/system-flatpaks-dx.list" + fi + + echo "Flatpak refs: ${flatpak_refs[@]}" + + # Generate Install Script for Flatpaks + tee "${TEMP_FLATPAK_INSTALL_DIR}/install-flatpaks.sh"< /output/flatpaks-with-deps + EOF + + # Create Flatpak List with dependencies + flatpak_list_args=() + flatpak_list_args+=("--rm" "--privileged") + flatpak_list_args+=("--entrypoint" "/usr/bin/bash") + flatpak_list_args+=("--env" "FLATPAK_SYSTEM_DIR=/flatpak/flatpak") + flatpak_list_args+=("--env" "FLATPAK_TRIGGERSDIR=/flatpak/triggers") + flatpak_list_args+=("--volume" "$(realpath ./${build_dir}):/output") + flatpak_list_args+=("--volume" "${TEMP_FLATPAK_INSTALL_DIR}:/temp_flatpak_install_dir") + flatpak_list_args+=("${IMAGE_FULL}" /temp_flatpak_install_dir/install-flatpaks.sh) + + if [[ ! -f "${build_dir}/flatpaks-with-deps" ]]; then + ${PODMAN} run "${flatpak_list_args[@]}" + else + echo "WARNING - Reusing previous determined flatpaks-with-deps" + fi + + if [[ "{{ pipeline }}" == "1" ]]; then + ${PODMAN} rmi ${IMAGE_FULL} + fi + + # List Flatpaks with Dependencies + cat "${build_dir}/flatpaks-with-deps" + + # Build ISO + iso_build_args=() + iso_build_args+=("--rm" "--privileged" "--pull=${PULL_POLICY}") + if [[ "{{ ghcr }}" == "0" ]]; then + iso_build_args+=( + "--security-opt=label=disable" + "--volume=/var/lib/containers/storage:/var/lib/containers/storage" + ) + fi + + curl -Lo iso_files/bluefin.repo https://copr.fedorainfracloud.org/coprs/ublue-os/bluefin/repo/fedora-${FEDORA_VERSION}/ublue-os-bluefin-fedora-${FEDORA_VERSION}.repo + iso_build_args+=("--volume=${PWD}:/github/workspace/") + iso_build_args+=(ARCH="$(uname -m)") + iso_build_args+=(REPOS="/github/workspace/iso_files/bluefin.repo /etc/yum.repos.d/fedora.repo /etc/yum.repos.d/fedora-updates.repo") + iso_build_args+=(ENROLLMENT_PASSWORD="universalblue") + iso_build_args+=(FLATPAK_REMOTE_REFS_DIR="/github/workspace/${build_dir}") + iso_build_args+=(IMAGE_NAME="${image_name}") + iso_build_args+=(IMAGE_REPO="${IMAGE_REPO}") + iso_build_args+=(IMAGE_SIGNED="true") + if [[ "{{ ghcr }}" == "0" ]]; then + iso_build_args+=(IMAGE_SRC="containers-storage:${IMAGE_FULL}") + fi + iso_build_args+=(IMAGE_TAG="${tag}") + iso_build_args+=(ISO_NAME="/github/workspace/${build_dir}/${image_name}-${tag}-$(uname -m).iso") + iso_build_args+=(SECURE_BOOT_KEY_URL="https://github.com/ublue-os/akmods/raw/main/certs/public_key.der") + iso_build_args+=(VARIANT="Silverblue") + iso_build_args+=(VERSION="${FEDORA_VERSION}") + iso_build_args+=(WEB_UI="false") + + ${SUDOIF} ${PODMAN} run "${iso_build_args[@]}" + + if [[ "${UID}" -gt "0" ]]; then + ${SUDOIF} chown "${UID}:${GROUPS}" -R "${PWD}" + elif [[ -n "${SUDO_UID:-}" ]]; then + chown "${SUDO_UID}":"${SUDO_GID}" -R "${PWD}" + fi + +# Build ISO using GHCR Image +[group('ISO')] +build-iso-ghcr image="bluefin" tag="latest" flavor="main": + @{{ just }} build-iso {{ image }} {{ tag }} {{ flavor }} 1 + +# Run ISO +[group('ISO')] +run-iso $image="bluefin" $tag="latest" $flavor="main": + #!/usr/bin/bash + set -eoux pipefail + + # Validate + {{ just }} validate "${image}" "${tag}" "${flavor}" + + # Image Name + image_name=$({{ just }} image_name {{ image }} {{ tag }} {{ flavor }}) + + # Check if ISO Exists + if [[ ! -f "${image_name}_build/${image_name}-${tag}.iso" ]]; then + {{ just }} build-iso "$image" "$tag" "$flavor" + fi + + # Determine which port to use + port=8006; + while grep -q :${port} <<< $(ss -tunalp); do + port=$(( port + 1 )) + done + echo "Using Port: ${port}" + echo "Connect to http://localhost:${port}" + run_args=() + run_args+=(--rm --privileged) + run_args+=(--pull=${PULL_POLICY}) + run_args+=(--publish "127.0.0.1:${port}:8006") + run_args+=(--env "CPU_CORES=4") + run_args+=(--env "RAM_SIZE=8G") + run_args+=(--env "DISK_SIZE=64G") + run_args+=(--env "BOOT_MODE=windows_secure") + run_args+=(--env "TPM=Y") + run_args+=(--env "GPU=Y") + run_args+=(--device=/dev/kvm) + run_args+=(--volume "${PWD}/${image_name}_build/${image_name}-${tag}.iso":"/boot.iso") + run_args+=(docker.io/qemux/qemu-docker) + xdg-open http://localhost:${port} & + ${PODMAN} run "${run_args[@]}" + +# Test Changelogs +[group('Changelogs')] +changelogs branch="stable" handwritten="": + #!/usr/bin/bash + set -eou pipefail + python3 ./.github/changelogs.py "{{ branch }}" ./output.env ./changelog.md --workdir . --handwritten "{{ handwritten }}" + +# Verify Container with Cosign +[group('Utility')] +verify-container container="" registry="ghcr.io/ublue-os" key="": + #!/usr/bin/bash + set -eou pipefail + + # Get Cosign if Needed + if [[ ! $(command -v cosign) ]]; then + COSIGN_CONTAINER_ID=$(${SUDOIF} ${PODMAN} create cgr.dev/chainguard/cosign:latest bash) + ${SUDOIF} ${PODMAN} cp "${COSIGN_CONTAINER_ID}":/usr/bin/cosign /usr/local/bin/cosign + ${SUDOIF} ${PODMAN} rm -f "${COSIGN_CONTAINER_ID}" + fi + + # Verify Cosign Image Signatures if needed + if [[ -n "${COSIGN_CONTAINER_ID:-}" ]]; then + if ! cosign verify --certificate-oidc-issuer=https://token.actions.githubusercontent.com --certificate-identity=https://github.com/chainguard-images/images/.github/workflows/release.yaml@refs/heads/main cgr.dev/chainguard/cosign >/dev/null; then + echo "NOTICE: Failed to verify cosign image signatures." + exit 1 + fi + fi + + # Public Key for Container Verification + key={{ key }} + if [[ -z "${key:-}" ]]; then + key="https://raw.githubusercontent.com/ublue-os/main/main/cosign.pub" + fi + + # Verify Container using cosign public key + if ! cosign verify --key "${key}" "{{ registry }}"/"{{ container }}" >/dev/null; then + echo "NOTICE: Verification failed. Please ensure your public key is correct." + exit 1 + fi + +# Secureboot Check +[group('Utility')] +secureboot $image="bluefin" $tag="latest" $flavor="main": + #!/usr/bin/bash + set -eou pipefail + + # Validate + {{ just }} validate "${image}" "${tag}" "${flavor}" + + # Image Name + image_name=$({{ just }} image_name ${image} ${tag} ${flavor}) + + # Get the vmlinuz to check + kernel_release=$(${PODMAN} inspect "${image_name}":"${tag}" | jq -r '.[].Config.Labels["ostree.linux"]') + TMP=$(${PODMAN} create "${image_name}":"${tag}" bash) + ${PODMAN} cp "$TMP":/usr/lib/modules/"${kernel_release}"/vmlinuz /tmp/vmlinuz + ${PODMAN} rm "$TMP" + + # Get the Public Certificates + curl --retry 3 -Lo /tmp/kernel-sign.der https://github.com/ublue-os/akmods/raw/main/certs/public_key.der + curl --retry 3 -Lo /tmp/akmods.der https://github.com/ublue-os/akmods/raw/main/certs/public_key_2.der + openssl x509 -in /tmp/kernel-sign.der -out /tmp/kernel-sign.crt + openssl x509 -in /tmp/akmods.der -out /tmp/akmods.crt + + # Make sure we have sbverify + CMD="$(command -v sbverify)" + if [[ -z "${CMD:-}" ]]; then + temp_name="sbverify-${RANDOM}" + ${PODMAN} run -dt \ + --entrypoint /bin/sh \ + --volume /tmp/vmlinuz:/tmp/vmlinuz:z \ + --volume /tmp/kernel-sign.crt:/tmp/kernel-sign.crt:z \ + --volume /tmp/akmods.crt:/tmp/akmods.crt:z \ + --name ${temp_name} \ + alpine:edge + ${PODMAN} exec ${temp_name} apk add sbsigntool + CMD="${PODMAN} exec ${temp_name} /usr/bin/sbverify" + fi + + # Confirm that Signatures Are Good + $CMD --list /tmp/vmlinuz + returncode=0 + if ! $CMD --cert /tmp/kernel-sign.crt /tmp/vmlinuz || ! $CMD --cert /tmp/akmods.crt /tmp/vmlinuz; then + echo "Secureboot Signature Failed...." + returncode=1 + fi + if [[ -n "${temp_name:-}" ]]; then + ${PODMAN} rm -f "${temp_name}" + fi + exit "$returncode" + +# Get Fedora Version of an image +[group('Utility')] +[private] +fedora_version image="bluefin" tag="latest" flavor="main" $kernel_pin="": + #!/usr/bin/bash + set -eou pipefail + {{ just }} validate {{ image }} {{ tag }} {{ flavor }} + if [[ ! -f /tmp/manifest.json ]]; then + if [[ "{{ tag }}" =~ stable ]]; then + # CoreOS does not uses cosign + skopeo inspect --retry-times 3 docker://quay.io/fedora/fedora-coreos:stable > /tmp/manifest.json + else + skopeo inspect --retry-times 3 docker://ghcr.io/ublue-os/base-main:"{{ tag }}" > /tmp/manifest.json + fi + fi + fedora_version=$(jq -r '.Labels["ostree.linux"]' < /tmp/manifest.json | grep -oP 'fc\K[0-9]+') + if [[ -n "${kernel_pin:-}" ]]; then + fedora_version=$(echo "${kernel_pin}" | grep -oP 'fc\K[0-9]+') + fi + echo "${fedora_version}" + +# Image Name +[group('Utility')] +[private] +image_name image="bluefin" tag="latest" flavor="main": + #!/usr/bin/bash + set -eou pipefail + {{ just }} validate {{ image }} {{ tag }} {{ flavor }} + if [[ "{{ flavor }}" =~ main ]]; then + image_name={{ image }} + else + image_name="{{ image }}-{{ flavor }}" + fi + echo "${image_name}" + +# Generate Tags +[group('Utility')] +generate-build-tags image="bluefin" tag="latest" flavor="main" kernel_pin="" ghcr="0" $version="" github_event="" github_number="": + #!/usr/bin/bash + set -eou pipefail + + TODAY="$(date +%A)" + WEEKLY="Sunday" + if [[ {{ ghcr }} == "0" ]]; then + rm -f /tmp/manifest.json + fi + FEDORA_VERSION="$({{ just }} fedora_version '{{ image }}' '{{ tag }}' '{{ flavor }}' '{{ kernel_pin }}')" + DEFAULT_TAG=$({{ just }} generate-default-tag {{ tag }} {{ ghcr }}) + IMAGE_NAME=$({{ just }} image_name {{ image }} {{ tag }} {{ flavor }}) + # Use Build Version from Rechunk + if [[ -z "${version:-}" ]]; then + version="{{ tag }}-${FEDORA_VERSION}.$(date +%Y%m%d)" + fi + version=${version#{{ tag }}-} + + # Arrays for Tags + BUILD_TAGS=() + COMMIT_TAGS=() + + # Commit Tags + github_number="{{ github_number }}" + SHA_SHORT="$(git rev-parse --short HEAD)" + if [[ "{{ ghcr }}" == "1" ]]; then + COMMIT_TAGS+=(pr-${github_number:-}-{{ tag }}-${version}) + COMMIT_TAGS+=(${SHA_SHORT}-{{ tag }}-${version}) + fi + + # Convenience Tags + if [[ "{{ tag }}" =~ stable ]]; then + BUILD_TAGS+=("stable-daily" "${version}" "stable-daily-${version}" "stable-daily-${version:3}") + else + BUILD_TAGS+=("{{ tag }}" "{{ tag }}-${version}" "{{ tag }}-${version:3}") + fi + + # Weekly Stable / Rebuild Stable on workflow_dispatch + github_event="{{ github_event }}" + if [[ "{{ tag }}" =~ "stable" && "${WEEKLY}" == "${TODAY}" && "${github_event}" =~ schedule ]]; then + BUILD_TAGS+=("stable" "stable-${version}" "stable-${version:3}") + elif [[ "{{ tag }}" =~ "stable" && "${github_event}" =~ workflow_dispatch|workflow_call ]]; then + BUILD_TAGS+=("stable" "stable-${version}" "stable-${version:3}") + elif [[ "{{ tag }}" =~ "stable" && "{{ ghcr }}" == "0" ]]; then + BUILD_TAGS+=("stable" "stable-${version}" "stable-${version:3}") + elif [[ ! "{{ tag }}" =~ stable|beta ]]; then + BUILD_TAGS+=("${FEDORA_VERSION}" "${FEDORA_VERSION}-${version}" "${FEDORA_VERSION}-${version:3}") + fi + + if [[ "${github_event}" == "pull_request" ]]; then + alias_tags=("${COMMIT_TAGS[@]}") + else + alias_tags=("${BUILD_TAGS[@]}") + fi + + echo "${alias_tags[*]}" + +# Generate Default Tag +[group('Utility')] +generate-default-tag tag="latest" ghcr="0": + #!/usr/bin/bash + set -eou pipefail + + # Default Tag + if [[ "{{ tag }}" =~ stable && "{{ ghcr }}" == "1" ]]; then + DEFAULT_TAG="stable-daily" + elif [[ "{{ tag }}" =~ stable && "{{ ghcr }}" == "0" ]]; then + DEFAULT_TAG="stable" + else + DEFAULT_TAG="{{ tag }}" + fi + + echo "${DEFAULT_TAG}" + +# Tag Images +[group('Utility')] +tag-images image_name="" default_tag="" tags="": + #!/usr/bin/bash + set -eou pipefail + + # Get Image, and untag + IMAGE=$(${PODMAN} inspect localhost/{{ image_name }}:{{ default_tag }} | jq -r .[].Id) + ${PODMAN} untag localhost/{{ image_name }}:{{ default_tag }} + + # Tag Image + for tag in {{ tags }}; do + ${PODMAN} tag $IMAGE {{ image_name }}:${tag} + done + + + # Show Images + ${PODMAN} images + +# Examples: +# > just retag-nvidia-on-ghcr stable-daily stable-daily-41.20250126.3 0 +# > just retag-nvidia-on-ghcr latest latest-41.20250228.1 0 +# +# working_tag: The tag of the most recent known good image (e.g., stable-daily-41.20250126.3) +# stream: One of latest, stable-daily, or stable +# dry_run: Only print the skopeo commands instead of running them +# +# First generate a PAT with package write access (https://github.com/settings/tokens) +# and set $GITHUB_USERNAME and $GITHUB_PAT environment variables + +# Retag images on GHCR +[group('Admin')] +retag-nvidia-on-ghcr working_tag="" stream="" dry_run="1": + #!/bin/bash + set -euxo pipefail + skopeo="echo === skopeo" + if [[ "{{ dry_run }}" -ne 1 ]]; then + echo "$GITHUB_PAT" | podman login -u $GITHUB_USERNAME --password-stdin ghcr.io + skopeo="skopeo" + fi + for image in bluefin-nvidia-open bluefin-dx-nvidia-open; do + $skopeo copy docker://ghcr.io/ublue-os/${image}:{{ working_tag }} docker://ghcr.io/ublue-os/${image}:{{ stream }} + done + +# Build a local ISO using Titanoboa +# Arguments: +# variant: lts, bluefin +# flavor: base, dx, gdx +# repo: local, ghcr + +# Usage: just local-iso +[group('ISO')] +[private] +local-iso variant="lts" flavor="base" repo="ghcr": + hack/local-iso-build.sh {{ variant }} {{ flavor }} {{ repo }} + +# Build a local Bluefin LTS ISO using Titanoboa +[group('ISO')] +local-iso-lts flavor="base" repo="ghcr": + just local-iso lts {{ flavor }} {{ repo }} + +# Build a local Fedora-based Bluefin ISO using Titanoboa +[group('ISO')] +local-iso-bluefin flavor="base" repo="ghcr": + just local-iso bluefin {{ flavor }} {{ repo }} diff --git a/README.md b/README.md index 399d6eb..08f0941 100644 --- a/README.md +++ b/README.md @@ -1,141 +1,384 @@ -# Bluefin Live ISO Builder +# Bluefin ISO Builder -Builds bootable UEFI live ISOs for [Bluefin](https://github.com/ublue-os/bluefin) and [Bluefin LTS](https://github.com/ublue-os/bluefin-lts) using the [bootc-installer](https://github.com/projectbluefin/bootc-installer) Flatpak and the ostree backend. +This repository builds Bluefin ISOs using Anaconda and [Titanoboa](https://github.com/ublue-os/titanoboa) ## Overview -| Variant | Image | Download | -|---------|-------|----------| -| **Bluefin** | `ghcr.io/ublue-os/bluefin:stable` | [⬇ bluefin-live-latest.iso](https://projectbluefin.dev/bluefin-live-latest.iso) | -| **Bluefin LTS** | `ghcr.io/ublue-os/bluefin-lts:latest` | [⬇ bluefin-lts-live-latest.iso](https://projectbluefin.dev/bluefin-lts-live-latest.iso) | +Workflows and configuration files needed to build bootable Bluefin ISOs for installation. -The live environment boots to GDM with a full GNOME session and launches the Bluefin installer automatically. ISOs support offline installation via embedded OCI containers-storage. +- Pre-configured Anaconda installer +- System flatpaks +- Custom branding and configuration +- Secure boot key enrollment -## How it works +![ISO go nomnom](https://github.com/user-attachments/assets/2feeb772-713f-40b3-81e8-3f93b157fa13) -The build uses two Podman containers: +## ⚠️ LTS ISO Status: DISABLED -1. **`-installer`** — a 3-stage container that pulls the Bluefin base image, builds a dmsquash-live initramfs (via Debian stage), installs Flatpaks, and configures the live environment. -2. **`-iso-builder`** — a Debian-based toolchain container (xorriso, mksquashfs, dosfstools, mtools) that assembles the final ISO. +**LTS (non-HWE) ISOs are currently broken.** Anaconda does not work correctly on +the LTS base image. This affects **all LTS flavors** including `main` and `gdx` +(Gnome Developer Experience). The `build-iso-lts.yml` workflow has no schedule and +will not fire automatically. Working LTS ISOs remain in the production bucket from +before this breakage and must not be overwritten. -The ISO layout: -- **EFI/efi.img** — FAT32 ESP with systemd-boot, kernel, and initramfs -- **LiveOS/squashfs.img** — squashfs of the full live rootfs (with embedded OCI) -- **El Torito** UEFI entry pointing to the ESP image +**Known symptom:** The installer completes normally but account creation fails +on first boot, leaving the system in an unusable state (#51). -At boot, `dmsquash-live` mounts the squashfs and creates an overlayfs so the live environment is fully writable. +**Do not** run `promote-iso.yml` with `variant: lts` or `variant: all` — both +patterns match `*-lts-*.iso*` filenames and would overwrite production ISOs. -## Requirements +Only `variant: stable` promotion is safe until LTS is fixed. -| Tool | Notes | -|---|---| -| `podman` | Rootless works; needs `--cap-add sys_admin` for the live env build | -| `just` | Task runner | -| KVM + `qemu-system-x86_64` | For local boot testing | -| OVMF firmware | `edk2-ovmf` (Fedora) or `ovmf` (Debian/Ubuntu) | +## Workflow Structure -## Building +The ISO build system consists of independent, focused workflows: -```bash -# Clone the repo -git clone https://github.com/projectbluefin/iso -cd iso - -# Build Bluefin ISO -just iso-sd-boot bluefin +``` +┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐ +│ build-iso-lts │ │ build-iso-lts-hwe │ │ build-iso-stable │ +│ (DISABLED) │ │ │ │ │ +│ ✓ workflow_dispatch │ │ ✓ workflow_dispatch │ │ ✓ workflow_dispatch │ +│ ✗ no schedule │ │ ✓ schedule (cron) │ │ ✓ schedule (cron) │ +│ │ │ │ │ │ +│ Builds: LTS ISOs │ │ Builds: LTS-HWE ISOs│ │ Builds: Stable ISOs │ +│ - amd64 × main │ │ - amd64 × main │ │ - amd64 × main │ +│ - amd64 × gdx │ │ - arm64 × main │ │ - amd64 × nvidia-open│ +│ - arm64 × main │ │ │ │ │ +│ - arm64 × gdx │ │ │ │ │ +└─────────┬───────────┘ └─────────┬───────────┘ └─────────┬───────────┘ + │ │ │ + └────────────────────────┼────────────────────────┘ + │ + ┌────────▼────────┐ + │ calls reusable │ + │ workflow │ + └─────────────────┘ + +┌─────────────────────────────────────────────────────────────┐ +│ build-iso-lts-hwe-testing │ +│ "Build LTS-HWE Testing ISOs" │ +│ │ +│ ✓ workflow_dispatch │ +│ ✓ schedule (weekly — every Monday) │ +│ │ +│ ONLY authorized workflow for lts-hwe-testing tags │ +│ Builds: 2 testing ISOs │ +│ ├─► amd64 × main (image_tag: lts-hwe-testing) │ +│ └─► arm64 × main (image_tag: lts-hwe-testing) │ +└─────────────────────────────────────────────────────────────┘ + +═══════════════════════════════════════════════════════════════ + +┌─────────────────────────────────────────────────────────────┐ +│ build-iso-all │ +│ "Build All ISOs" │ +│ │ +│ ✓ workflow_dispatch + schedule (monthly cron) │ +│ │ +│ Calls reusable workflow directly for each variant: │ +│ ├─► stable (image_tag: stable) │ +│ ├─► lts (image_tag: lts) │ +│ └─► lts-hwe (image_tag: lts-hwe) │ +└─────────────────────────────────────────────────────────────┘ +``` -# Build Bluefin LTS ISO -just iso-sd-boot bluefin-lts +### Key Features +- **Strict ISO Scoping:** Each workflow builds ONLY its designated ISOs — no cross-contamination + - `build-iso-lts.yml` → **LTS ISOs only** — currently DISABLED (Anaconda broken on LTS) + - `build-iso-lts-hwe.yml` → **LTS-HWE ISOs only** + - `build-iso-stable.yml` → **Stable ISOs only** +- **Independent Execution:** Each workflow can run independently +- **Flexible Upload:** Control artifact and R2 uploads per execution +- **Testing tags:** LTS and LTS-HWE callers accept `image_tag` input to select `-testing` variants +- **Monthly schedule:** Stable and LTS-HWE run at 2am UTC on the 1st of every month + +## ISO Variants + +The following ISO variants are built: + +### Standard Releases +- **Stable** - Current stable release + +### LTS Releases +- **LTS** - Long-term support based on CentOS Stream +- **LTS-HWE** - LTS with hardware enablement kernel + +Each variant supports multiple flavors: +- `main` - Standard Bluefin +- `nvidia-open` - With NVIDIA open drivers (Stable only) +- `gdx` - Bluefin DX for developers (LTS only) + +## Building ISOs + +ISOs are built automatically via GitHub Actions workflows. Each variant has its own dedicated workflow that builds **only its specific ISOs**. + +### Workflow Separation (Important!) + +Each workflow is **strictly scoped** to build only its designated ISO variant: + +| Workflow File | Builds | Does NOT Build | +|---------------|--------|----------------| +| `build-iso-lts.yml` | **4 LTS ISOs only** (DISABLED — no schedule)
- amd64 × main
- amd64 × gdx
- arm64 × main
- arm64 × gdx | ❌ Stable
❌ LTS-HWE | +| `build-iso-lts-hwe.yml` | **2 LTS-HWE ISOs only** (production tags)
- amd64 × main
- arm64 × main | ❌ Stable
❌ LTS
❌ Testing tags | +| `build-iso-lts-hwe-testing.yml` | **2 LTS-HWE testing ISOs only** (weekly schedule)
- amd64 × main (lts-hwe-testing)
- arm64 × main (lts-hwe-testing) | ❌ Stable
❌ Production tags | +| `build-iso-stable.yml` | **2 Stable ISOs only**
- amd64 × main
- amd64 × nvidia-open | ❌ LTS
❌ LTS-HWE | +| `build-iso-all.yml` | All 8 production ISOs (calls reusable workflow directly) | ❌ Testing tags | + +This strict separation ensures: +- ✅ Predictable builds: You know exactly which ISOs each workflow produces +- ✅ Faster iterations: Build only the variants you need +- ✅ Easier debugging: Issues are isolated to specific variants +- ✅ Resource efficiency: No unnecessary builds + +### Manual Build +Trigger individual workflow dispatches for specific variants: +1. Go to Actions +2. Select a workflow: + - "Build LTS ISOs" - for LTS variant + - "Build LTS-HWE ISOs" - for LTS-HWE variant + - "Build Stable ISOs" - for Stable variant + - "Build All ISOs" - to build all variants +3. Click "Run workflow" +4. Choose upload options: + - `upload_artifacts` - Upload ISOs as job artifacts (default: false) + - `upload_r2` - Upload ISOs to CloudFlare R2 (default: true) + +### Automatic Build +ISOs are built automatically: +- **Monthly schedule:** Stable and LTS-HWE run at 2am UTC on the 1st of every month +- **LTS:** No automatic schedule — see LTS disabled warning above +- **On changes:** When ISO configuration files are modified (via pull requests) + +## Repository Structure -# Override output directory -just output_dir=/var/data/iso-output iso-sd-boot bluefin +``` +. +├── .github/workflows/ +│ ├── build-iso-stable.yml # Caller: Stable ISOs +│ ├── build-iso-lts.yml # Caller: LTS ISOs (DISABLED) +│ ├── build-iso-lts-hwe.yml # Caller: LTS-HWE ISOs +│ ├── build-iso-all.yml # Orchestrator (workflow_dispatch only) +│ ├── reusable-build-iso-anaconda.yml # Core build logic +│ ├── promote-iso.yml # Promote testing → production +│ ├── pull-request.yml # PR check builds (no upload) +│ └── validate-renovate.yml # Validate Renovate config +├── iso_files/ +│ ├── configure_iso_anaconda.sh # Hook script for Stable ISOs +│ └── configure_lts_iso_anaconda.sh # Hook script for LTS/LTS-HWE ISOs +├── hack/ +│ └── local-iso-build.sh # Local development build script +├── just/ +│ ├── bluefin-apps.just # Application management recipes +│ └── bluefin-system.just # System management recipes +├── Justfile # Build automation +└── AGENTS.md # Agent instructions ``` -Output: `output/-live.iso` +## Configuration Files -### Build stages +### ISO Configuration Scripts +- `iso_files/configure_iso_anaconda.sh` - Configures the live environment and Anaconda installer for Stable releases +- `iso_files/configure_lts_iso_anaconda.sh` - Configures the live environment and Anaconda installer for LTS/LTS-HWE releases -```bash -just container bluefin # Build the live environment container -just iso-builder bluefin # Build the ISO assembly toolchain container -just iso-sd-boot bluefin # Full end-to-end build -``` +### Flatpak Lists +Flatpaks are **not stored in this repo**. The build workflow clones +[projectbluefin/common](https://github.com/projectbluefin/common) at build time +and parses all `*system-flatpaks.Brewfile` files to generate the installer list. -### Debug builds (SSH enabled) +For downstream forks, update the git clone URL in the "Generate titanoboa-compatible +file list" step of `reusable-build-iso-anaconda.yml`. -```bash -just debug=1 iso-sd-boot bluefin -# SSH: liveuser@ password: live -``` +## Development -## Testing +### Prerequisites +- Just command runner +- Podman or Docker +- Pre-commit +### Pre-installation Checks (End Users) + +> **⚠️ Intel RST / Optane** — If the installer cannot detect your hard drive, +you may have Intel Rapid Storage Technology (RST) or Optane enabled in your +BIOS. This affects all Fedora-based installers (including Silverblue). +Disable RST/Optane in your BIOS/UEFI settings before installing. +See [#49](https://github.com/projectbluefin/iso/issues/49) for details. + +### Validation ```bash -# Boot ISO in QEMU serial console (headless) -just boot-iso-serial bluefin +# Validate all files +pre-commit run --all-files + +# Check Just syntax +just check + +# Fix formatting +just fix +``` -# Boot in libvirt with SSH access -just debug=1 boot-libvirt-debug bluefin +### Local ISO Build +```bash +# Build an ISO locally +just build-iso bluefin stable main -# Full LUKS E2E test (build + install + reboot + unlock) -just debug=1 e2e bluefin +# Build using GHCR image +just build-iso-ghcr bluefin stable main ``` -## Installer configuration +## Output + +Built ISOs are uploaded to: +- CloudFlare R2 `testing` bucket (for automatic builds) +- GitHub Actions artifacts (when `upload_artifacts: true`) +- GitHub prereleases — torrent files are generated for each ISO and attached + to a prerelease (`YY.MM[.N]`) automatically after every successful build + +ISO naming format: `{image-name}-{version}-{arch}.iso` -The installer is pre-configured for Bluefin. Configuration lives in `src/etc/bootc-installer/`: +Example: `bluefin-stable-x86_64.iso` -| File | Purpose | -|---|---| -| `images.json` | Locks the image catalog to Bluefin (`grub2` bootloader, `btrfs` filesystem, ostree backend) | -| `recipe.json` | Sets distro branding, tour slides, and install steps | +## ISO Release Pipeline -## Repository structure +The repository uses a two-stage release pipeline with testing and production buckets: ``` -. -├── bluefin/ # Bluefin variant (payload_ref) -├── bluefin-lts/ # Bluefin LTS variant (payload_ref) -├── Containerfile # 3-stage live environment build -├── Containerfile.builder # Debian ISO assembly toolchain -├── src/ -│ ├── build-iso.sh # ISO assembly script -│ ├── configure-live.sh # Live environment setup -│ ├── install-flatpaks.sh # Flatpak pre-installation -│ ├── flatpaks # Flatpak app list -│ ├── luks-unlock.py # LUKS passphrase automation -│ ├── show-screenshot.sh # Terminal screenshot display -│ ├── dracut/ # dmsquash-live initramfs modules -│ ├── etc/bootc-installer/ # Installer configs -│ ├── icons/ # Bluefin icon theme -│ └── images/ # Installer tour images -├── justfile # Build automation -└── .github/workflows/ # CI workflows - ├── build-iso.yml # Daily ISO builds - └── test-luks-install.yml # LUKS E2E validation +┌─────────────────────────────────────────────────────────────┐ +│ ISO Build Workflows │ +│ (build-iso-lts, stable, lts-hwe) │ +└───────────────────────────┬─────────────────────────────────┘ + │ + ▼ + ┌───────────────┐ + │ Testing │ + │ Bucket │ ← Automatic builds + │ (testing) │ + └───────┬───────┘ + │ + │ Manual promotion + │ with variant selection + ▼ + ┌───────────────────────┐ + │ Promote ISOs to │ + │ Production Workflow │ + └───────────┬───────────┘ + │ + ▼ + ┌───────────────┐ + │ Production │ + │ Bucket │ ← Controlled release + │ (bluefin) │ + └───────────────┘ ``` -## Adding a new variant +### Promoting ISOs to Production + +The `promote-iso.yml` workflow allows controlled promotion of ISOs from testing to production. -Each variant is a directory containing a single file — `payload_ref` — with the OCI image reference: +#### When to Promote + +- After verifying ISOs in the testing bucket +- When ready to release specific variants to users +- Before announcing new ISO availability + +#### Promotion Workflow Steps + +**Step 1: Preview Changes (Dry Run)** + +1. Navigate to **Actions → Promote ISOs to Production** +2. Click **"Run workflow"** +3. Configure inputs: + - **variant**: Select which ISOs to promote: + - `stable` - Promotes Stable ISOs only + - `lts` - Promotes LTS, LTS-HWE, and GDX ISOs only (currently unsafe — see LTS warning) + - `lts-hwe` - Promotes LTS-HWE ISOs only (excludes testing ISOs) + - **dry_run**: ✅ Keep checked (default: `true`) +4. Click **"Run workflow"** +5. Review the workflow output to see what files would be promoted + +**Step 2: Execute Promotion** + +1. After verifying the dry run output looks correct +2. Run the workflow again with same settings +3. Configure inputs: + - **variant**: Same selection as dry run + - **dry_run**: ❌ Uncheck (set to `false`) +4. Click **"Run workflow"** +5. ISOs will be copied from `testing` to `prodtest` bucket +6. Verify the promotion in the workflow output + +#### Variant Selection Details + +> ⚠️ **LTS is currently broken.** Do NOT promote with `variant: lts` or `variant: all` +> — both patterns match `*-lts-*.iso*` files and will overwrite working production +> LTS ISOs with broken builds. Only `variant: stable` is safe. + +| Variant | ISOs Promoted | Use Case | +|---------|--------------|----------| +| **stable** | • Stable ISOs (`*-stable-*.iso*`) | Regular stable release cycle | +| **lts** | • LTS ISOs (`*-lts-*.iso*`)
• LTS-HWE ISOs (`*-lts-hwe-*.iso*`)
• GDX ISOs (`*-dx-lts-*.iso*`) | LTS release cycle (currently unsafe — see above) | +| **lts-hwe** | • LTS-HWE ISOs (`*-lts-hwe-*.iso*`, excludes testing) | LTS-HWE-only release | + +#### Important Notes + +- **Dry run is enabled by default** - Always preview before promoting +- **rclone sync is used** - Files in testing will mirror to production: + - New files are copied + - Updated files are replaced + - Files not in testing (matching the filter) are removed from production +- **Selective promotion** - Promote stable and LTS independently +- **Checksums included** - `.iso-CHECKSUM` files are automatically included + +#### Example Workflow ```bash -mkdir my-variant -echo 'ghcr.io/ublue-os/my-image:latest' > my-variant/payload_ref -just iso-sd-boot my-variant +# Scenario: Releasing new Stable ISOs + +# 1. Verify ISOs built successfully in testing bucket +# 2. Run promotion workflow: +# - variant: stable +# - dry_run: true +# 3. Review output - confirm Stable ISOs will be promoted +# 4. Run again: +# - variant: stable +# - dry_run: false +# 5. ISOs are now in production bucket +# 6. Announce availability to users ``` -## CI +## Contributing -- **build-iso.yml**: Daily builds of Bluefin and Bluefin LTS ISOs at 03:00 UTC. Uploads to Cloudflare R2. -- **test-luks-install.yml**: Weekly LUKS encrypted install end-to-end test (Monday 04:00 UTC). Posts screenshots to PR comments. +Contributions are welcome! Please ensure: +1. Pre-commit checks pass +2. Just syntax is valid +3. Flatpak lists are properly validated +4. Follow conventional commits ## License See main [Bluefin repository](https://github.com/ublue-os/bluefin) for license information. -## Related projects +## Troubleshooting + +### Drive not detected during install + +If the installer does not show your internal drive (`lsblk` also shows nothing), +you may have **Intel Rapid Storage Technology (RST)** — also called "Optane" — +enabled in your BIOS/UEFI. RST puts the SATA controller into RAID mode, hiding +drives from the standard AHCI driver that Linux uses. + +This affects all Linux distributions, not just Bluefin. + +**Fix:** Enter your BIOS/UEFI setup (usually F2, Del, or F12 during boot) and +look for SATA Operation or Storage Controller settings. Switch from +"RAID" / "RST with Optane" to **"AHCI."** + +> ⚠️ Changing this setting on a dual-boot system will prevent Windows from +> booting until you reinstall or reconfigure the Windows storage driver. + +After switching to AHCI, reboot and the installer should detect your drive. + +## Related Projects -- [Bluefin](https://github.com/ublue-os/bluefin) — Main Bluefin image repository -- [Bluefin LTS](https://github.com/ublue-os/bluefin-lts) — Long-term support variant -- [bootc-installer](https://github.com/projectbluefin/bootc-installer) — Installer Flatpak +- [Bluefin](https://github.com/ublue-os/bluefin) - Main Bluefin image repository +- [Bluefin LTS](https://github.com/ublue-os/bluefin-lts) - Long-term support variant +- [Bluefin Documentation](https://github.com/ublue-os/bluefin-docs) - User documentation +- [Titanoboa](https://github.com/ublue-os/titanoboa) - ISO builder tool diff --git a/bluefin-lts/payload_ref b/bluefin-lts/payload_ref deleted file mode 100644 index 2cda6ef..0000000 --- a/bluefin-lts/payload_ref +++ /dev/null @@ -1 +0,0 @@ -ghcr.io/ublue-os/bluefin:lts diff --git a/bluefin/payload_ref b/bluefin/payload_ref deleted file mode 100644 index f59758c..0000000 --- a/bluefin/payload_ref +++ /dev/null @@ -1 +0,0 @@ -ghcr.io/ublue-os/bluefin:stable diff --git a/hack/local-iso-build.sh b/hack/local-iso-build.sh new file mode 100755 index 0000000..c35096a --- /dev/null +++ b/hack/local-iso-build.sh @@ -0,0 +1,168 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Script to build Bluefin LTS images using the Titanoboa builder +# Usage: local-iso-build.sh [hook_script] [flatpaks_file] +# flavor: base, dx, gdx +# repo: local, ghcr +# hook_script: optional post_rootfs hook script (default: iso_files/configure_lts_iso_anaconda.sh) +# flatpaks_file: optional flatpaks list (default: flatpaks/system-flatpaks.list or empty if missing) + +GITHUB_REPOSITORY_OWNER="${GITHUB_REPOSITORY_OWNER:-ublue-os}" +IMAGE_NAME="${IMAGE_NAME:-bluefin}" + +# Resolve repo root (assuming script is in hack/) +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +variant="${1:-lts}" +flavor="${2:-base}" +repo="${3:-ghcr}" + +if [ "$variant" == "lts" ]; then + IMAGE_DISTRO="centos" + DEFAULT_HOOK="$REPO_ROOT/iso_files/configure_lts_iso_anaconda.sh" +elif [ "$variant" == "bluefin" ]; then + IMAGE_DISTRO="fedora" + DEFAULT_HOOK="$REPO_ROOT/iso_files/configure_iso_anaconda.sh" +else + echo "Error: Unknown variant '$variant'. Supported variants: lts, bluefin" + exit 1 +fi + +hook_script="${4:-$DEFAULT_HOOK}" +flatpaks_source="${5:-https://raw.githubusercontent.com/projectbluefin/common/refs/heads/main/system_files/bluefin/usr/share/ublue-os/homebrew/system-flatpaks.Brewfile}" + +# Verify hook script exists +if [ ! -f "$hook_script" ]; then + echo "Error: Hook script not found at $hook_script" + exit 1 +fi + +BUILD_DIR="$REPO_ROOT/.build/${variant}-${flavor}" + +# Construct the image URI +if [ "$flavor" != "base" ]; then + FLAVOR_SUFFIX="-$flavor" +else + FLAVOR_SUFFIX="" +fi + +# Map variant name to image tag +if [ "$variant" = "bluefin" ]; then + IMAGE_TAG="stable" +else + IMAGE_TAG="$variant" +fi + +if [ "$repo" = "ghcr" ]; then + TARGET_IMAGE_NAME="ghcr.io/${GITHUB_REPOSITORY_OWNER}/${IMAGE_NAME}:${IMAGE_TAG}${FLAVOR_SUFFIX}" +elif [ "$repo" = "local" ]; then + TARGET_IMAGE_NAME="localhost/${IMAGE_NAME}:${variant}${FLAVOR_SUFFIX}" +else + echo "Unknown repo: $repo. Use 'local' or 'ghcr'" >&2 + exit 1 +fi + +echo -e "\n\033[1;36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\033[0m" +echo -e "\033[1;33m Building with Titanoboa\033[0m" +echo -e "\033[1;36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\033[0m" +echo -e " \033[1;32mVariant:\033[0m $variant" +echo -e " \033[1;32mFlavor:\033[0m $flavor" +echo -e " \033[1;32mRepo:\033[0m $repo" +echo -e " \033[1;32mImage Distro:\033[0m $IMAGE_DISTRO" +echo -e " \033[1;32mImage Name:\033[0m $TARGET_IMAGE_NAME" +echo -e " \033[1;32mHook Script:\033[0m $hook_script" +echo -e " \033[1;32mFlatpaks Source:\033[0m $flatpaks_source" +echo -e "\033[1;36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\033[0m\n" + +# Clone or update Titanoboa +if [ ! -f "$BUILD_DIR/Justfile" ]; then + echo "Fetching Titanoboa..." + # Clone to temp then copy files (BUILD_DIR may have root-owned work/ from previous runs) + git clone https://github.com/hanthor/titanoboa "/tmp/titanoboa-fresh-$$" + mkdir -p "$BUILD_DIR" + rsync -a --exclude='work/' "/tmp/titanoboa-fresh-$$/" "$BUILD_DIR/" + rm -rf "/tmp/titanoboa-fresh-$$" +fi +# Clean work dir from previous build using Titanoboa's own clean target +if [ -d "$BUILD_DIR/work" ]; then + echo "Cleaning previous work dir via privileged container..." + sudo /usr/bin/podman run --rm --privileged \ + -v "$BUILD_DIR/work:/work" \ + alpine sh -c 'rm -rf /work/*' 2>/dev/null || true + rm -rf "$BUILD_DIR/work" 2>/dev/null || true +fi + +# Handle flatpaks file +echo "Setting up flatpaks list..." +if [ -f "$flatpaks_source" ]; then + echo "Using local flatpaks file: $flatpaks_source" + cp "$flatpaks_source" "$BUILD_DIR/flatpaks.list" +elif [[ "$flatpaks_source" =~ ^https?:// ]]; then + echo "Fetching flatpaks from URL: $flatpaks_source" + if curl -sL "$flatpaks_source" -o "$BUILD_DIR/flatpaks.raw"; then + # Check if it's a Brewfile and parse it + if grep -q '^flatpak "' "$BUILD_DIR/flatpaks.raw"; then + echo "Detected Brewfile format, parsing..." + grep '^flatpak ' "$BUILD_DIR/flatpaks.raw" | awk -F'"' '{print $2}' > "$BUILD_DIR/flatpaks.list" + else + mv "$BUILD_DIR/flatpaks.raw" "$BUILD_DIR/flatpaks.list" + fi + else + echo "Warning: Failed to fetch flatpaks list, creating empty list." + touch "$BUILD_DIR/flatpaks.list" + fi +else + echo "Warning: Flatpaks source '$flatpaks_source' not found, creating empty list." + touch "$BUILD_DIR/flatpaks.list" +fi + + + +# Patch Titanoboa Justfile to ignore setfiles errors (workaround for smartmontools/FS issues) +echo "Patching Titanoboa Justfile to ignore setfiles errors..." +sed -i 's/setfiles -F -r . \/etc\/selinux\/targeted\/contexts\/files\/file_contexts ./setfiles -F -r . \/etc\/selinux\/targeted\/contexts\/files\/file_contexts . || true/' "$BUILD_DIR/Justfile" + +# Patch Titanoboa Justfile to ensure builder has device access (fix loop mount) +echo "Patching Titanoboa Justfile to add --device /dev/fuse to builder..." +sed -i 's/--security-opt label=disable/--security-opt label=disable --device \/dev\/fuse/' "$BUILD_DIR/Justfile" + +# Patch out root check so we can build without sudo +echo "Patching Titanoboa Justfile to remove root check..." +sed -i "s/if \[ \`id -u\` -gt 0 \]; then echo.*Must be root.*exit 1; fi/echo 'Skipping root check'/" "$BUILD_DIR/Justfile" + +# Patch clean recipe to handle root-owned overlay files via privileged podman +echo "Patching Titanoboa clean recipe to handle root-owned files..." +sed -i '/^@clean:/,/^[^ @]/{s|rm -rf {{ absolute_path(workdir) }}|{{ PODMAN }} run --rm --privileged -v {{ absolute_path(workdir) }}:/work alpine sh -c \x27rm -rf /work/*\x27 2>/dev/null \|\| true \&\& rm -rf {{ absolute_path(workdir) }} 2>/dev/null \|\| true|}' "$BUILD_DIR/Justfile" + +echo "Copying hook script to $BUILD_DIR directory..." +cp "$hook_script" "$BUILD_DIR/hook.sh" + +# Change to the $BUILD_DIR directory +cd "$BUILD_DIR" + +# Run the Titanoboa build command +# Titanoboa needs root podman for loop device access during ISO creation +echo "Running Titanoboa build..." +export PODMAN="sudo /usr/bin/podman" +TITANOBOA_BUILDER_DISTRO="$IMAGE_DISTRO" \ + HOOK_post_rootfs="hook.sh" \ + just PODMAN="sudo /usr/bin/podman" build "$TARGET_IMAGE_NAME" 1 flatpaks.list || true + +echo "Titanoboa build process finished." + +# Locate and Move ISO +ISO_PATH="$BUILD_DIR/output.iso" +if [ -f "$ISO_PATH" ]; then + TIMESTAMP="$(date +%Y%m%d)" + OUTPUT_NAME="${IMAGE_NAME}-${variant}${FLAVOR_SUFFIX}-${TIMESTAMP}.iso" + + echo "Copying ISO to $REPO_ROOT/$OUTPUT_NAME..." + cp "$ISO_PATH" "$REPO_ROOT/$OUTPUT_NAME" + + echo -e "\n\033[1;32mSUCCESS: ISO available at: $REPO_ROOT/$OUTPUT_NAME\033[0m" +else + echo "Error: Output ISO not found at $ISO_PATH" + exit 1 +fi diff --git a/iso_files/configure_iso_anaconda.sh b/iso_files/configure_iso_anaconda.sh new file mode 100644 index 0000000..504bd0d --- /dev/null +++ b/iso_files/configure_iso_anaconda.sh @@ -0,0 +1,196 @@ +#!/usr/bin/env bash + +set -eoux pipefail + +IMAGE_INFO="$(cat /usr/share/ublue-os/image-info.json)" +IMAGE_TAG="$(jq -c -r '."image-tag"' <<<"$IMAGE_INFO")" +IMAGE_REF="$(jq -c -r '."image-ref"' <<<"$IMAGE_INFO")" +IMAGE_REF="${IMAGE_REF##*://}" +sbkey='https://github.com/ublue-os/akmods/raw/main/certs/public_key.der' + +# Configure Live Environment + +# Setup dock +tee /usr/share/glib-2.0/schemas/zz2-org.gnome.shell.gschema.override <= F42 +SPECS=( + "libblockdev-btrfs" + "libblockdev-lvm" + "libblockdev-dm" + "anaconda-live" + "firefox" +) + +dnf install -y "${SPECS[@]}" + +# Anaconda Profile Detection + +# Bluefin +tee /etc/anaconda/profile.d/bluefin.conf <<'EOF' +# Anaconda configuration file for Bluefin + +[Profile] +# Define the profile. +profile_id = bluefin + +[Profile Detection] +# Match os-release values +os_id = bluefin + +[Network] +default_on_boot = FIRST_WIRED_WITH_LINK + +[Bootloader] +efi_dir = fedora +menu_auto_hide = True + +[Storage] +default_scheme = BTRFS +btrfs_compression = zstd:1 +default_partitioning = + / (min 1 GiB, max 70 GiB) + /home (min 500 MiB, free 50 GiB) + /var (btrfs) + +[User Interface] +custom_stylesheet = /usr/share/anaconda/pixmaps/silverblue/fedora-silverblue.css +webui_web_engine = slitherer +hidden_spokes = + NetworkSpoke + PasswordSpoke + UserSpoke +hidden_webui_pages = + anaconda-screen-accounts + +[Localization] +use_geolocation = False +EOF + +if [[ "${IMAGE_TAG}" =~ lts ]]; then + sed -i 's/^ID=.*/ID=bluefin/' /usr/lib/os-release + echo "VARIANT_ID=bluefin" >>/usr/lib/os-release +fi + +# Configure +. /etc/os-release +echo "Bluefin release $VERSION_ID ($VERSION_CODENAME)" >/etc/system-release +sed -i 's/ANACONDA_PRODUCTVERSION=.*/ANACONDA_PRODUCTVERSION=""/' /usr/{,s}bin/liveinst || true +sed -i 's|^Icon=.*|Icon=/usr/share/pixmaps/fedora-logo-icon.png|' /usr/share/applications/liveinst.desktop || true +sed -i 's| Fedora| Bluefin|' /usr/share/anaconda/gnome/fedora-welcome || true +sed -i 's|Activities|in the dock|' /usr/share/anaconda/gnome/fedora-welcome || true + +# Get Artwork +git clone --depth=1 https://github.com/projectbluefin/branding.git /tmp/branding +mkdir -p /usr/share/anaconda/pixmaps/silverblue +cp -r /tmp/branding/anaconda/* /usr/share/anaconda/pixmaps/silverblue/ +rm -rf /tmp/branding + +# Interactive Kickstart +tee -a /usr/share/anaconda/interactive-defaults.ks <= F42 +SPECS=( + "libblockdev" + "libblockdev-lvm" + "libblockdev-dm" + "anaconda" + "anaconda-live" + "anaconda-webui" + "anaconda-webui" + "firefox" + "openssh-server" +) + +dnf copr enable -y jreilly1821/anaconda-webui + +dnf install -y --nobest --allowerasing "${SPECS[@]}" + +rpm --erase --nodeps --justdb centos-logos + +# Fix the wrong dir for webui +sed -i 's|/usr/libexec/webui-desktop|/usr/libexec/anaconda/webui-desktop|g' /bin/liveinst + +# HOTFIX: Fix Blivet/Dasbus import error in Anaconda Storage Module. We need to bump Blivet +sed -i "s/from blivet.safe_dbus import SafeDBusError/from dasbus.error import DBusError as SafeDBusError/g" /usr/lib64/python3.12/site-packages/pyanaconda/modules/storage/iscsi/discover.py + + +# Anaconda Profile Detection + +# Bluefin +tee /etc/anaconda/profile.d/bluefin-lts.conf <<'EOF' +# Anaconda configuration file for Bluefin LTS + +[Profile] +# Define the profile. +profile_id = bluefin + +[Profile Detection] +# Match os-release values +os_id = bluefin-lts + +[Network] +default_on_boot = FIRST_WIRED_WITH_LINK + +[Bootloader] +efi_dir = centos +menu_auto_hide = True + +[Storage] +file_system_type = xfs +default_partitioning = + / (min 5 GiB, max 70 GiB) + /var (min 5 GiB) + +[User Interface] +custom_stylesheet = /usr/share/anaconda/pixmaps/silverblue/fedora-silverblue.css +hidden_spokes = + NetworkSpoke + PasswordSpoke + UserSpoke +hidden_webui_pages = + anaconda-screen-accounts + +[Localization] +use_geolocation = False +EOF + +sed -i 's/^ID=.*/ID=bluefin-lts/' /usr/lib/os-release +echo "VARIANT_ID=bluefin-lts" >>/usr/lib/os-release + +# Configure +. /etc/os-release +# if [[ "$IMAGE_TAG" =~ gts ]]; then +# echo "Bluefin ${IMAGE_TAG^^} release $VERSION_ID (${VERSION_CODENAME:=Big Bird})" >/etc/system-release +# else +echo "Bluefin release $VERSION_ID Achillobator" >/etc/system-release +sed -i 's/ANACONDA_PRODUCTVERSION=.*/ANACONDA_PRODUCTVERSION=""/' /usr/{,s}bin/liveinst || true +sed -i 's|^Icon=.*|Icon=/usr/share/pixmaps/fedora-logo-icon.png|' /usr/share/applications/liveinst.desktop || true +sed -i 's| Fedora| Bluefin|' /usr/share/anaconda/gnome/fedora-welcome || true +sed -i 's|Activities|in the dock|' /usr/share/anaconda/gnome/fedora-welcome || true + +# Get Artwork +git clone --depth=1 https://github.com/projectbluefin/branding.git /tmp/branding +mkdir -p /usr/share/anaconda/pixmaps/silverblue +cp -r /tmp/branding/anaconda/* /usr/share/anaconda/pixmaps/silverblue/ +rm -rf /tmp/branding + +# Interactive Kickstart +tee -a /usr/share/anaconda/interactive-defaults.ks < $HOME/.config/systemd/user/opentabletdriver.service && \ + systemctl --user daemon-reload && \ + systemctl enable --user --now opentabletdriver.service + elif [[ "${OPTION,,}" =~ ^uninstall ]]; then + echo "Uninstalling OpenTabletDriver..." + pkexec rm /etc/udev/rules.d/71-opentabletdriver.rules && \ + flatpak --system remove -y flathub net.opentabletdriver.OpenTabletDriver + else + echo "Have a good day :)!" + fi diff --git a/just/bluefin-system.just b/just/bluefin-system.just new file mode 100644 index 0000000..7a8b045 --- /dev/null +++ b/just/bluefin-system.just @@ -0,0 +1,233 @@ +# vim: set ft=make : +######################## +### bluefin-system.just +######################## +## Standardized verbs +# configure- = configure something that is pre-installed on the image +# install- = install something, no uninstall or configuration provided +# setup- = install something and also provide configuration and/or uninstallation options +# toggle- = turn something on/off, logic can be automatic or manual selection +# fix- = apply fix/patch/workaround for something +# foo = no verb is used for shortcuts or something deemed important enough to use a super memorable name + +# Run a one minute system benchmark +[group('System')] +benchmark: + #!/usr/bin/env bash + source /usr/lib/ujust/ujust.sh + if ! type -P "stress-ng" &>/dev/null ; then + if gum confirm "Stress does not seem to be on your path, do you wish to install it?" ; then + set -eu + brew install stress-ng + brew link stress-ng + set +eu + else + exit 0 + fi + fi + + echo 'Running a 1 minute benchmark ...' + trap popd EXIT + pushd $(mktemp -d) + stress-ng --matrix 0 -t 1m --times + +# Configure Bluefin-CLI Terminal Experience with Brew +[group('System')] +bluefin-cli: + @/usr/libexec/ublue-bling + +# alias for toggle-devmode +devmode: + @ujust toggle-devmode + +# Toggle between Bluefin and the Developer Experience +[group('System')] +toggle-devmode: + #!/usr/bin/env bash + source /usr/lib/ujust/ujust.sh + CURRENT_IMAGE=$(rpm-ostree status -b --json | jq -r '.deployments[0]."container-image-reference"') + if grep -q "/var/ublue-os/image" <<< $CURRENT_IMAGE ; then + bash -c "cat < /dev/null + fi + } + + GROUPS_ADD=("docker" "incus-admin" "libvirt" "dialout") + + for GROUP_ADD in "${GROUPS_ADD[@]}" ; do + append_group $GROUP_ADD + usermod -aG $GROUP_ADD {{ `id -un` }} + done + + echo "Reboot system and log back in to use docker, libvirt, incus, and serial connections." + +# Install system flatpaks for rebasers +[group('System')] +install-system-flatpaks $dx="dynamic": + #!/usr/bin/bash + TARGET_FLATPAK_FILE="${TARGET_FLATPAK_FILE:-/etc/ublue-os/system-flatpaks.list}" + TARGET_DEVMODE_FILE="${TARGET_DEVMODE_FILE:-/etc/ublue-os/system-flatpaks-dx.list}" + case "$dx" in + "0"|"1") + ADD_DEVMODE="$dx" + ;; + "dynamic") + if [[ $(jq '."image-flavor"' /usr/share/ublue-os/image-info.json) =~ dx ]] ; then + ADD_DEVMODE=1 + fi + ;; + *) + echo "Unsupported option" + exit 1 + ;; + esac + + flatpak remote-add --if-not-exists --system flathub https://flathub.org/repo/flathub.flatpakrepo + xargs flatpak --system -y install --or-update < $TARGET_FLATPAK_FILE + if [ "$ADD_DEVMODE" == "1" ] ; then + xargs flatpak --system -y install --or-update < $TARGET_DEVMODE_FILE + fi + +# Install extra system flatpaks for rebasers +[group('System')] +install-system-flatpaks-extra: + #!/usr/bin/bash + TARGET_FLATPAK_EXTRA_FILE="${TARGET_FLATPAK_EXTRA_FILE:-/etc/ublue-os/system-flatpaks-extra.list}" + flatpak remote-add --if-not-exists --system flathub https://flathub.org/repo/flathub.flatpakrepo + xargs flatpak --system -y install --or-update < $TARGET_FLATPAK_EXTRA_FILE + +# Alias to install both system flatpaks and extra flatpaks +[group('System')] +bluefin-apps: + #!/usr/bin/env bash + echo "Installing default system flatpaks..." + just install-system-flatpaks + echo "Installing some extra awesome applications..." + just install-system-flatpaks-extra + +# Install Brewfile bundles +[group('System')] +bluefin-ai: + brew bundle --file /usr/share/ublue-os/homebrew/bluefin-ai.Brewfile + +[group('System')] +bluefin-fonts: + brew bundle --file /usr/share/ublue-os/homebrew/bluefin-fonts.Brewfile + +[group('System')] +bluefin-k8s: + brew bundle --file /usr/share/ublue-os/homebrew/bluefin-k8s.Brewfile + +# Configure grub bootmenu visibility +[group('System')] +configure-grub: + @/usr/libexec/configure-grub.sh + +alias switch-stream := rebase-helper +alias switch-streams := rebase-helper +alias rollback-helper := rebase-helper + +# Rebase assistant +[group('System')] +rebase-helper: + @/usr/bin/ublue-rollback-helper + +# Toggle IWD +[group('System')] +toggle-iwd: + #!/usr/bin/bash + echo -e "This script manages enabling or disabling iwd as a replacement for wpa_supplicant for Wi-Fi networking." + echo -e "Enabling this can improve throughput, mesh networking, and reduce latency increases when scanning for networks" + echo -e "Disabling this can improve corporate or eduroam network compatibility" + echo -e "" + echo -e "WARNING: Changing this will remove all saved wifi networks" + get_current_status() { + if [[ -f "/etc/NetworkManager/conf.d/iwd.conf" ]]; then + echo "Enabled" + else + echo "Disabled" + fi + } + remove_saved_networks() { + nmcli -t -f NAME connection show | while read -r line; do sudo nmcli connection delete "$line"; done + } + enable_iwd() { + sudo mkdir -p "/etc/NetworkManager/conf.d/" + sudo rm -f "/etc/NetworkManager/conf.d/iwd.conf" + printf "[device]\nwifi.backend=iwd" | sudo tee /etc/NetworkManager/conf.d/iwd.conf > /dev/null + remove_saved_networks + echo -e "iwd enabled. Reboot required to apply changes." + } + disable_iwd() { + sudo rm -f "/etc/NetworkManager/conf.d/iwd.conf" + remove_saved_networks + echo -e "iwd disabled. Reboot required to apply changes." + } + # Display current status + current_status=$(get_current_status) + echo -e "\nCurrent iwd status: $current_status\n" + # Prompt user for action + CHOICE=$(ugum choose "Enable iwd" "Disable iwd" "Exit without changes") + case "$CHOICE" in + "Enable iwd") + enable_iwd + ;; + "Disable iwd") + disable_iwd + ;; + "Exit without changes") + echo "No changes made." + ;; + *) + echo "Invalid choice. Exiting without changes." + ;; + esac diff --git a/justfile b/justfile deleted file mode 100644 index 7fc8e46..0000000 --- a/justfile +++ /dev/null @@ -1,777 +0,0 @@ -image-builder := "image-builder" -image-builder-dev := "image-builder-dev" - -# Output directory for built ISOs and intermediate artifacts. -# Override with: just output_dir=/your/path iso-sd-boot bluefin -output_dir := "output" - -# Working directory for ISO builds where container storage staging -# and the squashfs-root are stored. -# Override with: just workdir=/your/path iso-sd-boot bluefin -workdir := output_dir - -# Set to 1 to enable SSH in the live session for debugging. -# Never use debug=1 for production/release ISOs. -debug := "0" - -# Set to "dev" to pull the bootc-installer dev build (continuous-dev release). -installer_channel := "stable" - -# LUKS passphrase used by luks-install for testing. -luks-passphrase := "testpassphrase" - -# Squashfs compression preset: -# fast (default) — zstd level 3, 128K blocks — quick local builds/CI -# release — zstd level 15, 1M blocks — ~20% smaller, ~5× slower -compression := "fast" - -# Path to the projectbluefin/fisherman repo for building the patched fisherman binary. -fisher_repo := "../fisherman/fisherman" - -# Create an XFS loopback mount at /mnt for faster VFS import. -mount-xfs: - #!/usr/bin/bash - set -euo pipefail - if findmnt -n -o FSTYPE /mnt 2>/dev/null | grep -q '^xfs$'; then - echo "/mnt is already XFS — skipping" - exit 0 - fi - echo "Creating 45G XFS loopback at /mnt..." - IMG="/var/tmp/bluefin-xfs-loopback.img" - truncate -s 0 "${IMG}" - chattr +C "${IMG}" 2>/dev/null || true - fallocate -l 45G "${IMG}" - mkfs.xfs -f "${IMG}" - mount -o loop "${IMG}" /mnt - echo "XFS mounted at /mnt (45G)" - echo "" - echo "Now run your build with workdir on /mnt:" - echo " just workdir=/mnt iso-sd-boot bluefin" - df -h /mnt - -# Build the ISO in the background, detached from the terminal session. -build-bg target: - #!/usr/bin/bash - set -euo pipefail - mkdir -p {{ output_dir }} - LOG=$(realpath {{ output_dir }})/build.log - echo "Starting background build → ${LOG}" - setsid \ - debug={{ debug }} \ - installer_channel={{ installer_channel }} \ - output_dir={{ output_dir }} \ - compression={{ compression }} \ - just iso-sd-boot {{ target }} \ - > "${LOG}" 2>&1 & - disown $! - echo "Build PID $! — tailing log (Ctrl-C is safe, build continues)" - tail -f "${LOG}" - -# Helper: returns "--bootc-installer-payload-ref " or "" if no payload_ref file -_payload_ref_flag target: - @if [ -f "{{ target }}/payload_ref" ]; then echo "--bootc-installer-payload-ref $(cat '{{ target }}/payload_ref' | tr -d '[:space:]')"; fi - -# Map target to filesystem: bluefin=btrfs, bluefin-lts=xfs. Default=btrfs. -_filesystem_for target: - @if [ "{{ target }}" = "bluefin-lts" ]; then echo "xfs"; else echo "btrfs"; fi - -container target: - @test -f "{{ target }}/payload_ref" || { echo "ERROR: {{ target }}/payload_ref not found — create it with the base image reference, e.g.: echo 'ghcr.io/ublue-os/bluefin:stable' > {{ target }}/payload_ref"; exit 1; } - podman build --cap-add sys_admin --security-opt label=disable \ - --layers \ - --build-arg DEBUG={{ debug }} \ - --build-arg INSTALLER_CHANNEL={{ installer_channel }} \ - --build-arg BASE_IMAGE=$(cat {{ target }}/payload_ref | tr -d '[:space:]') \ - --build-arg FILESYSTEM=$(just _filesystem_for {{ target }}) \ - -t {{ target }}-installer -f ./Containerfile . - -# Build the Debian-based ISO assembly container for the given target. -iso-builder target: - podman build --security-opt label=disable -t {{ target }}-iso-builder \ - -f ./Containerfile.builder . - -# Build a UEFI live ISO for the given target using systemd-boot and dmsquash-live. -# -# Uses a two-container approach: -# 1. localhost/-installer — the live environment (3-stage Containerfile) -# 2. localhost/-iso-builder — Debian ISO assembly tools (Containerfile.builder) -# -# Output: output/-live.iso -iso-sd-boot target: - #!/usr/bin/bash - set -euo pipefail - PAYLOAD_IMAGE=$(cat "{{ target }}/payload_ref" | tr -d '[:space:]') - - mkdir -p {{ output_dir }} - OUTPUT_DIR=$(realpath "{{ output_dir }}") - WORKDIR=$(realpath "{{ workdir }}") - - echo "=== Disk space before container build ===" - df -h "${OUTPUT_DIR}" - - if ! findmnt -n -o FSTYPE -T "${WORKDIR}" 2>/dev/null | grep -qE '^(xfs|btrfs)$'; then - echo "Hint: $WORKDIR is not an XFS/BTRFS mount. For faster VFS import, run:" >&2 - echo " sudo just mount-xfs" >&2 - echo " sudo just workdir=/mnt iso-sd-boot {{ target }}" >&2 - fi - - AVAILABLE_KB=$(df --output=avail -B1024 "${OUTPUT_DIR}" | tail -1 | tr -d ' ') - REQUIRED_KB=$((20 * 1024 * 1024)) - if [ "$AVAILABLE_KB" -lt "$REQUIRED_KB" ]; then - echo "WARNING: Only $(( AVAILABLE_KB / 1024 / 1024 ))GB free on $(df --output=target "${OUTPUT_DIR}" | tail -1) — ISO output needs ~5GB, full build needs more" >&2 - fi - podman images --format "table {{{{.Repository}}}}\t{{{{.Tag}}}}\t{{{{.Size}}}}" 2>/dev/null || true - - just debug={{ debug }} installer_channel={{ installer_channel }} container {{ target }} - - echo "=== Disk space after container build ===" - df -h "${OUTPUT_DIR}" - podman images --format "table {{{{.Repository}}}}\t{{{{.Tag}}}}\t{{{{.Size}}}}" 2>/dev/null || true - - podman rmi debian:sid 2>/dev/null || true - podman image prune -f 2>/dev/null || true - echo "=== Disk space after intermediate cleanup ===" - df -h "${OUTPUT_DIR}" - - if [[ $(id -u) -eq 0 ]]; then - _ns() { bash -c "$1"; } - else - _ns() { podman unshare bash -c "$1"; } - fi - - SQUASHFS="${OUTPUT_DIR}/{{ target }}-rootfs.sfs" - BOOT_TAR="${OUTPUT_DIR}/{{ target }}-boot-files.tar" - CS_STAGING="${WORKDIR}/{{ target }}-cs-staging" - SQUASHFS_ROOT="${WORKDIR}/{{ target }}-sfs-root" - trap "rm -f '${SQUASHFS}' '${BOOT_TAR}' '${OUTPUT_DIR}/{{ target }}-payload.oci.tar' 2>/dev/null || true" EXIT - echo "=== Disk space before squashfs assembly ===" - df -h "${OUTPUT_DIR}" - if [[ "$WORKDIR" != "$OUTPUT_DIR" ]]; then - df -h "${WORKDIR}" - fi - echo "Building squashfs and boot tar from localhost/{{ target }}-installer..." - _ns " - set -euo pipefail - - SQUASHFS_ROOT='${SQUASHFS_ROOT}' - CS_STAGING='${CS_STAGING}' - OVERLAY_UPPER=\$(mktemp -d \"\${SQUASHFS_ROOT}_upper_XXXXXX\") - OVERLAY_WORK=\$(mktemp -d \"\${SQUASHFS_ROOT}_work_XXXXXX\") - - ns_cleanup() { - umount \"\${SQUASHFS_ROOT}/usr/lib/containers/storage\" 2>/dev/null || true - umount \"\${SQUASHFS_ROOT}\" 2>/dev/null || true - podman image unmount localhost/{{ target }}-installer 2>/dev/null || true - rm -rf \"\${OVERLAY_UPPER}\" \"\${OVERLAY_WORK}\" 2>/dev/null || true - rm -rf \"\${CS_STAGING}\" \"\${SQUASHFS_ROOT}\" 2>/dev/null || true - } - trap ns_cleanup EXIT - - MOUNT=\$(podman image mount localhost/{{ target }}-installer) - PATH=/usr/sbin:/usr/bin:/home/linuxbrew/.linuxbrew/bin:\$PATH - - PAYLOAD_OCI='${OUTPUT_DIR}/{{ target }}-payload.oci.tar' - SQUASHFS_STORAGE=\"\${CS_STAGING}/usr/lib/containers/storage\" - STORAGE_CONF=\"\$(mktemp '${OUTPUT_DIR}'/live-storage-XXXXXX.conf)\" - mkdir -p \"\${SQUASHFS_STORAGE}\" - printf '[storage]\ndriver = \"overlay\"\nrunroot = \"/tmp/cs-runroot\"\ngraphroot = \"/vfs-storage\"\n' \ - > \"\${STORAGE_CONF}\" - - podman save -o \"\${PAYLOAD_OCI}\" --format oci-archive '"${PAYLOAD_IMAGE}"' - - - echo 'Importing Bluefin OCI image into squashfs containers-storage...' - echo '=== Disk space before VFS import ===' - df -h '${OUTPUT_DIR}' - if [[ '$WORKDIR' != '$OUTPUT_DIR' ]]; then - df -h '${WORKDIR}' - fi - podman run --rm \ - --privileged \ - -v \"\${PAYLOAD_OCI}:/payload.oci.tar:ro\" \ - -v \"\${SQUASHFS_STORAGE}:/vfs-storage\" \ - -v \"\${STORAGE_CONF}:/tmp/st.conf:ro\" \ - localhost/{{ target }}-installer \ - sh -c 'mkdir -p /tmp/cs-runroot /var/tmp && CONTAINERS_STORAGE_CONF=/tmp/st.conf skopeo copy oci-archive:/payload.oci.tar:'"${PAYLOAD_IMAGE}"' containers-storage:'"${PAYLOAD_IMAGE}"'' - - rm -f \"\${PAYLOAD_OCI}\" \"\${STORAGE_CONF}\" - - echo '=== Disk space after VFS import ===' - df -h '${OUTPUT_DIR}' - if [[ '$WORKDIR' != '$OUTPUT_DIR' ]]; then - df -h '${WORKDIR}' - fi - du -sh \"\${CS_STAGING}\" 2>/dev/null || true - - echo 'Building unified squashfs source tree using bind mounts...' - mkdir -p \"\${SQUASHFS_ROOT}\" - - FS_TYPE=\$(findmnt -n -o FSTYPE -T \"\${SQUASHFS_ROOT}\" 2>/dev/null || echo \"unknown\") - if [[ \"\${FS_TYPE}\" == \"xfs\" || \"\${FS_TYPE}\" == \"ext4\" ]]; then - echo \"Filesystem is \${FS_TYPE}, trying overlay\" - if ! mount -t overlay overlay \ - -o lowerdir=\"\${MOUNT}\",upperdir=\"\${OVERLAY_UPPER}\",workdir=\"\${OVERLAY_WORK}\" \"\${SQUASHFS_ROOT}\"; then - echo \"Overlay mount failed on \${FS_TYPE}; falling back to cp -a\" - cp -a \"\${MOUNT}/.\" \"\${SQUASHFS_ROOT}/\" - fi - else - echo \"Filesystem is \${FS_TYPE}, doing it the boring way\" - cp -a \"\${MOUNT}/.\" \"\${SQUASHFS_ROOT}/\" - fi - - mkdir -p \"\${SQUASHFS_ROOT}/usr/lib/containers/storage\" - mount --bind \"\${CS_STAGING}/usr/lib/containers/storage\" \"\${SQUASHFS_ROOT}/usr/lib/containers/storage\" - echo '=== Disk space after creation of squashfs root ===' - df -h '${OUTPUT_DIR}' - if [[ '$WORKDIR' != '$OUTPUT_DIR' ]]; then - df -h '${WORKDIR}' - fi - du -sh \"\${SQUASHFS_ROOT}\" 2>/dev/null || true - - SFS_LEVEL=3; SFS_BLOCK=131072 - [[ '{{ compression }}' == 'release' ]] && { SFS_LEVEL=15; SFS_BLOCK=1048576; } - mksquashfs \"\${SQUASHFS_ROOT}\" '${SQUASHFS}' \ - -noappend -comp zstd -Xcompression-level \${SFS_LEVEL} -b \${SFS_BLOCK} \ - -processors 4 \ - -e proc -e sys -e dev -e run -e tmp - - tar -C \"\$MOUNT\" \ - -cf '${BOOT_TAR}' \ - ./usr/lib/modules \ - ./usr/lib/systemd/boot/efi - " - - echo "=== Disk space after squashfs, before ISO assembly ===" - df -h "${OUTPUT_DIR}" - du -sh "${SQUASHFS}" "${BOOT_TAR}" 2>/dev/null || true - - TMPDIR="${OUTPUT_DIR}" \ - PATH="/usr/sbin:/usr/bin:/home/linuxbrew/.linuxbrew/bin:${PATH}" \ - bash "src/build-iso.sh" "${BOOT_TAR}" "${SQUASHFS}" "${OUTPUT_DIR}/{{ target }}-live.iso" - - echo "ISO ready: ${OUTPUT_DIR}/{{ target }}-live.iso" - -# ── QEMU and libvirt boot / LUKS testing recipes ───────────────────────────── - -# Boot a built ISO in QEMU via UEFI (OVMF) with serial console output on stdout. -boot-iso-serial target: - #!/usr/bin/bash - set -euo pipefail - QEMU=$(command -v /usr/libexec/qemu-kvm /usr/bin/qemu-kvm \ - /usr/bin/qemu-system-x86_64 \ - /home/linuxbrew/.linuxbrew/bin/qemu-system-x86_64 2>/dev/null | head -1) - [[ -z "$QEMU" ]] && { echo "qemu-kvm / qemu-system-x86_64 not found" >&2; exit 1; } - ISO=$(ls \ - {{ output_dir }}/{{ target }}-live.iso \ - output/bootiso/install.iso \ - output/bootc-{{ target }}*.iso \ - 2>/dev/null | head -1 || true) - if [[ -z "$ISO" ]]; then - echo "No ISO found for '{{ target }}' — run: just iso-sd-boot {{ target }}" >&2 - exit 1 - fi - - OVMF_CODE="" - for f in \ - /usr/share/OVMF/OVMF_CODE.fd \ - /usr/share/edk2/ovmf/OVMF_CODE.fd \ - /usr/share/edk2-ovmf/x64/OVMF_CODE.fd \ - /usr/share/ovmf/OVMF.fd \ - /home/linuxbrew/.linuxbrew/share/qemu/edk2-x86_64-code.fd \ - /home/linuxbrew/.linuxbrew/Cellar/qemu/11.0.0/share/qemu/edk2-x86_64-code.fd; do - [[ -f "$f" ]] && { OVMF_CODE="$f"; break; } - done - OVMF_VARS_SRC="" - for f in \ - /usr/share/OVMF/OVMF_VARS.fd \ - /usr/share/edk2/ovmf/OVMF_VARS.fd \ - /usr/share/edk2-ovmf/x64/OVMF_VARS.fd \ - /home/linuxbrew/.linuxbrew/share/qemu/edk2-i386-vars.fd; do - [[ -f "$f" ]] && { OVMF_VARS_SRC="$f"; break; } - done - if [[ -z "$OVMF_CODE" ]]; then - echo "OVMF firmware not found — install edk2-ovmf or ovmf" >&2 - exit 1 - fi - - OVMF_VARS=$(mktemp /tmp/OVMF_VARS.XXXXXX.fd) - [[ -n "$OVMF_VARS_SRC" ]] && cp "${OVMF_VARS_SRC}" "${OVMF_VARS}" - trap "rm -f ${OVMF_VARS}" EXIT - - echo "Booting ${ISO} via UEFI — serial console below (Ctrl-A X to quit)" - echo "SSH available on localhost:2222 (user: liveuser, password: live) if built with debug=1" - "$QEMU" \ - -machine q35 \ - -m 4096 \ - -accel kvm \ - -cpu host \ - -smp 4 \ - -drive if=pflash,format=raw,readonly=on,file="${OVMF_CODE}" \ - -drive if=pflash,format=raw,file="${OVMF_VARS}" \ - -drive if=none,id=live-disk,file="${ISO}",media=cdrom,format=raw,readonly=on \ - -device virtio-scsi-pci,id=scsi \ - -device scsi-cd,drive=live-disk \ - -net nic,model=virtio -net user,hostfwd=tcp::2222-:22 \ - -serial mon:stdio \ - -display none \ - -no-reboot - -# Boot a built ISO in libvirt with UEFI, a target install disk, and SSH via -# the default libvirt network. -boot-libvirt-debug target: - #!/usr/bin/bash - set -euo pipefail - - VM_NAME="bluefin-debug" - VM_RAM=8192 - VM_CPUS=4 - DISK_SIZE=64 - - ISO=$(ls \ - {{ output_dir }}/{{ target }}-live.iso \ - output/bootiso/install.iso \ - output/bootc-{{ target }}*.iso \ - 2>/dev/null | head -1 || true) - if [[ -z "$ISO" ]]; then - echo "No ISO found for '{{ target }}' — run: just debug=1 iso-sd-boot {{ target }}" >&2 - exit 1 - fi - - OVMF_CODE="" - for f in \ - /usr/share/OVMF/OVMF_CODE.fd \ - /usr/share/edk2/ovmf/OVMF_CODE.fd \ - /usr/share/edk2-ovmf/x64/OVMF_CODE.fd \ - /usr/share/ovmf/OVMF.fd \ - /home/linuxbrew/.linuxbrew/share/qemu/edk2-x86_64-code.fd \ - /home/linuxbrew/.linuxbrew/Cellar/qemu/11.0.0/share/qemu/edk2-x86_64-code.fd; do - [[ -f "$f" ]] && { OVMF_CODE="$f"; break; } - done - OVMF_VARS="" - for f in \ - /usr/share/OVMF/OVMF_VARS.fd \ - /usr/share/edk2/ovmf/OVMF_VARS.fd \ - /usr/share/edk2-ovmf/x64/OVMF_VARS.fd \ - /home/linuxbrew/.linuxbrew/share/qemu/edk2-i386-vars.fd; do - [[ -f "$f" ]] && { OVMF_VARS="$f"; break; } - done - if [[ -z "$OVMF_CODE" ]]; then - echo "OVMF firmware not found — install edk2-ovmf or ovmf" >&2 - exit 1 - fi - - sudo cp "$ISO" /var/lib/libvirt/images/${VM_NAME}.iso - - if sudo virsh dominfo "$VM_NAME" &>/dev/null; then - echo "VM '${VM_NAME}' already exists — swapping ISO and rebooting..." - sudo virsh destroy "$VM_NAME" 2>/dev/null || true - CDROM_DEV=$(sudo virsh domblklist "$VM_NAME" \ - | awk 'NR>2 && $2 == "-" {print $1; exit}') - if [[ -z "$CDROM_DEV" ]]; then - CDROM_DEV=$(sudo virsh domblklist "$VM_NAME" \ - | awk 'NR>2 && ($2 ~ /\.iso$/) {print $1; exit}') - fi - sudo virsh change-media "$VM_NAME" "$CDROM_DEV" \ - /var/lib/libvirt/images/${VM_NAME}.iso --force - sudo virsh start "$VM_NAME" - else - echo "Creating libvirt VM: ${VM_NAME} (${VM_RAM}M RAM, ${VM_CPUS} vCPUs, ${DISK_SIZE}G disk)" - sudo virt-install \ - --name "$VM_NAME" \ - --memory "$VM_RAM" --vcpus "$VM_CPUS" \ - --boot loader="${OVMF_CODE}",loader.readonly=yes,loader.type=pflash,nvram.template="${OVMF_VARS}" \ - --cdrom /var/lib/libvirt/images/${VM_NAME}.iso \ - --disk size=${DISK_SIZE},format=qcow2 \ - --network network=default \ - --graphics vnc,listen=127.0.0.1 \ - --os-variant generic \ - --tpm none \ - --noautoconsole - fi - - MAC=$(sudo virsh domiflist "$VM_NAME" | awk '/network/{print $5}') - echo "VM started. MAC: ${MAC}" - echo "Waiting for DHCP lease (this takes 30-90s while the ISO boots)..." - - GUEST_IP="" - for i in $(seq 1 60); do - GUEST_IP=$(sudo virsh net-dhcp-leases default 2>/dev/null \ - | awk -v mac="$MAC" '$3 == mac {split($5, a, "/"); print a[1]}' \ - | head -1) - if [[ -n "$GUEST_IP" ]]; then - break - fi - sleep 3 - done - - if [[ -z "$GUEST_IP" ]]; then - echo "WARNING: No DHCP lease found after 3 minutes." >&2 - echo "Try: sudo virsh net-dhcp-leases default" >&2 - echo "Or: sudo virsh console ${VM_NAME}" >&2 - exit 1 - fi - - echo "" - echo "========================================" - echo " SSH ready:" - echo " ssh liveuser@${GUEST_IP}" - echo " password: live" - echo "========================================" - echo "" - echo "VNC: $(sudo virsh domdisplay ${VM_NAME} 2>/dev/null || echo 'unavailable')" - echo "Serial: sudo virsh console ${VM_NAME}" - echo "Cleanup: sudo virsh destroy ${VM_NAME} && sudo virsh undefine ${VM_NAME} --nvram" - -# Run LUKS encrypted install via fisherman into the running bluefin-debug libvirt VM. -luks-install target: - #!/usr/bin/bash - set -euo pipefail - - VM_NAME="bluefin-debug" - PASSPHRASE="{{ luks-passphrase }}" - DISK="/dev/sda" - PAYLOAD_IMAGE=$(cat "{{ target }}/payload_ref" | tr -d '[:space:]') - SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -o ConnectTimeout=5 -o IdentitiesOnly=yes -o PreferredAuthentications=password" - SSH="sshpass -p live ssh $SSH_OPTS" - SCP="sshpass -p live scp $SSH_OPTS" - - MAC=$(sudo virsh domiflist "$VM_NAME" 2>/dev/null | awk '/network/{print $5; exit}') - if [[ -z "$MAC" ]]; then - echo "ERROR: VM '${VM_NAME}' is not running." - echo "Start it first: just debug=1 boot-libvirt-debug {{ target }}" - exit 1 - fi - - GUEST_IP="" - echo "Looking up DHCP lease for ${VM_NAME} (${MAC})..." - for i in $(seq 1 20); do - GUEST_IP=$(sudo virsh net-dhcp-leases default 2>/dev/null \ - | awk -v mac="$MAC" '$3 == mac {split($5, a, "/"); print a[1]}' \ - | head -1) - [[ -n "$GUEST_IP" ]] && break - sleep 3 - done - if [[ -z "$GUEST_IP" ]]; then - echo "ERROR: no DHCP lease found — is the VM fully booted?" - echo "Check: sudo virsh net-dhcp-leases default" - exit 1 - fi - echo "Guest IP: ${GUEST_IP}" - - echo "Waiting for SSH..." - for i in $(seq 1 30); do - $SSH liveuser@"$GUEST_IP" true 2>/dev/null && break - sleep 3 - done - $SSH liveuser@"$GUEST_IP" true || { echo "ERROR: SSH timed out"; exit 1; } - - FILESYSTEM=$(just _filesystem_for "{{ target }}") - RECIPE_TMP=$(mktemp /tmp/luks-recipe-XXXXXX.json) - trap "rm -f '${RECIPE_TMP}'" EXIT - printf '{\n "disk": "%s",\n "filesystem": "%s",\n "image": "%s",\n "composeFsBackend": false,\n "bootloader": "grub2",\n "hostname": "bluefin-luks-test",\n "encryption": {"type": "luks-passphrase", "passphrase": "%s"},\n "flatpaks": []\n}\n' \ - "${DISK}" "${FILESYSTEM}" "${PAYLOAD_IMAGE}" "${PASSPHRASE}" > "${RECIPE_TMP}" - $SCP "${RECIPE_TMP}" liveuser@"$GUEST_IP":/tmp/luks-recipe.json - echo "Uploaded recipe to /tmp/luks-recipe.json" - - echo "Running fisherman install (pulls from registry, takes several minutes)..." - $SSH liveuser@"$GUEST_IP" 'sudo /usr/local/bin/fisherman /tmp/luks-recipe.json' - echo "Install finished." - - CDROM_DEV=$(sudo virsh domblklist "$VM_NAME" \ - | awk 'NR>2 && ($2 ~ /\.iso$/ || $2 == "-") {print $1; exit}') - if [[ -n "$CDROM_DEV" ]]; then - sudo virsh change-media "$VM_NAME" "$CDROM_DEV" --eject --force 2>/dev/null || true - echo "ISO ejected from ${CDROM_DEV}." - else - echo "Warning: could not identify CD-ROM device; eject skipped." - fi - - echo "Rebooting VM into installed system..." - sudo virsh reboot "$VM_NAME" || $SSH liveuser@"$GUEST_IP" 'sudo reboot' || true - - echo "" - echo "========================================" - echo " VM is rebooting into the installed system." - echo " Unlock LUKS: just luks-unlock {{ target }}" - echo " Watch boot: just luks-boot {{ target }}" - echo "========================================" - -# Automate LUKS passphrase entry on the bluefin-debug VM serial console. -luks-unlock target: - #!/usr/bin/bash - VM_NAME="bluefin-debug" - PASSPHRASE="{{ luks-passphrase }}" - if ! sudo virsh domstate "$VM_NAME" 2>/dev/null | grep -q running; then - echo "ERROR: VM '${VM_NAME}' is not running." - echo "Run: just luks-install {{ target }}" - exit 1 - fi - MAC=$(sudo virsh domiflist "$VM_NAME" 2>/dev/null | awk '/network/{print $5; exit}') - if [[ -z "$MAC" ]]; then - echo "ERROR: VM '${VM_NAME}' is not running." - exit 1 - fi - echo "Waiting for Plymouth passphrase prompt (VM MAC: ${MAC})..." - echo "Passphrase: ${PASSPHRASE}" - sudo python3 "src/luks-unlock.py" libvirt "$VM_NAME" "$PASSPHRASE" "$MAC" - -# Connect to the serial console of the bluefin-debug VM. -luks-boot target: - #!/usr/bin/bash - VM_NAME="bluefin-debug" - if ! sudo virsh domstate "$VM_NAME" 2>/dev/null | grep -q running; then - echo "ERROR: VM '${VM_NAME}' is not running." - echo "Run: just luks-install {{ target }}" - exit 1 - fi - echo "Connecting to serial console (detach: Ctrl-])" - echo "At the LUKS passphrase prompt type: {{ luks-passphrase }}" - echo "" - sudo virsh console "$VM_NAME" - -# ── QEMU-native LUKS test (used by CI; mirrors the libvirt recipes) ─────────── - -luks-qemu-disk := "/var/tmp/bluefin-luks-install.qcow2" -luks-qemu-monitor-live := "/tmp/bluefin-qemu-live.sock" -luks-qemu-monitor-installed := "/tmp/bluefin-qemu-installed.sock" -luks-qemu-serial-live := "/tmp/bluefin-qemu-live-serial.log" -luks-qemu-serial-installed := "/tmp/bluefin-qemu-installed-serial.log" -luks-qemu-ssh-port := "2222" -# SSH port forwarded into the installed (post-LUKS-unlock) VM for boot detection. -luks-qemu-ssh-port-installed := "2223" -luks-qemu-ram := "8192" - -# Full end-to-end test: build the ISO then run the LUKS install + boot test. -e2e target: - #!/usr/bin/bash - set -euo pipefail - echo "=== Step 1/2: Building ISO (debug={{ debug }}, installer_channel={{ installer_channel }}) ===" - just debug={{ debug }} installer_channel={{ installer_channel }} output_dir={{ output_dir }} iso-sd-boot {{ target }} - echo "=== Step 2/2: LUKS end-to-end test ===" - sudo rm -f "{{ luks-qemu-disk }}" "{{ luks-qemu-monitor-live }}" "{{ luks-qemu-monitor-installed }}" \ - "{{ luks-qemu-serial-live }}" "{{ luks-qemu-serial-installed }}" - just luks-test-qemu {{ target }} - -# Run the full LUKS end-to-end test in QEMU (CI entry point). -luks-test-qemu target: - #!/usr/bin/bash - set -euo pipefail - just luks-qemu-disk={{ luks-qemu-disk }} luks-boot-qemu-live {{ target }} - just luks-qemu-ssh-port={{ luks-qemu-ssh-port }} luks-install-qemu {{ target }} - just luks-qemu-disk={{ luks-qemu-disk }} \ - luks-qemu-ssh-port-installed={{ luks-qemu-ssh-port-installed }} \ - luks-boot-qemu-installed {{ target }} - just luks-qemu-monitor-installed={{ luks-qemu-monitor-installed }} \ - luks-qemu-serial-installed={{ luks-qemu-serial-installed }} \ - luks-qemu-ssh-port-installed={{ luks-qemu-ssh-port-installed }} \ - luks-unlock-qemu {{ target }} - -# Boot the live ISO in QEMU (daemonized) with a blank install disk attached. -luks-boot-qemu-live target: - #!/usr/bin/bash - set -euo pipefail - QEMU=$(command -v /usr/libexec/qemu-kvm /usr/bin/qemu-kvm \ - /usr/bin/qemu-system-x86_64 \ - /home/linuxbrew/.linuxbrew/bin/qemu-system-x86_64 2>/dev/null | head -1) - [[ -z "$QEMU" ]] && { echo "qemu-kvm / qemu-system-x86_64 not found" >&2; exit 1; } - ISO=$(ls \ - {{ output_dir }}/{{ target }}-live.iso \ - output/bootiso/install.iso \ - output/bootc-{{ target }}*.iso \ - 2>/dev/null | head -1 || true) - if [[ -z "$ISO" ]]; then - echo "No ISO found — run: just debug=1 iso-sd-boot {{ target }}" >&2 - exit 1 - fi - - OVMF_CODE=""; OVMF_VARS="" - for f in /usr/share/OVMF/OVMF_CODE_4M.fd /usr/share/OVMF/OVMF_CODE.fd \ - /usr/share/edk2/ovmf/OVMF_CODE.fd /usr/share/ovmf/OVMF.fd \ - /home/linuxbrew/.linuxbrew/share/qemu/edk2-x86_64-code.fd \ - /home/linuxbrew/.linuxbrew/Cellar/qemu/11.0.0/share/qemu/edk2-x86_64-code.fd; do - [[ -f "$f" ]] && { OVMF_CODE="$f"; break; } - done - for f in /usr/share/OVMF/OVMF_VARS_4M.fd /usr/share/OVMF/OVMF_VARS.fd \ - /usr/share/edk2/ovmf/OVMF_VARS.fd \ - /home/linuxbrew/.linuxbrew/share/qemu/edk2-i386-vars.fd; do - if [[ -f "$f" ]]; then cp "$f" /var/tmp/bluefin-qemu-live-vars.fd; OVMF_VARS=/var/tmp/bluefin-qemu-live-vars.fd; break; fi - done - [[ -z "$OVMF_CODE" ]] && { echo "OVMF firmware not found" >&2; exit 1; } - - [[ -f "{{ luks-qemu-disk }}" ]] || qemu-img create -f qcow2 "{{ luks-qemu-disk }}" 64G - sudo rm -f "{{ luks-qemu-monitor-live }}" "{{ luks-qemu-serial-live }}" - - echo "Booting live ISO: $ISO" - QEMU_ACCEL="-accel kvm" - QEMU_PREFIX="" - if ! test -r /dev/kvm 2>/dev/null; then - if sudo test -r /dev/kvm 2>/dev/null; then - echo "Using sudo for KVM access" - QEMU_PREFIX="sudo" - else - echo "KVM not available, falling back to TCG emulation (slower)" - QEMU_ACCEL="-accel tcg,thread=multi" - QEMU_PREFIX="" - fi - fi - $QEMU_PREFIX "$QEMU" \ - -machine q35 -cpu host -m {{ luks-qemu-ram }} -smp 4 $QEMU_ACCEL \ - -drive "if=pflash,format=raw,readonly=on,file=${OVMF_CODE}" \ - -drive "if=pflash,format=raw,file=${OVMF_VARS}" \ - -drive "if=none,id=iso,file=${ISO},media=cdrom,readonly=on,format=raw" \ - -device virtio-scsi-pci,id=scsi \ - -device scsi-cd,drive=iso \ - -drive "if=none,id=disk,file={{ luks-qemu-disk }},format=qcow2" \ - -device virtio-blk-pci,drive=disk \ - -netdev "user,id=net0,hostfwd=tcp::{{ luks-qemu-ssh-port }}-:22" \ - -device virtio-net-pci,netdev=net0 \ - -monitor "unix:{{ luks-qemu-monitor-live }},server,nowait" \ - -serial "file:{{ luks-qemu-serial-live }}" \ - -display none \ - -daemonize - echo "Live QEMU started (monitor: {{ luks-qemu-monitor-live }})" - - SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -o ConnectTimeout=5 -o PreferredAuthentications=password" - echo "Waiting for live environment on port {{ luks-qemu-ssh-port }}..." - for i in $(seq 1 60); do - if sudo grep -q "BLUEFIN_LIVE_READY" "{{ luks-qemu-serial-live }}" 2>/dev/null; then - echo "Live environment ready (serial marker seen)" - break - fi - if sshpass -p live ssh $SSH_OPTS liveuser@127.0.0.1 -p {{ luks-qemu-ssh-port }} true 2>/dev/null; then - echo "Live environment ready (SSH connected)" - break - fi - [[ "$i" -eq 60 ]] && { echo "ERROR: live env not ready after 5m"; sudo tail -30 "{{ luks-qemu-serial-live }}" || true; exit 1; } - sleep 5 - done - - echo "Live environment ready. Waiting 25s for GUI to fully render..." - sleep 25 - sudo socat - "UNIX-CONNECT:{{ luks-qemu-monitor-live }}" \ - <<< "screendump /tmp/luks-screenshot-live.ppm" 2>/dev/null || true - -# Run fisherman LUKS install via SSH into the live QEMU VM. -luks-install-qemu target: - #!/usr/bin/bash - set -euo pipefail - PASSPHRASE="{{ luks-passphrase }}" - DISK="/dev/vda" - PAYLOAD_IMAGE=$(cat "{{ target }}/payload_ref" | tr -d '[:space:]') - SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -o ConnectTimeout=5 -o PreferredAuthentications=password -o ServerAliveInterval=30 -o ServerAliveCountMax=20" - SSH="sshpass -p live ssh $SSH_OPTS liveuser@127.0.0.1 -p {{ luks-qemu-ssh-port }}" - SCP="sshpass -p live scp $SSH_OPTS -P {{ luks-qemu-ssh-port }}" - - FILESYSTEM=$(just _filesystem_for "{{ target }}") - RECIPE_TMP=$(mktemp /tmp/luks-recipe-XXXXXX.json) - trap "rm -f '${RECIPE_TMP}'" EXIT - # Empty image triggers bootcDirect: fisherman runs `bootc install - # to-filesystem` natively on the live ISO (which IS the Bluefin image). - # No podman, no OCI export, no overlay, no RAM issues. - # target_imgref tells bootc what to track for day-2 updates. - printf '{\n "disk": "%s",\n "filesystem": "%s",\n "image": "",\n "targetImgref": "%s",\n "composeFsBackend": false,\n "bootloader": "grub2",\n "hostname": "bluefin-luks-test",\n "encryption": {"type": "luks-passphrase", "passphrase": "%s"},\n "flatpaks": []\n}\n' \ - "${DISK}" "${FILESYSTEM}" "${PAYLOAD_IMAGE}" "${PASSPHRASE}" > "${RECIPE_TMP}" - $SCP "${RECIPE_TMP}" liveuser@127.0.0.1:/tmp/luks-recipe.json - - # Use the fisherman already installed on the live ISO (Flatpak). - # bootcDirect doesn't need any of our patches — it runs bootc natively. - # Build patched fisherman for the direct-mode --source-imgref fix. - FISHER_REPO="${FISHER_REPO:-{{ fisher_repo }}}" - FISHERMAN_BIN=$(mktemp /tmp/fisherman-XXXXXX) - trap "rm -f '${RECIPE_TMP}' '${FISHERMAN_BIN}'" EXIT - (cd "${FISHER_REPO}" && CGO_ENABLED=0 go build -o "${FISHERMAN_BIN}" ./cmd/fisherman/) - $SCP "${FISHERMAN_BIN}" liveuser@127.0.0.1:/tmp/fisherman - $SSH 'chmod +x /tmp/fisherman' - echo "Running fisherman (direct bootc install, takes several minutes)..." - if ! $SSH 'sudo /tmp/fisherman /tmp/luks-recipe.json'; then - echo "=== INSTALL FAILURE DIAGNOSTICS ===" - echo "--- dmesg ---" - $SSH 'sudo dmesg | tail -n 100' || true - echo "--- journalctl ---" - $SSH 'sudo journalctl -n 100 --no-pager' || true - echo "--- systemd-oomd status ---" - $SSH 'sudo systemctl status systemd-oomd --no-pager' || true - echo "--- podman system info ---" - $SSH 'sudo podman info' || true - exit 1 - fi - echo "Install complete. Shutting down live QEMU..." - echo "system_powerdown" | sudo socat - "UNIX-CONNECT:{{ luks-qemu-monitor-live }}" 2>/dev/null || true - sleep 5 - echo "quit" | sudo socat - "UNIX-CONNECT:{{ luks-qemu-monitor-live }}" 2>/dev/null || true - -# Boot the installed disk in QEMU (no ISO). Called after luks-install-qemu. -luks-boot-qemu-installed target: - #!/usr/bin/bash - set -euo pipefail - QEMU=$(command -v /usr/libexec/qemu-kvm /usr/bin/qemu-kvm \ - /usr/bin/qemu-system-x86_64 \ - /home/linuxbrew/.linuxbrew/bin/qemu-system-x86_64 2>/dev/null | head -1) - [[ -z "$QEMU" ]] && { echo "qemu-kvm / qemu-system-x86_64 not found" >&2; exit 1; } - OVMF_CODE=""; OVMF_VARS="" - for f in /usr/share/OVMF/OVMF_CODE_4M.fd /usr/share/OVMF/OVMF_CODE.fd \ - /usr/share/edk2/ovmf/OVMF_CODE.fd /usr/share/ovmf/OVMF.fd \ - /home/linuxbrew/.linuxbrew/share/qemu/edk2-x86_64-code.fd \ - /home/linuxbrew/.linuxbrew/Cellar/qemu/11.0.0/share/qemu/edk2-x86_64-code.fd; do - [[ -f "$f" ]] && { OVMF_CODE="$f"; break; } - done - for f in /usr/share/OVMF/OVMF_VARS_4M.fd /usr/share/OVMF/OVMF_VARS.fd \ - /usr/share/edk2/ovmf/OVMF_VARS.fd \ - /home/linuxbrew/.linuxbrew/share/qemu/edk2-i386-vars.fd; do - if [[ -f "$f" ]]; then cp "$f" /var/tmp/bluefin-qemu-installed-vars.fd; OVMF_VARS=/var/tmp/bluefin-qemu-installed-vars.fd; break; fi - done - [[ -z "$OVMF_CODE" ]] && { echo "OVMF firmware not found" >&2; exit 1; } - - sudo rm -f "{{ luks-qemu-monitor-installed }}" "{{ luks-qemu-serial-installed }}" - - echo "Booting installed disk: {{ luks-qemu-disk }}" - QEMU_ACCEL="-accel kvm" - QEMU_PREFIX="" - if ! test -r /dev/kvm 2>/dev/null; then - if sudo test -r /dev/kvm 2>/dev/null; then - echo "Using sudo for KVM access" - QEMU_PREFIX="sudo" - else - echo "KVM not available, falling back to TCG emulation (slower)" - QEMU_ACCEL="-accel tcg,thread=multi" - QEMU_PREFIX="" - fi - fi - $QEMU_PREFIX "$QEMU" \ - -machine q35 -cpu host -m {{ luks-qemu-ram }} -smp 4 $QEMU_ACCEL \ - -drive "if=pflash,format=raw,readonly=on,file=${OVMF_CODE}" \ - -drive "if=pflash,format=raw,file=${OVMF_VARS}" \ - -drive "if=none,id=disk,file={{ luks-qemu-disk }},format=qcow2" \ - -device virtio-blk-pci,drive=disk \ - -netdev "user,id=net0,hostfwd=tcp::{{ luks-qemu-ssh-port-installed }}-:22" \ - -device virtio-net-pci,netdev=net0 \ - -monitor "unix:{{ luks-qemu-monitor-installed }},server,nowait" \ - -serial "file:{{ luks-qemu-serial-installed }}" \ - -display none \ - -daemonize - echo "Installed QEMU started (monitor: {{ luks-qemu-monitor-installed }})" - - for i in $(seq 1 15); do - [[ -S "{{ luks-qemu-monitor-installed }}" ]] && break - sleep 2 - done - -# Send LUKS passphrase to installed QEMU VM via monitor screendump + sendkey. -# luks-qemu-ssh-port-installed: forwarded SSH port for boot-completion detection -# (0 = disabled, use framebuffer fallback only) -luks-unlock-qemu target: - #!/usr/bin/bash - set -euo pipefail - PASSPHRASE="{{ luks-passphrase }}" - echo "Unlocking LUKS on installed QEMU VM..." - echo "Passphrase: ${PASSPHRASE}" - sudo python3 "src/luks-unlock.py" qemu \ - "{{ luks-qemu-monitor-installed }}" \ - "$PASSPHRASE" \ - "{{ luks-qemu-serial-installed }}" \ - "{{ luks-qemu-ssh-port-installed }}" - - for label in "Plymouth prompt" "Final boot"; do - key=$(echo "$label" | tr ' ' '-' | tr '[:upper:]' '[:lower:]') - bash "src/show-screenshot.sh" "/tmp/luks-screenshot-${key}.ppm" "$label" || true - done diff --git a/src/build-iso.sh b/src/build-iso.sh deleted file mode 100644 index 6fc1f65..0000000 --- a/src/build-iso.sh +++ /dev/null @@ -1,184 +0,0 @@ -#!/usr/bin/bash -# build-iso.sh -# -# Creates a UEFI-bootable systemd-boot live ISO from pre-built components: -# — tar containing only kernel + EFI files from the rootfs -# — squashfs of the full live rootfs (built with correct UIDs -# via mksquashfs inside podman unshare) -# -# Boot architecture (no GRUB2, no shim): -# El Torito EFI entry → EFI/efi.img (FAT ESP image containing): -# EFI/BOOT/BOOTX64.EFI systemd-boot EFI binary (arch-detected) -# loader/loader.conf systemd-boot configuration -# loader/entries/bluefin-live.conf boot entry (kernel + initrd + cmdline) -# images/pxeboot/vmlinuz Bluefin kernel -# images/pxeboot/initrd.img dmsquash-live initramfs -# ISO9660 root: -# EFI/BOOT/BOOTX64.EFI EFI fallback path for Proxmox OVMF / Ventoy -# EFI/efi.img (also referenced by El Torito) -# images/pxeboot/* kernel/initramfs copies for loopback ISO boot tools -# boot/grub/loopback.cfg metadata for Ventoy/GRUB-style loopback boot -# LiveOS/squashfs.img squashfs of the full Bluefin live rootfs -# -# Live boot flow: -# UEFI firmware → El Torito → FAT ESP → systemd-boot → kernel+initramfs -# dmsquash-live: scans for CDLABEL=BLUEFIN_LIVE → mounts ISO → squashfs → overlayfs - -set -euo pipefail - -BOOT_TAR="${1:?Usage: build-iso.sh }" -SQUASHFS_SRC="${2:?Usage: build-iso.sh }" -OUTPUT_ISO="${3:?Usage: build-iso.sh }" -LABEL="BLUEFIN_LIVE" - -WORK=$(mktemp -d "${TMPDIR:-/tmp}/iso-build.XXXXXX") -trap "chmod -R u+rwX '${WORK}' 2>/dev/null; rm -rf '${WORK}'" EXIT - -BOOT_DIR="${WORK}/boot-files" -ISO_ROOT="${WORK}/iso-root" -ESP_STAGING="${WORK}/esp-staging" - -mkdir -p "${BOOT_DIR}" "${ISO_ROOT}/EFI" "${ISO_ROOT}/LiveOS" - -# ── Extract boot files (kernel, initramfs, systemd-boot EFI) ───────────────── -echo ">>> Extracting boot files..." -tar -xf "${BOOT_TAR}" -C "${BOOT_DIR}" --no-same-owner - -# ── Locate kernel ──────────────────────────────────────────────────────────── -kernel=$(ls "${BOOT_DIR}/usr/lib/modules" | sort -V | tail -1) -echo ">>> Kernel: ${kernel}" - -VMLINUZ="${BOOT_DIR}/usr/lib/modules/${kernel}/vmlinuz" -INITRD="${BOOT_DIR}/usr/lib/modules/${kernel}/initramfs.img" - -# Detect EFI binary: arm64 ships systemd-bootaa64.efi → BOOTAA64.EFI -# amd64 ships systemd-bootx64.efi → BOOTX64.EFI -BOOT_EFI_SRC="" -BOOT_EFI_DEST="" -for _candidate in \ - "systemd-bootaa64.efi:EFI/BOOT/BOOTAA64.EFI" \ - "systemd-bootx64.efi:EFI/BOOT/BOOTX64.EFI"; do - _src="${BOOT_DIR}/usr/lib/systemd/boot/efi/${_candidate%%:*}" - _dest="${_candidate##*:}" - if [[ -f "${_src}" ]]; then - BOOT_EFI_SRC="${_src}" - BOOT_EFI_DEST="${_dest}" - break - fi -done -[[ -n "${BOOT_EFI_SRC}" ]] || { echo "ERROR: no systemd-boot EFI binary found in boot-files tar"; exit 1; } - -for f in "${VMLINUZ}" "${INITRD}" "${BOOT_EFI_SRC}"; do - [[ -f "${f}" ]] || { echo "ERROR: missing ${f}"; exit 1; } -done -echo ">>> Kernel: $(du -sh "${VMLINUZ}" | cut -f1)" -echo ">>> Initramfs: $(du -sh "${INITRD}" | cut -f1)" -echo ">>> EFI: ${BOOT_EFI_SRC} → ${BOOT_EFI_DEST}" - -# ── Assemble the ESP staging directory ────────────────────────────────────── -# systemd-boot reads loader entries and kernel/initramfs exclusively from the -# FAT volume it was loaded from. Everything it needs must be in the ESP image. -mkdir -p \ - "${ESP_STAGING}/EFI/BOOT" \ - "${ESP_STAGING}/loader/entries" \ - "${ESP_STAGING}/images/pxeboot" - -cp "${BOOT_EFI_SRC}" "${ESP_STAGING}/${BOOT_EFI_DEST}" -cp "${VMLINUZ}" "${ESP_STAGING}/images/pxeboot/vmlinuz" -cp "${INITRD}" "${ESP_STAGING}/images/pxeboot/initrd.img" - -cat > "${ESP_STAGING}/loader/loader.conf" << 'EOF' -timeout 5 -default bluefin-live.conf -EOF - -# Kernel cmdline for dmsquash-live live boot: -# root=live:CDLABEL=... dmsquash-live: find the ISO by volume label -# rd.live.image enable dmsquash-live mode -# rd.live.overlay.overlayfs=1 use overlayfs (not device mapper) for the rw layer -# enforcing=0 disable SELinux enforcement (for live environment) -# console=ttyS0,115200n8 serial output on amd64 (16550/QEMU q35) — validation target -# console=ttyAMA0,115200n8 serial output on arm64 (PL011/QEMU virt) — validation target -cat > "${ESP_STAGING}/loader/entries/bluefin-live.conf" << EOF -title Bluefin Live -linux /images/pxeboot/vmlinuz -initrd /images/pxeboot/initrd.img -options root=live:CDLABEL=${LABEL} rd.live.image rd.live.overlay.overlayfs=1 enforcing=0 quiet console=ttyS0,115200n8 console=ttyAMA0,115200n8 -EOF - -# ── Create the FAT ESP image ────────────────────────────────────────────────── -# Size = kernel + initramfs + EFI binary + loader files + 32 MiB headroom -INITRD_MB=$(du -m "${INITRD}" | cut -f1) -VMLINUZ_MB=$(du -m "${VMLINUZ}" | cut -f1) -ESP_MB=$(( INITRD_MB + VMLINUZ_MB + 4 + 32 )) -ESP_IMG="${ISO_ROOT}/EFI/efi.img" - -echo ">>> Creating ${ESP_MB} MiB FAT ESP image..." -truncate -s "${ESP_MB}M" "${ESP_IMG}" -mkfs.fat -F 32 -n "ESP" "${ESP_IMG}" - -# Populate the FAT image using mtools — no loop mount required, works -# in unprivileged/restricted containers. -export MTOOLS_SKIP_CHECK=1 - -mmd -i "${ESP_IMG}" \ - ::/EFI \ - ::/EFI/BOOT \ - ::/loader \ - ::/loader/entries \ - ::/images \ - ::/images/pxeboot - -mcopy -i "${ESP_IMG}" "${ESP_STAGING}/${BOOT_EFI_DEST}" ::/"${BOOT_EFI_DEST}" -mcopy -i "${ESP_IMG}" "${ESP_STAGING}/loader/loader.conf" ::/loader/loader.conf -mcopy -i "${ESP_IMG}" "${ESP_STAGING}/loader/entries/bluefin-live.conf" ::/loader/entries/bluefin-live.conf -mcopy -i "${ESP_IMG}" "${ESP_STAGING}/images/pxeboot/vmlinuz" ::/images/pxeboot/vmlinuz -mcopy -i "${ESP_IMG}" "${ESP_STAGING}/images/pxeboot/initrd.img" ::/images/pxeboot/initrd.img - -# ── EFI fallback path on the ISO9660 root ──────────────────────────────────── -mkdir -p "${ISO_ROOT}/EFI/BOOT" -cp "${BOOT_EFI_SRC}" "${ISO_ROOT}/${BOOT_EFI_DEST}" -echo ">>> EFI fallback: ${BOOT_EFI_DEST} added to ISO root" - -# ── ISO-root kernel/initramfs and loopback metadata ────────────────────────── -mkdir -p "${ISO_ROOT}/images/pxeboot" "${ISO_ROOT}/boot/grub" -cp "${VMLINUZ}" "${ISO_ROOT}/images/pxeboot/vmlinuz" -cp "${INITRD}" "${ISO_ROOT}/images/pxeboot/initrd.img" -cat > "${ISO_ROOT}/boot/grub/loopback.cfg" << EOF -menuentry "Bluefin Live" { - linux /images/pxeboot/vmlinuz root=live:CDLABEL=${LABEL} rd.live.image rd.live.overlay.overlayfs=1 enforcing=0 quiet console=ttyS0,115200n8 console=ttyAMA0,115200n8 rd.bluefin.isofile=\${iso_path} - initrd /images/pxeboot/initrd.img -} -EOF -echo ">>> Loopback boot metadata added to ISO root" - -# ── Place the pre-built squashfs ───────────────────────────────────────────── -echo ">>> Copying squashfs..." -cp "${SQUASHFS_SRC}" "${ISO_ROOT}/LiveOS/squashfs.img" -echo ">>> Squashfs: $(du -sh "${ISO_ROOT}/LiveOS/squashfs.img" | cut -f1)" - -# ── Assemble the ISO with xorriso ──────────────────────────────────────────── -echo ">>> Assembling ISO..." -xorriso -as mkisofs \ - -iso-level 3 \ - -r \ - -J --joliet-long \ - -V "${LABEL}" \ - --efi-boot EFI/efi.img \ - -efi-boot-part \ - --efi-boot-image \ - -o "${OUTPUT_ISO}" \ - "${ISO_ROOT}" - -implantisomd5 "${OUTPUT_ISO}" 2>/dev/null || true - -# ── Verify protective MBR + GPT layout ─────────────────────────────────────── -echo ">>> Partition layout:" -xorriso -indev "${OUTPUT_ISO}" -report_system_area plain 2>/dev/null | \ - grep -E '^(System area|ISO image size|MBR|GPT|Partition)' || true -xorriso -indev "${OUTPUT_ISO}" -report_system_area plain 2>/dev/null | \ - grep 'System area summary' | grep -q 'protective' && \ - echo ">>> Protective MBR + GPT: OK" || \ - echo ">>> WARNING: protective MBR not found — USB may not boot on older firmware" - -echo ">>> Done: ${OUTPUT_ISO} ($(du -sh "${OUTPUT_ISO}" | cut -f1))" diff --git a/src/configure-live.sh b/src/configure-live.sh deleted file mode 100644 index aa05d21..0000000 --- a/src/configure-live.sh +++ /dev/null @@ -1,361 +0,0 @@ -#!/usr/bin/bash -# Live-environment setup for the Bluefin ISO installer image. -# -# Runs inside the final Bluefin container stage with: -# --cap-add sys_admin --security-opt label=disable -# -# At this point the initramfs has already been replaced (by the Debian -# initramfs-builder stage) with a dmsquash-live capable one. This script -# handles the runtime live-environment: user, GDM autologin, bootc-installer -# configuration + autostart, and Flatpak pre-installation. - -set -exo pipefail - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -# ── VERSION_ID ──────────────────────────────────────────────────────────────── -# Ensure VERSION_ID is present in os-release for image-builder and bootc tooling. -if grep -q '^VERSION_ID=' /usr/lib/os-release 2>/dev/null; then - sed -i 's/^VERSION_ID=.*/VERSION_ID=latest/' /usr/lib/os-release -else - echo 'VERSION_ID=latest' >> /usr/lib/os-release -fi - -# ── Live user ───────────────────────────────────────────────────────────────── -# Create a passwordless live user for the live session. -useradd --create-home --uid 1000 --user-group \ - --comment "Live User" liveuser || true -passwd --delete liveuser - -# Debug builds only: enable SSH so the live session is reachable for testing. -# Never enabled in production ISOs. -if [[ "${DEBUG:-0}" == "1" ]]; then - echo "liveuser:live" | chpasswd - - # Enable root login with a known password so hotfixes can be applied - # directly via `ssh root@` or `su -` without going through sudo. - passwd --unlock root - echo "root:root" | chpasswd - - # Enable sshd: the Bluefin preset marks sshd disabled, so a plain - # wants symlink gets overridden at first boot. A preset file in - # /etc/systemd/system-preset/ takes priority over /usr/lib and forces it on. - mkdir -p /etc/systemd/system-preset - echo "enable sshd.service" > /etc/systemd/system-preset/90-live-debug.preset - mkdir -p /etc/systemd/system/multi-user.target.wants - ln -sf /usr/lib/systemd/system/sshd.service \ - /etc/systemd/system/multi-user.target.wants/sshd.service - - cat >> /etc/ssh/sshd_config << 'SSHEOF' -PermitEmptyPasswords no -PasswordAuthentication yes -PermitRootLogin yes -SSHEOF - - # Open SSH through firewalld so port 22 is reachable from the host - mkdir -p /etc/firewalld/zones - cat > /etc/firewalld/zones/public.xml << 'FWEOF' - - - Public - - - - -FWEOF - - # Print SSH connection info to the serial console once the network is up. - cat > /usr/lib/systemd/system/debug-ssh-banner.service << 'BANNEREOF' -[Unit] -Description=Print SSH connection info to serial console -After=sshd.service network-online.target -Wants=network-online.target - -[Service] -Type=oneshot -ExecStart=/bin/bash -c '\ - IP=$(hostname -I | awk "{print \\$1}"); \ - echo ""; \ - echo "========================================"; \ - echo " DEBUG SSH READY"; \ - echo " ssh liveuser@${IP:-} (password: live)"; \ - echo " ssh root@${IP:-} (password: root)"; \ - echo "========================================"; \ - echo ""' -StandardOutput=journal+console - -[Install] -WantedBy=multi-user.target -BANNEREOF - systemctl enable debug-ssh-banner.service -fi - -# Give liveuser passwordless sudo so the live session is fully manageable -echo 'liveuser ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/liveuser -chmod 0440 /etc/sudoers.d/liveuser - -# Skip gnome-initial-setup in the live session so GNOME Shell starts directly -mkdir -p /home/liveuser/.config -touch /home/liveuser/.config/gnome-initial-setup-done -chown -R liveuser:liveuser /home/liveuser/.config - -# Remove gnome-tour desktop file so GNOME Shell can never launch it on the -# live ISO regardless of dconf state. -rm -f /usr/share/applications/org.gnome.Tour.desktop - -# Override the bootc-installer flatpak's desktop entry so it appears as -# "Bluefin Installer" with the bluefin icon instead of "bootc Installer (Devel)". -# On Fedora/ostree /usr/local is a symlink to /var/usrlocal — resolve it. -LOCAL_APPS=$(realpath /usr/local 2>/dev/null || echo /usr/local)/share/applications -mkdir -p "${LOCAL_APPS}" || { LOCAL_APPS=/usr/share/applications; mkdir -p "${LOCAL_APPS}"; } -cat > "${LOCAL_APPS}/org.bootcinstaller.Installer.Devel.desktop" << 'DESKTOPEOF' -[Desktop Entry] -Name=Bluefin Installer -Exec=/usr/bin/flatpak run --branch=master --arch=x86_64 --command=bootc-installer org.bootcinstaller.Installer.Devel -Icon=bluefin -Terminal=false -Type=Application -Categories=GTK;System;Settings; -StartupNotify=true -X-Flatpak=org.bootcinstaller.Installer.Devel -DESKTOPEOF - -# Suppress the GNOME Tour / "Welcome to Bluefin" dialog on first login. -mkdir -p /etc/dconf/db/distro.d /etc/dconf/db/distro.d/locks -cat > /etc/dconf/db/distro.d/50-live-iso << 'DCONFEOF' -[org/gnome/shell] -welcome-dialog-last-shown-version='999' -favorite-apps=['bluefin-installer.desktop', 'org.mozilla.firefox.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Console.desktop'] - -[org/gnome/desktop/screensaver] -lock-enabled=false -idle-activation-enabled=false - -[org/gnome/desktop/session] -idle-delay=uint32 0 - -[org/gnome/settings-daemon/plugins/power] -sleep-inactive-ac-type='nothing' -sleep-inactive-battery-type='nothing' -sleep-inactive-ac-timeout=0 -sleep-inactive-battery-timeout=0 -power-button-action='nothing' -DCONFEOF - -cat > /etc/dconf/db/distro.d/locks/50-live-iso << 'LOCKSEOF' -/org/gnome/desktop/screensaver/lock-enabled -/org/gnome/desktop/screensaver/idle-activation-enabled -/org/gnome/desktop/session/idle-delay -/org/gnome/shell/favorite-apps -/org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-type -/org/gnome/settings-daemon/plugins/power/sleep-inactive-battery-type -/org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-timeout -/org/gnome/settings-daemon/plugins/power/sleep-inactive-battery-timeout -LOCKSEOF - -dconf update - -# Mask systemd sleep/suspend targets so the kernel never suspends regardless -# of what any userspace tool requests — belt-and-suspenders for the install. -systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target - -# ── GDM autologin ───────────────────────────────────────────────────────────── -mkdir -p /etc/gdm -cat > /etc/gdm/custom.conf << 'GDMEOF' -[daemon] -AutomaticLoginEnable=True -AutomaticLogin=liveuser -GDMEOF - -# ── /var/tmp tmpfs ──────────────────────────────────────────────────────────── -# The live overlayfs puts /var on a small RAM overlay. bootc needs substantial -# space in /var/tmp when staging an install; mount a dedicated tmpfs there. -cat > /usr/lib/systemd/system/var-tmp.mount << 'UNITEOF' -[Unit] -Description=Large tmpfs for /var/tmp in the live environment - -[Mount] -What=tmpfs -Where=/var/tmp -Type=tmpfs -Options=size=8G,nr_inodes=1m - -[Install] -WantedBy=local-fs.target -UNITEOF -systemctl enable var-tmp.mount - -# ── Default mounts for containers ───────────────────────────────────────────── -# Automatically bind-mount the read-only SquashFS cache at /usr/lib/containers/storage -# from the host into all container namespaces, allowing offline installation to work. -mkdir -p /etc/containers -cat > /etc/containers/mounts.conf << 'EOF' -/usr/lib/containers/storage:/usr/lib/containers/storage -EOF - - -# ── Live-ready marker service ───────────────────────────────────────────────── -# Prints BLUEFIN_LIVE_READY to the serial console after display-manager.service -# starts. CI boot verification greps for this token in the serial log. -cat > /usr/lib/systemd/system/live-ready.service << 'LREOF' -[Unit] -Description=Live environment ready marker -After=display-manager.service -Requires=display-manager.service - -[Service] -Type=oneshot -ExecStart=/bin/echo BLUEFIN_LIVE_READY -StandardOutput=tty -TTYPath=/dev/ttyS0 - -[Install] -WantedBy=multi-user.target -LREOF -systemctl enable live-ready.service - -# fisherman (bootc-installer backend) creates /var/fisherman-tmp and bind-mounts -# it to /var/tmp. Pre-create the directory so it exists at boot time. -mkdir -p /var/fisherman-tmp - -# ── Bluefin icon ────────────────────────────────────────────────────────────── -# Install icon in hicolor theme hierarchy for desktop integration -mkdir -p /usr/share/icons/hicolor/{16x16,24x24,32x32,48x48,64x64,128x128,256x256,512x512}/apps -for size in 16 24 32 48 64 128 256 512; do - install -Dm644 "$SCRIPT_DIR/icons/hicolor/${size}x${size}/apps/bluefin.png" \ - "/usr/share/icons/hicolor/${size}x${size}/apps/bluefin.png" -done -# Symlink 512×512 to pixmaps for compatibility -install -Dm644 "$SCRIPT_DIR/icons/hicolor/512x512/apps/bluefin.png" /usr/share/pixmaps/bluefin.png -gtk-update-icon-cache /usr/share/icons/hicolor/ - -# ── Installer tour images ───────────────────────────────────────────────────── -# The bootc-installer Flatpak has --filesystem=host so absolute paths are visible. -mkdir -p /usr/share/bootc-installer/images -install -Dm644 "$SCRIPT_DIR/images/bluefin.png" /usr/share/bootc-installer/images/bluefin.png - -# ── Installer configuration ─────────────────────────────────────────────────── -# The bootc-installer reads both overrides from /etc/bootc-installer/: -# images.json — locks the catalog to Bluefin only -# recipe.json — sets distro branding, tour slides, and install steps -mkdir -p /etc/bootc-installer -cp "$SCRIPT_DIR/etc/bootc-installer/images.json" /etc/bootc-installer/images.json -cp "$SCRIPT_DIR/etc/bootc-installer/recipe.json" /etc/bootc-installer/recipe.json -# Flag file read by the installer to activate live ISO mode. -touch /etc/bootc-installer/live-iso-mode - -# ── Installer autostart ─────────────────────────────────────────────────────── -# App ID differs between stable and dev channel builds. -INSTALLER_APP_ID="org.bootcinstaller.Installer" -[[ "${INSTALLER_CHANNEL:-stable}" == "dev" ]] && INSTALLER_APP_ID="org.bootcinstaller.Installer.Devel" - -# Create a wrapper script to handle the delay safely without desktop entry quoting issues -cat > /usr/bin/autostart-installer << EOF -#!/usr/bin/bash -sleep 5 -exec flatpak run --filesystem=/etc/bootc-installer:ro --env=VANILLA_CUSTOM_RECIPE=/etc/bootc-installer/recipe.json ${INSTALLER_APP_ID} -EOF -chmod +x /usr/bin/autostart-installer - -mkdir -p /etc/xdg/autostart -cat > /etc/xdg/autostart/tuna-installer.desktop << DTEOF -[Desktop Entry] -Name=Bluefin Installer -Exec=/usr/bin/autostart-installer -Icon=bluefin -Type=Application -X-GNOME-Autostart-enabled=true -DTEOF - -# A matching entry in /usr/share/applications/ lets GNOME Shell reference this -# app in the dock via favorite-apps. -mkdir -p /usr/share/applications -cat > /usr/share/applications/bluefin-installer.desktop << DTEOF -[Desktop Entry] -Name=Bluefin Installer -Comment=Install Bluefin to your computer -Exec=flatpak run --filesystem=/etc/bootc-installer:ro --env=VANILLA_CUSTOM_RECIPE=/etc/bootc-installer/recipe.json ${INSTALLER_APP_ID} -Icon=bluefin -Type=Application -Categories=System; -NoDisplay=false -DTEOF - -# ── Polkit rules for live installer ─────────────────────────────────────────── -# The installer's polkit action (org.tunaos.Installer.install) defaults to -# auth_admin. On the live ISO we want liveuser to install without any password -# prompt. Two complementary mechanisms are used for belt-and-suspenders: -# -# 1. Policy override: write the action definition directly with allow_active=yes -# so polkit approves it at the policy level before rules even run. -# -# 2. JS rule: belt-and-suspenders fallback that grants YES for liveuser. - -# fisherman symlink — installer calls /usr/local/bin/fisherman via pkexec -INSTALLER_APP_DIR=$(find /var/lib/flatpak/app/${INSTALLER_APP_ID} -name fisherman -type f 2>/dev/null | head -1 | xargs dirname 2>/dev/null || true) -if [ -n "$INSTALLER_APP_DIR" ]; then - mkdir -p /usr/local/bin - ln -sf "${INSTALLER_APP_DIR}/fisherman" /usr/local/bin/fisherman -fi - -# Policy file: allow any active session to run the installer without auth. -mkdir -p /usr/share/polkit-1/actions -cat > /usr/share/polkit-1/actions/org.bootcinstaller.Installer.policy << 'POLICYEOF' - - - - - Install an operating system to disk - Authentication is required to install an operating system - drive-harddisk - - no - no - yes - - /usr/local/bin/fisherman - true - - -POLICYEOF - -# JS rule: grant YES for liveuser on both custom + generic polkit exec actions. -mkdir -p /etc/polkit-1/rules.d -cat > /etc/polkit-1/rules.d/99-live-installer.rules << 'EOF' -polkit.addRule(function(action, subject) { - if ((action.id === "org.freedesktop.policykit.exec" || - action.id === "org.tunaos.Installer.install") && - subject.user === "liveuser" && subject.local) { - return polkit.Result.YES; - } -}); -EOF - -# ── Live network defaults ───────────────────────────────────────────────────── -# /etc/hostname is bind-mounted by the container runtime during builds; writing -# to it in a RUN step doesn't persist into the image layer. Use tmpfiles.d to -# create it at first boot instead. -mkdir -p /usr/lib/tmpfiles.d -echo 'f /etc/hostname 0644 - - - bluefin-live' > /usr/lib/tmpfiles.d/live-hostname.conf - -# ── Container storage ──────────────────────────────────────────────────────── -# Use overlay driver for space-efficient container operations. -# The embedded OCI in the squashfs is available via skopeo/podman pull -# from the registry. Overlay avoids VFS's full-image copy per layer. -# fuse-overlayfs (installed in Containerfile) handles overlay-on-overlay -# on kernels without native support (e.g. CentOS Stream 10 in bluefin-lts). -cat > /etc/containers/storage.conf << 'STOREOF' -[storage] -driver = "overlay" -runroot = "/run/containers/storage" -graphroot = "/var/lib/containers/storage" - -[storage.options] -additionalimagestores = [ - "/usr/lib/containers/storage" -] -STOREOF - -# fisherman handles scratch space, OCI export, and GPT partition setup natively. diff --git a/src/dracut/95bluefin-isofile/bluefin-isofile.sh b/src/dracut/95bluefin-isofile/bluefin-isofile.sh deleted file mode 100644 index b478585..0000000 --- a/src/dracut/95bluefin-isofile/bluefin-isofile.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/sh -# Locate a Bluefin live ISO file on Ventoy/USB partitions and expose it as -# /dev/disk/by-label/BLUEFIN_LIVE so the standard dmsquash-live CDLABEL path works. - -LABEL="BLUEFIN_LIVE" -RUN_DIR="/run/initramfs/bluefin-isofile" -FOUND_MARKER="${RUN_DIR}/found" - -[ -e "/dev/disk/by-label/${LABEL}" ] && return 0 -[ -e "${FOUND_MARKER}" ] && return 0 - -mkdir -p "${RUN_DIR}" /dev/disk/by-label - -debug() { - echo "bluefin-isofile: $*" > /dev/kmsg 2>/dev/null || echo "bluefin-isofile: $*" -} - -iso_hint="" -for arg in $(cat /proc/cmdline); do - case "$arg" in - rd.bluefin.isofile=*|findiso=*|iso-scan/filename=*|rd.live.iso=*) - iso_hint="${arg#*=}" - ;; - esac -done - -try_iso() { - iso="$1" - [ -f "$iso" ] || return 1 - - loopdev=$(losetup --find --show --read-only "$iso" 2>/dev/null) || return 1 - iso_label=$(blkid -s LABEL -o value "$loopdev" 2>/dev/null || true) - - if [ "$iso_label" = "$LABEL" ]; then - ln -sf "$loopdev" "/dev/disk/by-label/${LABEL}" - : > "${FOUND_MARKER}" - udevadm settle 2>/dev/null || true - debug "using ISO file $iso via $loopdev" - /sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root "$loopdev" - return 0 - fi - - losetup -d "$loopdev" 2>/dev/null || true - return 1 -} - -scan_mount() { - dev="$1" - base=$(basename "$dev") - mp="${RUN_DIR}/mnt-${base}" - mkdir -p "$mp" - - mount -o ro -t auto "$dev" "$mp" 2>/dev/null || return 1 - - if [ -n "$iso_hint" ]; then - case "$iso_hint" in - /*) - try_iso "${mp}${iso_hint}" && return 0 - ;; - *) - try_iso "${mp}/${iso_hint}" && return 0 - ;; - esac - fi - - # Fast common cases first. Avoid deep recursive searches in initramfs. - for iso in \ - "$mp"/bluefin*.iso \ - "$mp"/Bluefin*.iso \ - "$mp"/*.iso \ - "$mp"/ISO/*.iso \ - "$mp"/iso/*.iso \ - "$mp"/*/bluefin*.iso \ - "$mp"/*/*.iso - do - [ -e "$iso" ] || continue - try_iso "$iso" && return 0 - done - - umount "$mp" 2>/dev/null || true - return 1 -} - -# Prefer real partition nodes. Skip whole disks and optical devices here because -# direct ISO block devices are handled by the normal CDLABEL path above. -for dev in /dev/disk/by-label/* /dev/disk/by-id/*-part* /dev/sd*[0-9] /dev/vd*[0-9] /dev/nvme*n*p* /dev/mmcblk*p*; do - [ -b "$dev" ] || continue - [ -e "/dev/disk/by-label/${LABEL}" ] && return 0 - scan_mount "$dev" && return 0 -done - -# Keep dracut's initqueue waiting if neither the normal CDLABEL path nor the -# Ventoy/file-backed path is ready yet. -return 1 diff --git a/src/dracut/95bluefin-isofile/module-setup.sh b/src/dracut/95bluefin-isofile/module-setup.sh deleted file mode 100644 index c02567e..0000000 --- a/src/dracut/95bluefin-isofile/module-setup.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# Dracut module: support booting Bluefin ISO as a file from Ventoy-style media. - -check() { - return 0 -} - -depends() { - echo dmsquash-live - return 0 -} - -installkernel() { - instmods loop iso9660 squashfs overlay - instmods usb-storage xhci-pci xhci_hcd ehci-pci ehci_hcd uhci-hcd ohci-hcd - instmods sd_mod sr_mod virtio_blk virtio_pci virtio_scsi - instmods exfat vfat fat ntfs3 ext4 nls_cp437 nls_iso8859_1 nls_utf8 -} - -install() { - inst_multiple mount umount blkid losetup find grep sed mkdir ln readlink basename cat sleep udevadm - inst_hook initqueue 20 "$moddir/bluefin-isofile.sh" -} diff --git a/src/etc/bootc-installer/images.json b/src/etc/bootc-installer/images.json deleted file mode 100644 index e18be56..0000000 --- a/src/etc/bootc-installer/images.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "default_image": "ghcr.io/ublue-os/bluefin:stable", - "fallback_flatpaks": [], - "images": [ - { - "name": "Bluefin", - "imgref": "ghcr.io/ublue-os/bluefin:stable", - "desc": "Cloud-native developer workstation", - "icon": "resource:///org/bootcinstaller/Installer/images/bluefin.png", - "bootloader": "grub2", - "filesystem": "btrfs", - "needs_user_creation": true, - "flatpak_var_path": "var" - } - ] -} diff --git a/src/etc/bootc-installer/recipe.json b/src/etc/bootc-installer/recipe.json deleted file mode 100644 index 9979367..0000000 --- a/src/etc/bootc-installer/recipe.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "log_file": "/var/log/bootc-installer.log", - "distro_name": "Bluefin", - "distro_logo": "resource:///org/bootcinstaller/Installer/images/bluefin.png", - "imgref": "ghcr.io/ublue-os/bluefin:stable", - "local_imgref": "containers-storage:ghcr.io/ublue-os/bluefin:stable", - "bootloader": "grub2", - "composeFsBackend": false, - "distroID": "bluefin", - "brewTap": "ublue-os/tap", - "tour": { - "welcome": { - "image": "/run/host/usr/share/bootc-installer/images/bluefin.png", - "title": "Welcome to Bluefin", - "description": "A cloud-native developer workstation built on Fedora Atomic Desktop technology." - }, - "features": { - "image": "/run/host/usr/share/bootc-installer/images/bluefin.png", - "title": "Developer-First", - "description": "Pre-configured with Brew, Devbox, Devcontainers, and cloud-native tools out of the box." - }, - "community": { - "image": "/run/host/usr/share/bootc-installer/images/bluefin.png", - "title": "Documentation & Community", - "description": "Find docs at docs.projectbluefin.io and join the community on Discord." - }, - "developer": { - "image": "/run/host/usr/share/bootc-installer/images/bluefin.png", - "title": "Always Up-to-Date", - "description": "Automatic updates via bootc. Your system stays current with the latest features and fixes." - }, - "completed": { - "image": "/run/host/usr/share/bootc-installer/images/bluefin.png", - "title": "Welcome to Bluefin", - "description": "Reboot into your new Bluefin system. Welcome aboard!" - } - }, - "steps": { - "welcome": { - "template": "welcome", - "protected": true - }, - "user": { - "template": "user" - }, - "image": { - "template": "image", - "protected": true - }, - "disk": { - "template": "disk" - }, - "encryption": { - "template": "encryption" - } - } -} diff --git a/src/flatpaks b/src/flatpaks deleted file mode 100644 index 5b0e6ca..0000000 --- a/src/flatpaks +++ /dev/null @@ -1,45 +0,0 @@ -# Bluefin system flatpaks -# Installed into the live squashfs at build time (committed to layer, not cache). -# Copied offline to the target by tuna-installer during installation. -# -# Note: org.bootcinstaller.Installer is installed separately via the GitHub -# Releases bundle (not on Flathub) earlier in build.sh. -# -# Format: one app ID per line, resolved from the flathub remote. -com.github.PintaProject.Pinta -com.github.tchx84.Flatseal -com.mattjakeman.ExtensionManager -com.ranfdev.DistroShelf -io.github.flattool.Ignition -io.github.flattool.Warehouse -io.github.kolunmi.Bazaar -io.gitlab.adhami3310.Impression -io.missioncenter.MissionCenter -it.mijorus.smile -org.gnome.Calculator -org.gnome.Calendar -org.gnome.Characters -org.gnome.Connections -org.gnome.Contacts -org.gnome.DejaDup -org.gnome.FileRoller -org.gnome.Firmware -org.gnome.Logs -org.gnome.Loupe -org.gnome.Maps -org.gnome.NautilusPreviewer -org.gnome.Papers -org.gnome.Showtime -org.gnome.SimpleScan -org.gnome.Snapshot -org.gnome.SoundRecorder -org.gnome.TextEditor -org.gnome.Weather -org.gnome.baobab -org.gnome.clocks -org.gnome.font-viewer -org.gtk.Gtk3theme.adw-gtk3 -org.gtk.Gtk3theme.adw-gtk3-dark -org.mozilla.Thunderbird -org.mozilla.firefox -page.tesk.Refine diff --git a/src/icons/hicolor/128x128/apps/bluefin.png b/src/icons/hicolor/128x128/apps/bluefin.png deleted file mode 100644 index 53b2e8b..0000000 Binary files a/src/icons/hicolor/128x128/apps/bluefin.png and /dev/null differ diff --git a/src/icons/hicolor/16x16/apps/bluefin.png b/src/icons/hicolor/16x16/apps/bluefin.png deleted file mode 100644 index 43a2e45..0000000 Binary files a/src/icons/hicolor/16x16/apps/bluefin.png and /dev/null differ diff --git a/src/icons/hicolor/24x24/apps/bluefin.png b/src/icons/hicolor/24x24/apps/bluefin.png deleted file mode 100644 index 73d91f8..0000000 Binary files a/src/icons/hicolor/24x24/apps/bluefin.png and /dev/null differ diff --git a/src/icons/hicolor/256x256/apps/bluefin.png b/src/icons/hicolor/256x256/apps/bluefin.png deleted file mode 100644 index 1e93c02..0000000 Binary files a/src/icons/hicolor/256x256/apps/bluefin.png and /dev/null differ diff --git a/src/icons/hicolor/32x32/apps/bluefin.png b/src/icons/hicolor/32x32/apps/bluefin.png deleted file mode 100644 index 865ade1..0000000 Binary files a/src/icons/hicolor/32x32/apps/bluefin.png and /dev/null differ diff --git a/src/icons/hicolor/48x48/apps/bluefin.png b/src/icons/hicolor/48x48/apps/bluefin.png deleted file mode 100644 index fa84225..0000000 Binary files a/src/icons/hicolor/48x48/apps/bluefin.png and /dev/null differ diff --git a/src/icons/hicolor/512x512/apps/bluefin.png b/src/icons/hicolor/512x512/apps/bluefin.png deleted file mode 100644 index a5e4ee1..0000000 Binary files a/src/icons/hicolor/512x512/apps/bluefin.png and /dev/null differ diff --git a/src/icons/hicolor/64x64/apps/bluefin.png b/src/icons/hicolor/64x64/apps/bluefin.png deleted file mode 100644 index eef19c0..0000000 Binary files a/src/icons/hicolor/64x64/apps/bluefin.png and /dev/null differ diff --git a/src/images/bluefin.png b/src/images/bluefin.png deleted file mode 100644 index a5e4ee1..0000000 Binary files a/src/images/bluefin.png and /dev/null differ diff --git a/src/images/bluefin.svg b/src/images/bluefin.svg deleted file mode 100644 index 75ee9e8..0000000 --- a/src/images/bluefin.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/install-flatpaks.sh b/src/install-flatpaks.sh deleted file mode 100755 index fdd2719..0000000 --- a/src/install-flatpaks.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/bash -# Pre-install flatpaks into the live squashfs. -# -# Uses --mount=type=cache,target=/var/cache/flatpak-dl to persist the flatpak -# ostree repo across builds. On each run the script: -# 1. Seeds /var/lib/flatpak/repo from the build cache (warm start) -# 2. Reconciles to match /tmp/flatpaks-list (only deltas downloaded) -# 3. Saves the repo back to the cache for next build -# -# /tmp/flatpaks-list is COPYd by the Containerfile so it's always current. -# Requires network at build time; CAP_SYS_ADMIN for dbus. - -set -exo pipefail - -FLATPAK_CACHE="/var/cache/flatpak-dl" - -# overlayfs inside Podman builds doesn't support O_TMPFILE. /dev/shm would -# work but is only ~3.5 GB on GHA 7-GB runners — too small for GNOME Platform. -# The --mount=type=cache volume is a bind-mount from btrfs (supports O_TMPFILE) -# and has ~60 GB free, so use a subdirectory of it as TMPDIR instead. -mkdir -p "${FLATPAK_CACHE}/tmp" -export TMPDIR="${FLATPAK_CACHE}/tmp" -mkdir -p /run/dbus -dbus-daemon --system --fork --nopidfile -sleep 1 - -# ── Seed flatpak repo from build cache (warm start) ────────────────────────── -if [ -d "${FLATPAK_CACHE}/repo/refs" ]; then - echo "Seeding flatpak repo from build cache..." - rsync -a --ignore-existing "${FLATPAK_CACHE}/repo/" /var/lib/flatpak/repo/ || true - echo "Cache seed complete" -fi - -flatpak remote-add --system --if-not-exists flathub \ - https://dl.flathub.org/repo/flathub.flatpakrepo - -# bootc-installer bundle -# INSTALLER_CHANNEL controls which release tag to pull from: -# stable (default) → continuous (latest stable build from prod branch) -# dev → continuous-dev (latest dev build, tracks dev branch) -# Primary source: projectbluefin/bootc-installer (Project Bluefin's fork). -# Fallback: tuna-os/tuna-installer (upstream) if projectbluefin assets are unavailable. -# v2.5.0 includes fisherman v0.2.0 with fix for #38 (OCI cache mount on composefs/btrfs). -INSTALLER_REPO="projectbluefin/bootc-installer" -FALLBACK_REPO="tuna-os/tuna-installer" -RELEASE_TAG="continuous" -FLATPAK_FILENAME="org.bootcinstaller.Installer.flatpak" -if [[ "${INSTALLER_CHANNEL:-stable}" == "dev" ]]; then - RELEASE_TAG="continuous-dev" - FLATPAK_FILENAME="org.bootcinstaller.Installer.Devel.flatpak" -fi -if ! curl --retry 3 --fail --location \ - "https://github.com/${INSTALLER_REPO}/releases/download/${RELEASE_TAG}/${FLATPAK_FILENAME}" \ - -o /tmp/tuna-installer.flatpak 2>/dev/null; then - echo "Primary source unavailable, falling back to ${FALLBACK_REPO}..." - curl --retry 3 --fail --location \ - "https://github.com/${FALLBACK_REPO}/releases/download/${RELEASE_TAG}/${FLATPAK_FILENAME}" \ - -o /tmp/tuna-installer.flatpak -fi -INSTALLER_APP_ID="org.bootcinstaller.Installer" -[[ "${INSTALLER_CHANNEL:-stable}" == "dev" ]] && INSTALLER_APP_ID="org.bootcinstaller.Installer.Devel" - -flatpak install --system --noninteractive --bundle /tmp/tuna-installer.flatpak || \ - flatpak update --system --noninteractive "${INSTALLER_APP_ID}" -rm /tmp/tuna-installer.flatpak - -flatpak override --system --filesystem=/etc:ro "${INSTALLER_APP_ID}" - -# ── Reconcile Flathub apps against the wanted list ─────────────────────────── -# In debug mode, skip the full Flathub app list to keep builds fast. -# NOTE: Disabled to allow debug ISOs with full flatpak suite + SSH access -# if [[ "${DEBUG:-0}" == "1" ]]; then -# echo "DEBUG mode: skipping Flathub app list (installer-only ISO)" -# # Still save cache for the installer runtime -# echo "Saving flatpak repo to build cache..." -# mkdir -p "${FLATPAK_CACHE}" -# rsync -a --delete /var/lib/flatpak/repo/ "${FLATPAK_CACHE}/repo/" -# exit 0 -# fi - -readarray -t WANTED < <(grep -v '^[[:space:]]*#' /tmp/flatpaks-list | grep -v '^[[:space:]]*$') - -# Install or update everything in the list (--or-update = skip if current) -# --no-related skips locale packs and debug symbols (~3 GB uncompressed) -flatpak install --system --noninteractive --no-related --or-update flathub "${WANTED[@]}" - -# Remove any system app that is no longer in the wanted list -readarray -t INSTALLED < <(flatpak list --app --system --columns=application 2>/dev/null || true) -for app in "${INSTALLED[@]}"; do - # Keep the installer regardless (stable or devel app ID) - [[ "$app" == "org.bootcinstaller.Installer" ]] && continue - [[ "$app" == "org.bootcinstaller.Installer.Devel" ]] && continue - if [[ ! " ${WANTED[*]} " =~ " ${app} " ]]; then - echo "Removing dropped flatpak: $app" - flatpak uninstall --system --noninteractive "$app" || true - fi -done - -# Prune unused runtimes left behind by removals -flatpak uninstall --system --noninteractive --unused || true - -# ── Save flatpak repo to build cache for next build ────────────────────────── -echo "Saving flatpak repo to build cache..." -mkdir -p "${FLATPAK_CACHE}" -rsync -a --delete /var/lib/flatpak/repo/ "${FLATPAK_CACHE}/repo/" -echo "Cache updated" diff --git a/src/luks-unlock.py b/src/luks-unlock.py deleted file mode 100644 index 1fdf735..0000000 --- a/src/luks-unlock.py +++ /dev/null @@ -1,534 +0,0 @@ -#!/usr/bin/env python3 -""" -Automate LUKS passphrase entry for a VM booting with Plymouth. - -Plymouth renders the passphrase prompt on the EFI framebuffer (not the serial -console), so we cannot detect it via serial output. Instead we detect the -Plymouth prompt by analysing QEMU screendumps (PPM files): - - - Plymouth passphrase prompt is a static, nearly all-black screen. - - We wait for the screendump MD5 hash to stabilise (stop changing) after - the framebuffer has first shown any non-zero content (OVMF/boot rendered). - - Then inject keystrokes via virsh send-key (libvirt) or QEMU HMP sendkey. - -Usage: - libvirt mode: luks-unlock.py libvirt - qemu mode: luks-unlock.py qemu - -Exit codes: - 0 — passphrase sent and boot succeeded (display re-stabilised after unlock) - 1 — error (timed out, passphrase prompt never appeared, etc.) - 2 — passphrase sent but boot resulted in emergency shell (issue #270 reproduced) -""" - -import hashlib -import os -import subprocess -import sys -import time - - -# ── Shared constants ────────────────────────────────────────────────────────── - -POLL_INTERVAL = 3 # seconds between screenshot polls -PLYMOUTH_WAIT = 10 # seconds to wait after display goes blank before sending keys -PROMPT_DEADLINE = 300 # seconds to wait for Plymouth to take over -BOOT_DEADLINE = 900 # seconds to wait for successful boot after passphrase - -# Headless QEMU (-display none) often keeps the framebuffer all-black after -# LUKS unlock while GRUB2 and Plymouth run. If the screen hash has not -# changed within this many seconds of the passphrase being sent, we assume -# the passphrase was accepted and the system is booting silently. -DARK_SCREEN_OVERRIDE_S = 90 - - -# ── Libvirt helpers ─────────────────────────────────────────────────────────── - -def virsh_screenshot_size(vm: str, path: str) -> int: - r = subprocess.run(["virsh", "screenshot", vm, path], capture_output=True) - if r.returncode != 0: - return 0 - try: - return os.path.getsize(path) - except OSError: - return 0 - - -def virsh_send_passphrase(vm: str, passphrase: str): - key_map = { - c: f"KEY_{c.upper()}" for c in "abcdefghijklmnopqrstuvwxyz" - } - key_map.update({str(i): f"KEY_{i}" for i in range(10)}) - key_map["-"] = "KEY_MINUS" - key_map["_"] = "KEY_MINUS" - key_map[" "] = "KEY_SPACE" - - for ch in passphrase: - key = key_map.get(ch) - if key is None: - print(f"[luks-unlock] WARNING: no key mapping for {ch!r}", file=sys.stderr) - continue - subprocess.run( - ["virsh", "send-key", vm, "--codeset", "linux", key], - capture_output=True, - ) - time.sleep(0.08) - subprocess.run( - ["virsh", "send-key", vm, "--codeset", "linux", "KEY_ENTER"], - capture_output=True, - ) - - -def virsh_dhcp_ip(mac: str) -> str: - r = subprocess.run( - ["virsh", "net-dhcp-leases", "default"], - capture_output=True, text=True, - ) - for line in r.stdout.splitlines(): - if mac.lower() in line.lower(): - for part in line.split(): - if "/" in part and "." in part: - return part.split("/")[0] - return "" - - -# ── QEMU monitor helpers ────────────────────────────────────────────────────── - -def qemu_screendump(sock: str, path: str) -> tuple: - """Return (brightness, md5_hash) for the screendump, or (-1, '') on error. - - PPM files are always the same byte length regardless of content, so we - analyse pixel values rather than file size. - - brightness — average sampled pixel value (0-255). - QEMU uninitialized: all zeros → 0.0 - OVMF/bootloader: dim text on black → typically 0.5–5 - Plymouth prompt: nearly all-black → typically 0.5–2, STABLE - GDM/GNOME: colourful UI → typically higher - - md5_hash — MD5 of the full PPM file. Used to detect when the display - has stopped changing (Plymouth is waiting for passphrase input). - """ - subprocess.run( - ["socat", "-", f"UNIX-CONNECT:{sock}"], - input=f"screendump {path}\n".encode(), - capture_output=True, - timeout=5, - ) - # Brief pause so QEMU can finish writing the PPM before we read it - time.sleep(0.5) - try: - data = open(path, "rb").read() - except OSError: - return -1, "" - md5 = hashlib.md5(data).hexdigest() - # Parse PPM header: "P6\n \n255\n" - try: - header_end = data.index(b"255\n") + 4 - except ValueError: - return -1, "" - pixel_data = data[header_end:] - if not pixel_data: - return -1, "" - # Sample every 100th byte for speed (each pixel = 3 bytes R,G,B) - sampled = pixel_data[::100] - return sum(sampled) / len(sampled), md5 - - -def qemu_send_passphrase(sock: str, passphrase: str): - # QEMU HMP sendkey takes individual key names (one per invocation). - # Keys are sent one character at a time with a small delay. - key_map = {c: c for c in "abcdefghijklmnopqrstuvwxyz0123456789"} - key_map["-"] = "minus" - key_map["_"] = "shift-minus" - key_map[" "] = "spc" - - def _sendkey(key: str): - subprocess.run( - ["socat", "-", f"UNIX-CONNECT:{sock}"], - input=f"sendkey {key}\n".encode(), - capture_output=True, - timeout=5, - ) - - for ch in passphrase: - key = key_map.get(ch) - if key is None: - print(f"[luks-unlock] WARNING: no key mapping for {ch!r}", file=sys.stderr) - continue - _sendkey(key) - time.sleep(0.1) - _sendkey("ret") - - -def qemu_check_serial(serial_log: str) -> str: - """Return 'plymouth', 'gdm', 'emergency', or '' if no marker yet. - - Checks for systemd unit messages that appear on the serial console when the - installed system has console=ttyS0 in its kernel cmdline. - Falls back gracefully to '' when serial output is absent. - """ - import re - try: - raw = open(serial_log).read() - except OSError: - return "" - # Strip ANSI escape codes and collapse whitespace so that systemd status - # lines like " OK ] Started \ngdm.service\n- GNOME Display…" - # become searchable as a single string. - content = re.sub(r'\x1b\[[0-9;]*[A-Za-z]', '', raw) - content_flat = ' '.join(content.split()) - if "emergency mode" in content or "emergency shell" in content: - return "emergency" - # systemd serial output (ANSI-stripped, whitespace-collapsed): - # "OK ] Started gdm.service - GNOME Display Manager." - if "Started gnome-initial-setup" in content_flat: - return "gnome-initial-setup" - if "Started gdm.service" in content_flat or "Started GNOME Display Manager" in content_flat: - return "gdm" - # Plymouth passphrase prompt — no ANSI codes, plain text on serial. - if "Please enter passphrase for disk" in raw: - return "plymouth" - return "" - - -# ── Mode implementations ────────────────────────────────────────────────────── - -def run_libvirt(vm: str, passphrase: str, mac: str): - snap = "/tmp/luks-unlock-snap.png" - seen_content = False - - print(f"[luks-unlock] libvirt mode — watching {vm} for Plymouth takeover...", flush=True) - deadline = time.time() + PROMPT_DEADLINE - - while time.time() < deadline: - size = virsh_screenshot_size(vm, snap) - print(f"[luks-unlock] screenshot: {size}B", flush=True) - - if not seen_content and size > 4096: - seen_content = True - print("[luks-unlock] Boot content visible (OVMF/bootloader)", flush=True) - - if seen_content and size <= 4096: - print( - f"[luks-unlock] Plymouth has the display — waiting {PLYMOUTH_WAIT}s...", - flush=True, - ) - time.sleep(PLYMOUTH_WAIT) - print("[luks-unlock] Sending passphrase via virsh send-key...", flush=True) - virsh_send_passphrase(vm, passphrase) - print("[luks-unlock] Passphrase sent — waiting for boot...", flush=True) - break - - time.sleep(POLL_INTERVAL) - else: - print("[luks-unlock] ERROR: Plymouth takeover never detected", file=sys.stderr) - sys.exit(1) - - deadline = time.time() + BOOT_DEADLINE - while time.time() < deadline: - ip = virsh_dhcp_ip(mac) - if ip: - print(f"[luks-unlock] RESULT: boot succeeded — guest IP {ip}", flush=True) - sys.exit(0) - time.sleep(5) - - print("[luks-unlock] WARNING: passphrase sent but no DHCP lease within timeout", file=sys.stderr) - sys.exit(2) - - -def ssh_reachable(port: int, timeout: int = 5) -> bool: - """Return True if sshd on localhost:port is accepting TCP connections. - - Checks TCP reachability only — does not require auth or a configured user. - An SSH banner in the response means the daemon is up and the system booted. - """ - import socket - try: - with socket.create_connection(("127.0.0.1", port), timeout=timeout) as s: - banner = s.recv(64) - return banner.startswith(b"SSH-") - except OSError: - return False - - -def run_qemu(monitor_sock: str, passphrase: str, serial_log: str, ssh_port: int = 0): - snap = "/tmp/luks-unlock-snap.ppm" - - # Plymouth detection strategy - # ---------------------------- - # QEMU with -display none renders very dim (brightness 0–5 for all phases). - # We cannot distinguish OVMF from Plymouth by absolute brightness, so we use - # two criteria instead: - # - # 1. had_content: at least one poll returned brightness > 0.5, meaning the - # VM has started rendering something (rules out the all-zeros framebuffer - # right after QEMU starts). - # - # 2. hash stability: the screendump MD5 has not changed for STABLE_POLLS - # consecutive polls. Plymouth passphrase prompt is a static screen - # (no animation) so it stabilises quickly; OVMF and early boot are - # actively changing. - CONTENT_THRESHOLD = 0.5 # any non-zero rendering - STABLE_POLLS = 2 # consecutive identical-hash polls → Plymouth waiting - # (≥ 6 s at POLL_INTERVAL=3) - - print(f"[luks-unlock] qemu mode — watching monitor {monitor_sock}...", flush=True) - deadline = time.time() + PROMPT_DEADLINE - - had_content = False - stable_count = 0 - prev_hash = "" - - while time.time() < deadline: - # Primary path: detect Plymouth passphrase prompt via serial log. - # With console=tty0 console=ttyS0 in the BLS entry, Plymouth writes - # the prompt to serial. Input still comes from tty0, so sendkey works. - serial_result = qemu_check_serial(serial_log) - if serial_result == "plymouth": - print("[luks-unlock] Plymouth passphrase prompt detected via serial", flush=True) - brightness, md5 = qemu_screendump(monitor_sock, snap) - prev_hash = md5 # anchor passphrase_hash so post-passphrase screen_changed is accurate - try: - import shutil - shutil.copy2(snap, "/tmp/luks-screenshot-plymouth.ppm") - except OSError: - pass - print(f"[luks-unlock] Waiting {PLYMOUTH_WAIT}s for Plymouth to settle...", flush=True) - time.sleep(PLYMOUTH_WAIT) - print("[luks-unlock] Sending passphrase via QEMU monitor sendkey...", flush=True) - qemu_send_passphrase(monitor_sock, passphrase) - print("[luks-unlock] Passphrase sent — watching for boot...", flush=True) - break - - brightness, md5 = qemu_screendump(monitor_sock, snap) - print(f"[luks-unlock] screendump brightness={brightness:.2f} hash={md5[:8]}", flush=True) - - if brightness < 0: - # Failed to read/parse screendump — socket not ready yet - stable_count = 0 - time.sleep(POLL_INTERVAL) - continue - - if not had_content and brightness > CONTENT_THRESHOLD: - had_content = True - print(f"[luks-unlock] VM is rendering (brightness {brightness:.2f})", flush=True) - - # Track hash stability only after the framebuffer has any content - if had_content: - if md5 == prev_hash: - stable_count += 1 - else: - stable_count = 0 - prev_hash = md5 - - # Fallback: detect Plymouth via framebuffer stability (no serial console) - if had_content and stable_count >= STABLE_POLLS: - print( - f"[luks-unlock] Plymouth prompt stable" - f" (brightness={brightness:.2f}, {stable_count} identical polls)", - flush=True, - ) - # Save a copy of the Plymouth screendump for CI diagnostics - try: - import shutil - shutil.copy2(snap, "/tmp/luks-screenshot-plymouth.ppm") - except OSError: - pass - print(f"[luks-unlock] Waiting {PLYMOUTH_WAIT}s for Plymouth to settle...", flush=True) - time.sleep(PLYMOUTH_WAIT) - print("[luks-unlock] Sending passphrase via QEMU monitor sendkey...", flush=True) - qemu_send_passphrase(monitor_sock, passphrase) - print("[luks-unlock] Passphrase sent — watching for boot...", flush=True) - break - - time.sleep(POLL_INTERVAL) - else: - print("[luks-unlock] ERROR: Plymouth takeover never detected", file=sys.stderr) - sys.exit(1) - - # After passphrase: watch for the screen to change from Plymouth (passphrase - # accepted → Plymouth clears → boot continues) and check serial for emergency - # shell (still useful for catching issue #270 even without ttyS0). - deadline = time.time() + BOOT_DEADLINE - passphrase_time = time.time() - passphrase_hash = prev_hash # Plymouth hash at time of passphrase send - screen_changed = False - gnome_bright_count = 0 - emergency_stable_count = 0 - - - while time.time() < deadline: - result = qemu_check_serial(serial_log) - if result == "emergency": - print("[luks-unlock] RESULT: emergency shell — issue #270 reproduced", flush=True) - sys.exit(2) - - # SSH success path: if caller provided a port, test TCP reachability to - # detect sshd banner — no auth needed, just "daemon is up = boot done". - # Wins reliably when the installed system starts sshd but lacks - # console=ttyS0 (so no serial markers reach the log). - if ssh_port and ssh_reachable(ssh_port): - print(f"[luks-unlock] RESULT: boot succeeded (sshd banner on port {ssh_port})", - flush=True) - print("[luks-unlock] Waiting 20s for GDM/desktop to fully render...", flush=True) - time.sleep(20) - try: - import shutil - qemu_screendump(monitor_sock, snap) - shutil.copy2(snap, "/tmp/luks-screenshot-final.ppm") - except OSError: - pass - sys.exit(0) - - # Dark-screen override: headless QEMU (-display none) often keeps the - # framebuffer all-black during GRUB2 + Plymouth even after a successful - # LUKS unlock. The passphrase_hash == post-passphrase hash so - # screen_changed never flips and the brightness check never runs. - # - # When the screen stays dark for DARK_SCREEN_OVERRIDE_S seconds: - # - With SSH port: do nothing. We just keep looping and polling SSH. - # - Without SSH port: exit 0 now. If the passphrase was wrong Plymouth - # would have re-prompted; silence = passphrase accepted = boot proceeding. - elapsed_since_passphrase = time.time() - passphrase_time - if not screen_changed and elapsed_since_passphrase > DARK_SCREEN_OVERRIDE_S: - if not ssh_port: - print( - f"[luks-unlock] Dark-screen override: screen unchanged for " - f"{int(elapsed_since_passphrase)}s and no SSH port configured — assuming boot succeeded", - flush=True, - ) - sys.exit(0) - - - brightness, md5 = qemu_screendump(monitor_sock, snap) - print(f"[luks-unlock] post-passphrase brightness={brightness:.2f} hash={md5[:8]}", - flush=True) - - if md5 != passphrase_hash and not screen_changed: - screen_changed = True - print( - "[luks-unlock] Screen changed after passphrase" - " — LUKS accepted, boot proceeding", - flush=True, - ) - - # Primary success path: serial log confirms gnome-initial-setup or GDM. - # gnome-initial-setup fires after GDM — screenshot taken immediately. - # If only GDM is seen, wait 30s as a fallback in case g-i-s is slow. - if result == "gnome-initial-setup": - print("[luks-unlock] gnome-initial-setup started (serial confirmed) — waiting 15s to render UI", flush=True) - time.sleep(15) - brightness, md5 = qemu_screendump(monitor_sock, snap) - print(f"[luks-unlock] RESULT: boot succeeded (g-i-s confirmed via serial, brightness={brightness:.2f})", flush=True) - elif result == "gdm": - print( - "[luks-unlock] GDM started — waiting 30s for gnome-initial-setup...", - flush=True, - ) - time.sleep(30) - brightness, md5 = qemu_screendump(monitor_sock, snap) - print( - f"[luks-unlock] RESULT: boot succeeded" - f" (GDM confirmed via serial, brightness={brightness:.2f})", - flush=True, - ) - if result in ("gnome-initial-setup", "gdm"): - try: - import shutil - shutil.copy2(snap, "/tmp/luks-screenshot-final.ppm") - except OSError: - pass - sys.exit(0) - - # Fallback: no serial console (console=ttyS0 absent). Use framebuffer - # brightness to distinguish GDM from emergency shell. - # GDM re-renders continuously (cursor blink, animations, clock), so we - # cannot require identical hashes. Instead, we detect GDM by verifying - # the screen remains bright for multiple consecutive polls. - # For the emergency shell, which is static and dark, we require identical - # hashes and low brightness. - GNOME_THRESHOLD = 1.8 - GNOME_BRIGHT_POLLS = 2 # Screen remains bright for 2 polls (~10s) - EMERGENCY_STABLE_POLLS = 3 # Screen remains stable and dark for 3 polls (~15s) - - if screen_changed: - if brightness > GNOME_THRESHOLD: - gnome_bright_count += 1 - else: - gnome_bright_count = 0 - - if md5 == prev_hash and brightness <= GNOME_THRESHOLD: - emergency_stable_count += 1 - else: - emergency_stable_count = 0 - - if gnome_bright_count >= GNOME_BRIGHT_POLLS: - print( - f"[luks-unlock] RESULT: boot succeeded" - f" (framebuffer bright for {gnome_bright_count} polls," - f" brightness={brightness:.2f})", - flush=True, - ) - print("[luks-unlock] Waiting 25s for GDM/desktop to fully render...", flush=True) - time.sleep(25) - try: - import shutil - qemu_screendump(monitor_sock, snap) - shutil.copy2(snap, "/tmp/luks-screenshot-final.ppm") - except OSError: - pass - sys.exit(0) - - if emergency_stable_count >= EMERGENCY_STABLE_POLLS: - print( - f"[luks-unlock] RESULT: emergency shell suspected" - f" (framebuffer stable and dark for {emergency_stable_count} polls," - f" brightness={brightness:.2f})", - flush=True, - ) - try: - import shutil - shutil.copy2(snap, "/tmp/luks-screenshot-final.ppm") - except OSError: - pass - sys.exit(2) - - prev_hash = md5 - time.sleep(5) - - print("[luks-unlock] WARNING: passphrase sent but boot did not complete within timeout", - file=sys.stderr) - sys.exit(2) - - -# ── Entry point ─────────────────────────────────────────────────────────────── - -def main(): - if len(sys.argv) < 2: - print(__doc__, file=sys.stderr) - sys.exit(1) - - mode = sys.argv[1] - - if mode == "libvirt": - if len(sys.argv) < 5: - print("Usage: luks-unlock.py libvirt ", file=sys.stderr) - sys.exit(1) - run_libvirt(sys.argv[2], sys.argv[3], sys.argv[4]) - - elif mode == "qemu": - if len(sys.argv) < 5: - print("Usage: luks-unlock.py qemu [ssh-port]", - file=sys.stderr) - sys.exit(1) - ssh_port = int(sys.argv[5]) if len(sys.argv) >= 6 else 0 - run_qemu(sys.argv[2], sys.argv[3], sys.argv[4], ssh_port=ssh_port) - - else: - print(f"Unknown mode: {mode!r}. Use 'libvirt' or 'qemu'.", file=sys.stderr) - sys.exit(1) - - -if __name__ == "__main__": - main() diff --git a/src/show-screenshot.sh b/src/show-screenshot.sh deleted file mode 100755 index aaf9c8a..0000000 --- a/src/show-screenshot.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/bash -# Display a PPM screendump inline in terminals that support it. -# Usage: show-screenshot.sh