kiss/contrib/kiss-outdated
sdsddsd1 ed4b6b7534 contrib: kiss-outdated: fix python-* remotes (#115)
Reviewed-on: https://codeberg.org/kiss-community/kiss/pulls/115
Co-authored-by: sdsddsd1 <sdsddsd1@noreply.codeberg.org>
Co-committed-by: sdsddsd1 <sdsddsd1@noreply.codeberg.org>
2023-01-03 13:07:56 +00:00

399 lines
7.1 KiB
Bash
Executable File

#!/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:]' <<EOF |
$remote
EOF
# Remote always uses -.
tr _ -
)
case $remote in
age)
remote=age-encryption
;;
baseinit|baselayout|kiss)
remote=-
;;
bat)
remote=bat-cat
;;
clang)
remote=llvm
;;
ctags)
remote=exuberant-ctags
;;
dash)
remote=dash-shell
;;
dejavu-ttf)
remote=fonts:dejavu
;;
dsp)
remote=dsp-audio-processing
;;
dust)
remote=du-dust
;;
emacs-nox)
# TODO [community]: Make default emacs no x11?
remote=emacs
;;
go-ipfs)
remote=ipfs
;;
fd)
remote=fd-find
;;
fetsh)
# TODO [community]: Rename package?
remote=fet.sh
;;
firefox-esr)
remote=firefox
;;
font-awesome-ttf)
remote=fonts:fontawesome
;;
foot-pgo)
remote=foot
;;
gc)
remote=boehm-gc
;;
gnugrep)
# shell-check is dumb here so this must be quoted.
remote='grep'
;;
gnupg[12])
# Reported to repology.org.
# https://github.com/repology/repology-rules/issues/285
remote=gnupg
;;
gtk+3)
remote=gtk3-classic
;;
gst-*)
remote=gstreamer:${remote##*-}
;;
gtar)
remote=tar
;;
eiwd)
remote=iwd
;;
hack)
# It might be nice to adopt Repology's naming scheme for
# fonts as it also makes them self-documenting and easy
# to search for ('kiss s font:\*).
remote=fonts:hack
;;
harfbuzz-icu)
# TODO: Report to repology.org?
# Package split.
remote=harfbuzz
;;
libelf)
remote=elfutils
;;
liberation-fonts)
remote=fonts:liberation
;;
libjpeg)
remote=ijg-libjpeg
;;
libmupdf | libxaw3d)
# TODO [community]: Rename packages?
remote=${remote##lib}
;;
libnghttp2)
remote=nghttp2
;;
libportaudio2)
remote=portaudio
;;
libseat)
remote=seatd
;;
libzmq)
remote=zeromq
;;
links2)
# TODO [community]: Rename package?
remote=links
;;
linux-headers)
remote=linux
;;
lpeg)
remote=lua:lpeg
;;
lux)
remote=lux-brightness-ventto
;;
man-pages)
# TODO: Report to repology.org.
# man-pages -> manpages
# man-pages-posix -> man-pages-posix
remote=manpages
;;
netsurf-fb)
remote=netsurf
;;
noto-emoji)
remote=fonts:noto-emoji
;;
openjpeg2)
# TODO [community]: Rename package?
remote=openjpeg
;;
osh)
remote=oil-shell
;;
pass)
remote=password-store
;;
pinentry-dmenu)
remote=pinentry-dmenu-cemkeylan
;;
pybind11)
remote=python:pybind11
;;
python-psutil)
remote=python:psutil
;;
pyqt5)
# TODO [community]: Rename package?
remote=python-qt
;;
python2)
remote=python
;;
python-docutils)
remote=python:docutils
;;
python-mako)
remote=python:mako
;;
python-markupsafe)
remote=python:markupsafe
;;
qt5*)
remote=qt
;;
rage)
remote=rage-encryption
;;
sane)
remote=sane-backends
;;
spleen-font)
remote=fonts:spleen
;;
sshfs)
remote=fusefs:sshfs
;;
slides)
remote=slides-presentation-tool
;;
surf)
remote=surf-browser
;;
st)
remote=st-term
;;
sway-no-seat | sway-tiny)
remote=sway
;;
tea)
remote=gitea-tea
;;
terminus-font)
remote=fonts:terminus
;;
tiv)
remote=tiv-terminalimageviewer
;;
tree)
remote=tree-steve-baker
;;
ttf-font-awesome)
remote=font-awesome6
;;
unifont)
remote=fonts:unifont
;;
vis)
remote=vis-editor
;;
webkit2gtk)
# TODO [community]: Rename package?
remote=webkitgtk
;;
xf86-*)
remote=xdrv:${remote##*-}
;;
xmlsec1)
# TODO [community]: Rename package?
remote=xmlsec
;;
esac
}
repology_version() {
[ -f "$1.svg" ] || return 1
read -r remote_ver < "$1.svg" || :
remote_ver=${remote_ver%</text>*}
remote_ver=${remote_ver##*>}
}
repo_version() {
read -r ver _ 2>/dev/null < "$2/version" || {
printf '%-30s local version not found\n' "$1" >&2
return 1
}
[ "$ver" != git ]
}
get_outdated() {
repo=${PWD%%/}
printf '\n[Checking Repology for outdated packages in %s]\n\n' "$repo" >&2
for pkg in */; do
pkg=${pkg%%/}
repology_name "${pkg##*/}"
[ "$remote" = - ] ||
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##*/}
repo_version "$pkg" "$_pkg" || continue
repology_name "$pkg"
repology_version "$remote" || continue
case $remote_ver in
*", $ver"* | *"$ver,"* | "$ver" | '') continue ;;
-) printf '%-30s no remote version found\n' "$pkg" >&2; continue ;;
esac
printf '%-30s %s -> %s\n' "$pkg" "$ver" "$remote_ver"
done
}
main() {
set -e
[ "$1" ] ||
die 'usage: kiss [ou]tdated /path/to/repo...'
mkdir -p "${tmp:=${XDG_CACHE_HOME:-"$HOME/.cache"}/kiss/repology}"
for repo do
old_pwd=$PWD
cd "$repo"
get_outdated
cd "$old_pwd"
done
}
main "$@"