summaryrefslogtreecommitdiff
path: root/repo/go/go.xibuild
blob: 585a2d08360db67c940b631eb6a25510144b24f4 (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
#!/bin/sh

# Ensure we have gcc-go
MAKEDEPS="make gcc"
DEPS=""

PKG_VER=1.20.3
SOURCE=https://go.dev/dl/go$PKG_VER.src.tar.gz

BOOTSTRAP="go-linux-amd64-bootstrap-1.19.1"
ADDITIONAL="
    https://dev.gentoo.org/~williamh/dist/$BOOTSTRAP.tbz
"

DESC="Core compiler tools for the Go programming language"

prepare () {
    export TMPDIR=/tmp
    tar -xvf $BOOTSTRAP.tbz
    mv go-linux-amd64-bootstrap $BOOTSTRAP
}

build () {
    export sourceroot=$(pwd)
    export GOARCH=amd64
    export GOAMD64=v1 # make sure we're building for the right x86-64 version
    export GOOS="linux"

    cd $BOOTSTRAP
    cd src
    echo "~~~~BUILDING BOOTSTRAP"
    CGO_ENABLED=0 ./make.bash -v || return 1
    
    cd $sourceroot
    export GOROOT_BOOTSTRAP="$(pwd)/$BOOTSTRAP"

    echo "~~~~BUILDING GOLANG"
    cd src
    if [ ! -z "${GOROOT_BOOTSTRAP}" ]; then
        ./bootstrap.bash -v || return 1
    fi
    ./make.bash -v || reutrn 1 
    cd ..
}

package () {
  install -d "$PKG_DEST/usr/bin" "$PKG_DEST/usr/lib/go" "$PKG_DEST/usr/share/doc/go" \
    "$PKG_DEST/usr/lib/go/pkg/linux_amd64_"dynlink \
    "$PKG_DEST/usr/lib/go/pkg/linux_amd64_"race

  cp -a bin pkg src lib misc api test "$PKG_DEST/usr/lib/go"
  cp -r doc/* "$PKG_DEST/usr/share/doc/go"

  ln -sf /usr/lib/go/bin/go "$PKG_DEST/usr/bin/go"
  ln -sf /usr/lib/go/bin/gofmt "$PKG_DEST/usr/bin/gofmt"
  ln -sf /usr/share/doc/go "$PKG_DEST/usr/lib/go/doc"

  install -Dm644 VERSION "$PKG_DEST/usr/lib/go/VERSION"

  rm -rf "$PKG_DEST/usr/lib/go/pkg/bootstrap" "$PKG_DEST/usr/lib/go/pkg/tool/*/api"

  # TODO: Figure out if really needed
  rm -rf "$PKG_DEST"/usr/lib/go/pkg/obj/go-build/*

  install -Dm644 LICENSE "$PKG_DEST/usr/share/licenses/$pkgname/LICENSE"
}