summaryrefslogtreecommitdiff
path: root/build_files/build.sh
diff options
context:
space:
mode:
authortranch <tranch.xiao@gmail.com>2026-11-17 00:13:25 +0800
committertranch <tranch.xiao@gmail.com>2026-11-17 00:21:20 +0800
commit2d46b8296a7ee7243f5f6d2d01d6effa1e5b27e9 (patch)
tree24359c8ce049669b7a880e3e54acee24a78dcd3d /build_files/build.sh
parentf273f285f546173a4a9abf61eee0ec8b83e09ad7 (diff)
downloadAeroCore-OS-2d46b8296a7ee7243f5f6d2d01d6effa1e5b27e9.tar.gz
AeroCore-OS-2d46b8296a7ee7243f5f6d2d01d6effa1e5b27e9.zip
Make Flatpak mirror setup resilienttesting-45.20261116
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.
Diffstat (limited to 'build_files/build.sh')
-rwxr-xr-xbuild_files/build.sh37
1 files changed, 35 insertions, 2 deletions
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