diff options
| author | tranch <tranch.xiao@gmail.com> | 2026-11-18 08:11:29 +0800 |
|---|---|---|
| committer | tranch <tranch.xiao@gmail.com> | 2026-11-18 08:11:29 +0800 |
| commit | de9a4f9275afccbaf0b18d1b8e18a17e3070102f (patch) | |
| tree | e567cd49c63b17c7809b19117d69889ca4f3c4eb | |
| parent | 977a1e6fb81dfc264fa1e5d87652a37508fedaf8 (diff) | |
| parent | 95702ac4933104a7e3b6c512982fdf9334409379 (diff) | |
| download | AeroCore-OS-de9a4f9275afccbaf0b18d1b8e18a17e3070102f.tar.gz AeroCore-OS-de9a4f9275afccbaf0b18d1b8e18a17e3070102f.zip | |
Merge testing-45.20261117 into main45.20261118
* testing:
ci: add scheduled GHCR image cleanup
build: align testing with Bazzite 45.20261117
Update existing Flatpak remotes at boot
Make Flatpak mirror setup resilient
| -rw-r--r-- | .github/workflows/build-live-iso.yml | 2 | ||||
| -rw-r--r-- | .github/workflows/build.yml | 6 | ||||
| -rw-r--r-- | .github/workflows/clean.yml | 40 | ||||
| -rw-r--r-- | Containerfile | 4 | ||||
| -rw-r--r-- | Justfile | 6 | ||||
| -rwxr-xr-x | build_files/build.sh | 41 | ||||
| -rw-r--r-- | image-template.env | 2 | ||||
| -rw-r--r-- | system_files/usr/lib/systemd/system/aerocore-flatpak-mirror.service | 11 | ||||
| -rwxr-xr-x | system_files/usr/libexec/aerocore-configure-flatpak-mirror | 21 | ||||
| -rw-r--r-- | tests/test-flatpak-mirror-build-config.sh | 68 | ||||
| -rwxr-xr-x | tests/test-flatpak-runtime-mirror.sh | 62 |
11 files changed, 251 insertions, 12 deletions
diff --git a/.github/workflows/build-live-iso.yml b/.github/workflows/build-live-iso.yml index def88be..2206038 100644 --- a/.github/workflows/build-live-iso.yml +++ b/.github/workflows/build-live-iso.yml @@ -67,7 +67,7 @@ jobs: fedora_version="$(sudo podman run --rm --network none --entrypoint /usr/bin/rpm "${IMAGE_REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}" -E %fedora)" [[ "${fedora_version}" =~ ^[0-9]+$ ]] || { echo "Invalid Fedora version: ${fedora_version}" >&2; exit 1; } [[ "${fedora_version}" == 45 ]] || { echo "Expected Fedora 45 payload, got ${fedora_version}" >&2; exit 1; } - echo "LIVE_BASE_IMAGE=ghcr.io/ublue-os/bazzite:stable-45.20261112" >> "$GITHUB_ENV" + echo "LIVE_BASE_IMAGE=ghcr.io/ublue-os/bazzite:stable-45.20261117" >> "$GITHUB_ENV" - name: Build installer ISO payload run: | diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5da933d..db4f0e1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,7 @@ env: IMAGE_LOGO_URL: ${{ vars.IMAGE_LOGO_URL || 'https://avatars.githubusercontent.com/u/120078124?s=200&v=4' }} DEFAULT_TAG: ${{ vars.DEFAULT_TAG || 'stable' }} BIB_IMAGE: ${{ vars.BIB_IMAGE || 'quay.io/centos-bootc/bootc-image-builder:latest' }} - BASE_IMAGE: ${{ vars.BASE_IMAGE || 'ghcr.io/ublue-os/bazzite-deck:stable-45.20261112' }} + BASE_IMAGE: ${{ vars.BASE_IMAGE || 'ghcr.io/ublue-os/bazzite-deck:stable-45.20261117' }} FLATPAK_REMOTE_URL: ${{ vars.FLATPAK_REMOTE_URL }} HOMEBREW_BOTTLE_DOMAIN: ${{ vars.HOMEBREW_BOTTLE_DOMAIN }} HOMEBREW_API_DOMAIN: ${{ vars.HOMEBREW_API_DOMAIN }} @@ -101,9 +101,9 @@ jobs: set -euo pipefail if [[ "${GITHUB_REF_NAME}" == "unstable" ]]; then - BASE_IMAGE="ghcr.io/ublue-os/bazzite-deck:stable-45.20261112" + BASE_IMAGE="ghcr.io/ublue-os/bazzite-deck:stable-45.20261117" else - BASE_IMAGE="${BASE_IMAGE_VAR:-ghcr.io/ublue-os/bazzite-deck:stable-45.20261112}" + BASE_IMAGE="${BASE_IMAGE_VAR:-ghcr.io/ublue-os/bazzite-deck:stable-45.20261117}" fi echo "Using BASE_IMAGE=${BASE_IMAGE}" echo "BASE_IMAGE=${BASE_IMAGE}" >> "$GITHUB_ENV" diff --git a/.github/workflows/clean.yml b/.github/workflows/clean.yml new file mode 100644 index 0000000..7954c84 --- /dev/null +++ b/.github/workflows/clean.yml @@ -0,0 +1,40 @@ +name: Cleanup Old Images + +on: + schedule: + - cron: "15 0 * * 0" # 00:15 UTC every Sunday + workflow_dispatch: + inputs: + dry_run: + description: "Preview deletions without removing images" + required: true + default: true + type: boolean + +permissions: {} + +concurrency: + group: cleanup-ghcr-images + cancel-in-progress: false + +jobs: + cleanup-ghcr: + name: Clean old GHCR image versions + runs-on: ubuntu-latest + permissions: + packages: write + + steps: + - name: Delete images older than 90 days + uses: dataaxiom/ghcr-cleanup-action@d52806a0dc70b430571a37da1fde39733ffd640f # v1.2.2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + packages: aerocore-os + older-than: 90 days + keep-n-tagged: 7 + keep-n-untagged: 7 + delete-orphaned-images: true + # Protect the rolling channel aliases, including the current Fedora-major aliases. + exclude-tags: '^(stable|latest|testing|stable-[0-9]+|testing-[0-9]+)$' + use-regex: true + dry-run: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run || false }} diff --git a/Containerfile b/Containerfile index 8b8776f..a746ded 100644 --- a/Containerfile +++ b/Containerfile @@ -1,5 +1,5 @@ # Allow build scripts to be referenced without being copied into the final image -ARG BASE_IMAGE="ghcr.io/ublue-os/bazzite-deck:stable-45.20261112" +ARG BASE_IMAGE="ghcr.io/ublue-os/bazzite-deck:stable-45.20261117" FROM scratch AS ctx COPY build_files / @@ -15,7 +15,7 @@ ARG VERSION_TAG="latest" ARG VERSION_PRETTY="latest" ARG OSTREE_IMAGE_REF="" ## Other possible base images include: -# ghcr.io/ublue-os/bazzite-deck:stable-45.20261112 +# ghcr.io/ublue-os/bazzite-deck:stable-45.20261117 ### [IM]MUTABLE /opt ## Some bootable images, like Fedora, have /opt symlinked to /var/opt, in order to @@ -11,9 +11,9 @@ export bib_image := env_var("BIB_IMAGE") export IMAGE_BRANCH := env_var_or_default("IMAGE_BRANCH", "testing-candidate") export VERSION_TAG := env_var_or_default("VERSION_TAG", "") export VERSION_PRETTY := env_var_or_default("VERSION_PRETTY", "") -export BASE_IMAGE := env_var_or_default("BASE_IMAGE", "ghcr.io/ublue-os/bazzite-deck:stable-45.20261112") +export BASE_IMAGE := env_var_or_default("BASE_IMAGE", "ghcr.io/ublue-os/bazzite-deck:stable-45.20261117") export OSTREE_IMAGE_REF := env_var_or_default("OSTREE_IMAGE_REF", "ostree-image-signed:docker://ghcr.io/" + repo_organization + "/" + image_name) -export LIVE_BASE_IMAGE := env_var_or_default("LIVE_BASE_IMAGE", "ghcr.io/ublue-os/bazzite:stable-45.20261112") +export LIVE_BASE_IMAGE := env_var_or_default("LIVE_BASE_IMAGE", "ghcr.io/ublue-os/bazzite:stable-45.20261117") export TITANOBOA_REPOSITORY := env_var_or_default("TITANOBOA_REPOSITORY", "https://github.com/Zeglius/titanoboa.git") export TITANOBOA_REVISION := env_var_or_default("TITANOBOA_REVISION", "7737f4748458252ac827dca14b3d6dd09298472a") export FLATPAK_REMOTE_URL := env_var_or_default("FLATPAK_REMOTE_URL", "") @@ -137,7 +137,7 @@ build $target_image=image_name $tag=default_tag: "--build-arg" "IMAGE_BRANCH={{ tag }}" "--build-arg" "VERSION_TAG=${VERSION_TAG:-{{ tag }}}" "--build-arg" "VERSION_PRETTY=${VERSION_PRETTY:-${VERSION_TAG:-{{ tag }}}}" - "--label" "org.opencontainers.image.base.name=${BASE_IMAGE:-ghcr.io/ublue-os/bazzite-deck:stable-45.20261112}" + "--label" "org.opencontainers.image.base.name=${BASE_IMAGE:-ghcr.io/ublue-os/bazzite-deck:stable-45.20261117}" ) for arg in BASE_IMAGE FLATPAK_REMOTE_URL HOMEBREW_BOTTLE_DOMAIN HOMEBREW_API_DOMAIN OSTREE_IMAGE_REF INSTRUMENTS_ENABLED INSTRUMENTS_RELEASE_REPOSITORY INSTRUMENTS_VERSION INSTRUMENTS_RELEASE_API_BASE; do diff --git a/build_files/build.sh b/build_files/build.sh index 94a5ef5..23e86cb 100755 --- a/build_files/build.sh +++ b/build_files/build.sh @@ -14,6 +14,10 @@ esac # Copy the contents of system_files/ of the git repo to / cp -avf "/ctx/system_files"/. / +# Apply configured Flatpak mirrors to existing installations as well as new +# remotes created from flathub.flatpakrepo during first boot. +systemctl enable aerocore-flatpak-mirror.service + # Keep Bazzite's game mode news hook unchanged; select the matching feed branch. NEWS_HOOK_CONFIG=/etc/gamemode-news-hook.conf if [[ ! -f "${NEWS_HOOK_CONFIG}" ]]; then @@ -145,6 +149,7 @@ if [[ -f "${CEC_CONFIG}" ]]; then fi fi +configure_mirrors() { mkdir -p /etc/environment.d if [[ -n "${FLATPAK_REMOTE_URL:-}" || -n "${HOMEBREW_BOTTLE_DOMAIN:-}" || -n "${HOMEBREW_API_DOMAIN:-}" ]]; then @@ -153,8 +158,35 @@ fi if [[ -n "${FLATPAK_REMOTE_URL:-}" ]]; then printf '%s\n' "FLATPAK_REMOTE_URL=${FLATPAK_REMOTE_URL}" >> /etc/environment.d/99-aerocore-mirrors.conf - if [[ -f /usr/libexec/bazzite-mirror-utils.sh ]]; then - bash /usr/libexec/bazzite-mirror-utils.sh update_flathub_repo_url "${FLATPAK_REMOTE_URL}" + mirror_utils=/usr/libexec/bazzite-mirror-utils.sh + flatpak_repo=/etc/flatpak/remotes.d/flathub.flatpakrepo + expected_flatpak_url="${FLATPAK_REMOTE_URL%/}/" + mirror_updated=false + + if [[ -r "${mirror_utils}" ]] && bash "${mirror_utils}" update_flathub_repo_url "${FLATPAK_REMOTE_URL}"; then + mirror_updated=true + fi + + # Keep mirror configuration best-effort. If Bazzite's helper is absent or + # cannot update the definition, update its Url field directly as a fallback. + if [[ "${mirror_updated}" != true && -w "${flatpak_repo}" ]]; then + temp_repo="$(mktemp)" + if awk -v url="${expected_flatpak_url}" ' + BEGIN { updated = 0 } + /^Url=/ { print "Url=" url; updated = 1; next } + { print } + END { if (!updated) print "Url=" url } + ' "${flatpak_repo}" > "${temp_repo}" && mv "${temp_repo}" "${flatpak_repo}"; then + mirror_updated=true + else + rm -f "${temp_repo}" + fi + fi + + if [[ "${mirror_updated}" == true ]]; then + echo "Configured Flathub mirror: ${expected_flatpak_url}" + else + echo "Warning: could not configure Flathub mirror ${expected_flatpak_url}; keeping the existing repo definition." >&2 fi fi @@ -172,6 +204,11 @@ if [[ -n "${HOMEBREW_API_DOMAIN:-}" ]]; then fi find /etc/environment.d /etc/skel/.config/environment.d -name 99-aerocore-mirrors.conf -type f -exec chmod 0644 {} + 2>/dev/null || true +} + +if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then + configure_mirrors +fi /ctx/install-instruments.sh /ctx/patch-bazzite-deck-identity.sh diff --git a/image-template.env b/image-template.env index 10720f4..01736f3 100644 --- a/image-template.env +++ b/image-template.env @@ -16,7 +16,7 @@ BIB_IMAGE="quay.io/centos-bootc/bootc-image-builder:latest" # Keep this on bazzite-deck for Steam Deck, game mode, and handheld customizations. # Use a concrete tag during transition windows if stable/testing moves underneath you. -BASE_IMAGE="ghcr.io/ublue-os/bazzite-deck:stable-45.20261112" +BASE_IMAGE="ghcr.io/ublue-os/bazzite-deck:stable-45.20261117" # Optional mirror settings. FLATPAK_REMOTE_URL="" diff --git a/system_files/usr/lib/systemd/system/aerocore-flatpak-mirror.service b/system_files/usr/lib/systemd/system/aerocore-flatpak-mirror.service new file mode 100644 index 0000000..8aed8cb --- /dev/null +++ b/system_files/usr/lib/systemd/system/aerocore-flatpak-mirror.service @@ -0,0 +1,11 @@ +[Unit] +Description=Apply configured AeroCore Flatpak mirror +After=flatpak-add-fedora-repos.service bazzite-flatpak-manager.service +Wants=flatpak-add-fedora-repos.service bazzite-flatpak-manager.service + +[Service] +Type=oneshot +ExecStart=/usr/libexec/aerocore-configure-flatpak-mirror + +[Install] +WantedBy=multi-user.target diff --git a/system_files/usr/libexec/aerocore-configure-flatpak-mirror b/system_files/usr/libexec/aerocore-configure-flatpak-mirror new file mode 100755 index 0000000..42b1d84 --- /dev/null +++ b/system_files/usr/libexec/aerocore-configure-flatpak-mirror @@ -0,0 +1,21 @@ +#!/usr/bin/bash + +set -u + +config_file=/etc/environment.d/99-aerocore-mirrors.conf +[[ -r "${config_file}" ]] || exit 0 + +FLATPAK_REMOTE_URL="$(sed -n 's/^FLATPAK_REMOTE_URL=//p' "${config_file}" | tail -n 1)" +[[ -n "${FLATPAK_REMOTE_URL}" ]] || exit 0 +[[ "${FLATPAK_REMOTE_URL}" =~ ^https?://[^[:space:]]+$ ]] || { + echo "Ignoring invalid FLATPAK_REMOTE_URL: ${FLATPAK_REMOTE_URL}" >&2 + exit 0 +} + +mirror_url="${FLATPAK_REMOTE_URL%/}/" +if flatpak remotes --system --columns=name | grep -Fxq flathub; then + flatpak remote-modify --system flathub --url="${mirror_url}" +else + flatpak remote-add --system --if-not-exists flathub /etc/flatpak/remotes.d/flathub.flatpakrepo + flatpak remote-modify --system flathub --url="${mirror_url}" +fi diff --git a/tests/test-flatpak-mirror-build-config.sh b/tests/test-flatpak-mirror-build-config.sh new file mode 100644 index 0000000..1b661bd --- /dev/null +++ b/tests/test-flatpak-mirror-build-config.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +set -euo pipefail + +project_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +build_script="${project_root}/build_files/build.sh" +test_root="$(mktemp -d)" +trap 'rm -rf "${test_root}"' EXIT + +mirror_function="${test_root}/configure-mirrors.sh" +sed -n '/^configure_mirrors() {/,/^}$/p' "${build_script}" > "${mirror_function}" +source "${mirror_function}" + +assert_eq() { + local expected="$1" actual="$2" message="$3" + if [[ "${expected}" != "${actual}" ]]; then + printf 'FAIL: %s\nexpected: <%s>\nactual: <%s>\n' "${message}" "${expected}" "${actual}" >&2 + exit 1 + fi +} + +run_case() { + local name="$1" helper_mode="$2" repo_mode="$3" + local case_root="${test_root}/${name}" + mkdir -p "${case_root}/etc/environment.d" "${case_root}/skel/.config/environment.d" "${case_root}/etc/flatpak/remotes.d" "${case_root}/usr/libexec" + export TEST_ROOT="${case_root}" + export FLATPAK_REMOTE_URL='https://mirror.example/flathub' + unset HOMEBREW_BOTTLE_DOMAIN HOMEBREW_API_DOMAIN + + if [[ "${helper_mode}" != missing ]]; then + cat > "${case_root}/usr/libexec/bazzite-mirror-utils.sh" <<'HELPER' +#!/usr/bin/env bash +[[ "${HELPER_MODE}" == fail ]] && exit 1 +awk -v url="${2%/}/" 'BEGIN{updated=0} /^Url=/{print "Url=" url;updated=1;next} {print} END{if(!updated)print "Url=" url}' "${TEST_ROOT}/etc/flatpak/remotes.d/flathub.flatpakrepo" > "${TEST_ROOT}/repo.tmp" && mv "${TEST_ROOT}/repo.tmp" "${TEST_ROOT}/etc/flatpak/remotes.d/flathub.flatpakrepo" +HELPER + chmod +x "${case_root}/usr/libexec/bazzite-mirror-utils.sh" + fi + + printf '[Flatpak Repo]\nTitle=Flathub\nUrl=https://dl.flathub.org/repo/\nHomepage=https://flathub.org/\n' > "${case_root}/etc/flatpak/remotes.d/flathub.flatpakrepo" + if [[ "${repo_mode}" == readonly ]]; then chmod 0444 "${case_root}/etc/flatpak/remotes.d/flathub.flatpakrepo"; fi + + # Relocate production paths into an isolated fixture, then execute the + # extracted production function directly. + export HELPER_MODE="${helper_mode}" + sed -e "s|/etc/environment.d|${case_root}/etc/environment.d|g" \ + -e "s|/etc/skel|${case_root}/skel|g" \ + -e "s|/usr/libexec|${case_root}/usr/libexec|g" \ + -e "s|/etc/flatpak|${case_root}/etc/flatpak|g" \ + "${mirror_function}" > "${case_root}/configure-mirrors.sh" + source "${case_root}/configure-mirrors.sh" + configure_mirrors + + local actual_url + actual_url="$(sed -n 's/^Url=//p' "${case_root}/etc/flatpak/remotes.d/flathub.flatpakrepo")" + if [[ "${helper_mode}" == success || ( "${repo_mode}" == writable && "${helper_mode}" != success ) ]]; then + assert_eq 'https://mirror.example/flathub/' "${actual_url}" "${name}: configured mirror URL" + else + assert_eq 'https://dl.flathub.org/repo/' "${actual_url}" "${name}: retain original URL when no write path exists" + fi + assert_eq 'FLATPAK_REMOTE_URL=https://mirror.example/flathub' "$(cat "${case_root}/etc/environment.d/99-aerocore-mirrors.conf")" "${name}: persist environment setting" +} + +run_case helper_success success writable +run_case helper_failure fail writable +run_case helper_missing missing writable +run_case no_write_path fail readonly + +echo "Flatpak mirror behavior checks passed." diff --git a/tests/test-flatpak-runtime-mirror.sh b/tests/test-flatpak-runtime-mirror.sh new file mode 100755 index 0000000..bd0fc86 --- /dev/null +++ b/tests/test-flatpak-runtime-mirror.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +set -euo pipefail + +project_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +source_script="${project_root}/system_files/usr/libexec/aerocore-configure-flatpak-mirror" +test_root="$(mktemp -d)" +trap 'rm -rf "${test_root}"' EXIT + +assert_eq() { + local expected="$1" actual="$2" message="$3" + if [[ "${expected}" != "${actual}" ]]; then + printf 'FAIL: %s\nexpected: <%s>\nactual: <%s>\n' "${message}" "${expected}" "${actual}" >&2 + exit 1 + fi +} + +run_case() { + local name="$1" exists="$2" url="$3" + local root="${test_root}/${name}" + mkdir -p "${root}/etc/environment.d" "${root}/etc/flatpak/remotes.d" "${root}/usr/bin" + printf 'FLATPAK_REMOTE_URL=%s\n' "${url}" > "${root}/etc/environment.d/99-aerocore-mirrors.conf" + : > "${root}/etc/flatpak/remotes.d/flathub.flatpakrepo" + printf '%s\n' "${exists}" > "${root}/remote-exists" + : > "${root}/flatpak.calls" + + cat > "${root}/usr/bin/flatpak" <<'FLATPAK' +#!/usr/bin/env bash +printf '%s\n' "$*" >> "${TEST_ROOT}/flatpak.calls" +if [[ "$1 $2 $3" == 'remotes --system --columns=name' ]]; then + [[ "$(cat "${TEST_ROOT}/remote-exists")" == true ]] && echo flathub +fi +if [[ "$1 $2 $3" == 'remote-add --system --if-not-exists' ]]; then + printf true > "${TEST_ROOT}/remote-exists" +fi +FLATPAK + chmod +x "${root}/usr/bin/flatpak" + + sed -e "s|/etc/environment.d|${root}/etc/environment.d|g" \ + -e "s|/etc/flatpak|${root}/etc/flatpak|g" \ + "${source_script}" > "${root}/configure-mirror" + chmod +x "${root}/configure-mirror" + export TEST_ROOT="${root}" PATH="${root}/usr/bin:${PATH}" + bash "${root}/configure-mirror" + cat "${root}/flatpak.calls" > "${root}/calls.actual" +} + +run_case existing_remote true https://mirror.example/flathub +assert_eq 'remotes --system --columns=name +remote-modify --system flathub --url=https://mirror.example/flathub/' "$(cat "${test_root}/existing_remote/calls.actual")" 'existing remote is updated' + +run_case missing_remote false https://mirror.example/flathub/ +expected_missing_calls="$(printf 'remotes --system --columns=name\nremote-add --system --if-not-exists flathub %s\nremote-modify --system flathub --url=https://mirror.example/flathub/' "${test_root}/missing_remote/etc/flatpak/remotes.d/flathub.flatpakrepo")" +assert_eq "${expected_missing_calls}" "$(cat "${test_root}/missing_remote/calls.actual")" 'missing remote is added then updated' + +run_case empty_url true '' +assert_eq '' "$(cat "${test_root}/empty_url/calls.actual")" 'empty setting leaves remotes unchanged' + +run_case invalid_url true 'not-a-url' +assert_eq '' "$(cat "${test_root}/invalid_url/calls.actual")" 'invalid setting leaves remotes unchanged' + +echo "Flatpak runtime mirror behavior checks passed." |
