#!/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'
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.
]]>#!/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.