#!/bin/sh # Check repository for outdated packages die() { printf '%s\n' "$*" >&2 exit 1 } mkcd() { mkdir -p "$1" && cd "$1" } repology_name() { # Fix any known naming inconsistences between packages and Repology. remote=$( # Strip unrelated suffixes. remote=${1%%-bin} remote=${remote%%-git} # Remote names are all lowercase. tr '[:upper:]' '[:lower:]' < manpages # man-pages-posix -> man-pages-posix remote=manpages ;; netsurf-fb) remote=netsurf ;; openjpeg2) # TODO [community]: Rename package? remote=openjpeg ;; osh) remote=oil-shell ;; pinentry-dmenu) remote=pinentry-dmenu-cemkeylan ;; pyqt5) # TODO [community]: Rename package? remote=python-qt ;; python2) remote=python ;; qt5*) remote=qt ;; rage) remote=rage-encryption-tool ;; sane) remote=sane-backends ;; spleen-font) remote=fonts:spleen ;; sshfs) remote=fusefs:sshfs ;; surf) remote=surf-browser ;; st) remote=st-term ;; terminus-font) remote=fonts:terminus ;; tiv) remote=tiv-unclassified ;; unifont) remote=fonts:unifont ;; webkit2gtk) # TODO [community]: Rename package? remote=webkitgtk ;; xf86-*) remote=xdrv:${remote##*-} ;; xmlsec1) # TODO [community]: Rename package? remote=xmlsec ;; esac } get_versions() { repo=${repo%%/} printf '\n[Checking Repology for outdated packages in %s]\n\n' "$repo" >&2 for pkg in */; do pkg=${pkg%%/} repology_name "${pkg##*/}" case $remote in -) continue esac set -- "$@" -z "$remote.svg" \ "https://repology.org/badge/latest-versions/$remote.svg" done mkcd "$tmp/${repo##*/}" curl -SsZ --parallel-max 16 --remote-name-all "$@" || die 'fatal: network error' for _pkg in "$OLDPWD"/*/; do pkg=${_pkg%%/} pkg=${pkg##*/} read -r ver _ 2>/dev/null < "$_pkg/version" || { printf '%-30s local version not found\n' "$pkg" >&2 continue } [ "$ver" != git ] || continue repology_name "$pkg" [ -f "$remote.svg" ] || continue read -r remote_ver < "$remote.svg" || : remote_ver=${remote_ver%*} remote_ver=${remote_ver##*>} case $remote_ver in *", $ver"* | *"$ver,"* | "$ver" | -) continue esac printf '%-30s %s -> %s\n' "$pkg" "$ver" "$remote_ver" done } main() { set -e case $1 in '') die 'usage: kiss [ou]tdated /path/to/repo...\n' esac mkdir -p "${tmp:=${XDG_CACHE_HOME:-"$HOME/.cache"}/kiss/repology}" for repo do old_pwd=$PWD cd "$repo" get_versions cd "$old_pwd" done } main "$@"