You are not logged in.

#1 2026-07-03 21:18:20

lmn
Member
Registered: 2021-05-09
Posts: 91
Website

pacman in the middle: a prefetching server for pacman

I have created a simple caching server using the regular pacman infrastructure.

I don't have the fastest internet and like to preload my updates during the night.
This limits the update time to my local network speed.

As most packages are shared between my machines this also is reduces the load on the mirrors. This is a nice side benefit and not a motivating reason.

I do have a rapsberry pi set up as a server though but as the architecture is different you can't use it directly.

You could try to string together some curl/wget script to download the packages from the mirror.
At ths point you would reinvent the dependency resolution in pacman. So it is only natural to use pacman in the first place.

The idea is to use a custom pacman.conf with a distinct package cache (and key store) to download all the packages.
It depends on pacman and coreutils to function. So it can be run on on every linux distribution with pacman installed.

You still need to install a web server (eg. nginx or apache) to serve the files over the network.

Then you need to configure your server with the CacheServer directive in your local mirrorlist. This setting does a lot of heavy lifting.
When the cache does not contain the package the regular mirrors are requested instead. This makes this setup fail safely.

You can create the package lists with

pacman -Qq

and store the result on the server under /etc/pitm/NAME.paclist

All *.paclist files are read into pacman and then downloaded to /var/cache/pitm/pkg .
I like to include all packages in the paclist files as this resolves the case when a packages asks you to choose a dependency.

The source code can be found in git via

git clone git://git.lemen.xyz/pacman_in_the_middle.git

and more info can be found at https://lemen.xyz/software/pacman_in_the_middle/ and in the README.

The utils directory contains a PKGBUILD to install it on pacman based distributions such as Arch Linux ARM.
Otherwise an install script called pitm_init is provided. This script needs to be run as root.

Also included are systemd service files for running the updater automatically.

Sometimes the download will fail eg. when a package is removed from the repositories.
In this case manual intervention is required. You can run the updater in manual mode with

pitm_download -m

Edit: changed title from "caching" to "prefetching"

Last edited by lmn (2026-07-03 22:56:37)

Offline

#2 2026-07-03 21:55:50

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,545

Offline

#3 2026-07-03 22:24:28

lmn
Member
Registered: 2021-05-09
Posts: 91
Website

Re: pacman in the middle: a prefetching server for pacman

Yes i did. My main goal was downloading the packages at a previous time to shorten the download times during updates.
These proxy caches as far as i can tell cache the HTTP results which are then reused when another machine requests the same package.
This means that the waiting time would still apply to the first machine I update.
Am I wrong in this assessment?

I wanted to download the packages onto my server which is not running x64 Arch Linux (it's ARM based) and at a specified time when the other machines are not running.
Am I missing something from the wiki page that already achieves this?

Edit: grammar and Pacoloco seems to have a prefetch feature.

Last edited by lmn (2026-07-03 22:43:33)

Offline

Board footer

Powered by FluxBB