Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions Taskfile.scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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
Expand Down
Loading