summaryrefslogtreecommitdiff
path: root/build_files
diff options
context:
space:
mode:
Diffstat (limited to 'build_files')
-rwxr-xr-xbuild_files/patch-bazzite-deck-identity.sh57
1 files changed, 57 insertions, 0 deletions
diff --git a/build_files/patch-bazzite-deck-identity.sh b/build_files/patch-bazzite-deck-identity.sh
index 05b6e5f..ea561e4 100755
--- a/build_files/patch-bazzite-deck-identity.sh
+++ b/build_files/patch-bazzite-deck-identity.sh
@@ -55,6 +55,61 @@ patch_condition() {
fi
}
+patch_steam_state_migration() {
+ local file="$1"
+ # shellcheck disable=SC2016
+ local condition='if [[ $IMAGE_NAME =~ "deck" || $IMAGE_NAME == aerocore-os ]]; then'
+ local marker='AeroCore Steam state migration'
+ local patched_file
+
+ if [[ ! -f "$file" ]]; then
+ echo "Unable to locate expected Bazzite Deck file: $file" >&2
+ exit 1
+ fi
+
+ if grep -Fq "$marker" "$file"; then
+ return 0
+ fi
+
+ if [[ "$(grep -Foc "$condition" "$file" || true)" -ne 1 ]]; then
+ echo "Unable to locate the AeroCore Steam bootstrap condition in $file" >&2
+ exit 1
+ fi
+
+ patched_file="$(mktemp)"
+ awk -v condition="$condition" '
+ !inserted && $0 == condition {
+ print
+ print " # AeroCore Steam state migration"
+ print " # Older AeroCore images could leave ~/.steam/steam as a directory."
+ print " # Preserve it before restoring the symlink expected by Steam."
+ print " STEAM_DATA_HOME=\"$HOME/.local/share/Steam\""
+ print " STEAM_DATA_LINK=\"$HOME/.steam/steam\""
+ print " if [[ -d \"$STEAM_DATA_LINK\" && ! -L \"$STEAM_DATA_LINK\" && -x \"$STEAM_DATA_HOME/steam.sh\" ]]; then"
+ print " STEAM_DATA_BACKUP=\"${STEAM_DATA_LINK}.aerocore-backup-$(date +%s)-$$\""
+ print " STEAM_DATA_TEMP=\"${STEAM_DATA_LINK}.aerocore-link-$$\""
+ print " if ln -s \"$STEAM_DATA_HOME\" \"$STEAM_DATA_TEMP\" && mv -- \"$STEAM_DATA_LINK\" \"$STEAM_DATA_BACKUP\" && mv -- \"$STEAM_DATA_TEMP\" \"$STEAM_DATA_LINK\"; then"
+ print " :"
+ print " else"
+ print " rm -f -- \"$STEAM_DATA_TEMP\""
+ print " fi"
+ print " fi"
+ inserted=1
+ next
+ }
+ { print }
+ END { if (!inserted) exit 1 }
+ ' "$file" > "$patched_file"
+
+ cp "$patched_file" "$file"
+ rm -f "$patched_file"
+
+ if ! grep -Fq "$marker" "$file"; then
+ echo "Failed to add the AeroCore Steam state migration to $file" >&2
+ exit 1
+ fi
+}
+
# Keep AeroCore's public image-name, while restoring the Deck capability checks
# used by Bazzite's runtime scripts. These are literal source lines; variable
# expansion must happen later, when the scripts run on the installed system.
@@ -84,6 +139,8 @@ patch_condition \
'if [[ $IMAGE_NAME =~ "deck" || $IMAGE_NAME == aerocore-os ]]; then' \
1
+patch_steam_state_migration "$(target_path /usr/bin/bazzite-steam)"
+
# shellcheck disable=SC2016
patch_condition \
"$(target_path /usr/libexec/bazzite-user-setup)" \