commit 1268dfbd9216e49251a6402d5a4619c8eb15bc35
parent 0481aeaa3ecfcee4749b7e20287adc03ee40241d
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Sun, 13 Sep 2026 19:58:58 +0530
parent 0481aeaa3ecfcee4749b7e20287adc03ee40241d
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Sun, 13 Sep 2026 19:58:58 +0530
Document foundationpkgs usage
2 files changed, 262 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md @@ -1,6 +1,8 @@ # foundationpkgs !TODO Think about renaming the project name? +Quick usage for agents and maintainers is in [`docs/usage.md`](docs/usage.md). + foundationpkgs is a collection of software build scripts written in a spcific APKBUILD format. Instead of following a specific operating systems hier, we use $variables and abstractions whenever possible, making it possible to port it across different operating
diff --git a/docs/usage.md b/docs/usage.md @@ -0,0 +1,260 @@ +# foundationpkgs usage quick reference + +This repository stores package recipes as POSIX-compatible `APKBUILD` files. Treat `APKBUILD` as the source of truth; generated `PKGBUILD` and `*.pacscript` files are intermediates. + +## Repository layout + +Recipes live under applicability buckets: + +```text +Linux/<pkg>/APKBUILD # Linux-specific recipe +Darwin/<pkg>/APKBUILD # macOS-specific recipe +Unix/<pkg>/APKBUILD # generic Unix recipe +noarch/<pkg>/APKBUILD # architecture-independent output +any/<pkg>/APKBUILD # fully generic fallback +x86_64-linux/<pkg>/... # legacy/explicit target bucket also present +pacscripts/ # legacy/generated-style pacstall/Arch scripts +scripts/ # build/conversion/CI helpers +``` + +Recipe lookup order for `scripts/build.sh <pkgname>` is: + +```text +$(canonical_os)/ -> Unix/ -> noarch/ -> any/ +``` + +On Windows, `Unix/` is skipped. + +## Validate scripts after changes + +Run before committing script or CI changes: + +```sh +sh -n scripts/*.sh +scripts/fpkgs-ci.sh plan HEAD | head +``` + +If touching a recipe, run a targeted build when possible. + +## Build one package locally + +By package name: + +```sh +scripts/build.sh authelia-fcgi-authz +``` + +By recipe path: + +```sh +scripts/build.sh x86_64-linux/authelia-fcgi-authz/APKBUILD +scripts/build.sh noarch/movements/APKBUILD +``` + +Choose output directory: + +```sh +scripts/build.sh -o dist noarch/movements/APKBUILD +``` + +Keep temporary workdir for debugging: + +```sh +scripts/build.sh -k noarch/movements/APKBUILD +``` + +Cross-target build: + +```sh +scripts/build.sh -t x86_64-unknown-linux-musl Unix/kcgi/APKBUILD +``` + +Outputs are tarballs, not real apk files, under: + +```text +dist/<target-or-noarch>/<pkgname>-<pkgver>-r<pkgrel>.tar.gz +dist/<target-or-noarch>/<pkgname>-<pkgver>-r<pkgrel>.tar.gz.sha256 +``` + +## CI/package planner + +Plan work for a revision: + +```sh +scripts/fpkgs-ci.sh plan HEAD +scripts/fpkgs-ci.sh plan <git-rev> +``` + +Run builds and publish artifacts: + +```sh +scripts/fpkgs-ci.sh run HEAD +``` + +Print the build key for one recipe/target/rev: + +```sh +scripts/fpkgs-ci.sh key noarch/movements/APKBUILD x86_64-unknown-linux-musl HEAD +``` + +Useful environment variables: + +```sh +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" +``` + +Published artifact layout: + +```text +$FPKGS_DL_ROOT/<target>/<pkgname>/<pkgver>-r<pkgrel>/<buildkey>/ + *.tar.gz + *.sha256 + build.log + manifest +``` + +Public URL is based on `$FPKGS_DL_BASE_URL`. + +## CI integration + +The CI runner is minci. The repo job file is: + +```text +.config/Jobfile +``` + +Current jobs: + +```sh +plan() # runs scripts/fpkgs-ci.sh plan "$FETCH_HEAD" +packages() # runs scripts/fpkgs-ci.sh run "$FETCH_HEAD" +``` + +Gitolite/minci invokes these on pushes to `refs/heads/main`. + +## Convert/install through pacstall helpers + +Convert one APKBUILD to pacscript: + +```sh +scripts/apkbuild-to-pacscript.sh path/to/APKBUILD +``` + +Install through pacstall from APKBUILD source: + +```sh +scripts/pacstall-install.sh <pkgname-or-path> +``` + +## Adding a new recipe + +1. Pick the narrowest correct bucket. +2. Create `<bucket>/<pkg>/APKBUILD`. +3. Keep it POSIX `sh`; no bashisms. +4. Include local source files beside the APKBUILD if needed. +5. Use `source="..."` for remote and local inputs. +6. Add checksums for fixed remote archives when possible. +7. Build locally: + +```sh +scripts/build.sh <bucket>/<pkg>/APKBUILD +``` + +8. Check CI plan: + +```sh +scripts/fpkgs-ci.sh plan HEAD | grep '<pkg>' +``` + +## APKBUILD conventions in this repo + +Minimum shape: + +```sh +pkgname=example +pkgver=0.1.0 +pkgrel=0 +pkgdesc="Short description" +url="https://example.org" +arch="all" # or noarch +license="MIT" +depends="" +makedepends="" +source="..." +options="!check" + +build() { + make +} + +package() { + install -Dm755 example "$pkgdir/usr/bin/example" +} +``` + +Common options: + +```sh +options="!check" # no check phase +options="!build" # recipe has no build phase +options="!check !build" +``` + +Split packages are supported with functions named after the suffix: + +```sh +subpackages="$pkgname-assets" + +assets() { + pkgdesc="Public static assets" + depends="" + install -Dm644 file "$subpkgdir/usr/share/example/file" +} +``` + +Built subpackage tarballs are named: + +```text +<pkgname>-<suffix>-<pkgver>-r<pkgrel>.tar.gz +``` + +## Package examples added for ops + +Authelia FastCGI authorizer: + +```text +x86_64-linux/authelia-fcgi-authz/APKBUILD +``` + +Build: + +```sh +scripts/build.sh x86_64-linux/authelia-fcgi-authz/APKBUILD +``` + +Movements PHP app with split assets package: + +```text +noarch/movements/APKBUILD +``` + +Build: + +```sh +scripts/build.sh noarch/movements/APKBUILD +``` + +Produces base app package and `movements-assets` subpackage. + +## Gotchas + +- Keep scripts POSIX `sh`; avoid arrays, `[[ ]]`, `local`, `pipefail`, process substitution. +- `depends` and `makedepends_host` are staged into the target sysroot. +- `makedepends` and `makedepends_build` are staged into native root and placed on `PATH`. +- If a dependency has no recipe, the build helper assumes it is a host/base tool and warns. +- Changes that affect output must affect the build key. Local files listed in `source` are included in the key. +- Do not commit generated package outputs or CI artifacts.
: nply/foundationpkgs