2021-05-05 12:12:34 +02:00
|
|
|
#!/bin/sh
|
2021-05-11 16:15:13 +02:00
|
|
|
# This script is executed by `./mk` when building inside
|
2021-05-06 21:20:45 +02:00
|
|
|
# an Alpine Linux docker container. Using Alpine Linux, which
|
|
|
|
# uses musl libc, allows us to emit static binaries.
|
2021-05-05 12:12:34 +02:00
|
|
|
set -e
|
|
|
|
if [ "$GOARCH" = "" ]; then
|
2021-05-11 16:15:13 +02:00
|
|
|
echo 'fatal: GOARCH is not set' 1>&2
|
|
|
|
exit 1
|
2021-05-05 12:12:34 +02:00
|
|
|
fi
|
|
|
|
set -x
|
|
|
|
apk update
|
|
|
|
apk upgrade
|
|
|
|
apk add --no-progress gcc git linux-headers musl-dev
|
2021-05-11 20:16:27 +02:00
|
|
|
# some of the following exports are redundant but are however
|
|
|
|
# useful because they provide explicit logging
|
|
|
|
export GOARM=$GOARM
|
2021-05-11 16:15:13 +02:00
|
|
|
export GOPATH=$GOPATH
|
|
|
|
export CGO_ENABLED=1
|
|
|
|
export GOOS=linux
|
|
|
|
export GOARCH=$GOARCH
|
|
|
|
go build -o "./CLI/linux/$GOARCH/" -ldflags='-s -w -extldflags "-static"' "$@" ./cmd/ooniprobe
|