: nply/foundationpkgs

commit 4e13e009252dd8fbd772e9b264a55504eeeb9a90
parent d438eb6e56cdc27386c8be1c41fb9fcedad9a539
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Thu, 29 Oct 2026 22:46:45 +0530

Add upstream APK backend with configurable format and verified publication
12 files changed, 490 insertions(+), 65 deletions(-)
M
AGENTS.md
|
7
+++++--
M
CONTEXT.md
|
8
+++++---
M
docs/ci.md
|
56
++++++++++++++++++++++++++++++++++++++++++++------------
M
docs/usage.md
|
67
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
A
scripts/build-apk.sh
|
46
++++++++++++++++++++++++++++++++++++++++++++++
M
scripts/build.sh
|
42
+++++++++++++++++++++++++++++++++---------
M
scripts/fpkgs-ci.sh
|
126
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------
M
scripts/functions.sh
|
24
++++++++++++++++++++++++
M
stage0/abuild/README.md
|
10
+++++-----
A
tests/apk-backend.sh
|
165
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
M
tests/artifact-status.sh
|
2
++
M
tests/staged-install.sh
|
2
+-
diff --git a/AGENTS.md b/AGENTS.md
@@ -8,8 +8,11 @@
 2. Write a POSIX-compatible `APKBUILD` in the narrowest applicable bucket.
    `PKGBUILD` and `*.pacscript` are generated intermediates. Add recipes for new
    dependencies unless they are system/base tools.
