summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorBazaah2019-11-06 16:15:00 +0000
committerBazaah2019-11-06 16:15:00 +0000
commitc041a96f48b9c930e92b2b582df8d51002a504af (patch)
tree6053381c30d256aa695ca197fd5c8a8339c08d95
parent99c3130a7d269976d71c9b48ee8906a8ad052121 (diff)
downloadaur-c041a96f48b9c930e92b2b582df8d51002a504af.tar.gz
added update.sh
-rwxr-xr-xupdate.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/update.sh b/update.sh
new file mode 100755
index 00000000000..520db40fd79
--- /dev/null
+++ b/update.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+set -e
+
+if [ ! -f ./PKGBUILD ] && [ ! -f ./.SRCINFO ]; then
+ echo "PKGBUILD & .SRCINFO not found in CWD... script is probably not being executed inside the repo"
+ exit 1
+fi
+
+JAESVE_LATEST=$(git ls-remote --tags git://github.com/bazaah/jaesve.git \
+ | sort -r -t '/' -k 3 -V \
+ | awk '{print $2}' \
+ | grep -E '[0-9]$' \
+ | head -n1 \
+ | awk -F '/' '{print $NF}'
+)
+PKG_LATEST=$(grep -oP "(\d+\.)+\d+(-[\d\w\.\-]+)?" ./PKGBUILD)
+
+echo "Latest jaesve tag: $JAESVE_LATEST, Latest PKG version: $PKG_LATEST, comparing..."
+
+LATEST=$(echo ${JAESVE_LATEST},${PKG_LATEST} | tr , "\n" | sort -rV | head -n1)
+
+echo "Using $LATEST as the latest version"
+
+if [ "$PKG_LATEST" = "$LATEST" ]; then
+ (
+ echo "No change in version, Incrementing PKG release..."
+ increment=$(grep -oP "pkgrel\s*=\s*(\d+)" ./PKGBUILD | grep -oP "\d+")
+ let "increment++"
+
+ for file in $(find . -maxdepth 1 -type f -name 'PKGBUILD' -or -name '.SRCINFO'); do
+ sed -i -E "s/(pkgrel\s*=\s*).*/\1$increment/" $file
+ done
+ )
+else
+ (
+ echo "Version changed, updating PKG version & setting PKG release to 1..."
+
+ for file in $(find . -maxdepth 1 -type f -name 'PKGBUILD' -or -name '.SRCINFO'); do
+ sed -i -E "s/(pkgver\s*=\s*).*/\1${LATEST}/" ./PKGBUILD
+ sed -i -E "s/(pkgrel\s*=\s*).*/\11/" ./PKGBUILD
+ done
+ )
+fi
+
+echo "AUR PKG update successful, repo is ready to be commited"