Skip to content

Commit 883ad28

Browse files
fix: update Alpine package handling to allow optional version pinning (#187)
Co-authored-by: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com>
1 parent 46b849a commit 883ad28

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

Taskfile.scripts.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,26 +190,26 @@ tasks:
190190
fetch_index main "$index_main"
191191
fetch_index community "$index_community"
192192
193-
if ! grep -Eq '^[a-zA-Z0-9+_.-]+(=~|~=)[0-9]+\.[0-9]+$' alpine-packages.txt; then
194-
echo "INFO: No pinned Alpine packages (~=X.Y) found in alpine-packages.txt"
195-
exit 0
196-
fi
197-
198193
tmp_out=".tmp/alpine-packages.updated.txt"
199194
: > "$tmp_out"
200195
updated=0
196+
processed=0
201197
while IFS= read -r line || [ -n "$line" ]; do
202198
if [ -z "$line" ] || printf '%s' "$line" | grep -Eq '^[[:space:]]*#'; then
203199
echo "$line" >> "$tmp_out"
204200
continue
205201
fi
206-
if ! printf '%s' "$line" | grep -Eq '^[a-zA-Z0-9+_.-]+(=~|~=)[0-9]+\.[0-9]+$'; then
202+
if ! printf '%s' "$line" | grep -Eq '^[a-zA-Z0-9+_.-]+((=~|~=)[0-9]+\.[0-9]+)?$'; then
207203
echo "$line" >> "$tmp_out"
208204
continue
209205
fi
210206
211-
pkg="$(printf '%s' "$line" | sed -E 's/^([a-zA-Z0-9+_.-]+)(=~|~=).*/\1/')"
212-
current_minor="$(printf '%s' "$line" | sed -E 's/^[a-zA-Z0-9+_.-]+(=~|~=)([0-9]+\.[0-9]+).*$/\2/')"
207+
pkg="$(printf '%s' "$line" | sed -E 's/^([a-zA-Z0-9+_.-]+).*/\1/')"
208+
current_minor=""
209+
if printf '%s' "$line" | grep -Eq '^[a-zA-Z0-9+_.-]+(=~|~=)[0-9]+\.[0-9]+$'; then
210+
current_minor="$(printf '%s' "$line" | sed -E 's/^[a-zA-Z0-9+_.-]+(=~|~=)([0-9]+\.[0-9]+).*$/\2/')"
211+
fi
212+
213213
latest_full="$(lookup_latest "$pkg" || true)"
214214
if [ -z "$latest_full" ]; then
215215
echo "WARN: Could not resolve latest version for $pkg; keeping $line"
@@ -218,6 +218,15 @@ tasks:
218218
fi
219219
220220
latest_minor="$(normalize_minor "$latest_full")"
221+
processed=1
222+
223+
if [ -z "$current_minor" ]; then
224+
echo "PIN: $pkg -> $latest_minor"
225+
echo "$pkg~=$latest_minor" >> "$tmp_out"
226+
updated=1
227+
continue
228+
fi
229+
221230
if [ "$latest_minor" = "$current_minor" ]; then
222231
echo "OK: $pkg already up to date at $current_minor"
223232
echo "$pkg~=$current_minor" >> "$tmp_out"
@@ -228,6 +237,10 @@ tasks:
228237
updated=1
229238
done < alpine-packages.txt
230239
240+
if [ "$processed" -eq 0 ]; then
241+
echo "INFO: No Alpine package entries found in alpine-packages.txt"
242+
fi
243+
231244
if ! cmp -s alpine-packages.txt "$tmp_out"; then
232245
mv "$tmp_out" alpine-packages.txt
233246
else

0 commit comments

Comments
 (0)