: nply/foundationpkgs

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
pkgname=minimal-fxa-server
pkgver=0_git20260225
pkgrel=7
# Explicit Debian output opt-in; upstream's underscore version is not Debian-valid.
deb_pkgver=0+git20260225
deb_postinst=debian.postinst
pkgdesc="Minimal Firefox Accounts server and local user management CLI"
url="https://github.com/ahyattdev/minimal-fxa-server"
arch="x86_64 aarch64"
license="MIT"
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
	enforce-pkce.patch
	cli-rpc-timeout.patch
	debian.postinst"
sha256sums="
d336c2d13f58b915dca33a3cd20a9d44239d800fa02b38a19b1ee7fd5efbc08a  $_commit.tar.gz
c7fab781228057577951fa1e61030d305b19035dcdbd7800232ffc32e925ee04  enforce-pkce.patch
c2f1d4240c86a0337dc0b56f268bdeacfe0976ba55592ef647cc2223cc649c82  cli-rpc-timeout.patch
2082b30dae3fdb4f7afa1b00b1623e94c264f80d1d22897ad6a3f1f7ad83adab  debian.postinst
"
builddir="$srcdir/$pkgname-$_commit"

build() {
	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"
	# Explicit exe overrides abuild's default PIE flag: no glibc/musl loader needed.
	# Serial builds fit the small CI host; only the listed patches are applied.
	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 -p 1 -buildmode=exe -mod=readonly ./...
	./fxa-user --help
}

package() {
	cd "$builddir"
	mkdir -p "$pkgdir/usr/bin" "$pkgdir/usr/share/licenses/$pkgname"
	install -m755 minimal-fxa-server fxa-user "$pkgdir/usr/bin/"
	install -m644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}