RSS Feed

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,

#!/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

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.

About Allen Choong

A cognitive science student, a programmer, a philosopher, a Catholic.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: