xoutdated
· 2.6 KiB · Text
原始檔案
#!/bin/bash
# List of available updates for unmaintained void packages installed locally
outdated_orphan(){
local DISTURL="https://repo-default.voidlinux.org/void-updates/void-updates/updates_orphan%40voidlinux.org.txt"
local 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 installed packages
awk 'NR==FNR{installed[$1]; next} $1 in installed' installed.txt ${DISTFILE} | sort | sponge ${DISTFILE}
# 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}
}
# 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"
wget --hsts-file="$XDG_CACHE_HOME/wget-hsts" --output-document ${MYFILE} --quiet "${MYURL}"
}
# List packages that have error checking updates
outdated_error(){
local LOG_URL="https://repo-default.voidlinux.org/void-updates/void-updates/_log.txt"
local LOG_FILE="updates_nover.txt"
wget --hsts-file="$XDG_CACHE_HOME/wget-hsts" --output-document ${LOG_FILE} --quiet ${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}
}
# 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_orphan
outdated_mypkg
outdated_error
# garbage clean
rm installed.txt
1 | #!/bin/bash |
2 | |
3 | # List of available updates for unmaintained void packages installed locally |
4 | outdated_orphan(){ |
5 | local DISTURL="https://repo-default.voidlinux.org/void-updates/void-updates/updates_orphan%40voidlinux.org.txt" |
6 | local DISTFILE="updates_orphan.txt" |
7 | |
8 | wget --hsts-file="$XDG_CACHE_HOME/wget-hsts" --output-document ${DISTFILE} --quiet ${DISTURL} |
9 | |
10 | # filter out uninterested packages |
11 | # opinionated, `lib` could be a bit overkill |
12 | 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} |
13 | |
14 | # dedup, leave only the highest available version |
15 | # side effect: order is slightly different |
16 | awk '!seen[$1]++ {line[$1] = $0} {line[$1] = $0} END {for (pkg in line) print line[pkg]}' ${DISTFILE} | sort | sponge ${DISTFILE} |
17 | |
18 | # dedup again, leave only installed packages |
19 | awk 'NR==FNR{installed[$1]; next} $1 in installed' installed.txt ${DISTFILE} | sort | sponge ${DISTFILE} |
20 | |
21 | # TODO: filter out existing update branches |
22 | # git branch --list |awk '{print $1}' > branches.txt |
23 | # awk 'NR==FNR{branches[$1]; next} {for (b in branches) if ($1 ~ b) next} {print}' branches.txt ${DISTFILE} |
24 | } |
25 | |
26 | # List my outdated packages w/o xcheckmypkgs |
27 | # only work in local void-packages copy if XBPS_DISTDIR is not set |
28 | outdated_mypkg(){ |
29 | local MYURL |
30 | XDISTDIR="$(xdistdir)" || exit 1 |
31 | MYURL="https://repo-default.voidlinux.org/void-updates/void-updates/updates_$(git -C "${XDISTDIR}" config user.email | sed 's/@/%40/').txt" |
32 | local MYFILE="updates_me.txt" |
33 | |
34 | wget --hsts-file="$XDG_CACHE_HOME/wget-hsts" --output-document ${MYFILE} --quiet "${MYURL}" |
35 | } |
36 | |
37 | # List packages that have error checking updates |
38 | outdated_error(){ |
39 | local LOG_URL="https://repo-default.voidlinux.org/void-updates/void-updates/_log.txt" |
40 | local LOG_FILE="updates_nover.txt" |
41 | |
42 | wget --hsts-file="$XDG_CACHE_HOME/wget-hsts" --output-document ${LOG_FILE} --quiet ${LOG_URL} |
43 | |
44 | # leave only (manually) installed packages |
45 | grep -v 'No such file' < ${LOG_FILE} | awk 'BEGIN { |
46 | while ((getline < "installed.txt") > 0) { |
47 | installed[$1] |
48 | } |
49 | } |
50 | { |
51 | package = $5; |
52 | if (package in installed) print $0 |
53 | }' | sponge ${LOG_FILE} |
54 | } |
55 | |
56 | # list only manually installed packages |
57 | xpkg -m > installed.txt |
58 | # query all installed packages (including core packages, more complete, but MUCH slower) |
59 | # xbps-query -l | awk '{ print $2 }' | xargs -n1 xbps-uhelper getpkgname > installed.txt |
60 | |
61 | # functions here |
62 | outdated_orphan |
63 | outdated_mypkg |
64 | outdated_error |
65 | |
66 | # garbage clean |
67 | rm installed.txt |
68 |