diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e1058552ac..484ab7b1ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -70,7 +70,7 @@ jobs: is_latest_version: true is_stable_version: true kernel_flavor: bazzite # must match a kernel_flavor from akmods repo - kernel_version: 6.11.5-306.bazzite.fc41.x86_64 # must match a cached version of the above flavor + kernel_version: 6.11.5-307.bazzite.fc41.x86_64 # must match a cached version of the above flavor exclude: - base_name: bazzite target_nvidia_flavor: nvidia diff --git a/system_files/desktop/shared/usr/bin/bazzite-rollback-helper b/system_files/desktop/shared/usr/bin/bazzite-rollback-helper index e07ccfa1b8..0fd7775a6a 100755 --- a/system_files/desktop/shared/usr/bin/bazzite-rollback-helper +++ b/system_files/desktop/shared/usr/bin/bazzite-rollback-helper @@ -1,7 +1,7 @@ #!/bin/bash -image="$(echo $2 | cut -d ':' -f1)" -branch="$(echo $2 | cut -d ':' -f2)" +image="$(echo "$2" | cut -d ':' -f1)" +branch="$(echo "$2" | cut -d ':' -f2)" IMAGE_INFO="/usr/share/ublue-os/image-info.json" DEFAULT_IMAGE=$(jq -r '."image-name"' < $IMAGE_INFO) @@ -17,10 +17,10 @@ This tool aims to help with rollbacks and rebases Usage: bazzite-rollback-helper [OPTION] [ARGUMENT] Options: - list List available Bazzite images, Default is "$DEFAULT_BRANCH" - rollback Rolls back to previously installed Bazzite image. alias for "rpm-ostree rollback" - current Show currently active Bazzite image - rebase Rebase/rollback to specified Bazzite image, Default is $DEFAULT_IMAGE:$DEFAULT_BRANCH + list [BRANCH] List available Bazzite images, Default is "$DEFAULT_BRANCH" + rollback Rolls back to previously installed Bazzite image. alias for "rpm-ostree rollback" + current Show currently active Bazzite image + rebase Rebase/rollback to specified Bazzite image, Default is $DEFAULT_IMAGE:$DEFAULT_BRANCH Examples: bazzite-rollback-helper list stable @@ -38,50 +38,115 @@ EOF ) -if [[ "$1" == "list" ]]; then - if [ -z "$2" ]; then - echo "Listing images for $DEFAULT_BRANCH" - skopeo list-tags docker://ghcr.io/ublue-os/bazzite | grep -E "\"$DEFAULT_BRANCH-[0-9]+\.[0-9]+|-$DEFAULT_BRANCH-[0-9]+" | sort -rV - else - echo "Listing images for $2" - skopeo list-tags docker://ghcr.io/ublue-os/bazzite | grep -E "\"$2-[0-9]+\.[0-9]+|-$2-[0-9]+" | sort -rV +function list_images() { + local _help="\ +List images with a specified tag + +INPUTS: + \$1: branch Branch we want to get tags from. + Fallbacks to \"$DEFAULT_BRANCH\" +" + if [[ $* =~ --help ]]; then + echo "$_help" && return + fi + local branch=${1:-$DEFAULT_BRANCH} + local regex='.Tags[]' + regex="$regex"\ ' | select(test("^PLACEHOLDER|^PLACEHOLDER-(?:\\d+\\.\\d+|\\d+)"))' + regex=${regex//PLACEHOLDER/$branch} + echo -e >&2 "Listing images for $branch\nThis can take a bit of time..." + skopeo list-tags docker://ghcr.io/ublue-os/bazzite | jq -r "$regex" +} + +function current() { + local _help="\ +Show currently active Bazzite image" + if [[ $* =~ --help ]]; then + echo "$_help" && return fi -elif [[ "$1" == "rollback" ]]; then - rpm-ostree rollback - echo "Reboot for changes to take effect" + rpm-ostree status -vb +} -elif [[ "$1" == "current" ]]; then - # current image - rpm-ostree status | grep ● - # current version - rpm-ostree status | grep -A 5 "●" | tail -n +2 +function rollback() { + local _help="Rolls back to previously installed Bazzite image. alias for \"rpm-ostree rollback\"" + if [[ $* =~ --help ]]; then + echo "$_help" && return + fi -elif [[ "$1" == "rebase" ]]; then - base_image=ostree-image-signed:docker://ghcr.io/ublue-os - rebase_target=$DEFAULT_IMAGE:$DEFAULT_BRANCH - - if [ -z "$2" ]; then - rebase_target=$DEFAULT_IMAGE:$DEFAULT_BRANCH - else - if [ "$image" == "$branch" ]; then - # only branch was provided as an arg, use default image - rebase_target=$DEFAULT_IMAGE:$branch - else - rebase_target=$image:$branch - fi + rpm-ostree rollback && \ + echo >&2 "Reboot for changes to take effect" +} + +function rebase() { + local _help="\ +Rebase/rollback to specified Bazzite image, Default is $DEFAULT_IMAGE:$DEFAULT_BRANCH + +INPUTS: + \$1: branch Branch we want to rebase. Format must be + one of the following: + - ostree-image (ex.: 'ostree-image-signed:docker://ghcr.io/ublue-os/bazzite:stable') + - NAME:TAG (ex.: 'bazzite:stable-40') + - TAG (ex.: 'testing') + Fallbacks to \"$DEFAULT_BRANCH\"\ +" + if [[ $* =~ --help ]]; then + local _help + echo "$_help" && return fi - full_image_path=$base_image/$rebase_target -question=$(cat <&2 "$_help"; return ;; + ostree-image-*) + # ostree-image + echo >&2 "Format detected" + img_ref=$usr_inpt + ;; + *:*) + # IMG_NAME:TAG + echo >&2 "Format detected: IMG_NAME:TAG" + img_ref="$base_img_pfx"/"$usr_inpt" + ;; + *) + # TAG + echo >&2 "Format detected: TAG" + img_ref="$base_img_pfx"/"$DEFAULT_IMAGE":"$usr_inpt" + ;; + esac + + # Ask for confirmation. If is okay, rebase. + local question="\ +Rebasing to $img_ref. Continue? [y/N]: " + read -rp "$question" yn case $yn in - [Yy]) echo "rebasing to $rebase_target" && rpm-ostree rebase $full_image_path && echo "Reboot for changes to take effect";; - *) echo "Unknown option, exiting.";; + # Finally, rebase + [yY]) rpm-ostree rebase "$img_ref" ;; + *) echo >&2 "Canceling..."; return ;; esac +} + +if [[ "$1" == "list" ]]; then + list_images "${@:2}" + exit + +elif [[ "$1" == "rollback" ]]; then + rollback "${@:2}" + exit + +elif [[ "$1" == "current" ]]; then + current "${@:2}" + exit + +elif [[ "$1" == "rebase" ]]; then + rebase "${@:2}" + exit # display the helptext elif [[ "$1" == "-h" || "$1" == "--h" || "$1" == "-help" || "$1" == "--help" || "$1" == "help" || -z "$1" ]]; then diff --git a/system_files/desktop/shared/usr/bin/brh b/system_files/desktop/shared/usr/bin/brh new file mode 120000 index 0000000000..653c66a029 --- /dev/null +++ b/system_files/desktop/shared/usr/bin/brh @@ -0,0 +1 @@ +bazzite-rollback-helper \ No newline at end of file