summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorJared J2024-02-25 19:51:45 +1100
committerJared J2024-02-25 19:51:45 +1100
commit02918bcc835ba189bc7aed63d71cdd3ed1bd2af8 (patch)
treedcc01b6c01a6bd36bd53d68cf31e21827e7defbc
parent0ba06b9a8de3c61ff3605a8c702382ceeacf5e2d (diff)
downloadaur-02918bcc835ba189bc7aed63d71cdd3ed1bd2af8.tar.gz
Add autoUpdate for version bumping.
-rwxr-xr-xautoUpdate79
1 files changed, 79 insertions, 0 deletions
diff --git a/autoUpdate b/autoUpdate
new file mode 100755
index 000000000000..41ce9add65ab
--- /dev/null
+++ b/autoUpdate
@@ -0,0 +1,79 @@
+#!/bin/bash
+# A script for automatically updating the kibana AUR package by checking the project's releases on github.
+# Improved for non-source building and support for different checksum methods.
+# Jared Johnstone
+# Sun 25 Feb 2024 18:47:34 AEDT
+
+set -o pipefail
+files=(PKGBUILD .SRCINFO)
+
+. PKGBUILD || { echo "This script must be placed and run in the AUR package dir" ; exit 1;}
+
+githubProject="elastic/${_relpkgname}"
+hashtool=$(grep -Po '.*sum(?=s=)' PKGBUILD)
+targetHashes=$(grep -Po '.*sums(?==)' PKGBUILD)
+declare -n checksums=${targetHashes}
+
+if [ -z "${hashtool}" ]
+then
+ echo "Failed to determine hash tool used for this package."
+ exit 1
+elif [ -z "${checksums}" ]
+then
+ echo "Failed to get checksums for this package."
+ exit 1
+fi
+
+if ! git status >/dev/null 2>&1
+then
+ echo "This script is not suitable for running outside of a git repository."
+ exit 1
+fi
+
+githubBaseurl="https://api.github.com/repos"
+githubLatestRelease="$(curl -Ss ${githubBaseurl}/${githubProject}/releases/latest)" || { echo "Failed fetching latest release info from github" ; exit 1;}
+latestRel=$(jq -r .tag_name <<< ${githubLatestRelease} | tr -d [a-z]) || { echo "Failed to read latest version" ; exit 1;}
+
+# Check if latest tag is equal or greater to the current version
+compareString="(pkgver=${pkgver}, latestRel=${latestRel})"
+if printf '%s\n%s\n' "${latestRel}" "${pkgver}" | sort --check=quiet --version-sort
+then
+ echo "No newer version detected. ${compareString}"
+ exit
+else
+ echo "New version detected. ${compareString}"
+ echo "Downloading latest files to generate replacement hashes with ${hashtool}..."
+
+ for sourceIndex in ${!source[*]}
+ do
+ oldChecksum="${checksums[${sourceIndex}]}"
+ echo old checksum is $oldChecksum
+ if [[ ${oldChecksum} == SKIP ]]
+ then
+ continue
+ fi
+ currentSource=${source[${sourceIndex}]/${pkgver}/${latestRel}}
+ echo "Getting: ${currentSource}"
+ if [[ ${currentSource} =~ ^http ]]
+ then
+ echo "Fetching $(basename ${currentSource})"
+ #newChecksum="$(curl -L --progress-meter "${currentSource/${pkgver}/${latestRel}}" | ${hashtool} | cut -f1 -d' ')" || { echo "Failed to download source for checksumming: ${source}" ; exit 1;}
+ newChecksum="$(cat kibana-8.12.2-linux-x86_64.tar.gz | ${hashtool} | cut -f1 -d' ')" || { echo "Failed to download source for checksumming: ${source}" ; exit 1;}
+ echo new checksum is: ${newChecksum}
+
+ # Update version vars, B2sums and pkgrel
+ sed -i -E -e "s/${pkgver//./\\.}/${latestRel}/g" \
+ -e "s/${oldChecksum}/${newChecksum}/g" \
+ -e 's/pkgrel=[0-9]+/pkgrel=1/g' \
+ -e 's/pkgrel = [0-9]+/pkgrel = 1/g' \
+ ${files[@]}
+ fi
+ done
+
+ makepkg --verifysource || { echo "Unable to verify sources, please verify checksums."; exit 1;}
+ git add ${files[@]}
+ echo 'Committing...'
+ git commit -m "Version bump to ${latestRel}"
+ echo 'Pushing...'
+ git push || { echo "Failed to push version bump." ; exit 1;}
+fi