#!/usr/bin/bashIMAGE_INFO="/usr/share/ublue-os/image-info.json"IMAGE_NAME="$(jq -r '."image-name"' < "$IMAGE_INFO")"IMAGE_TAG="$(jq -r '."image-tag"' < "$IMAGE_INFO")"IMAGE_VENDOR="$(jq -r '."image-vendor"' < "$IMAGE_INFO")"IMAGE_REGISTRY="ghcr.io/${IMAGE_VENDOR}"set -euo pipefailfunction list_tags() {local filter="$1"skopeo list-tags "docker://${IMAGE_REGISTRY}/${IMAGE_NAME}" \| jq -r '.Tags[]' \| grep -E --color=never "$filter" \| sort -rV | head -n 31}echo -ne "Current image: ${IMAGE_NAME}:${IMAGE_TAG}\n"declare -a IMAGESIMAGES=(aurora aurora-dx aurora-nvidia-open aurora-dx-nvidia-open)IMAGE_NAME="$(gum choose --header="Select your image:" "${IMAGES[@]}" cancel)"[[ "$IMAGE_NAME" == "cancel" || "$IMAGE_NAME" == "" ]] && exit 0base_image="${IMAGE_REGISTRY}/${IMAGE_NAME}"declare -a CHANNELSCHANNELS=(stable latest testing)echo -e "\nstable: The default selection (weekly builds) with gated CoreOS kernel\nlatest: For enthusiast, stock Fedora kernel and latest updates\ntesting: Get a sneak peak into future Aurora builds and Fedora versions\n\nSee our docs: https://docs.getaurora.dev/guides/release-streams\n"channel_choice="$(gum choose "${CHANNELS[@]}" cancel)"[[ "$channel_choice" == "cancel" || "$channel_choice" == "" ]] && exit 0channel_selected=${channel_choice%% *}rebase_target="${base_image}:${channel_selected}"if gum confirm --default=no "Would you like to pin to a specific build date?" ; thenecho "Fetching available tags for channel: $channel_selected..."filter="${channel_selected}.[0-9]{8}"valid_tags=( $(list_tags "$filter") )[[ "${#valid_tags[@]}" -eq 0 ]] && { echo "No tags found for $filter"; exit 1; }selected_tag="$(gum choose cancel "${valid_tags[@]}")"[[ "$selected_tag" == "cancel" || "$selected_tag" == "" ]] && exit 0rebase_target="${base_image}:${selected_tag}"figum confirm "Confirm rebase to ${rebase_target}?" || exit 1if grep -q "^LockLayering=true" /etc/rpm-ostreed.conf; thenpkexec bootc switch --enforce-container-sigpolicy "${rebase_target}"elserpm-ostree rebase ostree-image-signed:docker://"${rebase_target}"fi