| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
function printHelp() { |
| 4 |
>&2 echo "USAGE: $0 -i PATH_TO_SOURCE_TARBALL -o OUTDIR |
| 5 |
|
| 6 |
Emits an archive of influxdb binaries based on the current environment's GOOS and GOARCH. |
| 7 |
Respects CGO_ENABLED. |
| 8 |
|
| 9 |
If the environment variable GO_NEXT is not empty, builds the binaries with the 'next' version of Go. |
| 10 |
" |
| 11 |
} |
| 12 |
|
| 13 |
if [ $# -eq 0 ]; then |
| 14 |
printHelp |
| 15 |
exit 1 |
| 16 |
fi |
| 17 |
|
| 18 |
if [ -z "$GOOS" ] || [ -z "$GOARCH" ]; then |
| 19 |
>&2 echo 'The environment variables $GOOS and $GOARCH must both be set.' |
| 20 |
exit 1 |
| 21 |
fi |
| 22 |
|
| 23 |
SRCDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 24 |
source "$SRCDIR/../_go_versions.sh" |
| 25 |
|
| 26 |
OUTDIR="" |
| 27 |
TARBALL="" |
| 28 |
RACE_FLAG="" |
| 29 |
|
| 30 |
while getopts hi:o:r arg; do |
| 31 |
case "$arg" in |
| 32 |
h) printHelp; exit 1;; |
| 33 |
i) TARBALL="$OPTARG";; |
| 34 |
o) OUTDIR="$OPTARG";; |
| 35 |
r) RACE_FLAG="-r";; |
| 36 |
esac |
| 37 |
done |
| 38 |
|
| 39 |
if [ -z "$OUTDIR" ] || [ -z "$TARBALL" ]; then |
| 40 |
printHelp |
| 41 |
exit 1 |
| 42 |
fi |
| 43 |
|
| 44 |
if [ -z "$GO_NEXT" ]; then |
| 45 |
DOCKER_TAG=latest |
| 46 |
GO_VERSION="$GO_CURRENT_VERSION" |
| 47 |
else |
| 48 |
DOCKER_TAG=next |
| 49 |
GO_VERSION="$GO_NEXT_VERSION" |
| 50 |
fi |
| 51 |
docker build --build-arg "GO_VERSION=$GO_VERSION" -t influxdata/influxdb/releng/raw-binaries:"$DOCKER_TAG" "$SRCDIR" |
| 52 |
|
| 53 |
mkdir -p "$OUTDIR" |
| 54 |
|
| 55 |
docker run --rm \ |
| 56 |
--mount type=bind,source="${OUTDIR}",destination=/out \ |
| 57 |
--mount type=bind,source="${TARBALL}",destination=/influxdb-src.tar.gz,ro=1 \ |
| 58 |
-e GOOS -e GOARCH -e CGO_ENABLED \ |
| 59 |
influxdata/influxdb/releng/raw-binaries:"$DOCKER_TAG" $RACE_FLAG |