@@ -324,26 +324,26 @@ tasks:
324324 fetch_index main "$index_main"
325325 fetch_index community "$index_community"
326326
327- if ! grep -Eq '^[a-zA-Z0-9+_.-]+(=~|~=)[0-9]+\.[0-9]+$' alpine-packages.txt; then
328- echo "INFO: No pinned Alpine packages (~=X.Y) found in alpine-packages.txt"
329- exit 0
330- fi
331-
332327 tmp_out=".tmp/alpine-packages.updated.txt"
333328 : > "$tmp_out"
334329 updated=0
330+ processed=0
335331 while IFS= read -r line || [ -n "$line" ]; do
336332 if [ -z "$line" ] || printf '%s' "$line" | grep -Eq '^[[:space:]]*#'; then
337333 echo "$line" >> "$tmp_out"
338334 continue
339335 fi
340- if ! printf '%s' "$line" | grep -Eq '^[a-zA-Z0-9+_.-]+(=~|~=)[0-9]+\.[0-9]+$'; then
336+ if ! printf '%s' "$line" | grep -Eq '^[a-zA-Z0-9+_.-]+(( =~|~=)[0-9]+\.[0-9]+)? $'; then
341337 echo "$line" >> "$tmp_out"
342338 continue
343339 fi
344340
345- pkg="$(printf '%s' "$line" | sed -E 's/^([a-zA-Z0-9+_.-]+)(=~|~=).*/\1/')"
346- current_minor="$(printf '%s' "$line" | sed -E 's/^[a-zA-Z0-9+_.-]+(=~|~=)([0-9]+\.[0-9]+).*$/\2/')"
341+ pkg="$(printf '%s' "$line" | sed -E 's/^([a-zA-Z0-9+_.-]+).*/\1/')"
342+ current_minor=""
343+ if printf '%s' "$line" | grep -Eq '^[a-zA-Z0-9+_.-]+(=~|~=)[0-9]+\.[0-9]+$'; then
344+ current_minor="$(printf '%s' "$line" | sed -E 's/^[a-zA-Z0-9+_.-]+(=~|~=)([0-9]+\.[0-9]+).*$/\2/')"
345+ fi
346+
347347 latest_full="$(lookup_latest "$pkg" || true)"
348348 if [ -z "$latest_full" ]; then
349349 echo "WARN: Could not resolve latest version for $pkg; keeping $line"
@@ -352,6 +352,15 @@ tasks:
352352 fi
353353
354354 latest_minor="$(normalize_minor "$latest_full")"
355+ processed=1
356+
357+ if [ -z "$current_minor" ]; then
358+ echo "PIN: $pkg -> $latest_minor"
359+ echo "$pkg~=$latest_minor" >> "$tmp_out"
360+ updated=1
361+ continue
362+ fi
363+
355364 if [ "$latest_minor" = "$current_minor" ]; then
356365 echo "OK: $pkg already up to date at $current_minor"
357366 echo "$pkg~=$current_minor" >> "$tmp_out"
@@ -362,6 +371,10 @@ tasks:
362371 updated=1
363372 done < alpine-packages.txt
364373
374+ if [ "$processed" -eq 0 ]; then
375+ echo "INFO: No Alpine package entries found in alpine-packages.txt"
376+ fi
377+
365378 if ! cmp -s alpine-packages.txt "$tmp_out"; then
366379 mv "$tmp_out" alpine-packages.txt
367380 else
0 commit comments