summaryrefslogtreecommitdiff
path: root/build_files/build.sh
blob: 988b7f088ee9ca33bf6c670dd1c44f564d0812fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/bin/bash

set -ouex pipefail

case "${BASE_IMAGE:-}" in
  ghcr.io/ublue-os/bazzite-deck:* | ghcr.io/ublue-os/bazzite-deck@*)
    ;;
  *)
    echo "AeroCore OS only supports bazzite-deck BASE_IMAGE values for HTPC game-mode builds: ${BASE_IMAGE:-<unset>}" >&2
    exit 1
    ;;
esac

# Copy the contents of system_files/ of the git repo to /
cp -avf "/ctx/system_files"/. /

# Keep Bazzite's game mode news hook unchanged; only switch its feed URL.
NEWS_HOOK_CONFIG=/etc/gamemode-news-hook.conf
if [[ ! -f "${NEWS_HOOK_CONFIG}" ]]; then
  echo "Unable to locate game mode news hook config: ${NEWS_HOOK_CONFIG}" >&2
  exit 1
fi
sed -i \
  's|^github = .*|github = https://git.mirror.aerocore.com.cn/AeroCore-IO/aerocore-os-gamemode-news/plain/announcements.json?h=testing|' \
  "${NEWS_HOOK_CONFIG}"
grep -Fxq \
  'github = https://git.mirror.aerocore.com.cn/AeroCore-IO/aerocore-os-gamemode-news/plain/announcements.json?h=testing' \
  "${NEWS_HOOK_CONFIG}"

# Bazzite's Kinoite/Plasma desktop shortcut used to start a privileged
# return-to-gamemode.service.  Current Bazzite invokes the user-session entry
# point directly; keep the shortcut correct when the base image still ships
# the legacy Exec= line.
RETURN_TO_GAMING_DESKTOP="/etc/skel/Desktop/Return.desktop"
if [[ -f "${RETURN_TO_GAMING_DESKTOP}" ]]; then
  sed -i 's|^Exec=.*|Exec=/usr/bin/return-to-gamemode|' "${RETURN_TO_GAMING_DESKTOP}"
fi

# ujust loads explicit imports, not every fragment in the just/ directory.
# Preserve upstream recipes and register our overlay after copying its files.
AEROCORE_DECKY_IMPORT='import "/usr/share/ublue-os/just/92-aerocore-decky-mirror.just"'
if ! grep -Fxq "${AEROCORE_DECKY_IMPORT}" /usr/share/ublue-os/justfile; then
  printf '\n%s\n' "${AEROCORE_DECKY_IMPORT}" >> /usr/share/ublue-os/justfile
fi
# Fail the image build if the public entry point cannot resolve the recipe.
ujust --show setup-decky-mirror >/dev/null

install_regular_file() {
  local source_file="$1"
  local destination_file="$2"

  # Several Bazzite branding paths are symlinks.  cp follows an existing
  # destination symlink, which leaves the name Plasma resolves untouched.
  # Replace the link itself so the final immutable image owns this exact path.
  rm -f -- "${destination_file}"
  install -Dm0644 -- "${source_file}" "${destination_file}"
}

# KDE's Deck presets use distributor-logo-steamdeck.svg for the Kickoff
# launcher.  In the Bazzite base image that name (and the related aliases)
# may already exist as links to the upstream distributor-logo.svg.  Install
# the AeroCore asset explicitly after the general overlay so the final image
# cannot silently retain the upstream Bazzite logo.
AEROCORE_DISTRIBUTOR_LOGO="/ctx/system_files/usr/share/icons/hicolor/scalable/places/distributor-logo.svg"
AEROCORE_ICON_DIR="/usr/share/icons/hicolor/scalable/places"
mkdir -p "${AEROCORE_ICON_DIR}"
for icon_name in \
  distributor-logo.svg \
  distributor-logo-steamdeck.svg \
  bazzite-logo.svg \
  start-here.svg; do
  install_regular_file "${AEROCORE_DISTRIBUTOR_LOGO}" "${AEROCORE_ICON_DIR}/${icon_name}"
done

# Use a downstream-specific, non-upstream icon name for Plasma's launcher.
install_regular_file \
  "/ctx/system_files/usr/share/pixmaps/bazzite-logo-le.svg" \
  "/usr/share/icons/hicolor/scalable/apps/aerocore-logo.svg"

# KDE's About System KCM loads this path from kcm-about-distrorc.  The base
# image may provide it as a symlink, so replace the directory entry itself or
# the KCM can continue rendering the upstream Bazzite logo.
install_regular_file \
  "/ctx/system_files/usr/share/pixmaps/system-logo-white.png" \
  "/usr/share/pixmaps/system-logo-white.png"

