summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiao Pan <gky44px1999@gmail.com>2024-02-24 15:58:07 -0800
committerXiao Pan <gky44px1999@gmail.com>2024-02-24 15:58:07 -0800
commit8fbd84e327bc5257f848207ab15c5486d308feca (patch)
tree3ae920701dd86986e825fa421e3ef12979d3a1be
parentff32d2e8a3ddfd4cbc2376cdd6cff1314be17ae2 (diff)
query checkrebuild log by query pacman hook output
/usr/share/libalpm/hooks/rebuild-detector.hook has a line `NeedsTargets` shows it maybe checkrebuild by `printf 'zoom\nminiconda3' | checkrebuild` instead of check all by `checkrebuild`, so I think query pacman hook will be faster than run another `checkrebuild`
-rwxr-xr-xsh/upd18
1 files changed, 15 insertions, 3 deletions
diff --git a/sh/upd b/sh/upd
index f80d761..ce1adfa 100755
--- a/sh/upd
+++ b/sh/upd
@@ -141,10 +141,22 @@ misc () {
}
pac () {
- pacpacs="$(sudo pacman --noconfirm -Syu | tee /dev/tty | grep -m1 '^Packages' | cut -d' ' -f3-)"
+ pac="$(sudo pacman --noconfirm -Syu | tee /dev/tty)"
+ pacpacs="$(echo "$pac" | grep -m1 '^Packages' | cut -d' ' -f3- | tee /dev/tty)"
# Update rust toolchains before paru so paru can compile things in newest rust if needed.
rustup update
- aurpacs="$(paru --color never --noconfirm -aSu --ignore libredwg-git | tee /dev/tty | grep '^Aur' | cut -d' ' -f3-)"
+ aur="$(paru --color never --noconfirm -aSu --ignore libredwg-git)"
+ aurpacs="$(echo "$aur" | grep '^Aur' | cut -d' ' -f3-)"
+ # /usr/share/libalpm/hooks/rebuild-detector.hook has a line `NeedsTargets` shows it maybe checkrebuild by `printf 'zoom\nminiconda3' | checkrebuild` instead of check all, so I think query pacman hook will be faster than run another `checkrebuild`
+ # notes about awk f=1 things see https://git.flylightning.xyz/public_archive_codes/tree/sh/mrt
+ checkrebuild_pacs="$(echo "$pac$aur" | nawk '
+ /^\([0-9]+\/[0-9]+\) Checking which packages need to be rebuilt$/ {f=1; next}
+ # check ^:: to consider rebuild-detector.hook is the last hook to run, and $aur start with ^::
+ /^\([0-9]+\/[0-9]+\) |^:: / {f=0}
+ f {
+ if($2!~"zoom|miniconda3")
+ printf("%s ",$2)
+ }')"
# part steal from aur comment
# sometimes "ERROR: Failure while downloading": https://github.com/neovim/neovim/issues/15709
# echo 1, printf 1 and yes 1 all works? not sure why
@@ -167,7 +179,7 @@ pac () {
updated pacman packages: $pacpacs
updated aur packages: $aurpacs
pacdiff: $(pacdiff -o | tr '\n' ' ')
-checkrebuild: $(checkrebuild | awk '$2!~"zoom|miniconda3"{printf("%s ",$2)}')
+checkrebuild: $checkrebuild_pacs
$(if echo "$pacpacs" | grep -q 'linux-\(megi-\)\?[0-9]'; then echo 'kernel upgraded, need reboot'; fi)
"
}