commit f72dd3f58702ea40e12b4015befbb555d307155f
parent 0ec84fd2393f2729f6329b0c6fa4dacabf7c6e8d
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Thu, 29 Oct 2026 23:32:41 +0530
parent 0ec84fd2393f2729f6329b0c6fa4dacabf7c6e8d
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Thu, 29 Oct 2026 23:32:41 +0530
Enable signed static FXA APK builds in CI
10 files changed, 162 insertions(+), 17 deletions(-)
diff --git a/.config/Jobfile b/.config/Jobfile @@ -1,5 +1,8 @@ project=foundationpkgs triggers="refs/heads/main: checks plan packages" +# First APK rollout: only this recipe has been migrated and verified. +# Add reviewed package names here as other recipes/toolchains are migrated. +ci_packages=${FPKGS_PACKAGES:-minimal-fxa-server} checks() { for file in "$srcdir"/scripts/*.sh "$srcdir"/tests/*.sh; do @@ -11,12 +14,17 @@ checks() { } plan() { + FPKGS_PACKAGES=$ci_packages \ FPKGS_ROOT=$srcdir \ FPKGS_WORK_ROOT=$workdir/fpkgs \ $srcdir/scripts/fpkgs-ci.sh plan "$FETCH_HEAD" } packages() { + # /tmp is a small tmpfs on the CI host; Go build work belongs on disk. + mkdir -p "$workdir/tmp" + TMPDIR=$workdir/tmp \ + FPKGS_PACKAGES=$ci_packages \ FPKGS_ROOT=$srcdir \ FPKGS_WORK_ROOT=$workdir/fpkgs \ $srcdir/scripts/fpkgs-ci.sh run "$FETCH_HEAD"
diff --git a/AGENTS.md b/AGENTS.md @@ -15,7 +15,9 @@ Explain if the host cannot build it. Run `sh -n <recipe-path>` and `git diff --check`. 4. For an authorized CI deployment, commit and push the recipe to `main`, then wait for the requested package artifact. A local commit does not start CI; - a successful push does not mean the binary is ready. + a successful push does not mean the binary is ready. During the initial APK + rollout, add migrated packages to `ci_packages` in `.config/Jobfile` before + expecting their CI artifact. ## CI and binary availability
diff --git a/Unix/minimal-fxa-server/APKBUILD b/Unix/minimal-fxa-server/APKBUILD @@ -1,11 +1,13 @@ pkgname=minimal-fxa-server pkgver=0_git20260225 -pkgrel=0 +pkgrel=1 pkgdesc="Minimal Firefox Accounts server and local user management CLI" url="https://github.com/ahyattdev/minimal-fxa-server" -arch="all" +arch="x86_64 aarch64" license="MIT" -makedepends="go" +makedepends="go>=1.25.5" +# Go's linker already strips both binaries; no target-prefixed strip is needed. +options="net !strip" _commit=8ec5f0d160269f5079431d2b75574337f0552940 source="$url/archive/$_commit.tar.gz" sha256sums=" @@ -14,21 +16,29 @@ d336c2d13f58b915dca33a3cd20a9d44239d800fa02b38a19b1ee7fd5efbc08a $_commit.tar.g builddir="$srcdir/$pkgname-$_commit" build() { - # Native CI builds only; do not label host Go binaries as a cross target. - if cross_compiling; then - echo "$pkgname: cross compilation is not supported" >&2 - return 1 - fi + case "$CHOST" in *-linux-*) ;; *) echo "$pkgname: Linux targets only" >&2; return 1 ;; esac + case "${CHOST%%-*}" in + x86_64) GOARCH=amd64 ;; + aarch64) GOARCH=arm64 ;; + *) echo "$pkgname: unsupported target architecture" >&2; return 1 ;; + esac + export GOARCH + export GOOS=linux CGO_ENABLED=0 cd "$builddir" - CGO_ENABLED=0 go build -mod=readonly -trimpath -ldflags="-s -w" -o minimal-fxa-server . - CGO_ENABLED=0 go build -mod=readonly -trimpath -ldflags="-s -w" -o fxa-user ./cmd/fxa-user - # The repository builder does not run check() separately. - check + # Explicit exe overrides abuild's default PIE flag: no glibc/musl loader needed. + # Serial builds fit the small CI host; upstream source remains unchanged. + go build -p 1 -buildmode=exe -mod=readonly -trimpath -ldflags="-s -w" -o minimal-fxa-server . + go build -p 1 -buildmode=exe -mod=readonly -trimpath -ldflags="-s -w" -o fxa-user ./cmd/fxa-user + # Pure-Go Linux binaries can be checked on Debian despite the Alpine ABI target. + # Also retain checks with the legacy builder, which does not call check(). + if [ "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" = "$GOOS/$GOARCH" ]; then + check + fi } check() { cd "$builddir" - CGO_ENABLED=0 go test -mod=readonly ./... + CGO_ENABLED=0 go test -p 1 -buildmode=exe -mod=readonly ./... ./fxa-user --help }
diff --git a/docs/ci.md b/docs/ci.md @@ -15,6 +15,13 @@ this backend to CI, provision native abuild/apk-tools, an unprivileged build use signing configuration and target dependencies. Package jobs do not provision the live host or rewrite existing recipes; keep legacy CI explicitly on tar.gz until its packages and toolchain have been migrated. + +**Initial APK rollout:** `.config/Jobfile` selects only `minimal-fxa-server` +through `ci_packages`/`FPKGS_PACKAGES`. Add reviewed recipe names to that list +as they are migrated. The helper without a filter still discovers all recipes; +this deliberate CI allowlist avoids switching unrelated legacy recipes blindly. +Go work uses disk-backed `$workdir/tmp`, not the small `/tmp` tmpfs. + Package builds are sequential; your package may be queued behind others. One package can be published even if other packages fail and the overall job fails. Verify the requested package, @@ -172,6 +179,25 @@ apk add /path/to/verified-package.apk This is for the intended APK target, not the Debian CI host. Do not extract APK files over `/` or use the APK manager to overwrite Debian's dpkg-managed base. SHA-256 transport checks complement, rather than replace, APK signature trust. +The public CI signing key is [`keys/foundationpkgs-ci.rsa.pub`](../keys/foundationpkgs-ci.rsa.pub), +also published at <https://nply.org/dl/foundationpkgs/keys/foundationpkgs-ci.rsa.pub>. +Trust it from an independently trusted foundationpkgs checkout before installing +on the intended APK target: + +```sh +install -m644 keys/foundationpkgs-ci.rsa.pub /etc/apk/keys/ +apk verify /path/to/verified-package.apk +apk add /path/to/verified-package.apk +``` + +The private key belongs to the `git` CI user, mode 0600, outside the repository. +The initial x86_64 Alpine target has an empty, isolated APK database for static +Go dependency tracing; no Alpine base filesystem or chroot is used to build. +Dynamic recipes require their actual target dependency state. Native Go 1.25.6 +is already supplied on this host by its existing `go-bin` package; the FXA +upstream module requires at least Go 1.25.5. That recipe-level toolchain is not +replaced by the base host package installer. + Downgrade does not roll back application databases or migrations. ## Install a legacy tar.gz CI binary
diff --git a/docs/firefox-sync.md b/docs/firefox-sync.md @@ -3,11 +3,14 @@ ## Deployment `Unix/minimal-fxa-server/APKBUILD` packages unchanged upstream commit -`8ec5f0d160269f5079431d2b75574337f0552940` as `0_git20260225-r0`. -It builds both `minimal-fxa-server` and `fxa-user` with CGO disabled. +`8ec5f0d160269f5079431d2b75574337f0552940` as `0_git20260225-r1`. +It builds both `minimal-fxa-server` and `fxa-user` with CGO disabled, explicit +Linux/Go architecture selection and static `-buildmode=exe` output. Go strips +symbols itself; abuild's target-prefixed strip is disabled for these binaries. Use the repository's CI artifacts for deployment, not ad hoc server builds. -The deployed Linux artifact was published by CI for repository revision +The existing deployed **r0 tarball** (not replaced by publishing the r1 APK) +was published by CI for repository revision `0fea439e434b278805ab3aaaa8fd4c39fc5a3ff3`, build key `48709aa96c4dee2eb5483d471d0b1866ebc7b2584741f69e7fc42f905228be44`: @@ -18,6 +21,22 @@ then use `install -o root -g root -m 755` for the two binaries under `/usr/bin`. **Do not extract the archive directly over `/`:** tar restores CI ownership and parent directory modes, which must not replace system directory metadata. +## APK publication + +The first APK rollout selects this recipe in `.config/Jobfile`. The target is +`x86_64-alpine-linux-musl`; build dependencies are provided by the Debian host, +using upstream abuild and the CI user's persistent signing key. Query the pushed +revision rather than assuming success from the push: + +```sh +scripts/fpkgs-ci.sh status minimal-fxa-server x86_64-alpine-linux-musl FULL_COMMIT_SHA +``` + +Use the public key and installation procedure in [CI documentation](ci.md#install-an-apk). +The APK contains both binaries and the MIT license. Static Go binaries avoid a +glibc/musl interpreter dependency; this is not a migration of the live Debian +service to APK management. Publishing an APK does not restart Accounts or Sync. + ## Services and configuration - `syncserver.service`: existing native syncstorage-rs 0.21.1; `127.0.0.1:8001`.
diff --git a/docs/usage.md b/docs/usage.md @@ -148,6 +148,7 @@ FPKGS_DL_BASE_URL=https://nply.org/dl/foundationpkgs FPKGS_FORMAT=apk # or tar.gz; same default as scripts/build.sh FPKGS_TARGETS="x86_64-alpine-linux-musl aarch64-alpine-linux-musl" FPKGS_ABUILD=abuild +FPKGS_PACKAGES="minimal-fxa-server" # optional name filter; unset means all discovered recipes ``` Published artifact layout:
diff --git a/keys/foundationpkgs-ci.rsa.pub b/keys/foundationpkgs-ci.rsa.pub @@ -0,0 +1,14 @@ +-----BEGIN PUBLIC KEY----- +MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAvNIK9BZdb5ucIGZM8pf5 +JwtcMmcKcDLkduGcF4FJB3V368zGoS2sEPRs4aQCa0EQRBYV3bqX+uuOQtfnju9A +p5nY92aYrNYTPERvvZ4q7v/Ir4EkEIAFf3I2k1jvpZegc7f0agqbeKoLY9wVIWMY +G6p0xPvp6SP0jF+hpPI6b+F5mcs+ldWUp3WoU+Hmj3/t3lX0eVM7tVV2+ESv7AJK +8Y2KqvcMfnBK9eYtJuNjaB3IrYhJotAEODoG4QUZYTHSIRidPZev6fOhsn47aqqJ +Pq6iGNEAXeeXyGZqkQ+qmOoSyfALiErSzjJsYNvv75Nr6QoSY4XW7LH8hNOpHFov +dKgCcEXgbK6yZDOnwCtw/5NRv0GGUxsl6oYm4PWPI2D3dORhQ/yEGTZ/hqrZNV2C +zPRZ0ux05hzyI7jTGRs7OgDJ35OOajHsipbJCevhEko3Uus1zGzfVskDj6UFEtbx +7EqWsWKPlKpdAQDYGBusM7/AA7S6GG//4IhsctMnPuMl5w+d+Y/z3oPSmScq6qnJ +5FJ2q6ZTL1F/t9hP6IPXdGE7AOBlCZ0IYBzbu8t2GQpHw8OA+vAbhxzCUyC0lXUk +dokspeUxDz4pZjatT9c0C+lfV+fnGM3NjVKUHj2fzpUZ9OzQ/eSdnoet9yzzSYJo +k1ZjN5hy+abM+e6LzJTorAUCAwEAAQ== +-----END PUBLIC KEY-----
diff --git a/scripts/fpkgs-ci.sh b/scripts/fpkgs-ci.sh @@ -17,6 +17,7 @@ # FPKGS_TARGETS target triplets (default: Alpine-musl for APK on Linux, native otherwise) # FPKGS_FORMAT apk or tar.gz (default: apk on Linux, tar.gz elsewhere) # FPKGS_ABUILD upstream abuild executable (default: abuild) +# FPKGS_PACKAGES optional whitespace-separated package-name filter set -eu SELF_ARG=$0 @@ -201,6 +202,9 @@ plan() { root=$(checkout_rev "$rev") list_apkbuilds "$root" | while IFS= read -r relapk; do apk=$root/$relapk + if [ -n "${FPKGS_PACKAGES:-}" ]; then + list_has "$(pkg_field "$apk" pkgname)" $FPKGS_PACKAGES || continue + fi targets | while IFS= read -r target; do key=$(build_key "$apk" "$target" "$rev") if is_built "$apk" "$target" "$key"; then
diff --git a/tests/apk-backend.sh b/tests/apk-backend.sh @@ -87,6 +87,10 @@ cli=$root/scripts/fpkgs-ci.sh apk_key=$(sh "$cli" key noarch/fixture/APKBUILD "$FPKGS_TARGETS" "$rev") tar_key=$(FPKGS_FORMAT=tar.gz sh "$cli" key noarch/fixture/APKBUILD "$FPKGS_TARGETS" "$rev") [ "$apk_key" != "$tar_key" ] +FPKGS_PACKAGES=not-selected sh "$cli" plan "$rev" >"$work/filter" +[ ! -s "$work/filter" ] +FPKGS_PACKAGES=fixture sh "$cli" plan "$rev" >"$work/filter" +[ "$(wc -l <"$work/filter" | tr -d ' ')" -eq 1 ] sh "$cli" run "$rev" >"$work/run.log" 2>&1 || { cat "$work/run.log" find "$FPKGS_WORK_ROOT/build" -name build.log -exec tail -n 100 {} \;
diff --git a/tests/minimal-fxa-recipe.sh b/tests/minimal-fxa-recipe.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# Recipe contract only; real Go build/signature checks run on the CI host. +set -eu +root=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd) +work=$(mktemp -d) +trap 'rm -rf "$work"' EXIT +mkdir -p "$work/bin" +export GO_TEST_LOG=$work/go.log +cat >"$work/bin/go" <<'GO' +#!/bin/sh +set -eu +printf '%s %s %s %s\n' "$GOOS" "$GOARCH" "$CGO_ENABLED" "$*" >>"$GO_TEST_LOG" +case "$1" in +build | test) + [ "$GOOS" = linux ] && [ "$CGO_ENABLED" = 0 ] + case " $* " in *' -buildmode=exe '*) ;; *) exit 1 ;; esac + if [ "$1" = build ]; then + while [ "$#" -gt 0 ]; do + if [ "$1" = -o ]; then + shift + printf '#!/bin/sh\nexit 0\n' >"$1" + chmod +x "$1" + break + fi + shift + done + fi + ;; +env) + case "$2" in GOHOSTOS) echo linux ;; GOHOSTARCH) echo amd64 ;; *) exit 1 ;; esac + ;; +*) exit 1 ;; +esac +GO +chmod +x "$work/bin/go" +export PATH=$work/bin:$PATH +run_recipe() ( + srcdir=$work/src + pkgdir=$work/pkg + CHOST=$1 + . "$root/Unix/minimal-fxa-server/APKBUILD" + case " $options " in *' !strip '*) ;; *) exit 1 ;; esac + mkdir -p "$builddir" + printf 'MIT\n' >"$builddir/LICENSE" + build || exit 1 + package +) +run_recipe x86_64-alpine-linux-musl +grep -q '^linux amd64 0 test ' "$GO_TEST_LOG" +[ -x "$work/pkg/usr/bin/minimal-fxa-server" ] && [ -x "$work/pkg/usr/bin/fxa-user" ] +: >"$GO_TEST_LOG" +run_recipe aarch64-alpine-linux-musl +grep -q '^linux arm64 0 build ' "$GO_TEST_LOG" +! grep -q ' 0 test ' "$GO_TEST_LOG" +if run_recipe aarch64-apple-darwin >"$work/rejected" 2>&1; then exit 1; fi +if run_recipe riscv64-alpine-linux-musl >"$work/rejected" 2>&1; then exit 1; fi +echo 'PASS: FXA static Go flags, target mapping, runnable checks, CLI packaging, unsupported-target rejection'
: nply/foundationpkgs