]> code.delx.au - monosys/commitdiff
Merge arch-build-system scripts repo
authorJames Bunton <jamesbunton@delx.net.au>
Sun, 26 Mar 2017 23:46:14 +0000 (10:46 +1100)
committerJames Bunton <jamesbunton@delx.net.au>
Sun, 26 Mar 2017 23:46:14 +0000 (10:46 +1100)
aur-install [new file with mode: 0755]
check-aur-updates [new file with mode: 0755]

diff --git a/aur-install b/aur-install
new file mode 100755 (executable)
index 0000000..ba50499
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+set -e
+
+PKGNAME="$1"
+if [ -z "$PKGNAME" ]; then
+    echo "Usage: $0 pkgname"
+    exit 1
+fi
+
+function enter_directory {
+    mkdir -p "$1"
+    cd "$1"
+}
+
+function fetch_latest_changes {
+    if [ ! -d .git ]; then
+        git init
+        git remote add origin "https://aur.archlinux.org/${PKGNAME}"
+    fi
+    git fetch
+    git reset origin/master
+}
+
+function show_diff {
+    git diff -R
+}
+
+function ask_user_to_continue {
+    read -p "Ok? (y/n) " ok
+    if [ "$ok" != "y" ]; then
+        return 1
+    fi
+}
+
+function build_and_install {
+    git clean -xf
+    git checkout .
+    makepkg -sri
+}
+
+enter_directory "/var/abs/aur/${PKGNAME}"
+fetch_latest_changes
+show_diff
+ask_user_to_continue
+build_and_install
diff --git a/check-aur-updates b/check-aur-updates
new file mode 100755 (executable)
index 0000000..67d4ef4
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+set -eu
+
+pacman -Qm | while read pkg installed_version; do
+    aur_version="$(curl -gsSf "https://aur.archlinux.org/rpc/?v=5&type=info&arg[]=${pkg}" | jq -r '.results[0].Version')"
+    if [ "$installed_version" != "$aur_version" ]; then
+        echo "New ${pkg}: $installed_version -> $aur_version"
+    fi
+done