diff --git a/Taskfile.scripts.yml b/Taskfile.scripts.yml index 6dd8909..c7e322d 100644 --- a/Taskfile.scripts.yml +++ b/Taskfile.scripts.yml @@ -190,26 +190,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" @@ -218,6 +218,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" @@ -228,6 +237,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