From 33d1543d7063460cc16a82637cb7ac754dbc114f Mon Sep 17 00:00:00 2001 From: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com> Date: Wed, 20 May 2026 21:30:03 +0200 Subject: [PATCH] fix: update Alpine package handling to allow optional version pinning --- Taskfile.scripts.yml | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Taskfile.scripts.yml b/Taskfile.scripts.yml index 429d778..64f67d0 100644 --- a/Taskfile.scripts.yml +++ b/Taskfile.scripts.yml @@ -324,26 +324,26 @@ tasks: fetch_index main "$index_main" fetch_index community "$index_community" - if ! grep -Eq '^[a-zA-Z0-9+_.-]+(=~|~=)[0-9]+\.[0-9]+$' alpine-packages.txt; then - echo "INFO: No pinned Alpine packages (~=X.Y) found in alpine-packages.txt" - exit 0 - fi - tmp_out=".tmp/alpine-packages.updated.txt" : > "$tmp_out" updated=0 + processed=0 while IFS= read -r line || [ -n "$line" ]; do if [ -z "$line" ] || printf '%s' "$line" | grep -Eq '^[[:space:]]*#'; then echo "$line" >> "$tmp_out" continue fi - if ! printf '%s' "$line" | grep -Eq '^[a-zA-Z0-9+_.-]+(=~|~=)[0-9]+\.[0-9]+$'; then + if ! printf '%s' "$line" | grep -Eq '^[a-zA-Z0-9+_.-]+((=~|~=)[0-9]+\.[0-9]+)?$'; then echo "$line" >> "$tmp_out" continue fi - pkg="$(printf '%s' "$line" | sed -E 's/^([a-zA-Z0-9+_.-]+)(=~|~=).*/\1/')" - current_minor="$(printf '%s' "$line" | sed -E 's/^[a-zA-Z0-9+_.-]+(=~|~=)([0-9]+\.[0-9]+).*$/\2/')" + pkg="$(printf '%s' "$line" | sed -E 's/^([a-zA-Z0-9+_.-]+).*/\1/')" + current_minor="" + if printf '%s' "$line" | grep -Eq '^[a-zA-Z0-9+_.-]+(=~|~=)[0-9]+\.[0-9]+$'; then + current_minor="$(printf '%s' "$line" | sed -E 's/^[a-zA-Z0-9+_.-]+(=~|~=)([0-9]+\.[0-9]+).*$/\2/')" + fi + latest_full="$(lookup_latest "$pkg" || true)" if [ -z "$latest_full" ]; then echo "WARN: Could not resolve latest version for $pkg; keeping $line" @@ -352,6 +352,15 @@ tasks: fi latest_minor="$(normalize_minor "$latest_full")" + processed=1 + + if [ -z "$current_minor" ]; then + echo "PIN: $pkg -> $latest_minor" + echo "$pkg~=$latest_minor" >> "$tmp_out" + updated=1 + continue + fi + if [ "$latest_minor" = "$current_minor" ]; then echo "OK: $pkg already up to date at $current_minor" echo "$pkg~=$current_minor" >> "$tmp_out" @@ -362,6 +371,10 @@ tasks: updated=1 done < alpine-packages.txt + if [ "$processed" -eq 0 ]; then + echo "INFO: No Alpine package entries found in alpine-packages.txt" + fi + if ! cmp -s alpine-packages.txt "$tmp_out"; then mv "$tmp_out" alpine-packages.txt else