kiss/contrib/kiss-outdated

53 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/bin/sh
# Check repository packages for updates
#
# Intended behavior.
# shellcheck disable=2106
kiss search "${@:-*}" | (while read -r pkg_loc _; do {
read -r ver _ 2>/dev/null < "$pkg_loc/version" || continue
2020-09-23 05:01:35 -06:00
pkg=${pkg_loc##*/}
2020-09-23 05:01:35 -06:00
# 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} " ;;
2020-09-23 05:01:35 -06:00
esac
2020-09-23 02:51:19 -06:00
# 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.
{
case $rep in -|''|' ') continue; esac
case $ver in git) continue; esac
}
# Split the comma separated list.
# Intentional (and safe) splitting.
# shellcheck disable=2086
{
IFS=', '
set -f
set +f -- $rep
unset IFS
}
2020-09-23 03:34:49 -06:00
# Parse comma separated version lists.
{
for v; do case $v in "$ver") match=1; esac; done
2020-09-23 03:34:49 -06:00
[ "$match" ] || printf '%s\n' "$pkg $ver -> $rep"
}
} & done; wait)