List all installed packages of specific repo in arch

3.3k Views Asked by At

Say I have the repo foo listed in my pacman.conf configuration file:

[foo]
Include = /etc/pacman.d/mirrolist-custom

I want to simply list of installed packages of my system from foo repo.

1

There are 1 best solutions below

2
On

You can list your installed packages, list the repo packages and compare. The output will be your installed packages from repo.

pacman -Qq | sort > tmp_installed.txt
pacman -Slq foo | sort > tmp_foo.txt
comm -12 tmp_installed.txt tmp_foo.txt

If you want to do it repetitively make a script. Here an example of a script called list_repo.sh

#!/bin/bash
# List installed packages from repo
if [ "$#" -lt "1" ] || [ "$#" -gt "2" ]; then
    echo "Invalid number of arguments"
    echo "Usage: $0 <repo>"
    exit
fi

pacman -Qq | sort > tmp_installed.txt
pacman -Slq $1 | sort > tmp_repo.txt

comm -12 tmp_installed.txt tmp_repo.txt
rm tmp_installed.txt
rm tmp_repo.txt

Run it as:

./list_repo.sh foo