Skip to content

Pacman package mananger

Managing pacman packages in Arch Linux and derivatives (Manjaro, endeavourOS).

Generating a list of packages

List non-AUR, explicitly installed packages:

pacman -Qnqe > pkgs.txt

List AUR packages:

pacman -Qqem > aurpkgs.txt

List all explicitly installed packages:

pacman -Qqe > allpkgs.txt

Install packages from a list

pacman -Syu  # Full upgrade the system first
pacman -S --needed - < pkgs.txt

Arch User Repository (AUR)

The Arch User Repository (AUR) hosts community-contributed PKGBUILDs, instructions to download and build a packages.

While you could clone the PKGBUILD files and run makepkg -si manually, AUR helpers automate these process, giving a similar experience for installing regular packages in pacman.

pikaur

pikaur reviews PKGBUILDs all in once and asks all questions before installing/building, using systemd dynamic users to spawn build processes.

You can install pikaur by another AUR helper, for example:

yay -S pikaur

Afterwards, you can install AUR packages as if installing regular ones

sudo pikaur -S google-chrome

To update all packages

sudo pikaur -Syu

paru

paru is an AUR helper written in Rust.

yay -S paru-bin # If you don't want to compile the Rust code
# yay -S paru   # Compile paru from source

Afterward, you can install AUR packages as if installing regular ones

paru -S google-chrome

To update all packages

paru

yay

yay is an AUR helper written in Go and is directly available in Manjaro/EnOS.

You can install AUR packages as if installing regular ones

yay -S google-chrome

To update all packages, just type

yay

Default options for yay could be saved using yay --save <options>, for example:

yay --answerclean All --answerdiff None --answerupgrade None --cleanafter --batchinstall --combinedupgrade --sudoloop --save

Explanation:
- --cleanafter: clean untracked files after build.
- --combinedupgrade: resolve dependency and then install both the repo and the AUR packages in one go.
- --sudoloop: Loop sudo calls in the background to prevent sudo from timing out during long builds.
- --batchinstall: Build all AUR packages and install them at once.

Compilation options for AUR packages

To customize compilation options, a good starting point is to copy from the system-wide config file:

cp /etc/makepkg.conf ~/.makepkg.conf

to you own ~/.makepkg.conf makepkg@ArchWiki. However, PKGBUILD settings in the packages still have higher priorities and can override your settings.

CPU target for building optimized binaries

.makepkg.conf
CFLAGS="-march=native -O2 -pipe -fstack-protector-strong -fno-plt"
CXXFLAGS="${CFLAGS}"
RUSTFLAGS="-C opt-level=2 -C target-cpu=native"

Parallel compilation

.makepkg.conf
MAKEFLAGS="-j$(nproc)"

Compressing packages

.makepkg.conf
# multiple cores on compression of xz archives
COMPRESSXZ=(xz -c -z - --threads=0)

# multiple cores on compression of zstd archives
COMPRESSZST=(zstd -c -z -q - --threads=0)

# multiple cores on compression of gz archives (requires pigz package)
COMPRESSGZ=(pigz -c -f -n)

And you can choose the preferred method for package compression. For example,

.makepkg.conf
PKGEXT='.pkg.tar.zst'

Or turn off compression completely (fastest)

.makepkg.conf
PKGEXT='.pkg.tar'

Comments