From b209827f381b9aa0c2a30c4dbf657fd786884b97 Mon Sep 17 00:00:00 2001 From: purian23 Date: Mon, 4 May 2026 23:10:12 -0400 Subject: [PATCH] distro:(Workflow) Save the resources --- distro/scripts/ppa-sync-plan.sh | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/distro/scripts/ppa-sync-plan.sh b/distro/scripts/ppa-sync-plan.sh index 7335047b..a38a931f 100755 --- a/distro/scripts/ppa-sync-plan.sh +++ b/distro/scripts/ppa-sync-plan.sh @@ -56,6 +56,15 @@ release_base() { echo "$1" | sed -E 's/ppa[0-9]+$//' | sed -E 's/-[0-9]+$//' } +ppa_suffix() { + local version="$1" + if [[ "$version" =~ ppa([0-9]+)$ ]]; then + echo "${BASH_REMATCH[1]}" + else + echo "0" + fi +} + embedded_commit() { echo "$1" | sed -nE 's/.*[+~]git[0-9]+\.([a-f0-9]{7,12}).*/\1/p' } @@ -75,6 +84,18 @@ target_ppa() { fi } +rebuild_release_is_newer() { + local series="$1" + local published="$2" + local requested current + + [[ -n "$REBUILD_RELEASE" ]] || return 1 + + requested="$(target_ppa "$series")" + current="$(ppa_suffix "$published")" + [[ "$requested" -gt "$current" ]] +} + include_package() { local package="$1" [[ "$PACKAGE_FILTER" == "all" || "$PACKAGE_FILTER" == "$package" ]] @@ -93,10 +114,7 @@ for pkg_info in "${PACKAGES[@]}"; do needs_update=false reason="" - if [[ -n "$REBUILD_RELEASE" ]]; then - needs_update=true - reason="manual rebuild" - elif [[ -z "$ppa_version" ]]; then + if [[ -z "$ppa_version" ]]; then needs_update=true reason="missing from ${series}" elif [[ "$type" == "git" ]]; then @@ -116,6 +134,11 @@ for pkg_info in "${PACKAGES[@]}"; do fi fi + if [[ "$needs_update" != "true" ]] && rebuild_release_is_newer "$series" "$ppa_version"; then + needs_update=true + reason="rebuild ppa$(ppa_suffix "$ppa_version") -> ppa$(target_ppa "$series")" + fi + if [[ "$needs_update" == "true" ]]; then target="${package}:${series}:$(target_ppa "$series")" TARGETS+=("$target")