-3. Run a targeted build: `scripts/build.sh <recipe-path>`. Explain if the current
-   host cannot build it. Run `sh -n <recipe-path>` and `git diff --check`.
+3. Run a targeted build: `scripts/build.sh <recipe-path>`. Linux defaults to
+   upstream abuild/APK and an Alpine-musl target; `-f tar.gz` retains the legacy
+   builder. For signing, target setup, or legacy recipe migration, read
+   [format prerequisites and builder contracts](docs/usage.md#format-target-and-prerequisites).
+   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.
diff --git a/CONTEXT.md b/CONTEXT.md
@@ -8,11 +8,13 @@
 
 **Recipe bucket**: A top-level directory that scopes recipes by applicability. Current buckets include OS buckets such as `Linux/` and `Darwin/`, broad Unix recipes in `Unix/`, architecture-independent recipes in `noarch/`, and fully generic recipes in `any/`.
 
-**Target**: The platform triplet a package is built for, such as `x86_64-unknown-linux-gnu`.
+**Target**: The platform triplet a package is built for, such as `x86_64-alpine-linux-musl` or `x86_64-unknown-linux-gnu`. It identifies the intended ABI, not a guarantee that the recipe's toolchain produces compatible binaries.
+
+**Package format**: The distribution container, independent of the target: genuine signed Alpine APKs or legacy tar.gz archives.
 
 **Build key**: The content hash used to decide whether a package/target needs rebuilding. It represents the APKBUILD, local source inputs, build scripts, target, git revision, build-affecting environment, and tool versions.
 
-**Artifact**: A built package tarball plus checksum, build log, and manifest published below the download root.
+**Artifact**: A built package file within a publication. A publication includes primary/split packages, checksums, a build log and a manifest; APK publications also contain a signed repository index.
 
 **Download root**: The filesystem tree where artifacts are published; configured as `$FPKGS_DL_ROOT` and normally `/srv/http/dl.nply.org/foundationpkgs`.
 

@@ -26,6 +28,6 @@
 
 **Jobfile**: A POSIX shell, APKBUILD-like file containing CI metadata variables and job functions. It uses lowercase variables (`project`, `targets`, `triggers`, etc.) and APKBUILD-style `!option` negation. Repositories provide it as `.config/Jobfile`.
 
-**Native target**: The target returned by `guess_triplet` for the current build host. The initial deployed CI run builds this target.
+**Native target**: The platform triplet of the build host. An Alpine-musl target on Debian is a cross target even when both use the same CPU architecture.
 
 **Cross target**: A non-native target requested through `$FPKGS_TARGETS`. It is attempted only when the recipe/toolchain can support it.
diff --git a/docs/ci.md b/docs/ci.md
@@ -8,7 +8,13 @@ CI deployment is authorized. On `cdg-1`, the Gitolite post-receive hook starts
 selected by the effective Jobfile. Committing locally does not trigger CI.
 
 The Jobfile runs `checks`, `plan`, and `packages`. `checks` runs shell syntax
-checks and the offline artifact-status/staged-install regression tests.
+checks and offline backend/publication/staged-install regressions. Linux builds
+default to APK and an Alpine-musl target; `FPKGS_FORMAT=tar.gz` explicitly retains
+legacy output. `FPKGS_TARGETS` selects targets independently. Before deploying
+this backend to CI, provision native abuild/apk-tools, an unprivileged build user,
+signing configuration and target dependencies. This code does not provision the
+live host or rewrite existing recipes; keep legacy CI explicitly on tar.gz until
+its packages and toolchain have been migrated.
 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,

@@ -44,13 +50,15 @@ rev=$(git rev-parse HEAD)  # the revision you actually pushed
 ssh cdg-1 "/home/git/.local/cache/minci/foundationpkgs/scripts/fpkgs-ci.sh status minimal-fxa-server x86_64-unknown-linux-gnu $rev"
 ```
 
-The command searches published manifests and verifies the main package archive's
-SHA-256. It returns manifest, archive, and log URLs plus the server archive path.
+The command searches published manifests and verifies SHA-256 for all files in
+new publications' `SHA256SUMS`, including split packages and signed indexes.
+Legacy publications without that registry retain main-archive sidecar checking.
+It returns format, manifest, archive, and log URLs plus the server archive path.
 It neither starts a build nor modifies artifacts.
 
 | Exit | Meaning | Next action |
 | --- | --- | --- |
-| 0 | Exact revision/target/package found; main artifact checksum verified | Use the returned artifact |
+| 0 | Exact revision/target/package found; publication checksums verified | Use the returned artifact |
 | 1 | No matching publication yet | Check CI jobs/logs; this alone does not distinguish queued, running, failed, or never triggered |
 | 2 | Matching manifest exists but artifact/checksum is missing or invalid | Investigate publication; do not deploy it |
 

@@ -58,8 +66,9 @@ Invocation/configuration errors are also nonzero and print a diagnostic.
 Use a full commit SHA for remote queries. A local branch name or short SHA is
 resolved against `FPKGS_ROOT` (default current directory). If several builds of
 the same revision exist, the command returns the first complete verified match;
-it is not a "latest version" selector. Split-package archives require their own
-checksum verification; status verifies the main package only.
+it is not a "latest version" selector. With no `FPKGS_FORMAT` filter it can find
+both APK and old tarball publications. Set `FPKGS_FORMAT=apk` or `tar.gz` to
+restrict lookup. Older GNU/tarball releases keep their original targets/URLs.
 
 **Do not compute the build key on your laptop to locate a CI artifact.** Keys
 include builder paths, environment, and tool versions. Read published manifests

@@ -88,17 +97,37 @@ Server root: `/srv/http/dl.nply.org/foundationpkgs`.
 <root>/<target>/<pkgname>/<pkgver>-r<pkgrel>/<buildkey>/
   manifest
   build.log
-  <pkgname>-<pkgver>-r<pkgrel>.tar.gz
-  <pkgname>-<pkgver>-r<pkgrel>.tar.gz.sha256
-  ...optional split-package archives and digests...
+  SHA256SUMS
+  <bucket>/<apk-arch>/<pkgname>-<pkgver>-r<pkgrel>.apk
+  <bucket>/<apk-arch>/APKINDEX.tar.gz
+  ...split APKs and matching .sha256 sidecars...
+  # tar.gz format instead retains flat *.tar.gz and *.tar.gz.sha256 files.
 ```
 
-The manifest identifies `gitrev`, `target`, `pkgname`, version, build key, public
-URL, and timestamp. The `.sha256` file contains a **bare hexadecimal digest**,
+The manifest identifies `gitrev`, `target`, `format`, the primary relative
+`artifact` path, package/version, build key, public URL, and timestamp. The build
+key includes format, backend scripts, compiler/tool versions, upstream abuild
+script/configuration fingerprints, public signing keys and build environment.
+Corrupt or incomplete cached publications are rebuilt rather than skipped. The `.sha256` file contains a **bare hexadecimal digest**,
 not a filename-bearing `sha256sum -c` record. Publication is atomic: artifacts,
 log, and manifest are staged together before the directory becomes visible.
 
-## Install a CI binary
+## Install an APK
+
+Use the verified `artifact_path` with the target system's normal APK manager,
+with its trusted signing key and dependency repositories configured:
+
+```sh
+apk add /path/to/verified-package.apk
+# An older explicit package version/file can be installed to downgrade.
+```
+
+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.
+Downgrade does not roll back application databases or migrations.
+
+## Install a legacy tar.gz CI binary
 
 On `cdg-1`, use the verified `artifact_path` from `status`. Extract into staging,
 then install only the files required by the deployment. This example is for the

@@ -146,6 +175,9 @@ scripts/fpkgs-ci.sh run FULL_COMMIT_SHA
 scripts/fpkgs-ci.sh key Unix/minimal-fxa-server/APKBUILD x86_64-unknown-linux-gnu FULL_COMMIT_SHA
 sh tests/artifact-status.sh
 sh tests/staged-install.sh
+sh tests/apk-backend.sh
+# With real upstream tools and signing configuration, as a non-root user:
+FPKGS_TEST_REAL_APK=1 sh tests/apk-backend.sh
 ```
 
 `run` builds/publishes locally; it is not the normal way to trigger deployed CI.
diff --git a/docs/usage.md b/docs/usage.md
@@ -70,7 +70,47 @@ Cross-target build:
 scripts/build.sh -t x86_64-unknown-linux-musl Unix/kcgi/APKBUILD
 ```
 
-Outputs are tarballs, not real apk files, under:
+### Format, target, and prerequisites
+
+On Linux the default is **genuine APK output through upstream abuild**, targeting
+`<host-arch>-alpine-linux-musl`. Other hosts retain tar.gz output and their native
+target. Choose independently with `-f`/`FPKGS_FORMAT` and `-t`/`FPKGS_TARGETS`:
+
+```sh
+scripts/build.sh -f apk -t x86_64-alpine-linux-musl Unix/kcgi/APKBUILD
+scripts/build.sh -f tar.gz Unix/kcgi/APKBUILD
+FPKGS_FORMAT=tar.gz scripts/fpkgs-ci.sh plan HEAD
+FPKGS_FORMAT=apk FPKGS_TARGETS=x86_64-unknown-linux-gnu scripts/fpkgs-ci.sh plan HEAD
+```
+
+The last example selects APK packaging for a GNU target; it is not an Alpine
+ABI compatibility claim. Recipes, compilers, sysroots and runtime dependencies
+remain the caller's responsibility. A target name does not convert libc.
+
+Install upstream `abuild`/`apk-tools` before APK builds. Debian 13 amd64 bootstrap
+`.deb` packages and build instructions live in `~/Projects/bootstrap-binaries`.
+Run builds as an unprivileged user, generate a signing key with
+`abuild-keygen -a -n`, and trust its **public** key for local index verification
+(the bootstrap README documents the key installation). No keys are generated or
+installed by foundationpkgs. `FPKGS_ABUILD` can select another abuild executable.
+
+The APK backend runs `abuild -d` in a temporary copy of the recipe directory.
+It leaves dependency provisioning to the caller and never installs APK build
+dependencies into the Debian system root. Use upstream `CBUILDROOT`, compiler
+variables and PATH for target dependencies/tools; `-s`/`-n` are legacy tar-only
+staging options and are rejected for APK builds. ELF dependency tracing expects
+a matching APK database, not dpkg. Configure it explicitly; tracing is not
+silently disabled. Upstream skips execution checks on cross builds.
+
+Outputs preserve upstream repository layout and signed indexes:
+
+```text
+dist/<target>/<recipe-bucket>/<apk-arch>/*.apk
+dist/<target>/<recipe-bucket>/<apk-arch>/APKINDEX.tar.gz
+# Each file also has a bare-digest .sha256 sidecar.
+```
+
+Explicit tar.gz output retains the old layout and semantics:
 
 ```text
 dist/<target-or-noarch>/<pkgname>-<pkgver>-r<pkgrel>.tar.gz

@@ -105,15 +145,20 @@ FPKGS_ROOT=$PWD
 FPKGS_WORK_ROOT=/var/tmp/fpkgs-ci
 FPKGS_DL_ROOT=/srv/http/dl.nply.org/foundationpkgs
 FPKGS_DL_BASE_URL=https://nply.org/dl/foundationpkgs
-FPKGS_TARGETS="x86_64-unknown-linux-musl aarch64-unknown-linux-musl"
+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
 ```
 
 Published artifact layout:
 
 ```text
 $FPKGS_DL_ROOT/<target>/<pkgname>/<pkgver>-r<pkgrel>/<buildkey>/
-  *.tar.gz
-  *.sha256
+  <recipe-bucket>/<apk-arch>/*.apk     # APK format, including splits
+  <recipe-bucket>/<apk-arch>/APKINDEX.tar.gz
+  *.tar.gz                          # instead, for tar.gz format
+  ...matching .sha256 sidecars...
+  SHA256SUMS                        # all package/index files
   build.log
   manifest
 ```

@@ -162,14 +207,22 @@ scripts/build.sh <bucket>/<pkg>/APKBUILD
 
 ### Builder contract
 
-`scripts/build.sh` sources the APKBUILD as POSIX shell, fetches/unpacks sources,
+**APK:** `scripts/build.sh -f apk` delegates recipe interpretation, prepare/build/
+check/package phases, splitting, metadata, signing and indexing to upstream
+abuild. Use Alpine's real recipe conventions: `arch="noarch"` rather than `any`,
+and full subpackage names such as `subpackages="$pkgname-dev $pkgname-doc"`.
+Custom `verify()`-only recipes and short split suffixes are legacy extensions,
+not an upstream recipe contract. Existing recipes need review before switching
+their production builds; selecting a new format does not migrate recipes.
+
+**Legacy tar.gz:** `scripts/build.sh -f tar.gz` sources the APKBUILD as POSIX shell, fetches/unpacks sources,
 applies listed `.patch` sources through `default_prepare`, then runs `build()`
 and `package()`. It does not call a recipe's `prepare()` hook. Build/package
 functions start in `$builddir`; it defaults to `$srcdir`. Prefer an explicit
 `builddir="$srcdir/$pkgname-$pkgver"` when the source archive has that root.
 `$pkgdir` is staging, not the live system; install only beneath it.
 
-The current builder **does not automatically run `check()`**, and it calls
+The tar.gz builder **does not automatically run `check()`**, and it calls
 `build()` even when `options="!build"` is present. Invoke `check` explicitly from
 `build()` when needed; for prebuilt/data-only packages define `build() { :; }`.
 `options` metadata may be used by other tooling, but is not a phase-control

@@ -208,7 +261,7 @@ package() {
 }
 ```
 
-Split packages are supported with functions named after the suffix:
+The legacy tar.gz backend supports split packages with functions named after the suffix:
 
 ```sh
 subpackages="assets"
diff --git a/scripts/build-apk.sh b/scripts/build-apk.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+# Internal APK backend. Upstream abuild owns every recipe/packaging phase.
+set -eu
+SELF_DIR=$(CDPATH= cd -- "$(dirname "$0")" && pwd)
+. "$SELF_DIR/functions.sh"
+recipe=$1
+dest=$2
+target=$3
+keep=$4
+abuild=${FPKGS_ABUILD:-abuild}
+command -v "$abuild" >/dev/null 2>&1 || die 'upstream abuild is required; install the bootstrap .debs or select -f tar.gz'
+recipe_dir=$(CDPATH= cd -- "$(dirname "$recipe")" && pwd)
+repo=$(basename "$(dirname "$recipe_dir")")
+pkg=$(basename "$recipe_dir")
+mkdir -p "$dest"
+dest=$(CDPATH= cd -- "$dest" && pwd)
+work=$(mktemp -d "${TMPDIR:-/tmp}/fpkgs-apk.XXXXXX")
+cleanup() {
+	if [ "$keep" -eq 1 ]; then msg "keeping work dir: $work"; else rm -rf "$work"; fi
+}
+trap cleanup EXIT
+trap 'exit 1' HUP INT TERM
+mkdir -p "$work/recipes/$repo/$pkg"
+cp -R "$recipe_dir/." "$work/recipes/$repo/$pkg/"
+# Build in a fresh copy: no mutation of the checkout or reuse of stale APKs.
+(
+	cd "$work/recipes/$repo/$pkg"
+	APKBUILD="$work/recipes/$repo/$pkg/$(basename "$recipe")" \
+		REPODEST="$work/packages" SRCDEST="${SRCDEST:-$work/sources}" "$abuild" -d
+)
+[ -d "$work/packages" ] || die 'abuild produced no repository'
+find "$work/packages" -type f -name '*.apk' >"$work/apks"
+[ -s "$work/apks" ] || die 'abuild produced no APKs'
+# Preserve upstream repository/architecture layout and the signed index.
+find "$work/packages" -type f \( -name '*.apk' -o -name 'APKINDEX.tar.gz' \) >"$work/artifacts"
+while IFS= read -r file; do
+	if command -v sha256sum >/dev/null 2>&1; then
+		digest=$(sha256sum "$file" | awk '{print $1}')
+	else
+		digest=$(shasum -a 256 "$file" | awk '{print $1}')
+	fi
+	printf '%s\n' "$digest" >"$file.sha256"
+done <"$work/artifacts"
+mkdir -p "$dest/$target"
+cp -R "$work/packages/." "$dest/$target/"
+msg "wrote APK repository to $dest/$target/$repo"
diff --git a/scripts/build.sh b/scripts/build.sh
@@ -3,7 +3,7 @@
 # folder. POSIX sh only. See functions.sh for the derivation notes (forked
 # from alpinelinux/abuild, generic parts only).
 #
-# Usage: build.sh [-o DESTDIR] [-s SYSROOT] [-n NATIVE_ROOT] [-t CHOST] [-k] <pkgname-or-path>
+# Usage: build.sh [-f apk|tar.gz] [-o DESTDIR] [-s SYSROOT] [-n NATIVE_ROOT] [-t CHOST] [-k] <pkgname-or-path>
 #
 # <pkgname-or-path> is either a bare package name (resolved via
 # resolve_recipe against $FPKGS_ROOT) or a direct path to a recipe

@@ -31,26 +31,29 @@ DESTDIR="./dist"
 SYSROOT="./sysroot"
 NATIVE_ROOT_ARG=""
 CHOST=""
+FORMAT=${FPKGS_FORMAT:-}
 KEEP_WORKDIR=0
 
 usage() {
 	cat <<EOF
-usage: $0 [-o DESTDIR] [-s SYSROOT] [-n NATIVE_ROOT] [-t CHOST] [-k] <pkgname-or-path>
+usage: $0 [-f apk|tar.gz] [-o DESTDIR] [-s SYSROOT] [-n NATIVE_ROOT] [-t CHOST] [-k] <pkgname-or-path>
 
-  -o DESTDIR      destination root for built tarballs (default: ./dist)
-  -s SYSROOT      root depends/makedepends_host get extracted into (default: ./sysroot)
-  -n NATIVE_ROOT  root makedepends/makedepends_build get extracted into
+  -f FORMAT       apk on Linux, tar.gz elsewhere; overrides FPKGS_FORMAT
+  -o DESTDIR      destination root for packages (default: ./dist)
+  -s SYSROOT      tar.gz only: target dependency staging root (default: ./sysroot)
+  -n NATIVE_ROOT  tar.gz only: root makedepends/makedepends_build get extracted into
                   (default: same as SYSROOT unless -t/--host cross-compiles)
   -t CHOST        target triplet, when different from this machine (CBUILD)
   -k              keep the temp work dir after the build (debugging)
 EOF
 }
 
-while getopts "o:s:n:t:kh" opt; do
+while getopts "f:o:s:n:t:kh" opt; do
 	case "$opt" in
+	f) FORMAT=$OPTARG ;;
 	o) DESTDIR=$OPTARG ;;
