diff options
| author | Tranch <tranch.xiao@gmail.com> | 2026-07-26 00:18:06 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-26 00:18:06 +0800 |
| commit | 1df1cf0b8e6a4b2ca39e51722ee96263f83db204 (patch) | |
| tree | 488c130b733a86caf35acade36806cb5d309a710 /build_files | |
| parent | 05c9b9bd017e8e20b70bd791e1f04cabd6664cd4 (diff) | |
| parent | 63e9dd98331d0ef7c9c9984cbcf6a7aaba9572dc (diff) | |
| download | AeroCore-OS-1df1cf0b8e6a4b2ca39e51722ee96263f83db204.tar.gz AeroCore-OS-1df1cf0b8e6a4b2ca39e51722ee96263f83db204.zip | |
Merge branch 'main' into testing
Diffstat (limited to 'build_files')
| -rwxr-xr-x | build_files/image-info | 2 | ||||
| -rwxr-xr-x | build_files/patch-bazzite-deck-identity.sh | 164 |
2 files changed, 140 insertions, 26 deletions
diff --git a/build_files/image-info b/build_files/image-info index a52d666..bd66383 100755 --- a/build_files/image-info +++ b/build_files/image-info @@ -49,7 +49,7 @@ sed -i "s|^DOCUMENTATION_URL=.*|DOCUMENTATION_URL=\"$DOCUMENTATION_URL\"|" /usr/ sed -i "s|^SUPPORT_URL=.*|SUPPORT_URL=\"$SUPPORT_URL\"|" /usr/lib/os-release sed -i "s|^BUG_REPORT_URL=.*|BUG_REPORT_URL=\"$BUG_SUPPORT_URL\"|" /usr/lib/os-release sed -i "s|^CPE_NAME=.*|CPE_NAME=\"cpe:/o:universal-blue:$IMAGE_ID\"|" /usr/lib/os-release -sed -i "s/^DEFAULT_HOSTNAME=.*/DEFAULT_HOSTNAME=\"$IMAGE_ID\"/" /usr/lib/os-release +sed -i "s/^DEFAULT_HOSTNAME=.*/DEFAULT_HOSTNAME=\"$IMAGE_NAME\"/" /usr/lib/os-release sed -i "s/^ID=fedora/ID=$IMAGE_ID\nID_LIKE=\"$IMAGE_LIKE\"/" /usr/lib/os-release sed -i "s/^LOGO=.*/LOGO=$LOGO_ICON/" /usr/lib/os-release sed -i "s/^ANSI_COLOR=.*/ANSI_COLOR=\"$LOGO_COLOR\"/" /usr/lib/os-release diff --git a/build_files/patch-bazzite-deck-identity.sh b/build_files/patch-bazzite-deck-identity.sh index 078b76c..ea561e4 100755 --- a/build_files/patch-bazzite-deck-identity.sh +++ b/build_files/patch-bazzite-deck-identity.sh @@ -2,34 +2,148 @@ set -euo pipefail -hardware_setup="${1:-/usr/libexec/bazzite-hardware-setup}" -# These are literal source lines; variable expansion must happen at boot time. -# shellcheck disable=SC2016 -old_condition='if [[ "$IMAGE_NAME" != *deck* && "$IMAGE_NAME" != *dx* ]]; then' -# shellcheck disable=SC2016 -new_condition='if [[ "$IMAGE_NAME" != aerocore-os && "$IMAGE_NAME" != *deck* && "$IMAGE_NAME" != *dx* ]]; then' +root="${AEROCORE_DECK_COMPAT_ROOT:-}" +root="${root%/}" + +target_path() { + printf '%s%s\n' "$root" "$1" +} + +patch_condition() { + local file="$1" + local old_condition="$2" + local new_condition="$3" + local expected_count="$4" + local old_count new_count patched_file + + if [[ ! -f "$file" ]]; then + echo "Unable to locate expected Bazzite Deck file: $file" >&2 + exit 1 + fi + + new_count="$(grep -Foc "$new_condition" "$file" || true)" + if [[ "$new_count" -eq "$expected_count" ]]; then + return 0 + fi + + old_count="$(grep -Foc "$old_condition" "$file" || true)" + if [[ "$old_count" -ne "$expected_count" ]]; then + echo "Unable to locate the expected Bazzite Deck image check in $file" >&2 + echo "Expected $expected_count occurrence(s), found old=$old_count new=$new_count" >&2 + exit 1 + fi + + patched_file="$(mktemp)" + awk \ + -v old_condition="$old_condition" \ + -v new_condition="$new_condition" \ + ' { + position = index($0, old_condition) + if (position) { + $0 = substr($0, 1, position - 1) new_condition substr($0, position + length(old_condition)) + } + print + }' "$file" > "$patched_file" + + cp "$patched_file" "$file" + rm -f "$patched_file" + + new_count="$(grep -Foc "$new_condition" "$file" || true)" + if [[ "$new_count" -ne "$expected_count" ]]; then + echo "Failed to patch the Bazzite Deck image check in $file" >&2 + exit 1 + fi +} -if grep -Fqx "$new_condition" "$hardware_setup"; then - exit 0 -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 [[ "$(grep -Fxc "$old_condition" "$hardware_setup")" -ne 1 ]]; then - echo "Unable to locate the Bazzite Deck image check in $hardware_setup" >&2 - exit 1 -fi + if [[ ! -f "$file" ]]; then + echo "Unable to locate expected Bazzite Deck file: $file" >&2 + exit 1 + fi -patched_file=$(mktemp) -trap 'rm -f "$patched_file"' EXIT + if grep -Fq "$marker" "$file"; then + return 0 + fi -awk \ - -v old_condition="$old_condition" \ - -v new_condition="$new_condition" \ - '$0 == old_condition { - print new_condition - next - } - { print }' "$hardware_setup" > "$patched_file" + if [[ "$(grep -Foc "$condition" "$file" || true)" -ne 1 ]]; then + echo "Unable to locate the AeroCore Steam bootstrap condition in $file" >&2 + exit 1 + fi -cp "$patched_file" "$hardware_setup" + 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" -grep -Fqx "$new_condition" "$hardware_setup" + 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. +# shellcheck disable=SC2016 +patch_condition \ + "${1:-$(target_path /usr/libexec/bazzite-hardware-setup)}" \ + 'if [[ "$IMAGE_NAME" != *deck* && "$IMAGE_NAME" != *dx* ]]; then' \ + 'if [[ "$IMAGE_NAME" != aerocore-os && "$IMAGE_NAME" != *deck* && "$IMAGE_NAME" != *dx* ]]; then' \ + 1 + +# The hardware setup has a second Deck-only block after the top-level image +# guard. Keep it active for AeroCore as well. +# shellcheck disable=SC2016 +patch_condition \ + "${1:-$(target_path /usr/libexec/bazzite-hardware-setup)}" \ + 'if [[ $IMAGE_NAME =~ "deck" || $IMAGE_NAME =~ "ally" ]]; then' \ + 'if [[ $IMAGE_NAME =~ "deck" || $IMAGE_NAME =~ "ally" || $IMAGE_NAME == aerocore-os ]]; then' \ + 1 + +# bazzite-steam gates the Steam bootstrap archive and -steamdeck flag on the +# image name. The user setup script has the same Deck-only gating in three +# places. +# shellcheck disable=SC2016 +patch_condition \ + "$(target_path /usr/bin/bazzite-steam)" \ + 'if [[ $IMAGE_NAME =~ "deck" ]]; then' \ + '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)" \ + 'if [[ $IMAGE_NAME =~ "deck" || $IMAGE_NAME =~ "ally" ]]; then' \ + 'if [[ $IMAGE_NAME =~ "deck" || $IMAGE_NAME =~ "ally" || $IMAGE_NAME == aerocore-os ]]; then' \ + 3 |
