Subject: [alpine-aports] [PATCH 1/2] main/go-bootstrap: install to /usr/lib/go-bootstrap

From: Sören Tempel <[email-masked]>
Date: Mon, 7 Sep 2015 01:27:54 +0200

To avoid that $GOROOT_BOOTSTRAP equals $GOROOT during main/go build.

See:
- https://github.com/golang/go/commit/f9379eb3467d2b6feb8fb0c7c2c366b81408305d

Also: Cleanup package further and fix removal of _test.go packages.
---
 main/go-bootstrap/APKBUILD | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/main/go-bootstrap/APKBUILD b/main/go-bootstrap/APKBUILD
index 558cb81..eadad50 100644
--- a/main/go-bootstrap/APKBUILD
+++ b/main/go-bootstrap/APKBUILD
@@ -4,18 +4,17 @@
 pkgname=go-bootstrap
 _realname="${pkgname%-*}"
 pkgver=1.4.2
-pkgrel=0
+pkgrel=1
 pkgdesc="Go programming language compiler used for bootstraping"
 url="http://www.golang.org/"
 arch="x86_64 armhf"
 license="BSD"
-replaces="go"
 depends=""
 depends_dev=""
-makedepends="bash perl"
+makedepends="bash"
 options="!strip"
 install=""
-subpackages="$pkgname-doc"
+subpackages=""
 source="
 	https://storage.googleapis.com/golang/go${pkgver}.src.tar.gz
 	no-werror.patch
@@ -41,7 +40,7 @@ build() {
 	export GOPATH="$srcdir"
 	export GOROOT="$_builddir"
 	export GOBIN="$GOROOT"/bin
-	export GOROOT_FINAL=/usr/lib/go
+	export GOROOT_FINAL=/usr/lib/$pkgname
 
 	case "$CARCH" in
 	x86)	export GOARCH="386" ;;
@@ -50,7 +49,6 @@ build() {
 	*)	return 1 ;;
 	esac
 
-	unset CC # ccache breaks build for some reason
 	./make.bash --no-clean || return 1
 
 	# FIXME: race and bench tests fail:
@@ -59,19 +57,20 @@ build() {
 
 package() {
 	cd "$_builddir"
-	mkdir -p "$pkgdir"/usr/bin "$pkgdir"/usr/lib/go "$pkgdir"/usr/share/doc/go
+	mkdir -p "$pkgdir"/usr/lib/$pkgname "$pkgdir"/usr/lib/$pkgname
 
 	# 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-doc sub package.
-	cp -a bin pkg src "$pkgdir"/usr/lib/go || return 1
-	cp -r doc misc "$pkgdir"/usr/share/doc/go || return 1
+	cp -a bin pkg src "$pkgdir"/usr/lib/$pkgname || return 1
 
-	# Remove tests from /usr/lib/go/src.
+	# Remove tests and bashscripts from /usr/lib/go/src.
 	# Those shouldn't be affacted by the upstream bug (see above).
-	find "$pkgdir"/usr/lib/go \( -type f -a -iname '*_test*' \) \
-		-o \( -type d -name 'testdata' \) -exec rm -rf \{\} \+
+	find "$pkgdir"/usr/lib/$pkgname/src \( -type f -a -name "*_test.go" \) \
+		-exec rm -rf \{\} \+ || return 1
+	find "$pkgdir"/usr/lib/$pkgname/src \( -type d -a -name "testdata" \) \
+		-exec rm -rf \{\} \+ || return 1
+	find "$pkgdir"/usr/lib/$pkgname/src \( -type f -a -name "*.bash" \) \
+		-exec rm -rf \{\} \+ || return 1
 }
 
 md5sums="907f85c8fa765d31f7f955836fec4049  go1.4.2.src.tar.gz
-- 
2.5.1

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Sören Tempel <[email-masked]>
Date: Mon, 7 Sep 2015 01:27:55 +0200

Also install go and gofmt binary to /usr/lib/go/bin and symlink it to
/usr/bin. Also fix removal of tests.
---
 main/go/APKBUILD | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/main/go/APKBUILD b/main/go/APKBUILD
index a0c4b60..5fdd612 100644
--- a/main/go/APKBUILD
+++ b/main/go/APKBUILD
@@ -4,12 +4,11 @@ pkgname=go
 pkgver=1.5
 # This should be the latest commit on the corresponding release branch
 _toolsver="d02228d1857b9f49cd0252788516ff5584266eb6"
-pkgrel=0
+pkgrel=1
 pkgdesc="Go programming language compiler"
 url="http://www.golang.org/"
 arch="x86_64 armhf"
 license="BSD"
-replaces="go-bootstrap"
 depends=""
 depends_dev=""
 makedepends="bash go-bootstrap"
@@ -32,7 +31,7 @@ build() {
 	export GOROOT="$_builddir"
 	export GOBIN="$GOROOT"/bin
 	export GOROOT_FINAL=/usr/lib/go
-	export GOROOT_BOOTSTRAP=/usr/lib/go
+	export GOROOT_BOOTSTRAP=/usr/lib/go-bootstrap
 
 	case "$CARCH" in
 	x86)	export GOARCH="386" ;;
@@ -64,8 +63,10 @@ package() {
 	cd "$_builddir"
 	mkdir -p "$pkgdir"/usr/bin "$pkgdir"/usr/lib/go "$pkgdir"/usr/share/doc/go
 
-	install -Dm755 bin/go "$pkgdir"/usr/bin || return 1
-	install -Dm755 bin/gofmt "$pkgdir"/usr/bin || return 1
+	for binary in go gofmt; do
+		install -Dm755 bin/$binary "$pkgdir"/usr/lib/go/bin/$binary || return 1
+		ln -s /usr/lib/go/bin/$binary "$pkgdir"/usr/bin/$binary || return 1
+	done
 
 	# The source needs to be installed due to an upstream
 	# bug (https://github.com/golang/go/issues/2775).
@@ -76,8 +77,15 @@ package() {
 
 	# Remove tests from /usr/lib/go/src.
 	# Those shouldn't be affacted by the upstream bug (see above).
-	find "$pkgdir"/usr/lib/go \( -type f -a -iname '*_test*' \) \
-		-o \( -type d -name 'testdata' \) -exec rm -rf \{\} \+
+	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" \) \
+		-exec rm -rf \{\} \+ || return 1
+
+	# Remove bootstrap files.
+	rm -rf "$pkgdir"/usr/lib/go/pkg/bootstrap
 }
 
 tools() {
-- 
2.5.1

---