Last active 1740366766

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

Revision fa37d7f3b2e455c733be4cba065278cff1e95b86

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