: 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 
#!/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'