summarylogtreecommitdiffstats
path: root/update_pkgbuild.sh
diff options
context:
space:
mode:
authorthynkon2020-11-07 10:27:18 +0100
committerthynkon2020-11-07 10:27:18 +0100
commit00229b5d31dde07df8c28017e5d96c3b7a4b2629 (patch)
tree1ff459ea1e4b9daa841282eb43214cb2aa7f94b4 /update_pkgbuild.sh
parentfedf3e12c7f4619cf43e8b10c36b4fbeaa5bd93b (diff)
downloadaur-00229b5d31dde07df8c28017e5d96c3b7a4b2629.tar.gz
Update to v. 1.3.18-1
Diffstat (limited to 'update_pkgbuild.sh')
-rwxr-xr-xupdate_pkgbuild.sh94
1 files changed, 94 insertions, 0 deletions
diff --git a/update_pkgbuild.sh b/update_pkgbuild.sh
new file mode 100755
index 000000000000..cd5a6a078e52
--- /dev/null
+++ b/update_pkgbuild.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+
+readonly PROGRAM_NAME=$(basename $0)
+
+usage() {
+ cat << EOF
+Update PKGBUILD
+
+Usage: ${PROGRAM_NAME} [options]
+
+Options:
+ -h, --help display this help message and exit.
+ -r, --pkgrel the package version
+ -v, --pkgver the package release
+EOF
+}
+
+main() {
+ pkgver=""
+ pkgrel=""
+
+ optspec=":hr:v:-:"
+ while getopts "$optspec" optchar; do
+ case "${optchar}" in
+ -)
+ case "${OPTARG}" in
+ help)
+ usage
+ exit 2
+ ;;
+ pkgver)
+ pkgver="${!OPTIND}";
+ OPTIND=$(( $OPTIND + 1 ))
+ ;;
+ pkgrel)
+ pkgrel="${!OPTIND}";
+ OPTIND=$(( $OPTIND + 1 ))
+ ;;
+ *)
+ echo "Unknown option --${OPTARG}" >&2
+ exit 1
+ ;;
+ esac;;
+ h)
+ usage
+ exit 2
+ ;;
+ r)
+ pkgrel="${OPTARG}"
+ ;;
+ v)
+ pkgver="${OPTARG}"
+ ;;
+ *)
+ echo "Non-option argument: '-${OPTARG}'" >&2
+ exit 1
+ ;;
+ esac
+ done
+
+ if [ -z "${pkgver}" ]; then
+ echo "You must specify the package version!"
+ echo "Exiting..."
+ exit 1
+ fi
+ sed -i -r "s/^pkgver=([0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,3})$/pkgver=${pkgver}/g" PKGBUILD
+
+ if [ -z "${pkgrel}" ]; then
+ pkgrel=$(grep "^pkgrel" PKGBUILD | cut -d '=' -f 2)
+ fi
+ sed -i -r "s/^pkgrel=([0-9])$/pkgrel=${pkgrel}/g" PKGBUILD
+
+ algorithm="sha512"
+ checksum_file="Joplin-${pkgver}.AppImage.${algorithm}"
+ repo_url="https://github.com/laurent22/joplin/releases/download/v${pkgver}/${checksum_file}"
+
+ status=$(curl --output /dev/null -I --write-out '%{http_code}' "${repo_url}")
+ # requests are always redirected to the aws servers
+ if [[ "302" != "${status}" ]]; then
+ echo "The file ${checksum_file} does not exists!"
+ echo "Exiting..."
+ exit 1
+ fi
+
+ sha512=$(curl --silent -L "${repo_url}")
+ sed -i -r "s/^\s\s([A-Fa-f0-9]{128})$/ ${sha512}/g" PKGBUILD
+ if [ $? -ne 0 ]; then
+ echo "Failed to update sha512!"
+ echo "Need manual intervention!"
+ exit 1
+ fi
+}
+
+main $@