List installed AUR packages but removed or renamed in AUR
Recently I found that, even the packages in the AUR are renamed, the AUR helper such as yaourt also cannot solve. When I prepared to ask for some solution in the Arch Linux BBS, I just think that it is possible to solve it myself. Finally, I come out with the following script,
[code language=“bash”] #!/bin/bash # # @author Allen Choong # @date 2014-09-04 # @version 0.0.1 # # This script is to identify the installed AUR packages, to check whether they are still # available in the AUR. This is because some packages are renamed or removed.
#Get the packages packages=(`pacman -Qmq | sort`)
#For each of the package, check with the AUR packagesStr=’’ for x in ${packages[@]} ; do packagesStr+="’$x’ " done
packagesOnAur=(`/bin/sh -c “package-query -A -f ‘%n’ $packagesStr | sort”`)
#As the rule of thumb, the installed packages are more than packages checked in the AUR for((i=0;i<${#packagesOnAur[@]};i++)) ; do j=0 while [[ $j -lt ${#packages[@]} ]] ; do if [[ ${packagesOnAur[$i]} == ${packages[$j]} ]] ; then unset packages[$j] packages=("${packages[@]}") break fi ((j++)) done done
for x in ${packages[@]} ; do echo $x done [/code]
The script requires package-query. It will list out all the installed packages which are not found in the AUR. This includes the packages we installed ourselves locally, or deleted or renamed packages in the AUR.