PKGBUILD 2.2 KB
Newer Older
1 2
pkgbase=go
pkgname=(go go-pie)
Jeff Huang's avatar
Jeff Huang committed
3 4
pkgver=1.11.4
pkgrel=1
Luca Giambonini's avatar
Luca Giambonini committed
5
arch=(x86_64)
Francesco Marinucci's avatar
Francesco Marinucci committed
6
url='http://golang.org/'
Luca Giambonini's avatar
Luca Giambonini committed
7 8
license=(BSD)
makedepends=(git go)
Chaoting Liu's avatar
Chaoting Liu committed
9 10
source=(https://storage.googleapis.com/golang/go$pkgver.src.tar.gz
        default-buildmode-pie.patch)
Jeff Huang's avatar
Jeff Huang committed
11
sha256sums=('4cfd42720a6b1e79a8024895fa6607b69972e8e32446df76d6ce79801bbadb15'
Chaoting Liu's avatar
Chaoting Liu committed
12
            '9d2f0d201d4e002d74f548cc82bd131139bab5dd62191004c71dd430fdc1666d')
Luca Giambonini's avatar
Luca Giambonini committed
13 14 15 16 17

export GOOS=linux
export GOARCH=amd64
export GOROOT_FINAL=/usr/lib/go
export GOROOT_BOOTSTRAP=/usr/lib/go
18
export GOCACHE=off
Luca Giambonini's avatar
Luca Giambonini committed
19 20

prepare() {
21 22 23
  cp -r $pkgbase ${pkgbase}-pie

  cd ${pkgbase}-pie
Chaoting Liu's avatar
Chaoting Liu committed
24
  patch -p1 -i "$srcdir"/default-buildmode-pie.patch
Luca Giambonini's avatar
Luca Giambonini committed
25
}
26 27

build() {
Francesco Marinucci's avatar
Francesco Marinucci committed
28 29
  export GOPATH="$srcdir/"

30 31 32 33 34 35
  for _pkgname in ${pkgname[@]}; do
    export GOROOT="$srcdir/$_pkgname"
    export GOBIN="$GOROOT/bin"

    cd "$srcdir/$_pkgname/src"
    ./make.bash --no-clean -v
Luca Giambonini's avatar
Luca Giambonini committed
36

37 38 39
    PATH="$GOBIN:$PATH" go install -v -buildmode=shared std
    PATH="$GOBIN:$PATH" go install -v -race std
  done
40 41 42
}

check() {
Luca Giambonini's avatar
Luca Giambonini committed
43 44
  # Run test suite only for unpatched Go as it expects non-PIE ldBuildmode
  export GOROOT="$srcdir/$pkgbase"
Francesco Marinucci's avatar
Francesco Marinucci committed
45
  export GOBIN="$GOROOT/bin"
Luca Giambonini's avatar
Luca Giambonini committed
46 47
  export PATH="$srcdir/$pkgbase/bin:$PATH"
  export GO_TEST_TIMEOUT_SCALE=2
48

Luca Giambonini's avatar
Luca Giambonini committed
49 50
  cd $pkgbase/src
  ./run.bash --no-rebuild -v -v -v -k 
51 52
}

Luca Giambonini's avatar
Luca Giambonini committed
53 54 55
_package() {
  options=(!strip staticlibs)
  cd "$srcdir/$1"
gnastyle's avatar
gnastyle committed
56

Luca Giambonini's avatar
Luca Giambonini committed
57
  install -d "$pkgdir/usr/bin" "$pkgdir/usr/lib/go" "$pkgdir/usr/share/doc/go"
58
  cp -a bin pkg src lib misc api "$pkgdir/usr/lib/go"
Luca Giambonini's avatar
Luca Giambonini committed
59
  cp -r doc/* "$pkgdir/usr/share/doc/go"
gnastyle's avatar
gnastyle committed
60

Luca Giambonini's avatar
Luca Giambonini committed
61 62 63
  ln -sf /usr/lib/go/bin/go "$pkgdir/usr/bin/go"
  ln -sf /usr/lib/go/bin/gofmt "$pkgdir/usr/bin/gofmt"
  ln -sf /usr/share/doc/go "$pkgdir/usr/lib/go/doc"
Francesco Marinucci's avatar
Francesco Marinucci committed
64

Luca Giambonini's avatar
Luca Giambonini committed
65
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/go/LICENSE"
gnastyle's avatar
gnastyle committed
66
  install -Dm644 VERSION "$pkgdir/usr/lib/go/VERSION"
Michael's avatar
Michael committed
67

Luca Giambonini's avatar
Luca Giambonini committed
68 69
  rm -rf "$pkgdir/usr/lib/go/pkg/bootstrap"
  rm -rf "$pkgdir/usr/lib/go/pkg/tool/*/api"
70 71 72

  # TODO: Figure out if really needed
  rm -rf "$pkgdir"/usr/lib/go/pkg/obj/go-build/*
73
}
Chaoting Liu's avatar
Chaoting Liu committed
74

Luca Giambonini's avatar
Luca Giambonini committed
75
package_go() {
76
  pkgdesc='Core compiler tools for the Go programming language'
Luca Giambonini's avatar
Luca Giambonini committed
77 78
  provides=(go-pie)
  conflicts=(go-pie)
gnastyle's avatar
gnastyle committed
79

Luca Giambonini's avatar
Luca Giambonini committed
80
  _package $pkgname
gnastyle's avatar
gnastyle committed
81
}
Luca Giambonini's avatar
Luca Giambonini committed
82

83 84 85 86 87 88 89
package_go-pie() {
  pkgdesc='Core compiler tools for the Go programming language (with PIE enabled by default)'
  provides=(go)
  conflicts=(go)

  _package $pkgname
}