-	s) SYSROOT=$OPTARG ;;
-	n) NATIVE_ROOT_ARG=$OPTARG ;;
+	s) SYSROOT=$OPTARG; LEGACY_ROOT_REQUESTED=1 ;;
+	n) NATIVE_ROOT_ARG=$OPTARG; LEGACY_ROOT_REQUESTED=1 ;;
 	t) CHOST=$OPTARG ;;
 	k) KEEP_WORKDIR=1 ;;
 	h)

@@ -71,8 +74,29 @@ shift $((OPTIND - 1))
 }
 target="$1"
 
+FPKGS_FORMAT=$FORMAT
+FORMAT=$(package_format)
+FPKGS_FORMAT=$FORMAT
+export FPKGS_FORMAT
 CBUILD=$(guess_triplet)
-CHOST="${CHOST:-$CBUILD}"
+CHOST="${CHOST:-$(default_target "$FORMAT")}"
+
+if [ "$FORMAT" = apk ]; then
+	# A vendor spelling alone must not turn a native musl build into a cross build.
+	case "$CBUILD" in
+	*-unknown-linux-musl) [ "$CHOST" != "$(default_target apk)" ] || CBUILD=$CHOST ;;
+	esac
+	[ "${LEGACY_ROOT_REQUESTED:-0}" -eq 0 ] || die '-s/-n are tar.gz staging options; configure upstream CBUILDROOT/PATH for APK builds'
+	if [ -f "$target" ]; then
+		apkbuild=$target
+	elif [ -f "$target/APKBUILD" ]; then
+		apkbuild=$target/APKBUILD
+	else
+		apkbuild=$(resolve_recipe "$target") || die "no recipe found for '$target'"
+	fi
+	export CBUILD CHOST
+	exec "$SELF_DIR/build-apk.sh" "$apkbuild" "$DESTDIR" "$CHOST" "$KEEP_WORKDIR"
+fi
 
 mkdir -p "$DESTDIR" "$SYSROOT"
 DESTDIR=$(cd "$DESTDIR" && pwd)
