Skip to content

Commit 5df2512

Browse files
authored
fix(rebase-helper): refactor rebase-helper script and add support for nvidia (#101)
* fix(rebase-helper): refactor rebase-helper script * update the script
1 parent 5c5598e commit 5df2512

1 file changed

Lines changed: 31 additions & 75 deletions

File tree

Lines changed: 31 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/usr/bin/bash
22

33
IMAGE_INFO="/usr/share/ublue-os/image-info.json"
4-
IMAGE_NAME=$(jq -r '."image-name"' < "$IMAGE_INFO")
5-
IMAGE_TAG=$(jq -r '."image-tag"' < "$IMAGE_INFO")
6-
IMAGE_VENDOR=$(jq -r '."image-vendor"' < "$IMAGE_INFO")
7-
FEDORA_VERSION=$(jq -r '."fedora-version"' < "$IMAGE_INFO")
4+
IMAGE_NAME="$(jq -r '."image-name"' < "$IMAGE_INFO")"
5+
IMAGE_TAG="$(jq -r '."image-tag"' < "$IMAGE_INFO")"
6+
IMAGE_VENDOR="$(jq -r '."image-vendor"' < "$IMAGE_INFO")"
87
IMAGE_REGISTRY="ghcr.io/${IMAGE_VENDOR}"
9-
ROOT_FS=$(findmnt -n -o FSTYPE /)
8+
9+
set -euo pipefail
1010

1111
function list_tags() {
1212
local filter="$1"
@@ -16,83 +16,39 @@ function list_tags() {
1616
| sort -rV | head -n 31
1717
}
1818

19-
function rebase_helper() {
20-
echo "Current image: ${IMAGE_NAME}:${IMAGE_TAG} (Fedora ${FEDORA_VERSION})"
21-
echo "Root filesystem: ${ROOT_FS}"
22-
echo
23-
24-
# Step 1: Choose image variant
25-
echo "Select your Aurora image:"
26-
IMAGE_OPTIONS=(aurora aurora-dx)
27-
28-
# Add current image if it's not already in the list
29-
if [[ ! " ${IMAGE_OPTIONS[*]} " =~ \ ${IMAGE_NAME}\ ]]; then
30-
IMAGE_OPTIONS+=("${IMAGE_NAME}")
31-
fi
32-
33-
IMAGE_OPTIONS+=(cancel)
34-
35-
selected_image=$(gum choose "${IMAGE_OPTIONS[@]}")
36-
[[ "$selected_image" == "cancel" ]] && exit 0
37-
38-
IMAGE_NAME="$selected_image"
39-
base_image="${IMAGE_REGISTRY}/${IMAGE_NAME}"
40-
41-
# Step 2: Channel Selection
42-
declare -a CHANNELS
43-
CHANNELS=(stable stable-daily latest)
44-
echo "The default selection is stable. Stable-daily (daily builds) are for enthusiasts, and latest is for testers"
19+
echo -ne "Current image: ${IMAGE_NAME}:${IMAGE_TAG}\n"
20+
declare -a IMAGES
21+
IMAGES=(aurora aurora-dx aurora-nvidia-open aurora-dx-nvidia-open)
22+
IMAGE_NAME="$(gum choose --header="Select your image:" "${IMAGES[@]}" cancel)"
23+
[[ "$IMAGE_NAME" == "cancel" || "$IMAGE_NAME" == "" ]] && exit 0
4524

46-
# Fetch Fedora version per channel and build display list
47-
declare -a CHANNELS_DISPLAY
48-
declare -a CHANNELS_RAW
25+
base_image="${IMAGE_REGISTRY}/${IMAGE_NAME}"
26+
declare -a CHANNELS
27+
CHANNELS=(stable stable-daily latest)
28+
echo "The default selection is stable (weekly builds). stable-daily (daily builds) are for enthusiasts, and latest is for testers"
4929

50-
for channel in "${CHANNELS[@]}"; do
51-
version=$(skopeo inspect --no-tags docker://${base_image}:${channel} | jq -r '.Labels["org.opencontainers.image.version"]' | sed 's/.*-//' | cut -c 1-2)
52-
CHANNELS_DISPLAY+=("${channel} (F${version})")
53-
CHANNELS_RAW+=("${channel}")
54-
done
30+
channel_choice="$(gum choose "${CHANNELS[@]}" cancel)"
31+
[[ "$channel_choice" == "cancel" || "$channel_choice" == "" ]] && exit 0
32+
channel_selected=${channel_choice%% *}
5533

56-
channel_choice=$(gum choose "${CHANNELS_DISPLAY[@]}" "cancel")
57-
[[ "$channel_choice" == "cancel" ]] && exit 0
58-
channel_selected=${channel_choice%% *}
34+
rebase_target="${base_image}:${channel_selected}"
5935

60-
rebase_target="${base_image}:${channel_selected}"
36+
if gum confirm --default=no "Would you like to pin to a specific build date?" ; then
37+
echo "Fetching available tags for channel: $channel_selected..."
38+
filter="${channel_selected}.[0-9]{8}"
39+
valid_tags=( $(list_tags "$filter") )
40+
[[ "${#valid_tags[@]}" -eq 0 ]] && { echo "No tags found for $filter"; exit 1; }
6141

62-
# Step 3: Date selection (scoped to channel)
63-
echo "Would you like to pin to a specific build date?"
64-
echo "NOTICE! You won't receive any updates after pinning to a specific build date."
65-
date_choice=$(gum choose "no" "yes" "cancel")
66-
[[ "$date_choice" == "cancel" ]] && return 1
42+
selected_tag="$(gum choose cancel "${valid_tags[@]}")"
43+
[[ "$selected_tag" == "cancel" || "$selected_tag" == "" ]] && exit 0
6744

68-
if [[ "$date_choice" == "yes" ]]; then
69-
echo "Fetching available tags for channel: $channel_selected..."
70-
filter="${channel_selected}-[0-9]{8}"
71-
72-
valid_tags=( $(list_tags "$filter") )
73-
[[ "${#valid_tags[@]}" -eq 0 ]] && { echo "No tags found for filter: $filter"; return 1; }
74-
75-
selected_tag=$(gum choose "cancel" "${valid_tags[@]}")
76-
[[ "$selected_tag" == "cancel" ]] && return 1
77-
78-
rebase_target="${base_image}:${selected_tag}"
79-
fi
80-
81-
echo "Rebase target: ${rebase_target}"
82-
echo "Confirm rebase?"
83-
[[ $(gum confirm) -ne 0 ]] && return 1
45+
rebase_target="${base_image}:${selected_tag}"
46+
fi
8447

85-
if grep -q "^LockLayering=true" /etc/rpm-ostreed.conf; then
86-
pkexec bootc switch --enforce-container-sigpolicy "${rebase_target}"
87-
else
88-
rpm-ostree rebase ostree-image-signed:docker://"${rebase_target}"
89-
fi
90-
}
48+
gum confirm "Confirm rebase to ${rebase_target}?" || exit 1
9149

92-
echo "Choose your action."
93-
option=$(gum choose "rebase" "cancel")
94-
if [[ "$option" == "rebase" ]]; then
95-
rebase_helper || /usr/bin/ublue-rollback-helper
50+
if grep -q "^LockLayering=true" /etc/rpm-ostreed.conf; then
51+
pkexec bootc switch --enforce-container-sigpolicy "${rebase_target}"
9652
else
97-
exit 0
53+
rpm-ostree rebase ostree-image-signed:docker://"${rebase_target}"
9854
fi

0 commit comments

Comments
 (0)