arch-mirror-receiver
Builds and serves a verified Arch Linux mirror from the chunks
arch-mirror-downloader ships.
The service polls an inbox (polling, not inotify, so it works on a read-only network share) and
only ever reads it. For each new chunk it checks the magic, extracts it, and checks every file
against the chunk's message.json; a damaged chunk is rejected whole. Files join a hardlinked
copy of the current snapshot. Once a snapshot's last chunk is in, it drops files the new state no
longer has, verifies every package against its repo database, writes index.html, style.css
and snapshot.json, and only then switches root/current. Clients never see a half-updated
mirror. Chunks can come in any order; one made for a snapshot that isn't here yet waits.
Which chunks were applied is kept in root/receiver.db (by name, size and mtime), along with a
checksum cache keyed by inode, so no file is hashed twice. A chunk that is still being copied in
(modified less than settle_seconds ago) is left for the next poll.
Install
sudo useradd --system --home-dir /srv/arch-mirror arch-mirror
sudo UV_TOOL_DIR=/opt/uv-tools UV_TOOL_BIN_DIR=/usr/local/bin uv tool install arch-mirror-receiver
arch-mirror-receiver default-config | sudo install -Dm644 /dev/stdin /etc/arch-mirror-receiver/config.yaml # then edit
sudo install -d -o arch-mirror -g arch-mirror /srv/arch-mirror
sudo install -m644 systemd/arch-mirror-receiver.service /etc/systemd/system/
sudo systemctl daemon-reload && sudo systemctl enable --now arch-mirror-receiver
default-config prints every setting with its default and what it does. The units in systemd/
are in the repository.
Serve root/current/ with any web server. Its index.html shows the snapshot, when upstream
reached that state and when it was published here, each repo's size, what changed, the packages
built from the AUR, and a pacman.conf snippet. Clients:
[core]
Server = http://mirror.example/$repo/os/$arch
# likewise extra, multilib, the -debug repos
[aur]
SigLevel = Optional TrustAll # built by the downloader, unsigned
Server = http://mirror.example/$repo/os/$arch
Use
arch-mirror-receiver watch # the service
arch-mirror-receiver apply # one pass
arch-mirror-receiver status # current snapshot, recent chunks and their state
arch-mirror-receiver default-config # commented default config (YAML) on stdout
arch-mirror-receiver --install-completion # tab completion for your shell (bash, zsh, fish)