From 20253bfffc4815e1c48aebb8ede28527ce80ad3e Mon Sep 17 00:00:00 2001 From: tranch Date: Fri, 23 Oct 2026 10:23:18 +0800 Subject: fix: detect Game Mode channel from booted image Read the booted deployment reference instead of filtering status by the os-release ID, which differs from AeroCore image names. --- build_files/patch-bazzite-os-branch-select.sh | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 build_files/patch-bazzite-os-branch-select.sh (limited to 'build_files/patch-bazzite-os-branch-select.sh') diff --git a/build_files/patch-bazzite-os-branch-select.sh b/build_files/patch-bazzite-os-branch-select.sh new file mode 100755 index 0000000..544b1a5 --- /dev/null +++ b/build_files/patch-bazzite-os-branch-select.sh @@ -0,0 +1,35 @@ +#!/usr/bin/bash + +set -euo pipefail + +file=/usr/libexec/os-branch-select + +if [[ ! -f "$file" ]]; then + echo "Unable to locate Bazzite OS branch selector: $file" >&2 + exit 1 +fi + +old=' branch=$(cut -d ":" -f4 <<< "$(rpm-ostree status --booted | grep -m 1 $ID)")' +if ! grep -Fxq "$old" "$file"; then + echo "Bazzite OS branch selector changed; review the downstream patch" >&2 + exit 1 +fi + +patched_file=$(mktemp) +awk -v old="$old" ' + $0 == old { + print " # Read the booted deployment directly; its image name need not match os-release ID." + print " image_ref=$(rpm-ostree status --booted --json | jq -r '\''[.deployments[] | select(.booted) | .[\"container-image-reference\"] // empty][0] // empty'\'')" + print " branch=\"\"" + print " if [[ $image_ref =~ :([^/:]+)$ ]]; then" + print " branch=${BASH_REMATCH[1]}" + print " fi" + found++ + next + } + { print } + END { if (found != 1) exit 1 } +' "$file" > "$patched_file" + +install -m 0755 "$patched_file" "$file" +rm -f "$patched_file" -- cgit v1.2.3