aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2020-03-03 22:49:03 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2020-03-03 22:49:03 +0000
commit50dda4c9167a67e95676f2f2459f78263199c096 (patch)
tree8e4588bbbb23121aa41b5ed451d3253255108edb /contrib
parentb9637eac9f3c40594a82188450383a8d6472b6f8 (diff)
downloadcpt-50dda4c9167a67e95676f2f2459f78263199c096.tar.gz
kiss-outdated: Check for outdated packages via repology
FossilOrigin-Name: fe7f65e17a4b7f115a92c10e848596ab7bb81a7c77fc385720d3b7b4bde40a07
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/kiss-outdated49
1 files changed, 49 insertions, 0 deletions
diff --git a/contrib/kiss-outdated b/contrib/kiss-outdated
new file mode 100755
index 0000000..db2b421
--- /dev/null
+++ b/contrib/kiss-outdated
@@ -0,0 +1,49 @@
+#!/bin/sh
+#
+# Check installed packages for updates.
+
+old_IFS=$IFS
+
+# List via arguments or all installed packages.
+if [ "$1" ]; then
+ set -- printf '%s\n' "$@"
+else
+ set -- kiss l
+fi
+
+"$@" | (while read -r pkg _; do {
+ read -r ver _ < "/var/db/kiss/installed/$pkg/version"
+
+ # Fix some package names.
+ case $pkg in
+ *-bin) fix=${pkg%%-bin} ;;
+ esac
+
+ # Grab the repology version from the SVG file.
+ rep=$(curl -s "https://repology.org/badge/latest-versions/${fix:-$pkg}.svg")
+ rep=${rep%</text>*}
+ rep=${rep##*>}
+
+ # Skip these.
+ # shellcheck disable=2106
+ {
+ [ "${rep:--}" = - ] && continue
+ [ "$ver" = git ] && continue
+ }
+
+ # Split the comma separated list.
+ # shellcheck disable=2086
+ {
+ IFS=', '
+ set -f
+ set +f -- $rep
+ IFS=$old_IFS
+ }
+
+ # Parse comma separated version lists.
+ {
+ for v; do case $v in "$ver") match=1; esac; done
+
+ [ "$match" ] || printf '%s\n' "$pkg $ver -> $rep"
+ }
+} & done; wait)