summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartchus2017-11-26 02:01:14 +0100
committerMartchus2017-11-26 02:01:14 +0100
commite61d81bec9d0f2116010e3cd99ccf1a5ba8f6fe9 (patch)
treed992597d9625f4443f61aa545ec39061c7153838
parent6102d9f7ffc290a7c70c924dede1927f3e63d362 (diff)
downloadaur-e61d81bec9d0f2116010e3cd99ccf1a5ba8f6fe9.tar.gz
Add script to update PKGBUILD
-rwxr-xr-xupdate.sh62
1 files changed, 62 insertions, 0 deletions
diff --git a/update.sh b/update.sh
new file mode 100755
index 00000000000..1fd3691ef71
--- /dev/null
+++ b/update.sh
@@ -0,0 +1,62 @@
+#!/usr/bin/bash
+
+set -e
+shopt -s nocasematch
+source '/usr/share/makepkg/util.sh'
+[[ -t 2 ]] && colorize
+
+msg 'Query list of nightly sources'
+srcurl='http://nightlies.videolan.org/build/source/'
+srclist=$(curl "$srcurl")
+
+msg 'Find latest nightly'
+fileregex='.*(<a\ +href=\")([^\"]+)(\">)'
+if ! [[ $srclist =~ $fileregex ]]; then
+ echo 'No source found'
+ exit -1
+fi
+srcfile=${BASH_REMATCH[2]}
+msg2 "source file: $srcfile"
+
+msg 'Split file name of latest nightly into components used in the PKGBUILD'
+compregex='vlc-(.*)-(.*)-(.*)-git.tar.xz'
+if ! [[ $srcfile =~ $compregex ]]; then
+ echo 'Unable to split source file into components used in PKGBUILD'
+ exit -1
+fi
+version=${BASH_REMATCH[1]}
+date=${BASH_REMATCH[2]}
+strange_number=${BASH_REMATCH[3]}
+msg2 "version: $version"
+msg2 "date: $date"
+msg2 "strange number: $strange_number"
+
+msg 'Update PKGBUILD'
+mv 'PKGBUILD' 'PKGBUILD.bak'
+awk \
+ -v pkgver="pkgver=${version}v${date}" \
+ -v _pkgver="_pkgver=${version}" \
+ -v _snapshot_="_snapshot_=${date}" \
+ -v _snapver_="_snapver_=${strange_number}" \
+' /^[[:blank:]]*_pkgver=.*$/ {
+ print _pkgver
+ next
+ }
+ /^[[:blank:]]*pkgver=.*$/ {
+ print pkgver
+ next
+ }
+ /^[[:blank:]]*_snapshot_=.*$/ {
+ print _snapshot_
+ next
+ }
+ /^[[:blank:]]*_snapver_=.*$/ {
+ print _snapver_
+ next
+ }
+ 1
+ END {
+
+ }
+' \
+ 'PKGBUILD.bak' > 'PKGBUILD'