1
0
mirror of https://codeberg.org/kiss-community/kiss synced 2024-11-04 14:05:41 -07:00
kiss/contrib/kiss-outdated
2020-05-09 21:28:09 +03:00

53 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
# Check repository packages for updates
#
# Intended behavior.
# shellcheck disable=2106
kiss s "${@:-*}" | (while read -r pkg_loc _; do {
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
# 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.
# Intentional (and safe) splitting.
# 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)