Debian Codegraph @

releng/source-tarball/build.bash

raw
1 #!/bin/bash
2
3 function printHelp() {
4 >&2 echo \
5 "USAGE: $0 [-p INFLUXDB_GIT_DIR]
6 -s INFLUXDB_SHA -b INFLUXDB_BRANCH -v INFLUXDB_VERSION -o OUTDIR
7
8 Emits a tarball of influxdb source code and dependencies to OUTDIR.
9
10 If using -p flag, directory containing influxdb source code will be used as source of truth.
11 This is helpful if you have local commits that have not been pushed.
12 "
13 }
14
15 if [ $# -eq 0 ]; then
16 printHelp
17 exit 1
18 fi
19
20 SRCDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
21 source "$SRCDIR/../_go_versions.sh"
22
23 SHA=""
24 BRANCH=""
25 VERSION=""
26 OUTDIR=""
27
28 # These variables may expand to command arguments. Don't double quote them when used later.
29 INFLUXDB_GIT_MOUNT=""
30
31
32 while getopts hs:b:v:o:p: arg; do
33 case "$arg" in
34 h) printHelp; exit 1;;
35 s) SHA="$OPTARG";;
36 b) BRANCH="$OPTARG";;
37 v) VERSION="$OPTARG";;
38 o) OUTDIR="$OPTARG";;
39 p) INFLUXDB_GIT_MOUNT="--mount type=bind,src=$OPTARG,dst=/influxdb-git,ro=1";;
40 esac
41 done
42
43 if [ -z "$OUTDIR" ]; then
44 # Not bothering to check the other variables since they're checked in the inner docker script.
45 printHelp
46 exit 1
47 fi
48
49 # Only build with GO_CURRENT_VERSION. No need to build source tarball with next version of Go.
50 docker build --build-arg "GO_VERSION=$GO_CURRENT_VERSION" -t influxdata/influxdb/releng/source-tarball:latest "$SRCDIR"
51
52 mkdir -p "$OUTDIR"
53
54 docker run --rm \
55 $INFLUXDB_GIT_MOUNT \
56 --mount "type=bind,src=${OUTDIR},dst=/out" \
57 influxdata/influxdb/releng/source-tarball:latest \
58 -s "$SHA" \
59 -b "$BRANCH" \
60 -v "$VERSION"