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