0d57899f46
See https://github.com/ooni/probe/issues/2119 While there, shrink the Makefile to only export the minimum set of rules to comfortable build using GHA.
61 lines
1.4 KiB
Bash
Executable File
61 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
if [[ $# -lt 2 ]]; then
|
|
echo "" 1>&2
|
|
echo "Compiler for a Go PACKAGE producing static linux/OONIARCH binaries." 1>&2
|
|
echo "" 1>&2
|
|
echo "usage: $0 OONIARCH PACKAGE..." 1>&2
|
|
echo "" 1>&2
|
|
echo "OONIARCH must be one of: 386, amd64, arm64, armv6, armv7." 1>&2
|
|
echo "" 1>&2
|
|
echo "Features:" 1>&2
|
|
echo "" 1>&2
|
|
echo "* automatically sets -tags=ooni_psiphon_config when possible;" 1>&2
|
|
echo "" 1>&2
|
|
echo "* if GOLANG_EXTRA_FLAGS is set, pass it to the Go compiler." 1>&2
|
|
echo "" 1>&2
|
|
echo "Example:" 1>&2
|
|
echo "" 1>&2
|
|
echo " ./CLI/go-build-linux-static arm64 ./internal/cmd/miniooni" 1>&2
|
|
echo "" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
GOLANG_DOCKER_IMAGE=golang:$(cat GOVERSION)-alpine
|
|
GOOS=linux
|
|
OONIARCH=$1
|
|
shift
|
|
|
|
if [[ $OONIARCH == armv7 ]]; then
|
|
GOARCH=arm
|
|
GOARM=7
|
|
DOCKER_ARCH=arm/v7
|
|
elif [[ $OONIARCH == armv6 ]]; then
|
|
GOARCH=arm
|
|
GOARM=6
|
|
DOCKER_ARCH=arm/v6
|
|
else
|
|
GOARCH=$OONIARCH
|
|
GOARM=
|
|
DOCKER_ARCH=$OONIARCH
|
|
fi
|
|
|
|
if [[ -f ./internal/engine/psiphon-config.json.age &&
|
|
-f ./internal/engine/psiphon-config.key ]]; then
|
|
OONI_PSIPHON_TAGS=ooni_psiphon_config
|
|
else
|
|
OONI_PSIPHON_TAGS=""
|
|
fi
|
|
|
|
set -x
|
|
|
|
docker pull --platform linux/$DOCKER_ARCH $GOLANG_DOCKER_IMAGE
|
|
|
|
docker run --platform linux/$DOCKER_ARCH \
|
|
-e GOARM=$GOARM -e GOOS=$GOOS -e GOARCH=$GOARCH \
|
|
-e OONI_PSIPHON_TAGS=$OONI_PSIPHON_TAGS \
|
|
-e OONIARCH=$OONIARCH -e GOLANG_EXTRA_FLAGS="${GOLANG_EXTRA_FLAGS:-}" \
|
|
-v $(pwd):/ooni -w /ooni $GOLANG_DOCKER_IMAGE ./CLI/go-build-alpine "$@"
|