commit 0dd7ac75c0ae4fee506a4cacb87803e57c03ce39
parent d82b595d7822e05b2819425862084fd0153284b9
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Fri, 30 Oct 2026 02:15:06 +0530
parent d82b595d7822e05b2819425862084fd0153284b9
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Fri, 30 Oct 2026 02:15:06 +0530
Publish retained Debian packages through a locally signed APT archive
10 files changed, 330 insertions(+), 20 deletions(-)
A
|
79
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
diff --git a/.gitattributes b/.gitattributes @@ -1,3 +1,4 @@ * text=auto eol=lf *.deb binary +*.gpg binary *.tar.gz binary
diff --git a/.gitignore b/.gitignore @@ -1,3 +1,9 @@ +/archive/ +/provenance/ +/repository +/repository-releases/ +/.apt-publish-lock/ +/.repository-next +__pycache__/ +*.pyc .DS_Store -out/ -*.log
diff --git a/AGENTS.md b/AGENTS.md @@ -1,15 +1,13 @@ -# Bootstrap binaries +# Foundation Packages Binaries -Read `README.md` for the host/package contract, build commands, and smoke test. -This repository distributes upstream tools; keep patches in `patches/` minimal. -Keep the ordinary upstream abuild interface and recipe-controlled toolchains. - -- Store `.deb` binaries and their digests under `packages/debian/<release>/<arch>/`. -- Keep corresponding source archives, checksums, and provenance under `sources/`. -- Build on the documented Debian host using `sh scripts/build-debs.sh`. -- Validate with `sh tests/debian-smoke.sh` on Debian, plus `sh -n` on each script. - The smoke test needs root only for switching to an unprivileged builder and - installing APKs into a disposable root; it never installs live host packages. -- Retain released versions. Bump package revisions when changing shipped bytes. -- Commit no private keys, credentials, local build logs, or temporary roots. -- Choose a remote explicitly before publishing. CI integration is not configured. +- **APT publication or client setup:** read [docs/apt.md](docs/apt.md). Completion + requires verified local and HTTPS copies; retained archives are not build outputs. +- **Bootstrap tool builds:** read [README.md](README.md) for the Debian host, + upstream source/patch contract, build commands, and privileged smoke-test scope. +- Keep recipes/patches for application packages authoritative in `foundationpkgs`; + this repository retains and publishes their verified CI artifacts and provenance. +- Retain released versions. Increment versions when changing package bytes. +- Private keys, revocation certificates, and credentials stay outside Git and all + publicly served trees. The signing fingerprint and public keys are versioned. +- Validate publisher changes with `python3 tests/apt-repository.py`; shell changes + with `sh -n`. Test actual APT signature rejection in isolated client state.
diff --git a/README.md b/README.md @@ -1,7 +1,14 @@ -# bootstrap-binaries +# Foundation Packages Binaries -Binary bootstrap packages for a Debian CI host that builds genuine Alpine APKs. -No Docker, Alpine root filesystem, or replacement packaging implementation. +Signed Debian package distribution for bootstrap tools and foundationpkgs-built +applications. The local checkout is `~/Projects/foundationpkgs-binaries` (formerly +`bootstrap-binaries`). + +For APT enrollment, signing-key custody, the local archive, publication commands, +and update policy, read **[the APT repository guide](docs/apt.md)**. + +The bootstrap tools build genuine Alpine APKs on a Debian CI host: no Docker, +Alpine root filesystem, or replacement packaging implementation. ## Included binaries @@ -106,4 +113,7 @@ An APK downgrade restores package files, not application databases or data. Application recovery still needs backups and compatible migrations. Private signing keys and bootstrap host credentials never belong in this repo. -A remote Git destination and long-term release signing policy are not configured. +APT publication is configured in `apt-repository.json`; the OpenPGP archive key +and local-only signing policy are documented in [docs/apt.md](docs/apt.md). +Git remote: `git@nply.org:nply/foundationpkgs-binaries.git`. +This public repository does not run server-side archive-signing CI.
diff --git a/apt-repository.json b/apt-repository.json @@ -0,0 +1,6 @@ +{ + "host": "cdg-1", + "remote_root": "/srv/http/dl.nply.org/foundationpkgs-binaries", + "base_url": "https://nply.org/dl/foundationpkgs-binaries/apt", + "signing_fingerprint": "9EF366A63EC38FB0A160549D33F4C03101AEC8D2" +}
diff --git a/docs/apt.md b/docs/apt.md @@ -0,0 +1,159 @@ +# Foundation Packages APT repository + +Supported suite: Debian 13 (`trixie`), architecture `amd64` (and architecture-independent packages). +Public URL: <https://nply.org/dl/foundationpkgs-binaries/apt>. + +## Signing and trust + +APT verifies the OpenPGP signature on `InRelease` (or `Release.gpg` + `Release`). +That metadata authenticates the package indexes; the indexes contain the `.deb` +checksums. The `.deb` files are not individually OpenPGP-signed. HTTPS provides +transport security, not a replacement for repository signature verification. + +Dedicated archive key: + +- Identity: `Foundation Packages Archive <packages@nply.org>` +- Fingerprint: **`9EF366A63EC38FB0A160549D33F4C03101AEC8D2`** +- Algorithm: RSA-3072, signing capability; created 2026-10-29 UTC, expires 2028-10-28. +- Public keys: `keys/foundationpkgs-archive-keyring.gpg` and `keys/foundationpkgs-archive.asc`. + +This is NOT the APK CI RSA key or an SSH key. The private OpenPGP key stays on the +publisher's Mac under `~/.local/share/foundationpkgs/gnupg/` (0700). The private key +has no passphrase, allowing unattended local signing; file permissions protect +it, not encryption. Anyone who compromises that user can sign repository data. +Do not copy that directory to Git, CI, or the HTTPS server. + +A private-key export and revocation certificate are saved under +`~/.local/share/foundationpkgs/key-backups/` (directory 0700, files 0600). This is +an on-disk backup, not protection against disk loss. Copy it to encrypted/offline +storage under the owner's control. Never place it in the public repository. +Renew or rotate the key before expiry; distribute a replacement through an +already trusted channel. A revocation certificate must remain private until used. + +## Enable on a Debian client + +Obtain the key from this trusted checkout, or compare its full fingerprint over +an independently trusted channel before enrolling a downloaded copy. Do not +blindly trust a key merely because it arrived from the package server. + +```sh +sudo install -d -m755 /etc/apt/keyrings +sudo install -m644 keys/foundationpkgs-archive-keyring.gpg /etc/apt/keyrings/ +``` + +Create `/etc/apt/sources.list.d/foundationpkgs.sources`: + +```text +Types: deb +URIs: https://nply.org/dl/foundationpkgs-binaries/apt +Suites: trixie +Components: main +Architectures: amd64 +Signed-By: /etc/apt/keyrings/foundationpkgs-archive-keyring.gpg +``` + +Then use normal APT commands: + +```sh +sudo apt update +sudo apt install minimal-fxa-server +sudo apt upgrade +``` + +The initial application release is `minimal-fxa-server` `0+git20260225-4`, +built by foundationpkgs CI at `fe3ac9a198f2d49b1bccd59e46662071204da9d5`. +Its package SHA-256 is +`bfccab54c4416b88b3f3726b5a9eed2aba1374c21fdcb22f7eee913cb9ef3110`. +On `cdg-1`, APT adopted the previously unmanaged binaries without changing their +bytes. The `.deb` owns both binaries and the license, not configuration, units, +secrets or databases. Its postinst uses `try-restart` for the existing Accounts +service; it does not enable an unconfigured service or restart Sync/lighttpd. +A root-only pre-adoption backup of binaries/configuration and three PostgreSQL +dumps is referenced by `/root/fxa-apt-adoption-latest-backup`. + +Only packages actually published to the signed index are available. Existing +bootstrap tools (`abuild`, `apk-tools`) are also published. This does not mirror +Debian's dependency repositories. Ordinary APT updates are supported; +`unattended-upgrades` is a separate administrator policy and is not enabled here. + +## Local archive and publication + +`archive/pool/` retains every imported package version. `repository-releases/` +retains complete signed snapshots, and `repository` points to the current local +snapshot. These are deliberately excluded from Git, but remain on the local +disk. Existing bootstrap binaries and their sources remain tracked in Git. +`provenance/` additionally retains downloaded CI artifacts/manifests/checksums, +build logs, and the exact recipe/tool snapshot; it too is excluded from Git. +Never delete these directories as if they were disposable build outputs. +The public CI artifact store independently retains the release provenance. + +```sh +python3 scripts/publish-apt.py import /path/to/verified/package_VERSION_amd64.deb +python3 scripts/publish-apt.py publish +``` + +The publisher needs Python 3.9+ (3.10+ recommended), local GnuPG, SSH and rsync; +the SSH destination needs Debian `apt-utils` (`apt-ftparchive`), `dpkg-deb`, +rsync and SHA-256 tools. No private archive key is required on that server. + +The publish command: + +1. Copies all retained packages into a local snapshot (hard links avoid duplication). +2. Stages public package files on the configured server. +3. Uses the server's standard `apt-ftparchive` to generate indexes/Release metadata. +4. Checks package paths, control metadata, architecture, sizes and SHA-256 against local bytes. +5. Signs locally with the dedicated archive key; no private key goes to the server. +6. Saves the complete signed local snapshot before activating its HTTPS copy. +7. Checks remote SHA-256, atomically selects the snapshot, and verifies every published + file over HTTPS against its local copy. Success means both copies were verified. + +Publication is explicit. CI can build while the Mac is offline, but cannot sign +or finalize an archive release without the local publisher. Download and retain +its verified artifacts before publication. A network failure can leave a staged +or activated release; the command reports failure rather than claiming both +copies are verified. Snapshots and failed staging directories are retained. +Inspect a stale `.apt-publish-lock` / remote `.publish-lock` before removing it; +never run concurrent publishers. `apt-repository.json` specifies the destination +and full key fingerprint. Publishing does not install or upgrade client packages. + +Metadata expires after 90 days to limit replay. Republish before expiry even +when package versions have not changed. A new snapshot retains old by-hash +indexes for clients downloading during publication. No historical `.deb` is +pruned automatically. A file-based APT source can use the local `repository` +path, provided APT's user can traverse its parent directories. + +## CI-produced application packages + +The `foundationpkgs` repository owns recipes and patches. Its opt-in Debian +backend produces `.deb` files as an unprivileged user with `dpkg-deb +--root-owner-group`; it never installs packages or holds this signing key. +Pacstall 6.3.11's build-only implementation still invokes sudo, so it is not used +in the unprivileged CI build. No broad sudo grant or Pacstall fork is introduced. + +For each release, retain its verified CI `.deb`, manifest, checksums and build +log under `provenance/` before importing it. Source recipes and patches remain +in foundationpkgs; copy their release snapshot locally too. An offline rebuild +also needs the Go module cache and compiler/toolchain; keeping `.deb` files alone +does not guarantee one. Offline installation can require Debian dependency +packages not present in this repository. + +## Application security is separate + +Repository signatures authenticate the distributed bytes; they do not make the +application safe. The current FxA release still has predictable Sync encryption +keys and incomplete credential/token revocation, among other unresolved findings. +Use synthetic data until those are addressed. Real Firefox multi-device testing +also remains separate from the passing HTTP/CLI smoke checks. + +## Checks + +```sh +python3 tests/apt-repository.py +# On a Debian client; network required, no installation or live-source changes: +sh tests/apt-client.sh +``` + +The client test verifies a real publication with isolated APT state and checks +an invalid signing key is rejected. It passed before live enrollment. The +publisher also compares every downloaded HTTPS file with the local archive. The local archive is not an +off-site backup; keep an additional copy for disk-loss recovery.
diff --git a/keys/foundationpkgs-archive-keyring.gpg b/keys/foundationpkgs-archive-keyring.gpg Binary files differ.
diff --git a/keys/foundationpkgs-archive.asc b/keys/foundationpkgs-archive.asc @@ -0,0 +1,24 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQGNBGrjqSkBDACgSokMZQtfOe+sHep7Rrxq1UXdLVhSqoC9jUrLC9LjSkWWu43G +Fni5mjFNC9DdfL/QyoQR+Z0HWDGMl8JzOIqpGUoIwfGmVfZB0q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MFvTNcGtL91ZyZWBX4fBk5VEAnuXdBEz9Uh/jWkMW +pXYqJddx/DN5dYoJfjPL7JjciMBrF/anbb2rITiymaR21z4sDZYP +=/Pxq +-----END PGP PUBLIC KEY BLOCK-----
diff --git a/tests/apt-client.sh b/tests/apt-client.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Network smoke test, isolated APT state; never installs or changes live sources. +set -eu +root=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd) +if ! command -v apt-get >/dev/null 2>&1; then + echo 'SKIP: apt-get required'; exit 0 +fi +work=$(mktemp -d) +trap 'rm -rf "$work"' 0 +mkdir -p "$work/lists/partial" "$work/cache/archives/partial" "$work/bad-lists/partial" +cp "$root/keys/foundationpkgs-archive-keyring.gpg" "$work/trusted.gpg" +printf 'not an archive key\n' > "$work/wrong.gpg" +url=https://nply.org/dl/foundationpkgs-binaries/apt +printf 'deb [signed-by=%s] %s trixie main\n' "$work/trusted.gpg" "$url" > "$work/good.list" +printf 'deb [signed-by=%s] %s trixie main\n' "$work/wrong.gpg" "$url" > "$work/bad.list" +apt_update() { + apt-get -o "Dir::Etc::sourcelist=$1" -o Dir::Etc::sourceparts=- \ + -o "Dir::State::lists=$2" -o Dir::State::status=/dev/null \ + -o "Dir::Cache=$work/cache" -o "APT::Sandbox::User=$(id -un)" \ + -o APT::Update::Error-Mode=any update +} +apt_update "$work/good.list" "$work/lists" +if apt_update "$work/bad.list" "$work/bad-lists" > "$work/rejected.log" 2>&1; then + echo 'FAIL: repository accepted with an invalid signing key' >&2; exit 1 +fi +grep -Ei 'NO_PUBKEY|Missing key|not signed|signature' "$work/rejected.log" >/dev/null +printf 'PASS: real APT accepts scoped archive key and rejects invalid key; live APT state untouched\n'
diff --git a/tests/apt-repository.py b/tests/apt-repository.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 +"""Offline archive/index safety checks; no SSH, private keys, or live APT state.""" +import datetime +from email.utils import format_datetime +import gzip +import hashlib +import importlib.util +from pathlib import Path +import tempfile + +spec = importlib.util.spec_from_file_location('publisher', Path(__file__).resolve().parents[1] / 'scripts/publish-apt.py') +publisher = importlib.util.module_from_spec(spec) +spec.loader.exec_module(publisher) + + +def rejected(call): + try: + call() + except (ValueError, KeyError): + return + raise AssertionError('unsafe input accepted') + + +with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + publisher.ROOT = root + source = root / 'fixture_1.0-1_amd64.deb' + source.write_bytes(b'synthetic archive fixture') + publisher.import_package(source) + publisher.import_package(source) + archived = root / 'archive/pool/main/f/fixture' / source.name + assert archived.read_bytes() == source.read_bytes() + source.write_bytes(b'different bytes at the same version') + rejected(lambda: publisher.import_package(source)) + assert archived.read_bytes() != source.read_bytes() + invalid = root / 'bad.deb' + invalid.write_bytes(b'bad filename') + rejected(lambda: publisher.import_package(invalid)) + stage = root / 'archive' + relative = archived.relative_to(stage).as_posix() + index = '\n'.join([ + 'Package: fixture', 'Version: 1.0-1', 'Architecture: amd64', + 'Filename: ' + relative, 'Size: ' + str(archived.stat().st_size), + 'SHA256: ' + publisher.digest(archived), '', + ]) + publisher.verify_packages(stage, index) + rejected(lambda: publisher.verify_packages(stage, index.replace(relative, '../outside.deb'))) + rejected(lambda: publisher.verify_packages(stage, index.replace(relative, '/outside.deb'))) + rejected(lambda: publisher.verify_packages(stage, index.replace('amd64\n', 'arm64\n'))) + rejected(lambda: publisher.verify_packages(stage, index.replace('Version: 1.0-1', 'Version: 2.0-1'))) + rejected(lambda: publisher.verify_packages(stage, index.replace(publisher.digest(archived), '0' * 64))) + extra = archived.parent / 'extra_1.0-1_amd64.deb' + extra.write_bytes(b'not indexed') + rejected(lambda: publisher.verify_packages(stage, index)) + index_dir = stage / 'dists/trixie/main/binary-amd64' + index_dir.mkdir(parents=True) + (index_dir / 'Packages').write_text(index) + (index_dir / 'Packages.gz').write_bytes(gzip.compress(index.encode())) + now = datetime.datetime.now(datetime.timezone.utc).replace(microsecond=0) + release = '\n'.join([ + 'Origin: Foundation Packages', 'Suite: trixie', 'Codename: trixie', + 'Architectures: amd64', 'Components: main', 'Acquire-By-Hash: yes', + 'Date: ' + format_datetime(now), + 'Valid-Until: ' + format_datetime(now + datetime.timedelta(days=90)), + ]) + '\n' + for algorithm in ('SHA256', 'SHA512'): + release += algorithm + ':\n' + for name in ('Packages', 'Packages.gz'): + data = (index_dir / name).read_bytes() + release += ' {} {} main/binary-amd64/{}\n'.format( + hashlib.new(algorithm.lower(), data).hexdigest(), len(data), name) + publisher.verify_release(stage, release) + rejected(lambda: publisher.verify_release(stage, release.replace('Suite: trixie', 'Suite: other'))) + rejected(lambda: publisher.verify_release(stage, release.replace('main/binary-amd64/Packages.gz', '../outside'))) + rejected(lambda: publisher.verify_release(stage, release.replace( + format_datetime(now + datetime.timedelta(days=90)), format_datetime(now - datetime.timedelta(days=1))))) + (index_dir / 'Packages').write_text('tampered') + rejected(lambda: publisher.verify_release(stage, release)) +print('PASS: immutable archive, complete/safe package index, Release identity/expiry/checksum rejection')
: nply/foundationpkgs-binaries