Caching Arch packages with pacoloco

Abstract. I have been using lately Arch Linux on both my workstation and my laptop. The laptop has only been used occasionally, so every time I picked it from the shelf there were gigabytes of packages to be updated. Since I have unacceptably low internet bandwidth at home (welcome to Germany, the digital desert), I decided to implement some kind of package cache on my workstation. Luckily, there is an easy solution: pacoloco - a caching proxy server for pacman.

Server configuration

Deploying pacoloco on an Arch Linux machine is a piece of cake!

$ pacman -S pacoloco

The repository contains an example of the config. I decided to put both the configs and the cache to /srv/pacoloco, so here we go.

$ mkdir -p /srv/pacoloco/cache
$ mv /etc/pacoloco.yaml /srv/pacoloco

My main workstation will peform as a pacoloco server and its client at the same time, so let’s move the list of mirrors I use to download Arch packages, and substitute it with pacoloco.

$ cat /srv/pacoloco/pacoloco.yaml
$ mv /etc/pacman.d/mirrorlist /srv/pacoloco
$ echo "Server = http://localhost:9129/repo/archlinux/$repo/os/$arch" > /etc/pacman.d/mirrorlist

Mind the corresponding changes in the config file (one can also see I removed the prefetch feature).

cache_dir: /srv/pacoloco/cache
port: 9129
download_timeout: 3600
purge_files_after: 2592000
    mirrorlist: /srv/pacoloco/mirrorlist

Since the config file’s location differs from its default, it must be explicitly specified in the systemd unit file.

$ cat /usr/lib/systemd/system/pacoloco.service 
Description=Pacoloco caching proxy server

ExecStart=/usr/bin/pacoloco -config /srv/pacoloco/pacoloco.yaml


Since this host also acts as pacoloco client, /etc/pacman.conf should be modified as well (see the next section).

Client configuration

The following line should be inserted at the beginning of /etc/pacman.d/mirrorlist on the client machine (mind to substitute the host addres!).

Server = http://yourpacoloco:9129/repo/archlinux/$repo/os/$arch

Finally, /etc/pacman.conf should be supplemented with the following section.

Server = http://yourpacoloco:9129/repo/quarry

Removing redundant package cache

With pacoloco the standard pacman cache (at least on the pacoloco host) becomes redundant. At the moment of writing my /var/cache/pacman was over 30G.

I didn’t find an easy solution to permanently disable native pacman’s caching. However here is paccache utility from pacman-contrib to rescue. It comes already with paccache.service and paccache.timer included.

I only replaced the default paccache -r to more a aggressive paccache -ruk0 in the corresponding systemd service file and enabled the corresponding timer.

systemctl enable --now paccache.timer