#!/usr/bin/env bash set -euo pipefail # Prerequisite: # 1. presumably Void Linux # 2. install xtools, perl (base-devel) # 3. set XBPS_DISTDIR to your local copy of void-packages # VERSION="3.2.2" # List available updates of void packages installed locally for a specific contributor # Usage: outdated_who email author outdated_who(){ # local EXCLUDE_REGEX="apache-" local email="$1" local author="$2" # URL encode email local encoded_email # encoded_email=$(echo -n "$email" | jq -sRr @uri) encoded_email=$(echo -n "$email" | perl -MURI::Escape -ne 'print uri_escape($_)') # encoded_email=$(echo -n "$email" | python3 -c "import sys, urllib.parse; print(urllib.parse.quote(sys.stdin.read()))") local DISTURL="https://repo-default.voidlinux.org/void-updates/void-updates/updates_${encoded_email}.txt" local DISTFILE="updates_${author}.txt" CONNECTION_TIMEOUT=5000 xbps-fetch -o "${DISTFILE}" "${DISTURL}" # wcurl --curl-options="--progress-bar" --output "${DISTFILE}" "${DISTURL}" # wget --hsts-file="$XDG_CACHE_HOME/wget-hsts" --output-document "${DISTFILE}" --quiet "${DISTURL}" # filter out uninterested packages # opinionated, `lib` could be a bit overkill # TODO: pass regex as variable to grep grep -vE 'apache-|avr-|brltty|cargo-|cinnamon|dkms|gnome-|gst-|jenkins|lib|linux|nemo-|pantheon-|perl-|ruby-|R-cran-|webkit2gtk' "${DISTFILE}" | sponge "${DISTFILE}" # dedup, leave only the highest available version # side effect: order is slightly different awk '!seen[$1]++ {line[$1] = $0} {line[$1] = $0} END {for (pkg in line) print line[pkg]}' "${DISTFILE}" | sort | sponge "${DISTFILE}" # dedup again, leave only installed packages awk 'NR==FNR{installed[$1]; next} $1 in installed' installed.txt "${DISTFILE}" | sort | sponge "${DISTFILE}" } # List my outdated packages w/o xcheckmypkgs # only work in local void-packages copy if XBPS_DISTDIR is not set outdated_mypkg(){ local MYURL XDISTDIR="$(xdistdir)" || exit 1 MYURL="https://repo-default.voidlinux.org/void-updates/void-updates/updates_$(git -C "${XDISTDIR}" config user.email | sed 's/@/%40/').txt" local MYFILE="updates_me.txt" CONNECTION_TIMEOUT=5000 xbps-fetch -o "${MYFILE}" "${MYURL}" } LOG_FILE="updates_nover.txt" # List packages that have error checking updates outdated_error(){ local LOG_URL="https://repo-default.voidlinux.org/void-updates/void-updates/_log.txt" CONNECTION_TIMEOUT=5000 xbps-fetch -o "${LOG_FILE}" "${LOG_URL}" # leave only (manually) installed packages grep -v 'No such file' < ${LOG_FILE} | awk 'BEGIN { while ((getline < "installed.txt") > 0) { installed[$1] } } { package = $5; if (package in installed) print $0 }' | sponge ${LOG_FILE} } # strip updated packages # TODO: add version comparison logic/walk through commit history to wisely include when newer updates are available strip_updated(){ # local UPDATED_PKGS=(colord-gtk lvm2 python3-usb) echo "Stripping..." # NOTE: assume you follow "$PKG-update" scheme in branch names (and "$PKG" is indeed latest) git branch | grep "update" | sed 's/-update//g' | awk '{ print $1 }' > branches.txt shopt -s nullglob for file in updates_*.txt do # skip no ver if [[ "${file}" == "${LOG_FILE}" ]] ; then true else # strip updated packages in branches with mixed commits grep -vE "colord-gtk|lvm2|python3-usb" "${file}" | sponge "${file}" # strip updated branch awk 'NR==FNR{branches[$1]; next} {for (b in branches) if ($1 ~ b) next} {print}' branches.txt "${file}" | sponge "${file}" fi done rm branches.txt } cd "$XBPS_DISTDIR" || exit 1 # list only manually installed packages xpkg -m > installed.txt # query all installed packages (including core packages, more complete, but MUCH slower) # xbps-query -l | awk '{ print $2 }' | xargs -n1 xbps-uhelper getpkgname > installed.txt # functions here outdated_who "orphan@voidlinux.org" "orphan" outdated_mypkg outdated_error strip_updated # garbage clean rm installed.txt