Pacman configuration

From wikinotes

Documentation

man pacman.conf https://man.archlinux.org/man/core/pacman/pacman.conf.5.en
man makepkg.conf https://man.archlinux.org/man/makepkg.conf.5.en
man alpm-hooks https://man.archlinux.org/man/core/pacman/alpm-hooks.5.en

Tutorials

alpm-hook examples https://github.com/andrewgregory/pachooks/tree/master/hooks

Locations

/etc/pacman.conf pacman config
/etc/pacman.d/mirrorlist package sources
/etc/makepkg.conf
~/.makepkg.conf
$XDG_CONFIG_HOME/makepkg.conf
configure default build options
/etc/pacman.d/hooks/*.hook alpm-hooks (trigger on package/file changes during update)

mirrorlist

You can automatically determine the fastest servers and sort them by quickest.
I wrote a bashscript pacman-mirrorlist to do this for me.

sudo pacman -S pacman-contrib

# generate mirrorlist for all CA/US mirrors
awk '/^## Canada$/{f=1; next}f==0{next}/^$/{exit}{print substr($0, 1);}' /etc/pacman.d/mirrorlist.pacnew | sed 's/^#//' | sudo tee /etc/pacman.d/mirrorlist.tmp
awk '/^## United States$/{f=1; next}f==0{next}/^$/{exit}{print substr($0, 1);}' /etc/pacman.d/mirrorlist.pacnew | sed 's/^#//' | sudo tee -a /etc/pacman.d/mirrorlist.tmp

rankmirrors -n 10 /etc/pacman.d/mirrorlist.tmp | sudo tee /etc/pacman.d/mirrorlist

pacman.conf

Holding/Pinning/Locking Packages

Packages can be set to be ignored in /etc/pacman.conf.

IgnorePkg = salt zfs-linux spl-linux


makepkg.conf

Customize global package build options.

update hooks

You can use alpm-hooks to run scripts when matching packages or files are changed.

# /etc/pacman.d/hooks/reset-kbd-settings.hook

# whenever a package matching 'linux*' is changed
# the executable /usr/bin/kbd is executed

[Trigger]
Type = Package
Operation = Install
Operation = Upgrade
Operation = Remove
Target = linux*

[Action]
When PostTransaction
Exec = test -e /usr/bin/kbd && /usr/bin/kbd
AbortOnFail