forked from kiss-community/kiss
55 lines
1.1 KiB
Bash
Executable File
55 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
# Check repository for outdated packages
|
|
#
|
|
# 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
|
|
}
|
|
|
|
printf 'Checking for outdated packages in %s\n' "$1" >&2
|
|
|
|
for pkg in *; do
|
|
read -r ver _ < "$pkg/version" || {
|
|
printf 'warning: %s/version not found' "$PWD/$pkg" >&2
|
|
continue
|
|
}
|
|
|
|
[ "$ver" = git ] && {
|
|
printf 'warning: skipping check for %s, version is git\n' "$pkg" >&2
|
|
continue
|
|
}
|
|
|
|
pkg=${pkg%%-bin}
|
|
pkg=${pkg%%-git}
|
|
|
|
rep=$(curl -s "https://repology.org/badge/latest-versions/$pkg.svg") || {
|
|
printf 'warning: failed to grab version for %s\n' "$pkg"
|
|
continue
|
|
}
|
|
|
|
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
|