Comparing Arch Packages Between Installations

Pacman database query option

Today I'm looking to generate meaningful package lists, for the day when I have to resurrect one of my Arch machines, or setup a new one. And to compare packages between my Arch machines.

man pacman tells us that -Q without a query string will list all installed packages.

Additional options to -Q for generating package lists and querying the package database.

option
-d packages installed as dependencies, with -t to
  list orphans, where the parent has been removed
-e explicitly installed, -t for packages not required
  by an others
-g packages which belong to groups, if no query str
  lists all groups
-i info on query str
-k check all files owned by pkg are present on system
-l list all files owned by pkg
-m foreign - downloaded manually and isntalled with -u
-n native - opposite of -f

Examples

``` bash # How many packages are installed? pacman -Q | wc -l

# list dependencies that have since become orphaned
pacman -Qdt

# List all packages in xfce4 group
pacman -Qg xfce4

# Tell me about python package
pacman -Qi python

# How many files belong to, missing from, emacs
pacman -Qk emacs

# Show me all the files owned by stow
pacman -Ql stow

# List all foreign packages
pacman -Qm

# List all explicitly installed packages
pacman -Qe

# List all explicitly installed foreign packages (e.g. AUR)
pacman -Qem

```

Comparing packages on differnet installations

From there, I write the output of pacman -Qe to a file on my local and remote machine, then diff the file with the standard diff util with some convenient options.

bash diff -y --suppress-common-lines package_list_desktop.txt package_list_laptop.txt

bash minidlna 1.1.4-3 < mousepad 0.3.0-3 < nodejs 0.10.33-5 | nodejs 0.10.33-6 ntfs-3g 2014.2.15-1 < nvidia 343.22-4 < orage 4.10.0-1 < os-prober 1.64-1 < p7zip 9.20.1-9 <

The list is rather long in its entirety, 90 lines, mostly because of some minor bloatware on my desktop. it was my first Arch box and I wasn't savvy enough to install only the required packages for groups such as xfce4 and texlive. Also, it's picking up on version differences, it'd be convenient to omit non alpha characters, but I'll leave that for another day - if you have some suggestion for this, please chime in comments, twitter, or the contact page.

Go Top
comments powered by Disqus