#!/usr/bin/env bash # bump-graphics-recipes.sh — Update tarball URLs/BLAKE3 for graphics recipes. # Scope: recipes/libs, recipes/gpu, recipes/kde, recipes/qt, recipes/wip/{wayland,gpu,kde,qt}. # Excludes: recipes/core/* (mini-ISO path), recipes/system/* (services). # # Usage: bump-graphics-recipes.sh [--dry-run] [--no-fetch] set -euo pipefail ROOT="$(cd "$(dirname "$0")/../.." && pwd)" DRY_RUN=0 NO_FETCH=0 for arg in "$@"; do case "$arg" in --dry-run) DRY_RUN=1 ;; --no-fetch) NO_FETCH=1 ;; --help|-h) echo "Usage: $0 [--dry-run] [--no-fetch]"; exit 0 ;; *) echo "Unknown option: $arg" >&2; exit 1 ;; esac done declare -A UPSTREAM_INDEX=( [cairo]=https://cairographics.org/releases/ [freetype2]=https://download.savannah.gnu.org/freetype/ [glib]=https://download.gnome.org/sources/glib/ [harfbuzz]=https://github.com/harfbuzz/harfbuzz/releases/ [libepoxy]=https://github.com/anholt/libepoxy/releases/ [libxkbcommon]=https://github.com/xkbcommon/libxkbcommon/releases/ [pango]=https://download.gnome.org/sources/pango/ [libjpeg]=https://github.com/libjpeg-turbo/libjpeg-turbo/releases/ [shared-mime-info]=https://gitlab.gnome.org/GNOME/shared-mime-info/-/tags/ [gdk-pixbuf]=https://download.gnome.org/sources/gdk-pixbuf/ [libxml2]=https://download.gnome.org/sources/libxml2/ [kf6-karchive]=https://download.kde.org/stable/frameworks/ [kf6-attica]=https://download.kde.org/stable/frameworks/ [kf6-kcodecs]=https://download.kde.org/stable/frameworks/ ) GRAPHICS_DIRS=( "$ROOT/recipes/libs" "$ROOT/recipes/gpu" "$ROOT/recipes/kde" "$ROOT/recipes/qt" "$ROOT/recipes/wip/wayland" "$ROOT/recipes/wip/gpu" "$ROOT/recipes/wip/kde" "$ROOT/recipes/wip/qt" ) VER_RE='-v?[0-9]+(\.[0-9]+){1,3}(-rc[0-9]+)?(-alpha[0-9]+)?(-beta[0-9]+)?' resolve_latest() { local cached="$1" prefix="$2" grep -oE "${prefix}${VER_RE}\.tar\.(gz|xz|bz2|zst)" "$cached" | sort -uV | tail -1 } UPDATED=0 SKIPPED=0 FAILED=0 for dir in "${GRAPHICS_DIRS[@]}"; do [ -d "$dir" ] || continue for rdir in "$dir"/*/; do [ -f "$rdir/recipe.toml" ] || continue name=$(basename "$rdir") if [ -z "${UPSTREAM_INDEX[$name]:-}" ]; then SKIPPED=$((SKIPPED+1)) continue fi current=$(grep '^tar = ' "$rdir/recipe.toml" | head -1 | sed -E 's/^tar = "//;s/"$//') [ -z "$current" ] && { SKIPPED=$((SKIPPED+1)); continue; } case "$name" in glib|pango|shared-mime-info|gdk-pixbuf|libxml2) prefix="$name" ;; freetype2) prefix="freetype" ;; libepoxy) prefix="libepoxy" ;; libxkbcommon) prefix="libxkbcommon" ;; libjpeg) prefix="libjpeg-turbo" ;; cairo) prefix="cairo" ;; harfbuzz) prefix="harfbuzz" ;; kf6-*) prefix="$(echo $name | sed 's/^kf6-//')" ;; *) prefix="$name" ;; esac cached="$ROOT/.redbear-recipe-bump/$name.html" mkdir -p "$(dirname "$cached")" if [ "$NO_FETCH" = "0" ]; then if ! curl -sLf "${UPSTREAM_INDEX[$name]}" -o "$cached"; then echo "WARN: $name: failed to fetch ${UPSTREAM_INDEX[$name]}" >&2 FAILED=$((FAILED+1)) continue fi fi [ -f "$cached" ] || continue latest=$(resolve_latest "$cached" "$prefix") [ -z "$latest" ] && { SKIPPED=$((SKIPPED+1)); continue; } latest_url=$(grep -m1 -oE "${UPSTREAM_INDEX[$name]}${latest}" "$cached" | head -1) [ -z "$latest_url" ] && latest_url="${UPSTREAM_INDEX[$name]}${latest}" if [ "$current" = "$latest_url" ]; then SKIPPED=$((SKIPPED+1)) continue fi echo "[$name] $current -> $latest_url" if [ "$DRY_RUN" = "0" ]; then tmp=$(mktemp) curl -sLf "$latest_url" -o "$tmp" new_hash=$(b3sum "$tmp" | awk '{print $1}') sed -i -E "s|^tar = \"[^\"]+\"|tar = \"$latest_url\"|" "$rdir/recipe.toml" sed -i -E "s|^blake3 = \"[a-f0-9]+\"|blake3 = \"$new_hash\"|" "$rdir/recipe.toml" rm -f "$tmp" fi UPDATED=$((UPDATED+1)) done done echo "" echo "=== Bump summary ===" echo "Updated (or would-update): $UPDATED" echo "Skipped (no index / already-current / non-tar): $SKIPPED" echo "Failed (network/parse): $FAILED" [ "$DRY_RUN" = "1" ] && echo "Dry-run only. No files changed."