forked from flannel-io/flannel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·38 lines (32 loc) · 884 Bytes
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash -e
function linker_dashX {
local version=$(go version)
local regex="go([0-9]+).([0-9]+)."
if [[ $version =~ $regex ]]; then
if [ ${BASH_REMATCH[1]} -eq "1" -a ${BASH_REMATCH[2]} -le "4" ]; then
echo "$1 \"$2\""
else
echo "$1=$2"
fi
else
echo "could not determine Go version"
exit 1
fi
}
ORG_PATH="github.com/coreos"
REPO_PATH="${ORG_PATH}/flannel"
VERSION=$(git describe --dirty)
GLDFLAGS="-X $(linker_dashX github.com/coreos/flannel/version.Version ${VERSION})"
if [ ! -h gopath/src/${REPO_PATH} ]; then
mkdir -p gopath/src/${ORG_PATH}
ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255
fi
export GOBIN=${PWD}/bin
export GOPATH=${PWD}/gopath
eval $(go env)
if [ ${GOOS} = "linux" ]; then
echo "Building flanneld..."
go build -o ${GOBIN}/flanneld -ldflags "${GLDFLAGS}" ${REPO_PATH}
else
echo "Not on Linux - skipping flanneld build"
fi