kiss/contrib/kiss-outdated

50 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/bin/sh
# Check repository packages for updates
kiss s "${@:-*}" | (while read -r pkg_loc _; do {
read -r ver _ 2>/dev/null < "$pkg_loc/version"
pkg=${pkg_loc##*/}
# Fix some package names.
case $pkg in
*-bin) fix=${pkg%%-bin} ;;
*[0-9]r) fix=${pkg%%r} ;;
esac
# Ignore duplicates.
# shellcheck disable=2106
case $seen in
*" ${fix:-$pkg} "*) continue ;;
*) seen=" $seen ${fix:-$pkg} " ;;
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
{
case $rep in -|''|' ') continue; esac
case $ver in git) continue; esac
}
# Split the comma separated list.
# shellcheck disable=2086
{
IFS=', '
set -f
set +f -- $rep
unset 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)