# Game Mode's Vapor splash asset is an upstream symlink on current Bazzite
# images, while VGUI is a regular file.  Replace both exact paths explicitly.
for look_and_feel in com.valve.vapor.desktop com.valve.vgui.desktop; do
  install_regular_file \
    "/ctx/system_files/usr/share/plasma/look-and-feel/${look_and_feel}/contents/splash/images/bazzite_logo.svgz" \
    "/usr/share/plasma/look-and-feel/${look_and_feel}/contents/splash/images/bazzite_logo.svgz"
done

# Steam's Game Mode transitions load these four assets directly.  They are
# symlinks in some upstream layers, so replace their directory entries just
# like the Plasma splash assets above.
for animation in \
  bazzite.webm \
  bazzite-oled.webm \
  bazzite-suspend.webm \
  bazzite-suspend-oled.webm; do
  install_regular_file \
    "/ctx/system_files/usr/share/ublue-os/bazzite/${animation}" \
    "/usr/share/ublue-os/bazzite/${animation}"
done

gtk-update-icon-cache -f /usr/share/icons/hicolor || true

# The Plasma launcher resolves the standard start-here name from both scalable
# and per-size places directories.  Populate every existing Bazzite icon size
# in the installed payload, not only in the live installer image.
for icon_dir in /usr/share/icons/hicolor/*; do
  [[ -d "${icon_dir}" ]] || continue
  source_icon="${icon_dir}/bazzite-logo-icon.png"
  if [[ -f "${source_icon}" ]]; then
    mkdir -p "${icon_dir}/apps" "${icon_dir}/places"
    cp -f "${source_icon}" "${icon_dir}/places/start-here.png"
    cp -f "${source_icon}" "${icon_dir}/apps/fedora-logo-icon.png"
  fi
done

if ! cmp -s "${AEROCORE_DISTRIBUTOR_LOGO}" "${AEROCORE_ICON_DIR}/distributor-logo.svg"; then
  echo "AeroCore distributor logo was not installed into the image" >&2
  exit 1
fi

# Default HDMI-CEC to putting the TV into standby when the system sleeps.
# `ujust toggle-cec-sleep enable` changes this same setting at runtime.  Keep
# the default in the base image's config so users do not need to run the
# command manually after a fresh install; the runtime command can still
# change it later.
CEC_CONFIG=/etc/default/cec-control
if [[ -f "${CEC_CONFIG}" ]]; then
  if grep -q '^CEC_ONSLEEP_STANDBY=' "${CEC_CONFIG}"; then
    sed -i 's/^CEC_ONSLEEP_STANDBY=.*/CEC_ONSLEEP_STANDBY=true/' "${CEC_CONFIG}"
  else
    printf '%s\n' 'CEC_ONSLEEP_STANDBY=true' >> "${CEC_CONFIG}"
  fi
fi

mkdir -p /etc/environment.d

if [[ -n "${FLATPAK_REMOTE_URL:-}" || -n "${HOMEBREW_BOTTLE_DOMAIN:-}" || -n "${HOMEBREW_API_DOMAIN:-}" ]]; then
  : > /etc/environment.d/99-aerocore-mirrors.conf
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}"
  fi
fi

if [[ -n "${HOMEBREW_BOTTLE_DOMAIN:-}" || -n "${HOMEBREW_API_DOMAIN:-}" ]]; then
  mkdir -p /etc/skel/.config/environment.d
  : > /etc/skel/.config/environment.d/99-aerocore-mirrors.conf
fi

if [[ -n "${HOMEBREW_BOTTLE_DOMAIN:-}" ]]; then
  printf '%s\n' "HOMEBREW_BOTTLE_DOMAIN=${HOMEBREW_BOTTLE_DOMAIN}" | tee -a /etc/environment.d/99-aerocore-mirrors.conf /etc/skel/.config/environment.d/99-aerocore-mirrors.conf >/dev/null
fi

if [[ -n "${HOMEBREW_API_DOMAIN:-}" ]]; then
  printf '%s\n' "HOMEBREW_API_DOMAIN=${HOMEBREW_API_DOMAIN}" | tee -a /etc/environment.d/99-aerocore-mirrors.conf /etc/skel/.config/environment.d/99-aerocore-mirrors.conf >/dev/null
fi

find /etc/environment.d /etc/skel/.config/environment.d -name 99-aerocore-mirrors.conf -type f -exec chmod 0644 {} + 2>/dev/null || true

/ctx/install-instruments.sh
/ctx/patch-bazzite-deck-identity.sh
/ctx/patch-bazzite-rollback-helper.sh