kiss/contrib/kiss-outdated

53 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/bin/sh
# Check repository packages for updates
2020-05-09 12:28:09 -06:00
#
# Intended behavior.
# shellcheck disable=2106
kiss search "${@:-*}" | (while read -r pkg_loc _; do {
2020-05-09 12:28:09 -06:00
read -r ver _ 2>/dev/null < "$pkg_loc/version" || continue
pkg=${pkg_loc##*/}
# Fix some package names.
case $pkg in
*-bin) fix=${pkg%%-bin} ;;
*[0-9]r) fix=${pkg%%r} ;;
esac
2020-05-09 12:28:09 -06:00
# 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.
{
case $rep in -|''|' ') continue; esac
case $ver in git) continue; esac
}
# Split the comma separated list.
2020-05-09 12:28:09 -06:00
# Intentional (and safe) splitting.
# shellcheck disable=2086
{
2020-05-09 12:28:09 -06:00
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)