diff --git a/scripts/fpkgs-ci.sh b/scripts/fpkgs-ci.sh
@@ -14,7 +14,9 @@
 #   FPKGS_DL_ROOT    publication root (default: /srv/http/dl.nply.org/foundationpkgs)
 #   FPKGS_DL_BASE_URL public artifact URL base (default: https://nply.org/dl/foundationpkgs)
 #   FPKGS_WORK_ROOT  work/cache root (default: /var/tmp/fpkgs-ci)
-#   FPKGS_TARGETS    target triplets (default: native guess_triplet)
+#   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)
 set -eu
 
 SELF_ARG=$0

@@ -38,6 +40,11 @@ else
 	guess_triplet() { uname -m | awk '{ print $0 "-unknown-" }' | sed 's/x86_64-unknown-$/x86_64-unknown-linux-gnu/'; }
 fi
 
+if [ -n "${FPKGS_FORMAT:-}" ]; then
+	FPKGS_FORMAT=$(package_format) || exit 1
+	export FPKGS_FORMAT
+fi
+
 usage() {
 	cat >&2 <<EOF
 usage: $SELF run [REV] | plan [REV] | key APKBUILD TARGET [REV]

@@ -62,15 +69,11 @@ sha256_stream() {
 	fi
 }
 
-native_target() {
-	guess_triplet
-}
-
 targets() {
 	if [ -n "${FPKGS_TARGETS:-}" ]; then
 		printf '%s\n' $FPKGS_TARGETS
 	else
-		native_target
+		default_target "$(package_format)"
 	fi
 }
 

@@ -128,13 +131,25 @@ local_sources() {
 }
 
 build_env_fingerprint() {
-	for name in MAKEFLAGS CFLAGS CPPFLAGS LDFLAGS PKG_CONFIG_PATH CC CHOST CBUILD; do
+	printf 'format=%s\n' "$(package_format)"
+	for name in MAKEFLAGS CFLAGS CPPFLAGS CXXFLAGS LDFLAGS PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PKG_CONFIG_SYSROOT_DIR CC CXX AR STRIP CHOST CBUILD CTARGET CARCH FPKGS_ABUILD APK CBUILDROOT SRCDEST options PACKAGER PACKAGER_PUBKEY; do
 		eval val=\${$name:-}
 		printf '%s=%s\n' "$name" "$val"
 	done
 	(command -v cc >/dev/null 2>&1 && cc --version 2>/dev/null | sed 1q) || true
 	(command -v make >/dev/null 2>&1 && make --version 2>/dev/null | sed 1q) || true
 	(command -v bmake >/dev/null 2>&1 && bmake -V MAKE_VERSION 2>/dev/null) || true
+	if [ "$(package_format)" = apk ]; then
+		("${FPKGS_ABUILD:-abuild}" -V 2>/dev/null) || printf 'abuild=unavailable\n'
+		(${APK:-apk} --version 2>/dev/null) || printf 'apk=unavailable\n'
+		abuild_path=$(command -v "${FPKGS_ABUILD:-abuild}" || true)
+		[ ! -f "$abuild_path" ] || printf 'abuild-sha256=%s\n' "$(sha256_file "$abuild_path")"
+		userdir=${ABUILD_USERDIR:-${XDG_CONFIG_HOME:-$HOME/.config}/abuild}
+		[ -d "$userdir" ] || userdir=$HOME/.abuild
+		for config in "${ABUILD_DEFCONF:-${ABUILD_SHAREDIR:-/usr/share/abuild}/default.conf}" "${ABUILD_SHAREDIR:-/usr/share/abuild}/functions.sh" "${ABUILD_CONF:-/etc/abuild.conf}" "${ABUILD_USERCONF:-$userdir/abuild.conf}" "$userdir/"*.pub "${PACKAGER_PUBKEY:-${PACKAGER_PRIVKEY:-}.pub}"; do
+			[ ! -f "$config" ] || printf 'abuild-config %s %s\n' "$config" "$(sha256_file "$config")"
+		done
+	fi
 }
 
 build_key() {

@@ -147,7 +162,7 @@ build_key() {
 		printf 'target=%s\n' "$target"
 		printf 'apkbuild=%s\n' "$apk"
 		printf 'apkbuild-sha256=%s\n' "$(sha256_file "$apk")"
-		for f in "$root/scripts/build.sh" "$root/scripts/functions.sh" "$root/scripts/apkbuild-to-pacscript.sh"; do
+		for f in "$root/scripts/build.sh" "$root/scripts/build-apk.sh" "$root/scripts/functions.sh" "$root/scripts/apkbuild-to-pacscript.sh"; do
 			[ -f "$f" ] && printf 'script %s %s\n' "$(basename "$f")" "$(sha256_file "$f")"
 		done
 		local_sources "$apk" | while IFS= read -r f; do

@@ -172,7 +187,13 @@ is_built() {
 	apk=$1
 	target=$2
 	key=$3
-	[ -f "$(artifact_dir "$apk" "$target" "$key")/manifest" ]
+	b_dir=$(artifact_dir "$apk" "$target" "$key")
+	[ -f "$b_dir/manifest" ] || return 1
+	b_file=$(pkg_field "$b_dir/manifest" artifact)
+	if [ -z "$b_file" ]; then
+		b_file=$(pkg_field "$apk" pkgname)-$(pkg_field "$apk" pkgver)-r$(pkg_field "$apk" pkgrel).tar.gz
+	fi
+	artifact_path_valid "$b_file" && [ -f "$b_dir/$b_file" ] && verify_artifacts "$b_dir" "$b_file"
 }
 
 plan() {

@@ -204,23 +225,40 @@ publish_output() {
 	rel=$(pkg_field "$apk" pkgrel)
 	[ -n "$rel" ] || rel=0
 	tmp=$out.tmp.$$
-	rm -rf "$tmp"
-	mkdir -p "$tmp"
-	find "$dist" -type f -name '*.tar.gz' -exec cp {} "$tmp/" \;
-	find "$dist" -type f -name '*.sha256' -exec cp {} "$tmp/" \;
-	cp "$log" "$tmp/build.log"
+	rm -rf "$tmp" || return 1
+	mkdir -p "$tmp" || return 1
+	format=$(package_format)
+	if [ "$format" = apk ]; then
+		cp -R "$dist/$target/." "$tmp/" || return 1
+	else
+		find "$dist" -type f \( -name '*.tar.gz' -o -name '*.sha256' \) \
+			-exec sh -c 'dest=$1; shift; cp "$@" "$dest/"' sh "$tmp" {} + || return 1
+	fi
+	artifact=$(cd "$tmp" && find . -type f -name "$pkg-$ver-r$rel.$format")
+	[ -n "$artifact" ] && [ "$(printf '%s\n' "$artifact" | wc -l | tr -d ' ')" -eq 1 ] || { rm -rf "$tmp"; warning 'missing or ambiguous primary package'; return 1; }
+	artifact=${artifact#./}
+	(cd "$tmp" && find . -type f \( -name '*.apk' -o -name '*.tar.gz' \) | sort) >"$tmp/files"
+	while IFS= read -r file; do
+		digest=$(sha256_file "$tmp/$file")
+		[ "${#digest}" -eq 64 ] || return 1
+		printf '%s  %s\n' "$digest" "$file" || return 1
+	done <"$tmp/files" >"$tmp/SHA256SUMS"
+	rm "$tmp/files" || return 1
+	verify_artifacts "$tmp" "$artifact" || return 1
+	cp "$log" "$tmp/build.log" || return 1
 	{
 		printf 'pkgname=%s\n' "$pkg"
 		printf 'pkgver=%s\n' "$ver"
 		printf 'pkgrel=%s\n' "$rel"
 		printf 'target=%s\n' "$target"
+		printf 'format=%s\nartifact=%s\n' "$format" "$artifact"
 		printf 'gitrev=%s\n' "$rev"
 		printf 'buildkey=%s\n' "$key"
 		printf 'artifact_url=%s/%s/%s/%s-r%s/%s/\n' "$FPKGS_DL_BASE_URL" "$target" "$pkg" "$ver" "$rel" "$key"
 		printf 'built_at=%s\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
-	} >"$tmp/manifest"
-	mkdir -p "$(dirname "$out")"
-	rm -rf "$out"
+	} >"$tmp/manifest" || return 1
+	mkdir -p "$(dirname "$out")" || return 1
+	rm -rf "$out" || return 1
 	mv "$tmp" "$out"
 }
 

@@ -242,10 +280,13 @@ run_one() {
 	rm -rf "$work"
 	mkdir -p "$dist" "$sysroot"
 	msg "build $relapk for $target ($key)"
-	if (cd "$root" && scripts/build.sh -o "$dist" -s "$sysroot" -t "$target" "$relapk") >"$log" 2>&1; then
-		publish_output "$apk" "$target" "$key" "$dist" "$log" "$rev"
-		msg "published $relapk for $target"
-		return 0
+	set --
+	[ "$(package_format)" != tar.gz ] || set -- -s "$sysroot"
+	if (cd "$root" && scripts/build.sh -f "$(package_format)" -o "$dist" -t "$target" "$@" "$relapk") >"$log" 2>&1; then
+		if publish_output "$apk" "$target" "$key" "$dist" "$log" "$rev"; then
+			msg "published $relapk for $target"
+			return 0
+		fi
 	fi
 	warning "failed $relapk for $target; see $log"
 	return 1

@@ -268,6 +309,32 @@ run() {
 	return "$status"
 }
 
+artifact_path_valid() {
+	case "$1" in
+	'' | /* | .. | ../* | */../* | */.. | *[!a-zA-Z0-9_./+~:-]*) return 1 ;;
+	esac
+}
+
+verify_artifacts() {
+	v_dir=$1
+	v_main=$2
+	if [ ! -f "$v_dir/SHA256SUMS" ]; then
+		# Old tarball publications have only a per-artifact sidecar.
+		[ -f "$v_dir/$v_main.sha256" ] || return 1
+		v_sum=$(awk 'NR == 1 {print $1}' "$v_dir/$v_main.sha256")
+		[ "${#v_sum}" -eq 64 ] && [ "$(sha256_file "$v_dir/$v_main")" = "$v_sum" ]
+		return
+	fi
+	v_seen=0
+	while read -r v_sum v_file; do
+		artifact_path_valid "$v_file" || return 1
+		[ "${#v_sum}" -eq 64 ] && [ -f "$v_dir/$v_file" ] || return 1
+		[ "$(sha256_file "$v_dir/$v_file")" = "$v_sum" ] || return 1
+		[ "${v_file#./}" != "$v_main" ] || v_seen=1
+	done <"$v_dir/SHA256SUMS"
+	[ "$v_seen" -eq 1 ]
+}
+
 # Lookup published manifests rather than recomputing a build key: keys include
 # builder paths and environment, which may differ from the querying machine.
 artifact_status() {

@@ -290,17 +357,24 @@ artifact_status() {
 		[ "$(pkg_field "$s_manifest" gitrev)" = "$s_rev" ] || continue
 		[ "$(pkg_field "$s_manifest" target)" = "$s_target" ] || continue
 		[ "$(pkg_field "$s_manifest" pkgname)" = "$s_pkg" ] || continue
+		s_format=$(pkg_field "$s_manifest" format)
+		s_format=${s_format:-tar.gz}
+		[ -z "${FPKGS_FORMAT:-}" ] || [ "$s_format" = "$(package_format)" ] || continue
 		s_seen=1
+		case "$s_format" in apk | tar.gz) ;; *) continue ;; esac
 		s_dir=${s_manifest%/manifest}
 		s_ver=$(pkg_field "$s_manifest" pkgver)
 		s_rel=$(pkg_field "$s_manifest" pkgrel)
-		s_archive=$s_dir/$s_pkg-$s_ver-r$s_rel.tar.gz
-		[ -f "$s_archive" ] && [ -f "$s_archive.sha256" ] || continue
-		s_expected=$(awk 'NR == 1 {print $1}' "$s_archive.sha256")
-		[ "$(sha256_file "$s_archive")" = "$s_expected" ] || continue
+		s_file=$(pkg_field "$s_manifest" artifact)
+		s_file=${s_file:-$s_pkg-$s_ver-r$s_rel.$s_format}
+		artifact_path_valid "$s_file" || continue
+		s_archive=$s_dir/$s_file
+		[ -f "$s_archive" ] || continue
+		verify_artifacts "$s_dir" "$s_file" || continue
 		s_url=$FPKGS_DL_BASE_URL/$s_target/$s_pkg/$(basename "${s_dir%/*}")/$(basename "$s_dir")
 		printf 'status=published\ngitrev=%s\ntarget=%s\nchecksum=verified\n' "$s_rev" "$s_target"
-		printf 'manifest_url=%s/manifest\nartifact_url=%s/%s\nlog_url=%s/build.log\n' "$s_url" "$s_url" "$(basename "$s_archive")" "$s_url"
+		printf 'format=%s\n' "$s_format"
+		printf 'manifest_url=%s/manifest\nartifact_url=%s/%s\nlog_url=%s/build.log\n' "$s_url" "$s_url" "$s_file" "$s_url"
 		printf 'artifact_path=%s\n' "$s_archive"
 		return 0
 	done
diff --git a/scripts/functions.sh b/scripts/functions.sh
@@ -117,6 +117,30 @@ canonical_os() {
 	esac
 }
 
+# APK is the Linux default; the legacy archive backend remains explicit.
+package_format() {
+	_format=${FPKGS_FORMAT:-}
+	if [ -z "$_format" ]; then
+		case "$(canonical_os)" in
+		Linux) _format=apk ;;
+		*) _format=tar.gz ;;
+		esac
+	fi
+	case "$_format" in
+	apk | tar.gz) printf '%s\n' "$_format" ;;
+	*) die "unsupported package format: $_format (use apk or tar.gz)" ;;
+	esac
+}
+
+default_target() {
+	_native=$(guess_triplet)
+	case "$1:$_native" in
+	apk:*-unknown-linux-gnu | apk:*-unknown-linux-musl)
+		printf '%s-alpine-linux-musl\n' "${_native%%-*}" ;;
+	*) printf '%s\n' "$_native" ;;
+	esac
+}
+
 # ---------------------------------------------------------------------------
 # Recipe resolution: <canonical-os>/ -> Unix/ (skipped on Windows) -> noarch/
 # -> any/. Most-specific-first, matching e.g. Darwin/bmake beating Unix/bmake.
