aboutsummaryrefslogtreecommitdiff
path: root/extra/go/build
blob: c051bc2dca50f259c95ae05a5ba4059bc3f6faed (plain)
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
65
66
67
68
69
70
71
#!/bin/sh -e

# Remove bash as a make dependency
patch -p1 < no-bash.patch

# Disable stripping of binaries.
# This breaks Go.
:> nostrip

export CC="${CC:-cc}"
export GOARCH=amd64
export GO_LDFLAGS="-w -s"

[ -f "$CPT_ROOT/var/db/cpt/installed/go/manifest" ] || {
    export GOROOT=$PWD/go1.4-bootstrap
    export GOROOT_FINAL=$PWD/lib/go-bootstrap

    mkdir -p lib/go-bootstrap

    cd "$GOROOT/src"
    ./make.bash
    cd ..
    cp -a bin pkg src ../lib/go-bootstrap
    cd ..
}

export GOROOT_FINAL=/usr/lib/go

if [ -f "$CPT_ROOT/var/db/cpt/go/manifest" ]; then
    export GOROOT_BOOTSTRAP=/usr/lib/go
else
    export GOROOT_BOOTSTRAP=$PWD/lib/go-bootstrap
fi

export GOROOT=$PWD/go-current

(
    cd "$GOROOT/src"
    ./make.bash --no-clean -v
)

cd "$GOROOT"

mkdir -p "$1/usr/bin" "$1/usr/lib/go/bin"

install -m755 "bin/go"    "$1/usr/lib/go/bin/go"
install -m755 "bin/gofmt" "$1/usr/lib/go/bin/gofmt"

ln -s "/usr/lib/go/bin/go"    "$1/usr/bin"
ln -s "/usr/lib/go/bin/gofmt" "$1/usr/bin"

cp -a misc pkg src lib "$1/usr/lib/go"

# Remove unneeded files.
rm -f  "$1/usr/share/go/doc/articles/wiki/get.bin"
rm -f  "$1/usr/lib/go/pkg/tool/"*/api
rm -rf "$1/usr/lib/go/pkg/bootstrap"
rm -rf "$1/usr/lib/go/pkg/obj"

cd "$1/usr/lib/go/src"

# Remove tests.
find . -type f -a -name \*_test.go -delete
find . -type f -a -name \*.bash    -delete
find . -type f -a -name \*.bat     -delete
find . -type f -a -name \*.rc      -delete

find . -type d -a -name testdata |
    while read -r dir; do
        rm -rf "$dir"
    done