# Contributor: Sören Tempel # Maintainer: Eivind Uggedal pkgname=go pkgver=1.7.1 # This should be the latest commit on the corresponding release branch _toolsver="26c35b4dcf6dfcb924e26828ed9f4d028c5ce05a" pkgrel=1 pkgdesc="Go programming language compiler" url="http://www.golang.org/" arch="all" license="BSD" depends="binutils gcc" depends_dev="" makedepends="bash" options="!strip" install="" subpackages="$pkgname-doc $pkgname-tools" source="http://golang.org/dl/go${pkgver/_/}.src.tar.gz $pkgname-tools-${pkgver/_/}.tar.gz::https://github.com/golang/tools/archive/${_toolsver}.tar.gz default-buildmode-pie.patch http://dev.alpinelinux.org/bootstrap/go/go-linux-musl-arm64-bootstrap.tar.bz2 " # NOTE: building go for x86 with grsec kernel requires: # sysctl -w kernel.modify_ldt=1 # use go-bootstrap for archs that are supported case "$CARCH" in aarch64) _goroot_bootstrap="$srcdir"/go-linux-arm64-bootstrap ;; *) makedepends="$makedepends go-bootstrap" _goroot_bootstrap=/usr/lib/go-bootstrap ;; esac _gotools="cover godoc stringer" _tooldir="$srcdir"/tools-${_toolsver} _gocross="darwin freebsd openbsd windows" for os in $_gocross; do subpackages="$subpackages $pkgname-cross-${os}:_crosspkg" done builddir="$srcdir"/$pkgname build() { cd "$builddir/src" export GOPATH="$srcdir" export GOROOT="$builddir" export GOBIN="$GOROOT"/bin export GOROOT_FINAL=/usr/lib/go export GOROOT_BOOTSTRAP="$_goroot_bootstrap" case "$CARCH" in aarch64)export GOARCH="arm64" ;; armhf) export GOARCH="arm" GOARM=6 ;; armv7) export GOARCH="arm" GOARM=7 ;; x86) export GOARCH="386" ;; x86_64) export GOARCH="amd64" ;; *) return 1 ;; esac ./make.bash --no-clean || return 1 for os in $_gocross; do for arch in "386" "amd64"; do GOARCH=$arch GOOS=$os ./make.bash --no-clean || return 1 done done # FIXME some tests fail: # PATH="$GOROOT/bin:$PATH" ./run.bash -no-rebuild || return 1 mkdir -p "$GOPATH"/src/golang.org/x/tools cp -r "$_tooldir"/* "$GOPATH"/src/golang.org/x/tools for tool in $_gotools; do "$GOROOT"/bin/go install \ golang.org/x/tools/cmd/$tool || return 1 done } package() { cd "$builddir" mkdir -p "$pkgdir"/usr/bin "$pkgdir"/usr/lib/go/bin "$pkgdir"/usr/share/doc/go for binary in go gofmt; do mv bin/"$binary" "$pkgdir"/usr/lib/go/bin/ || return 1 ln -s /usr/lib/go/bin/"$binary" "$pkgdir"/usr/bin/ || return 1 done # The source needs to be installed due to an upstream # bug (https://github.com/golang/go/issues/2775). # When this is resolved we can split out the source to a # go-src sub package. cp -a pkg src lib "$pkgdir"/usr/lib/go || return 1 cp -r doc misc "$pkgdir"/usr/share/doc/go || return 1 # 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 \{\} \+ || return 1 find "$pkgdir"/usr/lib/go/src \( -type d -a -name "testdata" \) \ -exec rm -rf \{\} \+ || return 1 find "$pkgdir"/usr/lib/go/src -type f -a \( -name "*.bash" -o -name "*.rc" -o -name "*.bat" \) \ -exec rm -rf \{\} \+ || return 1 rm -rf "$pkgdir"/usr/lib/go/pkg/bootstrap rm -f "$pkgdir"/usr/lib/go/pkg/tool/*/api } tools() { pkgdesc="Go programming language tools" depends="$pkgname" mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/usr/lib/go/bin for binary in "$builddir"/bin/*; do mv $binary "$subpkgdir"/usr/lib/go/bin || return 1 ln -s /usr/lib/go/bin/"${binary##*/}" "$subpkgdir"/usr/bin/ || return 1 done mkdir -p "$subpkgdir"/usr/lib/go/pkg/tool/linux_$GOARCH cp "$subpkgdir"/usr/lib/go/bin/godoc \ "$pkgdir"/usr/lib/go/pkg/tool/linux_$GOARCH/godoc || return 1 for tool in $_gotools; do [ -f "$pkgdir"/usr/lib/go/pkg/tool/linux_$GOARCH/$tool ] \ || continue mv "$pkgdir"/usr/lib/go/pkg/tool/linux_$GOARCH/$tool \ "$subpkgdir"/usr/lib/go/pkg/tool/linux_$GOARCH/$tool || return 1 done } _crosspkg() { local name="$(echo "${subpkgname}" | cut -d '-' -f3)" pkgdesc="Go cross compiler for $name" depends="$pkgname" mkdir -p "$subpkgdir"/usr/lib/go/pkg/tool/ mv "$pkgdir"/usr/lib/go/pkg/tool/${name}_* \ "$subpkgdir"/usr/lib/go/pkg/tool/ || return 1 mv "$pkgdir"/usr/lib/go/pkg/${name}_* \ "$subpkgdir"/usr/lib/go/pkg/ || return 1 } md5sums="433e2158e5c28fe24b11622df393cc46 go1.7.1.src.tar.gz 9e14a20ca24062e0855293bc8d38c00b go-tools-1.7.1.tar.gz 1e3ad4f657ac6c22a92e8fc907893e4f default-buildmode-pie.patch 3bda1b07117ed599a991877465eaffdd go-linux-musl-arm64-bootstrap.tar.bz2" sha256sums="2b843f133b81b7995f26d0cb64bbdbb9d0704b90c44df45f844d28881ad442d3 go1.7.1.src.tar.gz b796a67a568ca0df5a5a9a1870703db281b17907f812b9cf6ff42568f6764275 go-tools-1.7.1.tar.gz f3e5a8e0c1c05c34f489ccbfb65291ab2265fa0ef04b8b501e5c98b17547c4b9 default-buildmode-pie.patch a1d870570317f5e87c606d6bad0d435a594fed802c99475ab306768dc853a029 go-linux-musl-arm64-bootstrap.tar.bz2" sha512sums="eab2b44f44d05c62645756e05078c2a8b7e3c4d2413617a20a6659df22e4612bb2059cf4906ab81134421eb371903034c1b197bb5595c9af9901819b2b3330a3 go1.7.1.src.tar.gz 553be713d03f1a53605c41f67822c75d86dacf9ccba9f2329e111b4178287aee1ddccd3ccc4ab76b9dbcff34f11aeddebce5deac47e715ea75d032bc9ab0355c go-tools-1.7.1.tar.gz 13cd386c38875b951da4057586007f3c67503dc79ddf57befbf763af85ec2cd2a2e6b00614450c179c93f1f8747ee7456ee412adccd08a5f115b33812598a148 default-buildmode-pie.patch da2a33c7bafe11bdad12e755bfe19c9f8ab34ae14899712a0e10da202d5457af419a920be5ffa19cc03d2351194b5c02f1edb595201f81dfb8a51f34b42a8162 go-linux-musl-arm64-bootstrap.tar.bz2"