Skip to content

Commit b925f52

Browse files
authored
Try to avoid multiple snapshots of the same version, in "downgrade" (#2060)
* Try to avoid multiple snapshots of the same version, in "downgrade" * Force "archimage5" in repositories of Archimages * Reset "$unique_urls" value when downgrading more apps * Ask for confirmation to exclude "snapshot" versions
1 parent 6df06d3 commit b925f52

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

modules/management.am

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,24 @@ _downgrade_entries_filter() {
133133
}'
134134
}
135135

136+
_downgrade_no_snapshots() {
137+
items=$(echo "$urls" | sed 's:.*/::' | sort -u --version-sort)
138+
unique_urls=""
139+
for i in $items; do
140+
item=$(echo "$urls" | grep -i "$i" | head -1)
141+
if [ -z "$unique_urls" ]; then
142+
unique_urls=$(printf "%b\n" "$item")
143+
else
144+
unique_urls=$(printf "%b\n%b" "$item" "$unique_urls")
145+
fi
146+
done
147+
if echo "$urls" | head -1 | grep -q "archimage"; then
148+
urls=$(echo "$unique_urls" | grep -i "archimage5")
149+
else
150+
urls="$unique_urls"
151+
fi
152+
}
153+
136154
_downgrade() {
137155
# Safety checks
138156
if [ ! -f "$argpath"/AM-updater ]; then
@@ -149,14 +167,22 @@ _downgrade() {
149167
cd "$argpath" || return 1
150168
entries_list=$(_downgrade_entries_filter)
151169
urls="$(eval "$entries_list" 2>/dev/null | grep -vi "zsync$")"
170+
171+
# Try to avoid multiple snapshots of the same version
172+
echo "$DIVIDING_LINE"
173+
read -r -p $" Do you want to exclude snapshot versions? (Y,n)" yn
174+
if ! echo "$yn" | grep -i '^n' >/dev/null 2>&1; then
175+
_downgrade_no_snapshots
176+
fi
177+
152178
if ! echo "$urls" | grep -q "[0-9]"; then
153179
echo $" ERROR: No valid links found, sorry!"
154180
exit 1
155181
fi
156182
echo "$DIVIDING_LINE"
157-
echo $"You have chosen to roll back \"$2\"."
183+
echo $"You have chosen to roll back \"$2\"." | _fit
158184
echo "$DIVIDING_LINE"
159-
echo $"Select a URL from this menu (read carefully) or press ZERO to abort:"
185+
echo $"Select a URL from this menu (read carefully) or press ZERO to abort:" | _fit
160186
echo "$DIVIDING_LINE"
161187
sleep 1
162188
select d in $urls; do

0 commit comments

Comments
 (0)