1
0
mirror of https://codeberg.org/kiss-community/kiss synced 2024-07-02 14:02:26 +00:00
kiss/contrib/kiss-outdated

57 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/bin/sh
# Check repository for outdated packages
2020-05-09 18:28:09 +00:00
#
# Intended behavior.
# shellcheck disable=2106
[ "$1" ] || {
printf 'usage: kiss outdated /path/to/repo\n' >&2
exit 1
}
cd "$1" 2>/dev/null || {
printf 'repository %s is inaccessible\n' "$1" >&2
exit 1
}
2020-09-23 08:58:16 +00:00
printf 'Checking repology.org for outdated packages in %s\n' "$1" >&2
2020-09-23 08:51:19 +00:00
for pkg in */; do
pkg=${pkg%%/}
read -r ver _ 2>/dev/null < "$pkg/version" || {
2020-09-23 08:56:15 +00:00
printf '%s: local version not found\n' "$pkg" >&2
continue
}
[ "$ver" = git ] && {
2020-09-23 08:51:19 +00:00
printf '%s: skipping, version is git\n' "$pkg" >&2
continue
}
pkg=${pkg%%-bin}
pkg=${pkg%%-git}
rep=$(curl -s "https://repology.org/badge/latest-versions/$pkg.svg") || {
2020-09-23 08:51:19 +00:00
printf '%s: failed to grab version from repology\n' "$pkg" >&2
continue
}
rep=${rep%</text>*}
rep=${rep##*>}
case $rep in
*", $ver"* | *"$ver,"* | "$ver")
# Found match, do nothing.
;;
- | '' | ' ')
2020-09-23 08:58:16 +00:00
printf '%s: empty response, is pkg named correctly?\n' "$pkg" >&2
;;
*)
2020-09-23 08:51:19 +00:00
printf '%s: %s -> %s\n' "$pkg" "$ver" "$rep"
;;
esac
done