# Contributor: Sören Tempel # Maintainer: Natanael Copa pkgname=go pkgver=1.11 pkgrel=3 pkgdesc="Go programming language compiler" url="http://www.golang.org/" arch="all" license="BSD" depends="binutils gcc" depends_dev="" makedepends="bash go-bootstrap" install="" subpackages="$pkgname-doc" source="https://golang.org/dl/go${pkgver/_/}.src.tar.gz default-buildmode-pie.patch set-external-linker.patch " # secfixes: # 1.9.4-r0: # - CVE-2018-6574 # NOTE: building go for x86 with grsec kernel requires: # sysctl -w kernel.modify_ldt=1 if [ "$CBUILD" = "$CTARGET" ]; then makedepends="go-bootstrap $makedepends" provides="go-bootstrap=$pkgver-r$pkgrel" subpackages="$subpackages" else pkgname="go-bootstrap" makedepends="go $makedepends" # Go expect host linker instead of the cross-compiler export CC_FOR_TARGET="$CC" export CC="${HOSTLD:-gcc}" export CXX="${HOSTLD:-g++}" export LD="${HOSTLD:-ld}" fi case "$CTARGET_ARCH" in aarch64)export GOARCH="arm64" ;; armhf) export GOARCH="arm" GOARM=6 ;; armv7) export GOARCH="arm" GOARM=7 ;; s390x) export GOARCH="s390x" ;; x86) export GOARCH="386" GO386=387 ;; x86_64) export GOARCH="amd64" ;; ppc64le) export GOARCH="ppc64le" ;; mips) export GOARCH="mips" ;; mips64) export GOARCH="mips64" ;; mips64el) export GOARCH="mips64le" ;; mipsel) export GOARCH="mipsle" ;; *) die "Unsupported arch" ;; esac builddir="$srcdir"/go build() { cd "$builddir/src" export GOOS="linux" export GOPATH="$srcdir" export GOROOT="$builddir" export GOBIN="$GOROOT"/bin export GOROOT_FINAL=/usr/lib/go local p; for p in /usr/lib/go-bootstrap /usr/lib/go-linux-$GOARCH-bootstrap /usr/lib/go; do if [ -d "$p" ]; then export GOROOT_BOOTSTRAP="$p" break fi done ./make.bash # copied from bootstrap.bash to fixup cross-built bootstrap go if [ "$CBUILD" != "$CTARGET" ]; then local gohostos="$(../bin/go env GOHOSTOS)" local gohostarch="$(../bin/go env GOHOSTARCH)" mv ../bin/*_*/* ../bin rmdir ../bin/*_* rm -rf "../pkg/${gohostos}_${gohostarch}"* "../pkg/tool/${gohostos}_${gohostarch}"* rm -rf ../pkg/bootstrap ../pkg/obj fi # FIXME some tests fail: # PATH="$GOROOT/bin:$PATH" ./run.bash -no-rebuild } check() { cd "$builddir" ./bin/go run doc/play/hello.go } package() { cd "$builddir" mkdir -p "$pkgdir"/usr/bin "$pkgdir"/usr/lib/go/bin "$pkgdir"/usr/share/doc/go for binary in go gofmt; do install -Dm755 bin/"$binary" "$pkgdir"/usr/lib/go/bin/"$binary" ln -s /usr/lib/go/bin/"$binary" "$pkgdir"/usr/bin/ done cp -a pkg lib "$pkgdir"/usr/lib/go cp -r doc misc "$pkgdir"/usr/share/doc/go rm -rf "$pkgdir"/usr/lib/go/pkg/obj rm -rf "$pkgdir"/usr/lib/go/pkg/bootstrap rm -f "$pkgdir"/usr/lib/go/pkg/tool/*/api mkdir -p "$pkgdir"/usr/lib/go/ cp -a "$builddir"/src "$pkgdir"/usr/lib/go # Remove tests from /usr/lib/go/src. # Those shouldn't be affacted by the upstream bug (see above). find "$pkgdir"/usr/lib/go/src \( -type f -a -name "*_test.go" \) \ -exec rm -rf \{\} \+ find "$pkgdir"/usr/lib/go/src \( -type d -a -name "testdata" \) \ -exec rm -rf \{\} \+ find "$pkgdir"/usr/lib/go/src -type f -a \( -name "*.bash" -o -name "*.rc" -o -name "*.bat" \) \ -exec rm -rf \{\} \+ } sha512sums="2758b7924b4b8cffc30b56fbf039b8e23d1a3c42506ed4997bd64531ba742e2c60e95d1fa70cae2ccda45d1959fadccfd2404af87d962530e4b1d3556c4aaf43 go1.11.src.tar.gz effff60c1fb4ff18f1be1d34b4fa326a284b2197d0e9151223d19062dd315fde3d565ce2193aa53f7481c6542eb56daef834a3526957b65a275400f9af5d21b3 default-buildmode-pie.patch faf8de430df185842902322f064254f3e9ecee0884b3075b5550c85da15ff61ea6c2bb8d0fb7cf3887abc0e40974bd73ee8f8c14da7f914dde7e9220177c4e2a set-external-linker.patch"