forked from heroku/heroku-buildpack-go
/
compile
executable file
·51 lines (42 loc) · 1.01 KB
/
compile
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
#!/bin/sh
##
# usage: bin/compile <build-dir> <cache-dir>
set -e
mkdir -p "$1" "$2"
build=$(cd "$1/" && pwd)
cache=$(cd "$2/" && pwd)
: ${GOVERSION:=release.r59}
# TODO: Check the version exists in src/go
echo "-----> Using Go version $GOVERSION"
GOROOT="$cache/src/go/$GOVERSION"
PATH="$GOROOT/bin:$PATH"
export GOROOT PATH
indent() {
sed 's/^/ /'
}
if [ -f $GOROOT/src/all.bash ]
then
echo "-----> Go version $GOVERSION cached; Skipping clone"
else
echo "-----> Cloning Go version $GOVERSION"
hg clone -r $GOVERSION http://go.googlecode.com/hg $GOROOT 2>&1 | indent
fi
if [ -f $GOROOT/bin/gofmt ]
then
echo "-----> Go version $GOVERSION built; Skipping build"
else
echo "-----> Building Go version $GOVERSION"
(cd $GOROOT/src && ./all.bash > $cache/build.log 2>&1)
fi
if [ -f $build/all.sh ]
then
echo "-----> Running all.sh"
(
# unset git dir or it will mess with goinstall
unset GIT_DIR
cd $build && ./all.sh
) | indent
else
echo "-----> all.sh does not exist; Aborting"
exit 1
fi