]> code.delx.au - monosys/blobdiff - check-aur-updates
check-pacman-updates: don't fail to exit if up to date
[monosys] / check-aur-updates
index 5df4f278a5d8c6eed9e2fa388fda0343a877fbcb..cec4e9ed6a9169b073f69ab5ed90853841421ccc 100755 (executable)
@@ -1,12 +1,18 @@
 #!/bin/bash
 
-set -e
+set -eu
 
-find /var/abs/aur -mindepth 1 -maxdepth 1 -type d | while read d; do
-    pushd "$d" > /dev/null
-    git fetch
-    if [ 0 -ne "$(git diff-index --cached origin/master | wc -l)" ]; then
-        echo "$d"
+declare -A pkg_versions
+query_url='https://aur.archlinux.org/rpc/?v=5&type=info'
+
+while read pkg installed_version; do
+    pkg_versions[$pkg]="$installed_version"
+    query_url="${query_url}&arg[]=${pkg}"
+done < <(pacman -Qm)
+
+curl -gsSf "$query_url" | jq -r '.results[] | .Name, .Version, "\u0000"' | while read -d $'\0' pkg aur_version; do
+    installed_version="${pkg_versions[$pkg]}"
+    if [ "$installed_version" != "$aur_version" ]; then
+        echo "${pkg} $installed_version -> $aur_version"
     fi
-    popd > /dev/null
 done