diff --git a/contrib/source-control-tools/automated-commits.sh b/contrib/source-control-tools/automated-commits.sh --- a/contrib/source-control-tools/automated-commits.sh +++ b/contrib/source-control-tools/automated-commits.sh @@ -12,8 +12,11 @@ help_message() { cat < -update-aur-version() { - # shellcheck source=../utils/compare-version.sh - source "${TOPLEVEL}"/contrib/utils/compare-version.sh - PACKAGE="$1" - - CURRENT_VERSION="" - get_current_version CURRENT_VERSION - - # Get the current version of the AUR package - PKGBUILD="${TOPLEVEL}"/contrib/aur/${PACKAGE}/PKGBUILD - # shellcheck source=../aur/bitcoin-abc/PKGBUILD - source "${PKGBUILD}" - - # Compare the versions. We only want to update if - # (software version > package version) to prevent downgrades. - if version_less_equal "${CURRENT_VERSION}" "${pkgver}" - then - echo "Current version ${CURRENT_VERSION} <= ${PACKAGE} AUR package version ${pkgver}, skip the update" - exit 0 - fi - - # Reset the release version to 0 and update the package version in the - # PKGBUILD file. - # Note that this pattern is very safe: because of the shell script syntax, - # no whitespace can occur and we have the original value as a variable. - sed -i "s/pkgrel=${pkgrel}/pkgrel=0/" "${PKGBUILD}" - sed -i "s/pkgver=${pkgver}/pkgver=${CURRENT_VERSION}/" "${PKGBUILD}" - - git add "${PKGBUILD}" - git commit -m "Bump ${PACKAGE} AUR package version to ${CURRENT_VERSION}" -} - case "${COMMIT_TYPE}" in archive-release-notes) # shellcheck source=../utils/compare-version.sh @@ -145,14 +117,6 @@ git commit -m "${BOT_PREFIX} Archive release notes for version ${RELEASE_NOTES_VERSION}" ;; - update-aur-version-bitcoin-abc) - update-aur-version "bitcoin-abc" - ;; - - update-aur-version-bitcoin-abc-qt) - update-aur-version "bitcoin-abc-qt" - ;; - update-chainparams) CHAINPARAMS_SCRIPTS_DIR="${DEVTOOLS_DIR}"/chainparams @@ -232,10 +196,25 @@ ;; *) - echo "Error: Invalid commit name '${COMMIT_TYPE}'" - exit 10 + if [ -z "${SCRIPT}" ]; then + echo "Error: Invalid commit name '${COMMIT_TYPE}'" + exit 10 + fi + + if [ ! -f "${SCRIPT}" ]; then + echo "Error: '${SCRIPT}' does not exist" + exit 10 + fi + + "${SCRIPT}" "${SCRIPT_ARGS[@]}" ;; esac +# Bail early if there's nothing to land +if [ "$(git rev-parse HEAD)" == "$(git rev-parse ${PARENT_COMMIT})" ]; then + echo "No new changes. Nothing to do." + exit 0 +fi + # Land the generated commit "${TOPLEVEL}"/contrib/source-control-tools/land-patch.sh "${LAND_PATCH_ARGS[@]}" diff --git a/contrib/source-control-tools/land-patch.sh b/contrib/source-control-tools/land-patch.sh --- a/contrib/source-control-tools/land-patch.sh +++ b/contrib/source-control-tools/land-patch.sh @@ -47,12 +47,6 @@ exit 10 fi -# Bail early if there's nothing to land -if [ "$(git rev-parse HEAD)" == "$(git rev-parse origin/master)" ]; then - echo "No new changes. Nothing to do." - exit 0 -fi - TOPLEVEL=$(git rev-parse --show-toplevel) # TODO: Autogen (update version numbers, copyright headers, etc.) diff --git a/contrib/source-control-tools/patch-recipes/update-aur-version.sh b/contrib/source-control-tools/patch-recipes/update-aur-version.sh new file mode 100755 --- /dev/null +++ b/contrib/source-control-tools/patch-recipes/update-aur-version.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +export LC_ALL=C.UTF-8 + +set -euxo pipefail + +# Common script to update the AUR packages. +# Usage: update-aur-version + +TOPLEVEL=$(git rev-parse --show-toplevel) +# shellcheck source=../../utils/compare-version.sh +source "${TOPLEVEL}"/contrib/utils/compare-version.sh +PACKAGE="$1" + +CURRENT_VERSION="" +get_current_version CURRENT_VERSION + +# Get the current version of the AUR package +PKGBUILD="${TOPLEVEL}"/contrib/aur/${PACKAGE}/PKGBUILD +# shellcheck source=../../aur/bitcoin-abc/PKGBUILD +source "${PKGBUILD}" + +# Compare the versions. We only want to update if +# (software version > package version) to prevent downgrades. +if version_less_equal "${CURRENT_VERSION}" "${pkgver}" +then + echo "Current version ${CURRENT_VERSION} <= ${PACKAGE} AUR package version ${pkgver}, skip the update" + exit 0 +fi + +# Reset the release version to 0 and update the package version in the +# PKGBUILD file. +# Note that this pattern is very safe: because of the shell script syntax, +# no whitespace can occur and we have the original value as a variable. +sed -i "s/pkgrel=${pkgrel}/pkgrel=0/" "${PKGBUILD}" +sed -i "s/pkgver=${pkgver}/pkgver=${CURRENT_VERSION}/" "${PKGBUILD}" + +git add "${PKGBUILD}" +git commit -m "Bump ${PACKAGE} AUR package version to ${CURRENT_VERSION}"