Last active 1740366766

List of available updates for void (anyone/mypkg/no version) packages installed locally.

Revision 93951770c6933236ef17e90e0150e4d1cfea319b

xoutdated.sh Raw
1#!/bin/bash
2
3# Prerequisite:
4# 1. presumably Void Linux
5# 2. install xtools, perl (base-devel)
6# 3. set XBPS_DISTDIR to your local copy of void-packages
7
8# List available updates of void packages installed locally for a specific contributor
9# Usage: outdated_who email author
10outdated_who(){
11 local email="$1"
12 local author="$2"
13
14 # URL encode email
15 local encoded_email
16 # encoded_email=$(echo -n "$email" | jq -sRr @uri)
17 encoded_email=$(echo -n "$email" | perl -MURI::Escape -ne 'print uri_escape($_)')
18 # encoded_email=$(echo -n "$email" | python3 -c "import sys, urllib.parse; print(urllib.parse.quote(sys.stdin.read()))")
19 local DISTURL="https://repo-default.voidlinux.org/void-updates/void-updates/updates_${encoded_email}.txt"
20 local DISTFILE="updates_${author}.txt"
21
22 CONNECTION_TIMEOUT=5000 xbps-fetch -o "${DISTFILE}" "${DISTURL}"
23 # wcurl --curl-options="--progress-bar" --output "${DISTFILE}" "${DISTURL}"
24 # wget --hsts-file="$XDG_CACHE_HOME/wget-hsts" --output-document "${DISTFILE}" --quiet "${DISTURL}"
25
26 # filter out uninterested packages
27 # opinionated, `lib` could be a bit overkill
28 grep -vE 'apache-|avr-|brltty|cargo-|cinnamon|dkms|gnome-|gst-|jenkins|lib|linux|nemo-|pantheon-|perl-|ruby-|R-cran-|webkit2gtk' "${DISTFILE}" | sponge "${DISTFILE}"
29
30 # dedup, leave only the highest available version
31 # side effect: order is slightly different
32 awk '!seen[$1]++ {line[$1] = $0} {line[$1] = $0} END {for (pkg in line) print line[pkg]}' "${DISTFILE}" | sort | sponge "${DISTFILE}"
33
34 # dedup again, leave only installed packages
35 awk 'NR==FNR{installed[$1]; next} $1 in installed' installed.txt "${DISTFILE}" | sort | sponge "${DISTFILE}"
36
37 # TODO: filter out existing update branches
38 # git branch --list |awk '{print $1}' > branches.txt
39 # awk 'NR==FNR{branches[$1]; next} {for (b in branches) if ($1 ~ b) next} {print}' branches.txt "${DISTFILE}"
40}
41
42# List my outdated packages w/o xcheckmypkgs
43# only work in local void-packages copy if XBPS_DISTDIR is not set
44outdated_mypkg(){
45 local MYURL
46 XDISTDIR="$(xdistdir)" || exit 1
47 MYURL="https://repo-default.voidlinux.org/void-updates/void-updates/updates_$(git -C "${XDISTDIR}" config user.email | sed 's/@/%40/').txt"
48 local MYFILE="updates_me.txt"
49
50 CONNECTION_TIMEOUT=5000 xbps-fetch -o "${MYFILE}" "${MYURL}"
51}
52
53# List packages that have error checking updates
54outdated_error(){
55 local LOG_URL="https://repo-default.voidlinux.org/void-updates/void-updates/_log.txt"
56 local LOG_FILE="updates_nover.txt"
57
58 CONNECTION_TIMEOUT=5000 xbps-fetch -o "${LOG_FILE}" "${LOG_URL}"
59
60 # leave only (manually) installed packages
61 grep -v 'No such file' < ${LOG_FILE} | awk 'BEGIN {
62 while ((getline < "installed.txt") > 0) {
63 installed[$1]
64 }
65 }
66 {
67 package = $5;
68 if (package in installed) print $0
69 }' | sponge ${LOG_FILE}
70}
71
72cd "$XBPS_DISTDIR" || exit 1
73
74# list only manually installed packages
75xpkg -m > installed.txt
76# query all installed packages (including core packages, more complete, but MUCH slower)
77# xbps-query -l | awk '{ print $2 }' | xargs -n1 xbps-uhelper getpkgname > installed.txt
78
79# functions here
80outdated_who "[email protected]" "orphan"
81outdated_mypkg
82outdated_error
83
84# garbage clean
85rm installed.txt
86