From c8bc7266914bedb1193060d1122ff52115a3c415 Mon Sep 17 00:00:00 2001 From: Kyle Gospodnetich Date: Wed, 21 Aug 2024 21:30:13 -0700 Subject: [PATCH] fix(deck): Ensure the branch is lowercase and trimmed in os-branch-select --- .../deck/shared/usr/libexec/os-branch-select | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/system_files/deck/shared/usr/libexec/os-branch-select b/system_files/deck/shared/usr/libexec/os-branch-select index b70c866d33..c7821e9649 100755 --- a/system_files/deck/shared/usr/libexec/os-branch-select +++ b/system_files/deck/shared/usr/libexec/os-branch-select @@ -1,26 +1,29 @@ #!/usr/bin/bash set -e +source /etc/os-release + if [[ $# -eq 1 ]]; then case "$1" in - "-c") + -c) if [[ -f /var/ublue-update/branch ]]; then branch=$(cat /var/ublue-update/branch) else - branch=$(cut -d ":" -f4 <<< "$(rpm-ostree status | grep -m 1 'bazzite')") + branch=$(cut -d ":" -f4 <<< "$(rpm-ostree status --booted | grep -m 1 $VARIANT_ID)") fi - branch=${branch,,} - case "$branch" in - "latest" | "stable") + # Trim and convert to lowercase + branch=$(echo "$branch" | tr '[:upper:]' '[:lower:]' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') + case $branch in + latest|stable) echo rel exit 0 ;; - "testing") + testing) echo rc exit 0 ;; - "unstable") + unstable) echo main exit 0 ;; @@ -33,7 +36,7 @@ if [[ $# -eq 1 ]]; then ;; esac ;; - "-l") + -l) echo rel echo rc echo beta @@ -41,15 +44,15 @@ if [[ $# -eq 1 ]]; then echo main exit 0 ;; - "rel" | "latest" | "stable") + rel|latest|stable) /usr/bin/pkexec /usr/libexec/ublue-update-rebase "stable" exit 0 ;; - "rc" | "beta" | "testing") + rc|beta|testing) /usr/bin/pkexec /usr/libexec/ublue-update-rebase "testing" exit 0 ;; - "bc" | "main" | "unstable") + bc|main|unstable) echo "The unstable branch has a high risk of breaking." echo "Do NOT use it unless you know what you are doing." /usr/bin/pkexec /usr/libexec/ublue-update-rebase "unstable"