From 2d46b8296a7ee7243f5f6d2d01d6effa1e5b27e9 Mon Sep 17 00:00:00 2001 From: tranch Date: Tue, 17 Nov 2026 00:13:25 +0800 Subject: Make Flatpak mirror setup resilient Try the Bazzite mirror helper first, then update the repo definition directly when the helper is unavailable or fails. Keep image builds running if neither path can configure the mirror, and add behavior coverage for each fallback. Verified on ayaneo-am02.lan with the Linux behavior test. --- build_files/build.sh | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'build_files/build.sh') diff --git a/build_files/build.sh b/build_files/build.sh index 94a5ef5..2d43e33 100755 --- a/build_files/build.sh +++ b/build_files/build.sh @@ -145,6 +145,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 +154,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 +200,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 -- cgit v1.2.3 From 7c9d6c1e358ea3c33aeef1191e3e02f001b083bd Mon Sep 17 00:00:00 2001 From: tranch Date: Tue, 17 Nov 2026 01:48:26 +0800 Subject: Update existing Flatpak remotes at boot Add a systemd oneshot that applies the configured Flathub mirror after Bazzite initializes system Flatpak remotes. Update an existing flathub URL, or create the remote first when it is missing. Cover both paths and invalid or empty mirror settings with behavior tests. --- build_files/build.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'build_files/build.sh') diff --git a/build_files/build.sh b/build_files/build.sh index 2d43e33..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 -- cgit v1.2.3