pkgs/README.md
Ivan Cherniy b9b4690269 Release without binary assets: Forgejo release gets links and checksums only
The site is the single canonical storage of the signed packages. The
release body carries links to pkgs.r4ven.me, the source tag and the
SHA256SUMS content. Landing page header gets the Blog/Apps/Git links.
2026-11-20 22:29:46 +03:00

172 lines
13 KiB
Markdown

# pkgs
**Signed package repositories of r4ven-me for deb, rpm, Arch (pacman) and apk (OpenWrt).** The projects build unsigned packages on the maintainer's machine. This repository signs them with a key that never leaves the maintainer's KeePassXC and publishes the result at <https://pkgs.r4ven.me>.
| Format | Path | Clients |
|---|---|---|
| deb | `https://pkgs.r4ven.me/deb` | Debian, Ubuntu, Linux Mint |
| rpm | `https://pkgs.r4ven.me/rpm/$basearch` | Fedora, RHEL and compatible |
| arch | `https://pkgs.r4ven.me/arch/$arch` | Arch Linux, pacman |
| apk | `https://pkgs.r4ven.me/apk/<release>/<arch>` | OpenWrt, Alpine (apk-tools 3) |
## Features
- **One repository for all projects and formats** — one address, one signing key. A project needs no key and no secret; its build only leaves unsigned `.deb`, `.rpm`, `.pkg.tar.zst` and `.apk` files in a directory (`dist/`).
- **The key stays in KeePassXC** — the private key is an attachment of an entry. `make release` exports it to tmpfs (`/dev/shm`), hands it to a container, and deletes it on exit.
- **Checked before publishing** — the project checkout of `SRC` must be clean and at the commit of the tag, and the same tag must exist on the public Forgejo and point at that commit (the script stops before signing otherwise), and file names, package names and architectures from metadata are validated. The signing container runs without network and capabilities. After signing, the script verifies the indexes and packages with the published public key only, as a client does.
- **Signed everywhere** — apt `InRelease` and `Release.gpg`; rpm packages and `repomd.xml.asc`; pacman packages (`.sig`) and database; apk packages and `packages.adb` (own EC key, separate container).
- **Bounded size** — only the newest `KEEP` versions (default 3) of each package and architecture stay on the site, to keep the site small.
- **Tested with real clients** — `make test` signs test packages and installs them with apt, dnf, pacman and apk with signature checks on.
- **A landing page** — `index.html` lists the newest version of each package with download links and a setup block for each format, in Russian and English, in light and dark theme. `build/gen_index.py` builds it from `catalog.json`. A new package gets a two-language description in `DESCRIPTIONS` of that script.
## Where the packages live
This Git repository contains the publisher: signing scripts, repository builders, public keys and site assets. Published package binaries are not stored in Git.
| Location | Role | Persistent |
|---|---|---|
| A project's `dist/` | Unsigned output of that project's local build | Until the project cleans it |
| `.work/releases/<owner>_<project>_<tag>/` | Local staging area for one release, including the signed files | No; ignored by Git and removed by `make clean` |
| `.work/site-mirror/` | Local working mirror of the complete production repository tree | No; downloaded again from the server on every release |
| The server directory selected by `SITE_REMOTE` | Canonical package-repository storage served by Angie at `https://pkgs.r4ven.me/` | Yes |
| The source project's Forgejo Release | Release metadata only: links to the site and the checksums; no package files | Yes |
Both package managers and links on the landing page download from the canonical server directory. For example, apt reads indexes below `/deb/dists/` and then downloads packages from `/deb/pool/`; a browser link to that `.deb` reaches the same file. The RPM, Arch and APK trees work the same way. Forgejo does not participate when a configured package manager installs or updates a package.
During `make release`, the publisher downloads the current server tree into `.work/site-mirror/`, adds the new packages, prunes old versions, rebuilds and signs the indexes, regenerates the landing page, and synchronizes the complete tree back with rsync. `SITE_REMOTE=pkgs@host:/` may look like the server root, but with the restricted `rrsync` key `/` means only the configured `pkgs` site directory.
## Quick start
Debian, Ubuntu, Linux Mint:
```bash
sudo install -d -m 0755 /etc/apt/keyrings
sudo curl -fsSL https://pkgs.r4ven.me/r4ven-pkgs.asc -o /etc/apt/keyrings/r4ven-pkgs.asc
sudo tee /etc/apt/sources.list.d/r4ven.sources << EOF
Types: deb
URIs: https://pkgs.r4ven.me/deb
Suites: stable
Components: main
Signed-By: /etc/apt/keyrings/r4ven-pkgs.asc
EOF
sudo apt update && sudo apt install korterm
```
Fedora, RHEL and compatible:
```bash
sudo tee /etc/yum.repos.d/r4ven.repo << 'EOF'
[r4ven]
name=r4ven.me packages
baseurl=https://pkgs.r4ven.me/rpm/$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://pkgs.r4ven.me/r4ven-pkgs.asc
EOF
sudo dnf install korterm
```
Arch Linux (the fingerprint is on the landing page and in `keys/r4ven-pkgs.asc`):
```bash
curl -fsSL https://pkgs.r4ven.me/r4ven-pkgs.asc | sudo pacman-key --add -
sudo pacman-key --lsign-key <FINGERPRINT>
sudo tee -a /etc/pacman.conf << 'EOF'
[r4ven]
Server = https://pkgs.r4ven.me/arch/$arch
EOF
sudo pacman -Sy korterm
```
OpenWrt 25.12 (the key is the one the apk repository `apk.r4ven.me` already uses):
```bash
wget -O /etc/apk/keys/r4ven-apk.pub https://pkgs.r4ven.me/apk/r4ven-apk.pub
echo https://pkgs.r4ven.me/apk/25.12/x86_64/packages.adb > /etc/apk/repositories.d/r4ven.list
apk update && apk add luci-app-ocserv-r4ven-me
```
## Maintainer guide
Tools: `bash`, `docker`, `curl`, `jq`, `rsync`, `gpg`, `keepassxc-cli`, `python3`. Packages are handled in a container; the host needs no `dpkg`, `rpm` or `pacman`.
### One-time setup
1. Copy `.local.mk.example` to `.local.mk` and set `KDBX` (the path of your KeePassXC database) and `ENTRY` (where the key is stored). `.local.mk` is ignored by git.
2. Create the key: `make keygen`. It makes an RSA 4096 signing key valid for three years (RSA, because RHEL 9 and older cannot verify Ed25519 in rpm), stores the private key and its revocation certificate in the entry `ENTRY`, reads them back, and writes the public key to `keys/r4ven-pkgs.asc`. Commit that file.
3. On the server, make sure the directory exists and Angie serves it as `pkgs.r4ven.me` and set `SITE_REMOTE` and the Forgejo token in `.local.mk`. The Forgejo API is closed on the public side, so run `make release` from the VPN. The first `make release` fills the empty directory.
**A key that can do nothing but sync the site (recommended).** Do not use an admin login with `sudo rsync`: that is root. Make a key just for this (`ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_pkgs`) and describe the user `pkgs` on the server as code (in your configuration management): the key line is `restrict,command="sudo -n /usr/bin/rrsync <site directory>"` (no terminal, no forwarding) and sudo allows exactly that one command line, with `env_keep += "SSH_ORIGINAL_COMMAND"` because `rrsync` reads it. Then set `SITE_REMOTE := pkgs@<host>:/` (`/` is the site directory) and `SITE_RSH := ssh -i /home/<you>/.ssh/id_ed25519_pkgs -o IdentitiesOnly=yes` in `.local.mk`; `SITE_RSYNC_PATH` is not needed.
### Release flow
1. In a project, build the unsigned packages (for example `make packages`). File names that the script understands: `*.deb`, `*.rpm`, `*.pkg.tar.zst`, `*.apk`. A project may build any subset of the formats.
2. Push the code and the tag to the public Forgejo (`git push public main && git push public v0.3.0`). The checkout that built the packages must stay at the tag, with no uncommitted changes.
3. Here: `make release SRC=../korterm/dist REPO=ivan/korterm TAG=v0.3.0`. `REPO` is the repository on the public Forgejo.
The command copies the packages from `SRC`, adds them, removes old versions, rebuilds and signs the indexes, regenerates `index.html`, updates the release of the tag with links to the site and the new `SHA256SUMS` (no package files are attached to the release), uploads the site by rsync, and publishes the release.
### Settings
| Variable | Default | Meaning |
|---|---|---|
| `KDBX` | none | Path of the KeePassXC database. Set it in `.local.mk`. |
| `KDBX_PASS_CMD` | none | Command that prints the database password (for example `secret-tool lookup Kee Pass`). Without it `keepassxc-cli` asks. |
| `ENTRY` | none | Entry that holds the private key, `<group>/<title>`. The group must exist. Set it in `.local.mk`. |
| `ATTACH` | `r4ven-pkgs.private.asc` | Name of the attachment with the private key (the public key in `keys/` is `r4ven-pkgs.asc`). |
| `KEEP` | `3` | Versions kept per package and architecture. |
| `APK_ENTRY` | none | Entry with the apk private key. Needed only for releases with `.apk` files. |
| `APK_ATTACH` | `r4ven-apk.pem` | Name of the attachment with the apk private key. |
| `APK_RELEASE` | `25.12` | OpenWrt release directory of the `.apk` files (the files do not say it). |
| `APK_ARCH` | `x86_64` | Architecture directory of the `.apk` files. |
| `SITE_REMOTE` | none | rsync target of the site, `user@host:/srv/pkgs`, or `user@host:/` for a key restricted by `rrsync`. Set it in `.local.mk`. |
| `SITE_RSH`, `SITE_RSYNC_PATH` | `ssh`, `rsync` | The ssh command (`rsync -e`) and the rsync command on the server (`--rsync-path`, for example `sudo -n /usr/bin/rsync` when the target belongs to root). |
| `FORGEJO_TOKEN`, `FORGEJO_TOKEN_CMD` | none | Forgejo token with the right to edit releases, or a command that prints it. If both are set, the command wins: a token left in the environment may belong to another Forgejo. |
| `FORGEJO_URL` | `https://git.r4ven.me` | Address of the public Forgejo (the API is reachable from the VPN only). |
| `SRC` | none | Directory with the unsigned packages; several directories are separated by a colon (`dist:dist-awg`). Set it on the command line: `make release SRC=...`. |
### Targets
- `make keygen` — create the signing key.
- `make release SRC=dir REPO=owner/name TAG=vX.Y.Z` — sign and publish the packages of `SRC` as the release `TAG`.
- `make test` — end-to-end test with apt, dnf, pacman and apk (needs docker and network to pull images).
- `make check` — `bash -n` and `shellcheck` for the scripts.
- `make clean` — remove `.work/` (release staging files, the local site mirror and lock).
### Site layout
```
index.html catalog.json r4ven-pkgs.asc r4ven-pkgs.gpg (binary)
deb/ pool/main/<p>/<package>/*.deb dists/stable/{InRelease,Release,Release.gpg,main/binary-*/}
rpm/ <arch>/*.rpm <arch>/repodata/{repomd.xml,repomd.xml.asc,...}
arch/ <arch>/*.pkg.tar.zst(.sig) <arch>/r4ven.db(.sig) r4ven.files(.sig)
apk/ <release>/<arch>/*.apk packages.adb r4ven-apk.pub catalog.json
```
### Replacing or revoking the key
The key expires after three years. To replace it, remove `keys/r4ven-pkgs.asc`, run `make keygen` again (use another `ENTRY` or `ATTACH`), run `make release` for the current packages, and tell the users to download the new `r4ven-pkgs.asc` (on Arch also `pacman-key --lsign-key` for the new fingerprint). If the key leaks, import the revocation certificate from the KeePassXC entry (remove the leading colon in front of the five dashes first), publish the revocation, and replace the key at once.
### apk (OpenWrt)
- The apk key is the existing `r4ven-apk` key (EC P-256) from the `openwrt` project (public part: `keys/r4ven-apk.pub`), so routers that trust it need no new key. Only the repository URL changes.
- A release needs `*.apk` files in `SRC`. The `apk-host` binary of the old flow is not used: the container runs `apk-tools` 3 from Alpine 3.23, and OpenWrt's own `apk` verifies what it signs (checked).
- The release and architecture directory come from `APK_RELEASE` and `APK_ARCH`, because the files do not hold them.
- The old `apk.r4ven.me` and `deb.r4ven.me` stay as they are.
## Layout
- `scripts/` — `keygen.sh` (key), `release.sh` (copy from `SRC`, check the tag, key export, publish), `sign_repo.sh` (deb, rpm and arch: packages, indexes and signatures, runs in the container), `sign_apk.sh` (the same for apk, in its own container).
- `build/` — `Dockerfile.sign` (Debian 13 with `apt-ftparchive`, `createrepo_c`, `repo-add`, `rpmsign`, `gpg`), `Dockerfile.apk` (Alpine 3.23 with `apk-tools` 3), `gen_index.py` (the landing page), and `site/` (logo and favicon).
- `tests/` — `run_test.sh`, `make_fixtures.sh` and `make_apk_fixtures.sh` (the end-to-end test).
- `keys/` — the public keys (`r4ven-pkgs.asc`, `r4ven-apk.pub`). The private keys are not in the repository.
- `.work/` — ignored local state created by `make release`: `releases/`, `site-mirror/` and `.lock`.
## Author
[Ivan Cherniy](https://r4ven.me) — [r4ven.me](https://r4ven.me).
Source: [git.r4ven.me/ivan/pkgs](https://git.r4ven.me/ivan/pkgs).
## License
GNU General Public License v3.0 or later (GPL-3.0-or-later), see [LICENSE](LICENSE).