diff --git a/stage0/abuild/README.md b/stage0/abuild/README.md
@@ -8,13 +8,13 @@ Build on the Debian host after provisioning native `apk-tools`, BusyBox,
 fakeroot, scanelf, `bc`, getcap, OpenSSL/zlib development files, pkgconf, and scdoc:
 
 ```sh
-scripts/build.sh stage0/abuild/APKBUILD
+scripts/build.sh -f tar.gz stage0/abuild/APKBUILD
 ```
 
-The existing foundationpkgs builder produces its usual tarball, not a `.deb` or
-APK. `stage0/` is not yet a default recipe-discovery bucket, so use the explicit
-path. This recipe does not change CI, discovery, or the output-format backend.
-The Debian bootstrap `.deb` files live in `bootstrap-binaries`.
+That explicit legacy-format invocation produces a tarball. Linux now defaults
+to real APK output through upstream abuild; use `-f apk` and an explicit target
+for that path. `stage0/` is not a default recipe-discovery bucket, so use the
+explicit recipe path. Debian bootstrap `.deb` files live in `bootstrap-binaries`.
 
 The recipe is also usable by real upstream abuild, with its normal package and
 index signing. When running on Debian, `abuild -d` leaves build dependencies to
diff --git a/tests/apk-backend.sh b/tests/apk-backend.sh
@@ -0,0 +1,165 @@
+#!/bin/sh
+# Offline contracts by default; FPKGS_TEST_REAL_APK=1 exercises real signed APKs.
+set -eu
+root=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
+(
+	. "$root/scripts/functions.sh"
+	unset FPKGS_FORMAT
+	case "$(canonical_os)" in
+	Linux)
+		[ "$(package_format)" = apk ]
+		case "$(default_target apk)" in *-alpine-linux-musl) ;; *) exit 1 ;; esac ;;
+	*) [ "$(package_format)" = tar.gz ] ;;
+	esac
+	FPKGS_FORMAT=tar.gz
+	[ "$(package_format)" = tar.gz ]
+	[ "$(default_target tar.gz)" = "$(guess_triplet)" ]
+)
+work=$(mktemp -d)
+trap 'rm -rf "$work"' EXIT
+trap 'exit 1' HUP INT TERM
+mkdir -p "$work/repo/noarch/fixture" "$work/repo/scripts" "$work/bin"
+cp "$root/scripts/"*.sh "$work/repo/scripts/"
+chmod +x "$work/repo/scripts/"*.sh
+cat >"$work/repo/noarch/fixture/APKBUILD" <<'RECIPE'
+pkgname=fixture
+pkgver=1.0
+pkgrel=0
+pkgdesc="Disposable APK backend test"
+url="https://example.invalid"
+arch="noarch"
+license="MIT"
+subpackages="$pkgname-data"
+source=""
+builddir="$srcdir"
+build() {
+	if cross_compiling; then echo cross >"$srcdir/checked"; fi
+}
+check() { echo checked >"$srcdir/checked"; }
+package() {
+	mkdir -p "$pkgdir/usr/share/fixture"
+	cp "$srcdir/checked" "$pkgdir/usr/share/fixture/checked"
+}
+data() {
+	mkdir -p "$subpkgdir/usr/share/fixture-data"
+	echo data >"$subpkgdir/usr/share/fixture-data/content"
+}
+RECIPE
+if [ "${FPKGS_TEST_REAL_APK:-0}" != 1 ]; then
+	cat >"$work/bin/abuild" <<'STUB'
+#!/bin/sh
+set -eu
+[ "$1" != -V ] || { echo 'abuild contract-test stub'; exit; }
+[ "$#" -eq 1 ] && [ "$1" = -d ]
+[ -n "$CBUILD" ] && [ "$CHOST" = x86_64-alpine-linux-musl ]
+[ -z "${FPKGS_TEST_EXPECT_CBUILD:-}" ] || [ "$CBUILD" = "$FPKGS_TEST_EXPECT_CBUILD" ]
+[ -n "$SRCDEST" ]
+touch generated-only-in-copy
+out=$REPODEST/noarch/x86_64
+mkdir -p "$out"
+printf main >"$out/fixture-1.0-r0.apk"
+printf split >"$out/fixture-data-1.0-r0.apk"
+printf index >"$out/APKINDEX.tar.gz"
+STUB
+	chmod +x "$work/bin/abuild"
+	export FPKGS_ABUILD=$work/bin/abuild
+	# Native musl must not be mistaken for cross compilation just due to vendor.
+	mkdir -p "$work/platform-bin"
+	printf '#!/bin/sh\ncase "$1" in -s) echo Linux ;; -m) echo x86_64 ;; esac\n' >"$work/platform-bin/uname"
+	printf '#!/bin/sh\necho musl\n' >"$work/platform-bin/ldd"
+	chmod +x "$work/platform-bin/"*
+	(unset FPKGS_FORMAT; PATH="$work/platform-bin:$PATH" FPKGS_TEST_EXPECT_CBUILD=x86_64-alpine-linux-musl sh "$root/scripts/build.sh" -o "$work/musl-dist" "$work/repo/noarch/fixture/APKBUILD") >"$work/musl.log" 2>&1 || { cat "$work/musl.log"; exit 1; }
+fi
+export FPKGS_ROOT=$work/repo FPKGS_WORK_ROOT=$work/cache FPKGS_DL_ROOT=$work/published
+export FPKGS_DL_BASE_URL=https://artifacts.invalid
+export FPKGS_FORMAT=apk FPKGS_TARGETS=x86_64-alpine-linux-musl
+if [ "${FPKGS_TEST_REAL_APK:-0}" = 1 ]; then
+	# Upstream intentionally skips execution checks for cross builds.
+	FPKGS_TARGETS=$(. "$root/scripts/functions.sh"; guess_triplet)
+fi
+mkdir -p "$FPKGS_DL_ROOT"
+cd "$work/repo"
+git init -q
+git add .
+git -c user.name=Test -c user.email=test@example.invalid commit -qm fixture
+rev=$(git rev-parse HEAD)
+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" ]
+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 {} \;
+	exit 1
+}
+[ ! -f noarch/fixture/generated-only-in-copy ]
+sh "$cli" status fixture "$FPKGS_TARGETS" "$rev" >"$work/status"
+grep -q '^format=apk$' "$work/status"
+grep -q '/noarch/x86_64/fixture-1.0-r0.apk$' "$work/status"
+archive=$(awk -F= '$1=="artifact_path" {print $2}' "$work/status")
+out=${archive%/noarch/x86_64/*}
+[ -f "$out/noarch/x86_64/fixture-data-1.0-r0.apk" ]
+[ -f "$out/noarch/x86_64/APKINDEX.tar.gz" ]
+if [ "${FPKGS_TEST_REAL_APK:-0}" = 1 ]; then
+	${APK:-apk} verify "$archive" "$out/noarch/x86_64/fixture-data-1.0-r0.apk"
+	tar -xOzf "$archive" usr/share/fixture/checked | grep -q '^checked$'
+	# Also exercise the actual Linux default, including upstream cross semantics.
+	(unset FPKGS_FORMAT; sh scripts/build.sh -o "$work/default-dist" noarch/fixture) >"$work/default.log" 2>&1 || { cat "$work/default.log"; exit 1; }
+	default_archive=$(find "$work/default-dist" -name fixture-1.0-r0.apk)
+	case "$default_archive" in */x86_64-alpine-linux-musl/*) ;; *) exit 1 ;; esac
+	${APK:-apk} verify "$default_archive"
+	tar -xOzf "$default_archive" usr/share/fixture/checked | grep -q '^cross$'
+fi
+sh "$cli" plan "$rev" >"$work/plan"
+grep -q '^skip ' "$work/plan"
+printf corruption >>"$out/noarch/x86_64/fixture-data-1.0-r0.apk"
+code=0
+sh "$cli" status fixture "$FPKGS_TARGETS" "$rev" >"$work/status" || code=$?
+[ "$code" -eq 2 ]
+sh "$cli" plan "$rev" >"$work/plan"
+grep -q '^build ' "$work/plan"
+sh "$cli" run "$rev" >"$work/rebuild.log" 2>&1 || { cat "$work/rebuild.log"; exit 1; }
+sh "$cli" status fixture "$FPKGS_TARGETS" "$rev" >/dev/null
+printf corruption >>"$out/noarch/x86_64/APKINDEX.tar.gz"
+code=0
+sh "$cli" status fixture "$FPKGS_TARGETS" "$rev" >"$work/status" || code=$?
+[ "$code" -eq 2 ]
+if sh scripts/build.sh -f apk -s "$work/unused" noarch/fixture >"$work/rejected" 2>&1; then
+	echo 'Legacy dependency staging unexpectedly accepted for APK' >&2; exit 1
+fi
+if sh scripts/build.sh -f invalid noarch/fixture >"$work/rejected" 2>&1; then
+	echo 'Invalid package format unexpectedly accepted' >&2; exit 1
+fi
+if FPKGS_FORMAT=invalid sh "$cli" plan "$rev" >"$work/rejected" 2>&1; then
+	echo 'Invalid CI package format unexpectedly accepted' >&2; exit 1
+fi
+# A missing tool must fail without creating a successful publication.
+before=$(find "$FPKGS_DL_ROOT" -name manifest | wc -l)
+if FPKGS_ABUILD="$work/absent" sh "$cli" run "$rev" >"$work/failed.log" 2>&1; then
+	echo 'Missing abuild unexpectedly succeeded' >&2; exit 1
+fi
+[ "$before" = "$(find "$FPKGS_DL_ROOT" -name manifest | wc -l)" ]
+# Keep the legacy backend and its flat publication layout working on Linux too.
+cat >noarch/fixture/APKBUILD <<'LEGACY'
+pkgname=fixture
+pkgver=1.0
+pkgrel=0
+arch=noarch
+source=""
+build() { :; }
+package() {
+	mkdir -p "$pkgdir/usr/share/fixture"
+	echo legacy >"$pkgdir/usr/share/fixture/content"
+}
+LEGACY
+git add noarch/fixture/APKBUILD
+git -c user.name=Test -c user.email=test@example.invalid commit -qm legacy
+rev=$(git rev-parse HEAD)
+export FPKGS_FORMAT=tar.gz FPKGS_TARGETS=x86_64-unknown-linux-gnu
+sh "$cli" run "$rev" >"$work/legacy.log" 2>&1 || { cat "$work/legacy.log"; exit 1; }
+sh "$cli" status fixture "$FPKGS_TARGETS" "$rev" >"$work/status"
+grep -q '^format=tar.gz$' "$work/status"
+archive=$(awk -F= '$1=="artifact_path" {print $2}' "$work/status")
+[ -f "$archive" ]
+[ -f "${archive%/*}/manifest" ]
+echo 'PASS: APK/tar dispatch, split/index publication, format-sensitive keys, verified cache, corruption/rebuild, isolation, tool failures'
diff --git a/tests/artifact-status.sh b/tests/artifact-status.sh
@@ -1,6 +1,8 @@
 #!/bin/sh
 # Offline regression check; never contacts CI or modifies the publication root.
 set -eu
+# These fixtures exercise legacy releases, regardless of the caller's format.
+unset FPKGS_FORMAT
 root=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
 work=$(mktemp -d)
 trap 'rm -rf "$work"' EXIT HUP INT TERM
diff --git a/tests/staged-install.sh b/tests/staged-install.sh
@@ -21,7 +21,7 @@ package() {
 	chmod 0750 "$pkgdir" "$pkgdir/usr" "$pkgdir/usr/bin"
 }
 RECIPE
-sh "$root/scripts/build.sh" -o "$work/dist" -s "$work/sysroot" "$work/recipe/APKBUILD" >"$work/build.log" 2>&1
+sh "$root/scripts/build.sh" -f tar.gz -o "$work/dist" -s "$work/sysroot" "$work/recipe/APKBUILD" >"$work/build.log" 2>&1
 archive=$(find "$work/dist" -name '*.tar.gz' -type f)
 [ -f "$archive" ]
 chmod 0700 "$work/target"