void-orphan-pkg.sh
· 1.4 KiB · Bash
Исходник
#!/bin/bash
# List of available updates for unmaintained void packages installed locally
DISTURL="https://repo-default.voidlinux.org/void-updates/void-updates/updates_orphan%40voidlinux.org.txt"
DISTFILE="updates_orphan.txt"
wget --hsts-file="$XDG_CACHE_HOME/wget-hsts" --output-document ${DISTFILE} --quiet ${DISTURL}
# filter out uninterested packages
# opinionated, `lib` could be a bit overkill
grep -vE 'apache-|avr-|cargo-|cinnamon|gnome-|gst-|jenkins|lib|linux|live555|nemo-|pantheon-|perl-|python3-grpcio|python3-google|ruby-|R-cran-' ${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 (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
awk 'NR==FNR{installed[$1]; next} $1 in installed' installed.txt ${DISTFILE} | sort | sponge ${DISTFILE}
rm installed.txt
# TODO: filter out existing update branches
# git branch --list |awk '{print $1}' > branches.txt
# awk 'NR==FNR{branches[$1]; next} {for (b in branches) if ($1 ~ b) next} {print}' branches.txt ${DISTFILE}
1 | #!/bin/bash |
2 | # List of available updates for unmaintained void packages installed locally |
3 | |
4 | DISTURL="https://repo-default.voidlinux.org/void-updates/void-updates/updates_orphan%40voidlinux.org.txt" |
5 | DISTFILE="updates_orphan.txt" |
6 | |
7 | wget --hsts-file="$XDG_CACHE_HOME/wget-hsts" --output-document ${DISTFILE} --quiet ${DISTURL} |
8 | |
9 | # filter out uninterested packages |
10 | # opinionated, `lib` could be a bit overkill |
11 | grep -vE 'apache-|avr-|cargo-|cinnamon|gnome-|gst-|jenkins|lib|linux|live555|nemo-|pantheon-|perl-|python3-grpcio|python3-google|ruby-|R-cran-' ${DISTFILE} | sponge ${DISTFILE} |
12 | |
13 | # dedup, leave only the highest available version |
14 | # side effect: order is slightly different |
15 | awk '!seen[$1]++ {line[$1] = $0} {line[$1] = $0} END {for (pkg in line) print line[pkg]}' ${DISTFILE} | sort | sponge ${DISTFILE} |
16 | |
17 | # dedup again, leave only (manually) installed packages |
18 | xpkg -m > installed.txt |
19 | # query all installed packages (including core packages, more complete, but MUCH slower) |
20 | # xbps-query -l | awk '{ print $2 }' | xargs -n1 xbps-uhelper getpkgname > installed.txt |
21 | awk 'NR==FNR{installed[$1]; next} $1 in installed' installed.txt ${DISTFILE} | sort | sponge ${DISTFILE} |
22 | rm installed.txt |
23 | |
24 | # TODO: filter out existing update branches |
25 | # git branch --list |awk '{print $1}' > branches.txt |
26 | # awk 'NR==FNR{branches[$1]; next} {for (b in branches) if ($1 ~ b) next} {print}' branches.txt ${DISTFILE} |
27 |