-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·64 lines (56 loc) · 1.4 KB
/
build.sh
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
if [ "$BUILD_UID" != "" -a $(whoami) = "root" ]
then
if [ "$BUILD_GID" != "" ]
then
groupadd --gid $BUILD_GID buildgroup
adduser --disabled-password --gecos '' --gid $BUILD_GID --uid $BUILD_UID builduser
chown -R builduser.buildgroup /go
else
adduser --disabled-password --gecos '' --uid $BUILD_UID builduser
chown -R builduser /go
fi
export HOME=/home/builduser
if [ -f /root/.netrc ]
then
cp /root/.netrc $HOME/.netrc
chown builduser $HOME/.netrc
chmod 0600 $HOME/.netrc
fi
exec su -m builduser -c $0 $@
fi
export GOPATH=/go
export PATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
GOSRCDIR="/go/src/$PACKAGE"
if [ "$SRCDIR" != "" -a "$SRCDIR" != "$GOSRCDIR" ]
then
mkdir -p $(dirname "$GOSRCDIR")
ln -s "$SRCDIR" "$GOSRCDIR"
fi
cd /go/src/$PACKAGE
# Run dep or glide if necessary (dep takes precedence)
if [ -f Gopkg.toml ]
then
echo "Running dep ensure..."
dep ensure
RET=$?
if [ $RET -ne 0 ]
then
echo "dep ensure failed with return code $RET"
fi
elif [ -f glide.yaml ]
then
echo "Running glide install..."
glide install
RET=$?
if [ $RET -ne 0 ]
then
echo "glide install failed with return code $RET"
fi
elif [ -f go.mod ]
then
# No Gopkg.toml or glide.yaml so enable Go 1.11 modules
export GO111MODULE=on
fi
echo "Building go project in $(pwd)..."
/usr/local/go/bin/go build -ldflags "-linkmode external -extldflags -static"