Debian Codegraph @

releng/source-tarball/fs/usr/local/bin/influxdb_tarball.bash

raw
1 #!/bin/bash
2
3 function printHelp() {
4 >&2 echo "USAGE: $0 -s INFLUXDB_SHA -b INFLUXDB_BRANCH -v INFLUXDB_VERSION
5
6 Emits a tarball of influxdb source code and dependencies to /out,
7 which must be a mounted volume if you want to access the file.
8
9 If the directory /influxdb-git exists and is mounted,
10 that will be used as the git repository used when cloning influxdb.
11 "
12 }
13
14 if [ $# -eq 0 ]; then
15 printHelp
16 exit 1
17 fi
18
19 SHA=""
20 BRANCH=""
21 VERSION=""
22
23 while getopts hs:b:v: arg; do
24 case "$arg" in
25 h) printHelp; exit 1;;
26 s) SHA="$OPTARG";;
27 b) BRANCH="$OPTARG";;
28 v) VERSION="$OPTARG";;
29 esac
30 done
31
32 if [ -z "$SHA" ] || [ -z "$BRANCH" ] || [ -z "$VERSION" ]; then
33 printHelp
34 exit 1
35 fi
36
37 IPATH=/go/src/github.com/influxdata
38 mkdir -p "$IPATH" && cd "$IPATH"
39 if [ -d /influxdb-git ]; then
40 git clone /influxdb-git "$IPATH/influxdb"
41 else
42
43 git clone https://github.com/influxdata/influxdb.git
44 fi
45
46 cd influxdb
47 git checkout "$SHA"
48 dep ensure -vendor-only
49 cd ..
50
51 # Emit version metadata to appropriate files.
52
53 # Include machine-parseable metadata JSON file.
54 printf '{
55 "version": "%s",
56 "branch": "%s",
57 "sha": "%s"
58 }' "$VERSION" "$BRANCH" "$SHA" > "./influxdb/.metadata.json"
59
60 # Set version info for influxdb binaries.
61
62 printf 'package main
63
64 // Code generated by influxdata/releng tooling. DO NOT EDIT.
65
66 func init() {
67 version = "%s"
68 branch = "%s"
69 commit = "%s"
70 }' "$VERSION" "$BRANCH" "$SHA" > "./influxdb/cmd/influxd/version.generated.go"
71
72
73 # influx uses just version.
74 printf 'package main
75
76 // Code generated by influxdata/releng tooling. DO NOT EDIT.
77
78 func init() {
79 version = "%s"
80 }' "$VERSION" > "./influxdb/cmd/influx/version.generated.go"
81
82 # Prebuild the man pages so that consumers of the source tarball don't have to build it themselves.
83 (cd /go/src/github.com/influxdata/influxdb/man && make build && gzip -9 ./*.1)
84
85 TARBALL_NAME="influxdb-src-$SHA.tar.gz"
86 (cd /go && tar czf "/out/$TARBALL_NAME" --exclude-vcs ./*) # --exclude-vcs is a GNU tar option.
87 (cd /out && md5sum "$TARBALL_NAME" > "$TARBALL_NAME.md5")
88 (cd /out && sha256sum "$TARBALL_NAME" > "$TARBALL_NAME.sha256")