You are not logged in.
I have a very childish script but that is helpful to me.
I know and used some AUR helper but I found they have many stuffs that I never use.
So I wrote my child play script.
#!/bin/dash
case $1 in
update)
for i in $(pacman -Qm | awk '{print $1}'); do
iv=$(pacman -Q $i | awk '{print $2}')
cv=$(lynx -dump https://aur.archlinux.org/packages/$i | awk '/Package Details: / {print $4}')
if [ $iv = $cv ]; then
echo "$i ----------> UP To Date"
else
cdp=~/.mydir/scripts/myaurB
[ -d $cdp ] && cd $cdp
[ ! -d $cdp ] && mkdir $cdp && cd $cdp
[ -d $i ] && rm -rf ./$i >> /dev/null 2>&1
[ -e $i ] && rm -f ./$i.tar.gz >> /dev/null 2>&1
wget https://aur.archlinux.org/cgit/aur.git/snapshot/$i.tar.gz
tar -xzf ./$i.tar.gz
cd ./$i
makepkg -isc
cd
fi
done
;;
install)
cdp=~/.mydir/scripts/myaurB
[ -d $cdp ] && cd $cdp
[ ! -d $cdp ] && mkdir $cdp && cd $cdp
[ -d $2 ] && rm -rf ./$2 >> /dev/null 2>&1
[ -e $2 ] && rm -f ./$2.tar.gz >> /dev/null 2>&1
wget https://aur.archlinux.org/cgit/aur.git/snapshot/$2.tar.gz
tar -xzf ./$2.tar.gz
cd ./$2
makepkg -isc
cd
;;
*)
echo " Do update or install <package-name> after this command."
echo " Eg. $ mshaur update"
echo " Eg. $ mshaur install pikaur"
;;
esac
In this script, using lynx to check the AUR package version on AUR website takes a bit time. If internet connection is slow and for 20-30 AUR packages, it takes more time.
cv=$(lynx -dump https://aur.archlinux.org/packages/$i | awk '/Package Details: / {print $4}')
So, is there any way faster and quicker to check my AUR packages' version on it AUR website page?
Thanks in advance.
Last edited by duyinthee (2022-12-04 10:25:36)
Offline
Perhaps look at the code of another AUR helper and see how they do it.
Offline
Alad’s aurutils may be what you’re asking about. It’s designed in a way, that makes it suitable to be included in user’s own AUR workflow.
If writing your tools, do not download and parse pages. You’re causing unnecessary load on the service. There is an RPC interface for scripts.
Last edited by mpan (2022-12-04 03:14:02)
Sometimes I seem a bit harsh — don’t get offended too easily!
Offline
Here's an excerpt of my own AUR script that checks for updates to currently installed packages. You should use the RPC interface, and you should not loop through packages, just use one call to get the info for all relevant packages:
#!/bin/sh
url='https://aur.archlinux.org/rpc?v=5&'
newer_fmt='\033[34m:: \033[0;1m%s \033[0;31m%s\033[0m -> \033[32m%s\033[0m\n'
older_fmt='\033[34m:: \033[0;1m%s \033[0m%s != %s\n'
pacman -Qm | sort >| /tmp/local.pkgs
curl -s "${url}type=info$(printf '&arg[]=%s' $(cut -f 1 /tmp/local.pkgs))" \
| jq -r '.results[]|.Name+" "+.Version' \
| sort | join /tmp/local.pkgs - \
| while read pkg a b; do
case "$(vercmp $a $b)" in
-1) printf "$newer_fmt" "$pkg" "$a" "$b" ;;
1) printf "$older_fmt" "$pkg" "$a" "$b" ;;
esac
done
Note that most of this code is for comparing the available version to the currently installed and formatting for a colorized output. If you really just want the available versions of all your aur packages, the following would suffice:
#!/bin/sh
url='https://aur.archlinux.org/rpc?v=5&'
curl -s "${url}type=info$(printf '&arg[]=%s' $(pacman -Qmq))" \
| jq -r '.results[]|.Name+" "+.Version'
Last edited by Trilby (2022-12-04 03:31:28)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thank you all for replies and advice.
Yes, AUR RPC interface that is what I need.
And thanks Trilby for an excerpt of your own code. I have learnt a lot from it.
Offline