From 33dd1ed46722da57a97a4e413aeff96497840dc3 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 4 Mar 2020 00:49:04 +0200 Subject: [PATCH] kiss-outdated: Check for outdated packages via repology --- contrib/kiss-outdated | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 contrib/kiss-outdated 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%*} + 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)