# Foundation Packages Binaries

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

Initial supported host: **Debian 13 (trixie), amd64**.

| Debian package | Upstream source | Adjustment |
| --- | --- | --- |
| `abuild` 3.18.0~rc5+git20260823-1 | alpinelinux/abuild `2770c8ec05ca2a5bbdaf74e340b9dba0257c1fd5` | One patch: `/bin/busybox ash` instead of `/bin/ash -e`, with `set -e` preserved |
| `apk-tools` 2.14.12-1 | Alpine apk-tools v2.14.12 | Native Debian build, no source patches |

Packages live in `packages/debian/trixie/amd64/`, with SHA-256 digests.
They include upstream licenses and Debian installed-file checksums. `apk-tools`
includes its native `libapk` shared library and an `ldconfig` trigger.
Sources are kept under `sources/` with checksums; see [provenance](sources/README.md).
These small binary artifacts are stored directly in Git, not Git LFS.

This is **distribution packaging of upstream software**, not an abuild fork.
Keep portability patches explicit and minimal. Do not add a replacement APKBUILD
parser, custom APK writer, or automatic libc/toolchain policy.

## Install on Debian

```sh
cd packages/debian/trixie/amd64
sha256sum -c SHA256SUMS
sudo apt install ./apk-tools_2.14.12-1_amd64.deb ./abuild_3.18.0~rc5+git20260823-1_amd64.deb
```

APT installs ordinary Debian dependencies, including BusyBox, fakeroot,
scanelf (`pax-utils`), getcap (`libcap2-bin`), and `bc`. This repository does not duplicate the entire
Debian base distribution. No APK database/repositories or signing private keys
are installed on the Debian host.

The upstream privileged helper `abuild-sudo` is deliberately packaged without
its setuid bit. This package does not introduce privileged APK dependency
installation into Debian's system root.

## Build APKs

Run as a regular user, using the normal upstream interface:

```sh
abuild-keygen -a -n
# Install the generated PUBLIC key in /etc/apk/keys for local index verification.
# The command above prints the key location. Keep its private key out of Git.
sudo install -d -m755 /etc/apk/keys
sudo install -m644 /path/to/generated-key.rsa.pub /etc/apk/keys/
cd /path/to/recipes/category/package
abuild -d
```

`-d` skips **Alpine's dependency checks**: provision the recipe's build tools
through APT or the user's toolchain. `-r` is Alpine's APK-based dependency
installer, not an APT resolver; do not use it to provision Debian dependencies.
This does not skip recipe `check()` execution. Signing, splitting, APK metadata,
repository indexing, and checks remain upstream abuild behavior. The packaged
configuration adds `/usr/sbin` and `/sbin` to PATH for Debian's getcap.

Configure the usual upstream variables in `~/.config/abuild/abuild.conf` (or
`ABUILD_USERCONF`): `REPODEST`, `SRCDEST`, signing keys, `CARCH`, `CHOST`, compiler
and flags. Binary target compatibility is the recipe/toolchain author's
responsibility. Merely creating an APK does not make a Debian-linked binary
compatible with Alpine. ELF dependency tracing also expects a matching target
APK database, not Debian's dpkg database. Provision that target dependency state
or explicitly control tracing and runtime dependencies for the recipe. This
package imposes no libc conversion policy.

Use `apk` to manage an Alpine system or an explicitly selected isolated root;
installing APKs directly into the Debian host can conflict with dpkg.

## Rebuild the Debian packages

On Debian 13 amd64:

```sh
sudo apt install build-essential pkgconf libssl-dev zlib1g-dev libzstd-dev patch
sh scripts/build-debs.sh
```

The script verifies pinned sources, builds natively in temporary staging, and
produces `.deb` files with root-owned package metadata. It does not install them.
Set `OUTDIR` and `JOBS` to change output location and parallelism. No live CI
configuration or foundationpkgs recipes are changed by this repository.
Man pages and Lua bindings are omitted from these initial bootstrap packages.

## Verify

```sh
# With normal runtime dependencies installed:
sudo sh tests/debian-smoke.sh
```

The test extracts both `.deb` files into a private temporary tree, builds and
signs two APK versions as `nobody` using upstream abuild and fakeroot, then tests
signature verification, install, upgrade, downgrade, ownership, audit, and removal
in a disposable APK root. It creates no persistent signing keys and installs no
packages into the live Debian system. If testing without installing runtime
prerequisites, `SCANELF_BIN` and `BC_BIN` may point at privately extracted Debian
binaries. `DEBDIR` selects a different artifact directory.

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.
APT publication is configured in `apt-repository.json`; the OpenPGP archive key
and separate `cdg-1` publisher identity are documented in [docs/apt.md](docs/apt.md).
Git remote: `git@nply.org:nply/foundationpkgs-binaries.git`.
Administrators install the native POSIX-shell publisher explicitly. The
`foundationpkgs` CI transfer/deploy jobs invoke that fixed host entry point;
tested branches cannot replace the installed signer or read its private key.
