Intro
This is a short post about how to conveniently manage packages from the Arch User Repository (AUR). Check out previous posts if you want to install Arch Linux from scratch or if you want to have some tips on configuring Arch Linux on a notebook.
I use aurutils to handle the AUR. It provides some nice wrapper scripts around the AUR and works from a local pacman repository to which all AUR packages are added. Those packages can then be managed by pacman like any other package from a repo.
Setting up aurutils and the local pacman repo
First lets add the key for aurutils’ author and then clone and build it manually. I do this, because to start a new local repo we need a package and we need aurutils as well, so that is the perfect first package.
$ gpg --recv-keys DBE7D3DD8C81D58D0A13D0E76BC26A17B9B7018A $ git clone https://aur.archlinux.org/aurutils.git $ cd aurutils $ makepkg -s $ mkdir /path/to/repo $ mv aurutils-xxx.pkg.tar.xz /path/to/repo
The folder were we built aurutils can now be deleted, it is no longer needed. Now edit the pacman.conf file and add the new local repository.
# /etc/pacman.conf
CacheDir = /path/to/repo/
...
[aur]
SigLevel = Optional TrustAll
Server = file:///path/to/repo
$ cd /path/to/repo $ repo-add aur.db.tar.bz2 aurutils-xxx.pkg.tar.xz $ sudo pacman -Syu $ sudo pacman -S aurutils
aurutils usage
With this we are done setting up the new repo. Now we can add, remove and upgrade the packages in it with aurutils. Add and install a new package from the AUR to the repo:
$ aur sync package_name
Update all packages in the repo:
$ aur sync -u
Remove a package from the repo:
$ aur remove package_name
Periodic cleaning of pacman and aurutils caches
Packages are stored in the repo folder. It acts as a pacman cache. To clean it automatically we can use paccache from pacman-contrib.
$ sudo pacman -S pacman-contrib # systemctl enable paccache.timer
As default this will clean the pacman cache once a week and will leave the three most recent package version of each package in the cache.
More detailed information on the local pacman repository and paccache can be found on the pacman Arch Wiki page.
aurutils keeps a separate cache with all the sources and downloads in ~/.cache/aurutils/sync. There is a folder with a git repository for each package inside. This means we can use git clean to clear this cache of all the downloads and big files but keep the repository with the PKGBUILDs. One possibility to do this is the following command posted by the aurutils author at https://github.com/AladW/aurutils/issues/317
find ~/.cache/aurutils/sync -name .git -execdir git clean -xf \;
It is possible to run this command in an automated interval with cron. I use the cronie package (don’t forget to start and enable the cronie.service after installing) and a 0 20 * * 1 (execute at 8pm each Monday) interval for this. A short introduction to cron can be found here.
Hello in a different post,
installing the aurutils was relaxing. Smooth and easy. No specials 🙂 Great description!
Just one annotation: the # in the gpg command line indicates that it should run as root. Which would be not so good.
Cheers
I’m really impressed with your writing skills and also with the layout on your blog.
Is this a paid theme or did you modify it yourself?
Either way keep up the nice quality writing, it is rare to see a great blog
like this one these days.
Hi, thank you for the praise 🙂
The theme is the free version of Saaya theme.
Cheers.