Metadata-Version: 2.5
Name: arch-mirror-receiver
Version: 0.1.0
Summary: Builds and serves a verified Arch Linux mirror from chunks shipped by arch-mirror-downloader
Project-URL: Repository, https://github.com/arch-mirror-krdp/arch-mirror
Author: arch-mirror-krdp
License-Expression: MIT
License-File: LICENSE
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: System :: Archiving :: Mirroring
Requires-Python: >=3.14
Requires-Dist: pydantic>=2
Requires-Dist: pyyaml>=6
Requires-Dist: typer>=0.12
Description-Content-Type: text/markdown

# arch-mirror-receiver

Builds and serves a verified Arch Linux mirror from the chunks
[arch-mirror-downloader](https://pypi.org/project/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

```sh
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](https://github.com/arch-mirror-krdp/arch-mirror/tree/main/packages/receiver).

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:

```ini
[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

```sh
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
```
