I currently use aurutils AUR helper in Arch Linux to install any package from Arch User Repository (AUR). Previously I have used yay and various other AUR helpers that existed before yay, such as yaourt and pacaur, to name a few.

However, I felt a need to use aurutils because of the custom local repository where it can store in the database. I can generate multiple repositories for different tasks and install the packages easily from other computers using the same repository I have created.

Using the custom local repository provides the advantage of file support from pacman itself and all packages to work with -asdeps, rather than foreign (using pacman -U) packages installed by the other AUR helpers. In addition, it has the advantage of ignoring packages too.

Install aurutils

There are two packages available inside AUR; pick either one to install:

Next, choose an appropriate build directory. For this example, I pick up aurutils using the AUR package installation procedure inside a directory called builds.

$ cd ~/builds
$ git clone https://aur.archlinux.org/aurutils.git
$ cd aurutils
$ makepkg -si

Apart from the step above, one can search and download PKGBUILD from the AUR Web Interface. It can be built into an installable package using makepkg, then installed tarball using sudo pacman -U ~/builds/aurutils/aurutils-[release-version].tar.gz.

Creating Custom Local Repository

Now I can set up an unofficial Arch Linux package repository, in this case, for aurutils. I need to create a separate pacman configuration file for the custom local repository in /etc/pacman.d/

$ sudo vim /etc/pacman.d/aur

Add these lines to the file /etc/pacman.d/aur

[options]
CacheDir = /var/cache/pacman/pkg
CacheDir = /var/cache/pacman/aur
CleanMethod = KeepCurrent

[aur]
SigLevel = Optional TrustAll
Server = file:///var/cache/pacman/aur

Add the following lines for the custom local repository configuration at the end of /etc/pacman.conf

Include = /etc/pacman.d/aur

Create the repository root in /var/cache/pacman

sudo install -d /var/cache/pacman/aur -o $USER

Use the repo-add script included with pacman to generate a database for custom local repository. Use repo-add --help for more details on its usage. A package database is a tar file, optionally compressed. Valid extensions are .db or .files followed by an archive extension of .tar, .tar.gz, .tar.bz2, .tar.xz, .tar.zst, or .tar.Z. The file does not need to exist, but all parent directories must exist.

Create the database in /var/cache/pacman/aur

repo-add /var/cache/pacman/aur/aur.db.tar.gz

If built packages are available, add them to the database; move all the *.pkg.tar* files to /var/cache/pacman/aur/, and proceed:

$ cd /var/cache/pacman/aur
$ repo-add -n aur.db.tar.gz *.pkg.tar*

The database and the packages do not need to be in the same directory when using repo-add, but keep in mind that they should be together when using pacman with that database.

One-liner alternative command from the method above:

$ repo-add -n /var/cache/pacman/aur/aur.db.tar.gz /var/cache/pacman/aur/*.pkg.tar*

Then synchronize pacman:

$ sudo pacman -Syu

Install Packages

I have finished setting up the database and custom local repository for aurutils. It’s time for me to install packages from AUR using aurutils.

Let’s say I want to install repoctl ― I can use aur-sync download and build AUR package automatically to a custom local repository. Then, use pacman to install the package.

$ aur sync repoctl
$ sudo pacman -S repoctl

Update All AUR Packages

Update all AUR packages with aur-sync

$ aur sync -u

Build Packages in a systemd-nspawn Container

Build imgurs and its dependencies with systemd-nspawn:

$ aur sync -c imgurs

Ignore Packages

There are two ways to achieve this:

  • Ignore by package

Ignore a package upgrade. Multiple packages can be specified by separating them with a comma, or by repeating the –ignore option.

$ aur sync --ignore=package-foo,package-bar 
  • Ignore by file

Ignore package upgrades listed in FILE. Each package name should be specified on a separate line. If a section (enclosed in square brackets) is specified, package names only apply to the local repository matching this section. Comments can be specified after a number sign.

Create a textfile in ~/.config/aurutils/ignore.conf.

$ vim ~/.config/aurutils/ignore.conf

Add the respective package names. For example:

[aur]
package-foo
package-bar

Run aur-sync with the correct path to ignore packages on a file:

$ aur sync --ignore-file=~/.config/aurutils/ignore.conf

Update Database on Removal Packages From Custom Local Repository

There are two ways to achieve this. One can use repo-remove or repoctl command.

  • repo-remove

This does not remove dependencies that came with it; you have to manually keep track of all the unused dependencies and run repo-remove for all of them.

$ repo-remove /var/cache/pacman/aur.db.tar.gz PKGNAME
  • repoctl

This is more effective at removing stale or unneeded packages. To use repoctl, I have to install it from the AUR. It makes a good combination with aurutils and custom local repository. Check the manpages.

Remove single package:

$ repoctl remove PKGNAME

Update database by adding packages and dispatching obsolete files.

$ repoctl update

Remove Packages

It is easy to remove packages, just like the other using sudo pacman -R PKGNAME, but this does not necessarily remove package tarballs inside the custom local repository directory.

To remove this, you can use pacman -Sc.

Note that when you set your repository as a pacman CacheDir, you can use KeepInstalled and simply run sudo pacman -Sc. Then, repoctl update to remove stale entries from the database.

I use paccache instead of pacman -Sc. You need to install pacman-contrib to use this. I just learned that paccache does not respect KeepInstalled.

The correct approach to cleanup cache of uninstalled packages is:

# paccache -r
# paccache -ruk0

repoctl update not only removes packages from the database but also deletes cached files (exactly like pacman -Sc).

Cleaning up cache inside ~/.cache/aurutils can be done with:

$ find ~/.cache/aurutils/sync -name .git -execdir git clean -xf \;

More Info

For more information, you can check:

$ man aur