aboutsummaryrefslogtreecommitdiff
path: root/contrib/cpt-outdated
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2020-07-24 09:45:05 +0000
committermerakor <cem@ckyln.com>2020-07-24 09:45:05 +0000
commita5742ec0d46f60fcbeec141744a2e35a9e5dd6d5 (patch)
tree653077a372cea7a5842db627546d2fab72c5f7e2 /contrib/cpt-outdated
parent453a27cc1b956246c9639555268631abf0687e40 (diff)
downloadcpt-a5742ec0d46f60fcbeec141744a2e35a9e5dd6d5.tar.gz
contrib: rename scripts
FossilOrigin-Name: d35a756a5d603ac894873aeb0a30826cb4b3fe9e257ecf21298225e07f517ddd
Diffstat (limited to 'contrib/cpt-outdated')
-rwxr-xr-xcontrib/cpt-outdated59
1 files changed, 59 insertions, 0 deletions
diff --git a/contrib/cpt-outdated b/contrib/cpt-outdated
new file mode 100755
index 0000000..27bb1ee
--- /dev/null
+++ b/contrib/cpt-outdated
@@ -0,0 +1,59 @@
+#!/bin/sh
+# Check installed packages for updates
+
+old_IFS=$IFS
+
+# Notify the user
+printf '\033[1;33m-> \033[1;36mnote \033[m%s\n' \
+ "If you are doing too many requests you will note be" \
+ "able to get information for every package you have" >&2
+
+# List via arguments or all installed packages.
+if [ "$1" ]; then
+ set -- printf '%s\n' "$@"
+else
+ set -- kiss l
+fi
+
+"$@" | (while read -r pkg _; do {
+ read -r ver _ < "/var/db/kiss/installed/$pkg/version"
+
+ # Fix some package names.
+ case $pkg in
+ *-bin) fix=${pkg%%-bin} ;;
+ esac
+
+ # Grab the repology version from the SVG file.
+ rep=$(curl -s "https://repology.org/badge/latest-versions/${fix:-$pkg}.svg")
+
+ # Skip these instead of outputting empty
+ # version informations.
+ # shellcheck disable=2106
+ case "$rep" in (*'Too Many Requests'*) continue ;; esac
+
+ rep=${rep%</text>*}
+ rep=${rep##*>}
+
+ # Skip these.
+ # shellcheck disable=2106
+ {
+ [ "${rep:--}" = - ] && continue
+ [ "$ver" = git ] && continue
+ }
+
+ # Split the comma separated list.
+ # shellcheck disable=2086
+ {
+ IFS=', '
+ set -f
+ set +f -- $rep
+ IFS=$old_IFS
+ }
+
+ # Parse comma separated version lists.
+ {
+ for v; do case $v in "$ver") match=1; esac; done
+
+ [ "$match" ] || printf '%s\n' "$pkg $ver -> $rep"
+ }
+} & done; wait)