From f068acf3b1c2a4551c5119997fd40909ddd35386 Mon Sep 17 00:00:00 2001 From: tranch Date: Sun, 13 Sep 2026 19:05:58 +0800 Subject: Run shortcut migration before setup guard Ensure legacy Return.desktop files are repaired even when Bazzite user setup has already completed for the user. --- build_files/patch-bazzite-deck-identity.sh | 30 +++++++++++++++++----- .../bazzite-44/usr/libexec/bazzite-user-setup | 2 ++ tests/test-patch-bazzite-deck-identity.sh | 4 +++ 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/build_files/patch-bazzite-deck-identity.sh b/build_files/patch-bazzite-deck-identity.sh index da2a74e..8ddacf9 100755 --- a/build_files/patch-bazzite-deck-identity.sh +++ b/build_files/patch-bazzite-deck-identity.sh @@ -161,6 +161,8 @@ patch_desktop_branding_migration() { patch_gamemode_shortcut_migration() { local file="$1" local marker='AeroCore Return to Gaming Mode shortcut migration' + local insertion='# Run script if updated' + local patched_file if [[ ! -f "$file" ]]; then echo "Unable to locate expected Bazzite user setup file: $file" >&2 @@ -171,14 +173,28 @@ patch_gamemode_shortcut_migration() { return 0 fi - cat >> "$file" <<'EOF' + if [[ "$(grep -Foc "$insertion" "$file" || true)" -ne 1 ]]; then + echo "Unable to locate the Bazzite user setup version guard in $file" >&2 + exit 1 + fi -# AeroCore Return to Gaming Mode shortcut migration -# Replace the legacy privileged systemd launcher left by older Bazzite images. -if [[ -f "$HOME/Desktop/Return.desktop" ]]; then - sed -i 's|^Exec=systemctl start return-to-gamemode\.service$|Exec=/usr/bin/return-to-gamemode|' "$HOME/Desktop/Return.desktop" -fi -EOF + patched_file="$(mktemp)" + awk -v insertion="$insertion" ' + !inserted && $0 == insertion { + print "# AeroCore Return to Gaming Mode shortcut migration" + print "# Replace the legacy privileged systemd launcher left by older Bazzite images." + print "if [[ -f \"$HOME/Desktop/Return.desktop\" ]]; then" + print " sed -i '\''s|^Exec=systemctl start return-to-gamemode\\.service$|Exec=/usr/bin/return-to-gamemode|'\'' \"$HOME/Desktop/Return.desktop\"" + print "fi" + print "" + inserted=1 + } + { print } + END { if (!inserted) exit 1 } + ' "$file" > "$patched_file" + + cp "$patched_file" "$file" + rm -f "$patched_file" } # Keep AeroCore's public image-name, while restoring the Deck capability checks diff --git a/tests/fixtures/bazzite-44/usr/libexec/bazzite-user-setup b/tests/fixtures/bazzite-44/usr/libexec/bazzite-user-setup index 9466a0b..4f40af4 100644 --- a/tests/fixtures/bazzite-44/usr/libexec/bazzite-user-setup +++ b/tests/fixtures/bazzite-44/usr/libexec/bazzite-user-setup @@ -2,6 +2,8 @@ pkexec /usr/libexec/bazzite-privileged-user-setup "$USER" +# Run script if updated + # Minimal structural fixture from Bazzite 44.20260820. if [[ $IMAGE_NAME =~ "deck" ]]; then touch "$HOME/Desktop/Return.desktop" diff --git a/tests/test-patch-bazzite-deck-identity.sh b/tests/test-patch-bazzite-deck-identity.sh index 0b0586c..cbe4382 100755 --- a/tests/test-patch-bazzite-deck-identity.sh +++ b/tests/test-patch-bazzite-deck-identity.sh @@ -43,6 +43,10 @@ assert_count 1 "${deck_condition}" "${steam}" assert_count 3 "${deck_condition}" "${user_setup}" assert_count 1 'AeroCore Steam state migration' "${steam}" assert_count 1 'AeroCore Return to Gaming Mode shortcut migration' "${user_setup}" +if [[ "$(grep -nF 'AeroCore Return to Gaming Mode shortcut migration' "${user_setup}" | cut -d: -f1)" -ge "$(grep -nF '# Run script if updated' "${user_setup}" | cut -d: -f1)" ]]; then + echo "Return to Gaming Mode migration must run before the user setup early-exit guard" >&2 + exit 1 +fi # A second run must recognize the patched fixture and make no further changes. first_digest="$(sha256sum "${hardware_setup}" "${steam}" "${user_setup}")" -- cgit v1.2.3