2

[alpine-aports] [PATCH] main/go: verify integrity of tools subpackage

Sören Tempel
Details
Message ID
<1439582904-22151-1-git-send-email-soeren+git@soeren-tempel.net>
Sender timestamp
1439582904
DKIM signature
missing
Download raw message
Patch: +20 -19
By downloading a tarball instead of cloning the git repository.
---
 main/go/APKBUILD | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/main/go/APKBUILD b/main/go/APKBUILD
index c9cc1e3..d875802 100644
--- a/main/go/APKBUILD
+++ b/main/go/APKBUILD
@@ -1,19 +1,24 @@
+# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
 # Maintainer: Eivind Uggedal <eivind@uggedal.com>
 pkgname=go
 pkgver=1.4.2
-pkgrel=0
+# This should be the latest commit on the corresponding release branch
+_toolsver="abf43428cc239218424c7a44dc9b5987cd351c3e"
+pkgrel=1
 pkgdesc="Go programming language compiler"
 url="http://www.golang.org/"
 arch="x86 x86_64 armhf"
 license="BSD"
 depends=""
 depends_dev=""
-makedepends="bash perl git"
+makedepends="bash perl"
 options="!strip"
 install=""
 subpackages="$pkgname-tools:tools"
 source="
 	http://golang.org/dl/go${pkgver}.src.tar.gz
+	tools.tar.gz::https://github.com/golang/tools/archive/${_toolsver}.tar.gz
+
 	no-werror.patch
 	no-pic.patch
 	no-longjmp-redefine.patch
@@ -22,8 +27,7 @@ source="
 	"
 
 _builddir="$srcdir"/$pkgname
-_toolrepo=golang.org/x/tools
-_tooltag=release-branch.go${pkgver%.*}
+_tooldir="$srcdir"/tools-${_toolsver}
 
 prepare() {
 	local i
@@ -52,26 +56,22 @@ build() {
 	export GOARCH
 
 	cd "$_builddir/src"
-
 	./make.bash || return 1
 
 	# FIXME: race and bench tests fail:
 	#PATH="$GOROOT/bin:$PATH" ./run.bash --no-rebuild --banner || return 1
 
-	# Build tools provided with the upstream binary distribution:
-	"$GOROOT"/bin/go get -d $_toolrepo/... || reteurn 1
-	(
-		cd "$srcdir"/src/$_toolrepo
-		git checkout -b $_tooltag origin/$_tooltag
-	) || return 1
-	local tool
+	mkdir -p "$GOPATH"/src/golang.org/x/tools
+	cp -r "$_tooldir"/* "$GOPATH"/src/golang.org/x/tools
+
+	local tool=
 	for tool in cover vet godoc; do
-		"$GOROOT"/bin/go install $_toolrepo/cmd/$tool
+		"$GOROOT"/bin/go install golang.org/x/tools/cmd/$tool
 	done
 }
 
 package() {
-	local f d
+	local f= d=
 	cd "$_builddir"
 
 	install -dm755 "$pkgdir"/usr/bin
@@ -83,7 +83,7 @@ package() {
 	cp -a pkg "$pkgdir"/usr/lib/go
 
 	# The source needs to be installed due to an upstream
-	# bug (http://code.google.com/p/go/issues/detail?id=2775).
+	# bug (https://github.com/golang/go/issues/2775).
 	# When this is resolved we can split out the source to a
 	# go-doc sub package.
 	install -dm755 "$pkgdir"/usr/lib/go/src
@@ -95,15 +95,13 @@ package() {
 }
 
 tools() {
-	local tool
-
 	pkgdesc="Go programming language tools"
 	depends="$pkgname"
 
 	install -Dm755 "$_builddir"/bin/godoc "$subpkgdir"/usr/bin/godoc
-
 	install -dm755 "$subpkgdir"/usr/lib/go/pkg/tool/linux_$GOARCH
 
+	local tool=
 	for tool in cover vet; do
 		mv "$pkgdir"/usr/lib/go/pkg/tool/linux_$GOARCH/$tool \
 			"$subpkgdir"/usr/lib/go/pkg/tool/linux_$GOARCH/$tool
@@ -113,24 +111,27 @@ tools() {
 	for tool in cover vet godoc; do
 		install -dm755 "$subpkgdir"/usr/lib/go/src/pkg/$tool
 		sed -e 's/^package main$/package documentation/' \
-			"$srcdir"/src/$_toolrepo/cmd/$tool/doc.go > \
+			"$srcdir"/src/golang.org/x/tools/cmd/$tool/doc.go > \
 			"$subpkgdir"/usr/lib/go/src/pkg/$tool/doc.go
 	done
 }
 
 md5sums="907f85c8fa765d31f7f955836fec4049  go1.4.2.src.tar.gz
+a8bc7ad3d0deff01bd45e4938cc3adb6  tools.tar.gz
 65330c61f6d6c881033b0a95ca228edb  no-werror.patch
 4391be88ce8bacdd7fee433b39635583  no-pic.patch
 93ad940db4a6d51e086f80755eaa8f53  no-longjmp-redefine.patch
 81ac9f3188df7a0c16c52cc4d8cc1ffa  fix-arm-hackery.patch
 fd4d1a7ccb5d37da4ff9c3a2d97aa976  default-sc-getpw-r-size-max.patch"
 sha256sums="299a6fd8f8adfdce15bc06bde926e7b252ae8e24dd5b16b7d8791ed79e7b5e9b  go1.4.2.src.tar.gz
+e754f0e28092f19d70e2c229023ef9b2d935e81ba886ece40e02803a83825f3d  tools.tar.gz
 65d38b9485da2ff9417a2c44a81b6e52cc9bd2727b27e7add10d48a63805d4a3  no-werror.patch
 86fc68a50bc4a9336a003239adf1dcc6d7cabfb9c1bcf09b0d53d09100ceff12  no-pic.patch
 084020e0eb6cb0aceee047bd5962872ed51dbb45465174018d108eb195c26605  no-longjmp-redefine.patch
 fced8436d9c32a43a5cc87f2243529e7a8209ba73a9afd4fd7733245bc55e4e3  fix-arm-hackery.patch
 3757d5f7c4e6d3b2fed4b01c7da6e3e8c0b7789333219ab10ec0b151fb163980  default-sc-getpw-r-size-max.patch"
 sha512sums="cda1a29d4418875dffaf3324004ddae8e1bbb573f7668e6e0c03d8b61284f4db7fca244c181f2859f8ccdd3db6391fb21e0d98a1a9fc15096c15883249d48a9c  go1.4.2.src.tar.gz
+1b4a6fb526029fe7f07a676cf2ee0b9e228e3b3b600e8607b04f129074892a85f39685257ffe25939478044ce1096ce053a283ef2b05465b4e6d8deb10da8e03  tools.tar.gz
 3cf139723e6ff0cbf7aaf76295fe4208f2062f2d4086e36d05cad83919217b5355e0e79b0b515a06a578389301bd07b062cb58b98fc0f9e4badf190cd1c34826  no-werror.patch
 a8e95c3c536a30e15b9bad5e623a085c521739639a58ac638679d99413a1bee8823729783123cbe4495ac42822df31f4776f0380a63786b9f4fc73190e012ae5  no-pic.patch
 3a9b665f8fda89729c4c269ea82f82ee515f0026d26f1d51e2cf84054456e394afc14875e7ed29280a12488907d50c70af313e2e4a5b62c328bbade098db9d4d  no-longjmp-redefine.patch
-- 
2.5.0



---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---

[alpine-aports] [PATCH] main/go: add cross subpackage

Sören Tempel
Details
Message ID
<1439585491-27955-1-git-send-email-soeren+git@soeren-tempel.net>
In-Reply-To
<1439582904-22151-1-git-send-email-soeren+git@soeren-tempel.net> (view parent)
Sender timestamp
1439585491
DKIM signature
missing
Download raw message
Patch: +36 -7
The cross subpackages ships cross compilers for Darwin, FreeBSD, OpenBSD
and Microsoft Windows. Those are not all platforms theoretically
supported by go but I guess those are the most relevant once.

In the future it might be a good idea to add cross compilers for other
platforms and architectures as well but before doing so you probably
want to create one subpackage for each platform otherwise the cross
subpackage gets too big.

My computer is too slow to compile go for all these platforms and
architectures in a timely manner so I only compiled the go cross
compiler for OpenBSD amd64 and OpenBSD i386. In addition to that the
OpenBSD amd64 cross compiler was successfully used to cross compile a
small program.

If you have access to a faster computer then please test this on other
architectures (Darwin, FreeBSD and Microsoft Windows).
---
 main/go/APKBUILD | 43 ++++++++++++++++++++++++++++++++++++-------
 1 file changed, 36 insertions(+), 7 deletions(-)

diff --git a/main/go/APKBUILD b/main/go/APKBUILD
index d875802..46a829c 100644
--- a/main/go/APKBUILD
+++ b/main/go/APKBUILD
@@ -4,7 +4,7 @@ pkgname=go
 pkgver=1.4.2
 # This should be the latest commit on the corresponding release branch
 _toolsver="abf43428cc239218424c7a44dc9b5987cd351c3e"
-pkgrel=1
+pkgrel=2
 pkgdesc="Go programming language compiler"
 url="http://www.golang.org/"
 arch="x86 x86_64 armhf"
@@ -14,7 +14,7 @@ depends_dev=""
 makedepends="bash perl"
 options="!strip"
 install=""
-subpackages="$pkgname-tools:tools"
+subpackages="$pkgname-tools:tools $pkgname-cross:cross"
 source="
 	http://golang.org/dl/go${pkgver}.src.tar.gz
 	tools.tar.gz::https://github.com/golang/tools/archive/${_toolsver}.tar.gz
@@ -44,20 +44,31 @@ build() {
 	export GOROOT="$_builddir"
 	export GOBIN="$GOROOT"/bin
 	export GOROOT_FINAL=/usr/lib/go
+
 	# ccache breaks build for some reason
 	unset CC
 
 	case "$CARCH" in
-	x86) GOARCH=386;;
-	x86_64) GOARCH=amd64;;
-	arm*) GOARCH=arm; export GOARM=6;;
-	*) return 1;;
+	x86)
+		export GOARCH="386" ;;
+	x86_64)
+		export GOARCH="amd64" ;;
+	arm*)
+		export GOARCH="arm"
+		export GOARM="6" ;;
+	*)
+		return 1 ;;
 	esac
-	export GOARCH
 
 	cd "$_builddir/src"
 	./make.bash || return 1
 
+	for os in darwin freebsd openbsd windows; do
+		for arch in "386" "amd64"; do
+			GOARCH=$arch GOOS=$os ./make.bash --no-clean || return 1
+		done
+	done
+
 	# FIXME: race and bench tests fail:
 	#PATH="$GOROOT/bin:$PATH" ./run.bash --no-rebuild --banner || return 1
 
@@ -116,6 +127,24 @@ tools() {
 	done
 }
 
+cross() {
+	pkgdesk="Go cross compilers"
+	depends="$pkgname"
+
+	mkdir -p "$subpkgdir"/usr/lib/go/pkg/tool \
+		"$subpkgdir"/usr/lib/go/src/runtime
+
+	for os in darwin freebsd openbsd windows; do
+		mv "$pkgdir"/usr/lib/go/pkg/tool/${os}_* \
+			"$subpkgdir"/usr/lib/go/pkg/tool || return 1
+		mv "$pkgdir"/usr/lib/go/pkg/${os}_* \
+			"$subpkgdir"/usr/lib/go/pkg || return 1
+		mv "$pkgdir"/usr/lib/go/src/runtime/zasm_${os}*.h \
+			"$subpkgdir"/usr/lib/go/src/runtime || return 1
+	done
+
+}
+
 md5sums="907f85c8fa765d31f7f955836fec4049  go1.4.2.src.tar.gz
 a8bc7ad3d0deff01bd45e4938cc3adb6  tools.tar.gz
 65330c61f6d6c881033b0a95ca228edb  no-werror.patch
-- 
2.5.0



---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---

[alpine-aports] [PATCH] main/go: major cleanup

Sören Tempel
Details
Message ID
<1439592678-12290-1-git-send-email-soeren+git@soeren-tempel.net>
In-Reply-To
<1439585491-27955-1-git-send-email-soeren+git@soeren-tempel.net> (view parent)
Sender timestamp
1439592678
DKIM signature
missing
Download raw message
Patch: +33 -51
---
 main/go/APKBUILD | 84 ++++++++++++++++++++++----------------------------------
 1 file changed, 33 insertions(+), 51 deletions(-)

diff --git a/main/go/APKBUILD b/main/go/APKBUILD
index 46a829c..62d891b 100644
--- a/main/go/APKBUILD
+++ b/main/go/APKBUILD
@@ -4,7 +4,7 @@ pkgname=go
 pkgver=1.4.2
 # This should be the latest commit on the corresponding release branch
 _toolsver="abf43428cc239218424c7a44dc9b5987cd351c3e"
-pkgrel=2
+pkgrel=3
 pkgdesc="Go programming language compiler"
 url="http://www.golang.org/"
 arch="x86 x86_64 armhf"
@@ -14,7 +14,7 @@ depends_dev=""
 makedepends="bash perl"
 options="!strip"
 install=""
-subpackages="$pkgname-tools:tools $pkgname-cross:cross"
+subpackages="$pkgname-doc $pkgname-tools $pkgname-cross"
 source="
 	http://golang.org/dl/go${pkgver}.src.tar.gz
 	tools.tar.gz::https://github.com/golang/tools/archive/${_toolsver}.tar.gz
@@ -26,44 +26,39 @@ source="
 	default-sc-getpw-r-size-max.patch
 	"
 
+_gotools="cover vet godoc"
+_gocross="darwin freebsd openbsd windows"
+
 _builddir="$srcdir"/$pkgname
 _tooldir="$srcdir"/tools-${_toolsver}
 
 prepare() {
-	local i
 	cd "$_builddir"
 	for i in $source; do
 		case $i in
-		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+		*.patch) patch -p1 -i "$srcdir"/$i || return 1 ;;
 		esac
 	done
 }
 
 build() {
+	cd "$_builddir/src"
+	unset CC # ccache breaks build for some reason
+
 	export GOPATH="$srcdir"
 	export GOROOT="$_builddir"
 	export GOBIN="$GOROOT"/bin
 	export GOROOT_FINAL=/usr/lib/go
 
-	# ccache breaks build for some reason
-	unset CC
-
 	case "$CARCH" in
-	x86)
-		export GOARCH="386" ;;
-	x86_64)
-		export GOARCH="amd64" ;;
-	arm*)
-		export GOARCH="arm"
-		export GOARM="6" ;;
-	*)
-		return 1 ;;
+	x86)	export GOARCH="386" ;;
+	x86_64)	export GOARCH="amd64" ;;
+	arm*)	export GOARCH="arm" ;;
+	*)	return 1 ;;
 	esac
 
-	cd "$_builddir/src"
-	./make.bash || return 1
-
-	for os in darwin freebsd openbsd windows; do
+	./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
@@ -75,55 +70,43 @@ build() {
 	mkdir -p "$GOPATH"/src/golang.org/x/tools
 	cp -r "$_tooldir"/* "$GOPATH"/src/golang.org/x/tools
 
-	local tool=
-	for tool in cover vet godoc; do
-		"$GOROOT"/bin/go install golang.org/x/tools/cmd/$tool
+	for tool in $_gotools; do
+		"$GOROOT"/bin/go install \
+			golang.org/x/tools/cmd/$tool || return 1
 	done
 }
 
 package() {
-	local f= d=
 	cd "$_builddir"
+	mkdir -p "$pkgdir"/usr/bin "$pkgdir"/usr/lib/go "$pkgdir"/usr/share/doc/go
 
-	install -dm755 "$pkgdir"/usr/bin
-	for f in go gofmt; do
-		install -m755 bin/$f "$pkgdir"/usr/bin
-	done
-
-	install -dm755 "$pkgdir"/usr/lib/go
-	cp -a pkg "$pkgdir"/usr/lib/go
+	install -Dm755 bin/go "$pkgdir"/usr/bin || return 1
+	install -Dm755 bin/gofmt "$pkgdir"/usr/bin || return 1
 
 	# 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.
-	install -dm755 "$pkgdir"/usr/lib/go/src
-	for p in src/*; do
-		if [ -d "$p" ]; then
-			cp -r $p "$pkgdir"/usr/lib/go/src
-		fi
-	done
+	cp -a pkg src "$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 \( -type f -a -iname '*_test*' \) \
+		-o \( -type d -name 'testdata' \) -exec rm -rf \{\} \+
 }
 
 tools() {
 	pkgdesc="Go programming language tools"
 	depends="$pkgname"
 
-	install -Dm755 "$_builddir"/bin/godoc "$subpkgdir"/usr/bin/godoc
 	install -dm755 "$subpkgdir"/usr/lib/go/pkg/tool/linux_$GOARCH
+	install -Dm755 "$_builddir"/bin/godoc \
+		"$pkgdir"/usr/lib/go/pkg/tool/linux_$GOARCH/$tool
 
-	local tool=
-	for tool in cover vet; do
+	for tool in $_gotools; do
 		mv "$pkgdir"/usr/lib/go/pkg/tool/linux_$GOARCH/$tool \
-			"$subpkgdir"/usr/lib/go/pkg/tool/linux_$GOARCH/$tool
-	done
-
-	# Make documentation for tools available through godoc:
-	for tool in cover vet godoc; do
-		install -dm755 "$subpkgdir"/usr/lib/go/src/pkg/$tool
-		sed -e 's/^package main$/package documentation/' \
-			"$srcdir"/src/golang.org/x/tools/cmd/$tool/doc.go > \
-			"$subpkgdir"/usr/lib/go/src/pkg/$tool/doc.go
+			"$subpkgdir"/usr/lib/go/pkg/tool/linux_$GOARCH/$tool || return 1
 	done
 }
 
@@ -134,7 +117,7 @@ cross() {
 	mkdir -p "$subpkgdir"/usr/lib/go/pkg/tool \
 		"$subpkgdir"/usr/lib/go/src/runtime
 
-	for os in darwin freebsd openbsd windows; do
+	for os in $_gocross; do
 		mv "$pkgdir"/usr/lib/go/pkg/tool/${os}_* \
 			"$subpkgdir"/usr/lib/go/pkg/tool || return 1
 		mv "$pkgdir"/usr/lib/go/pkg/${os}_* \
@@ -142,7 +125,6 @@ cross() {
 		mv "$pkgdir"/usr/lib/go/src/runtime/zasm_${os}*.h \
 			"$subpkgdir"/usr/lib/go/src/runtime || return 1
 	done
-
 }
 
 md5sums="907f85c8fa765d31f7f955836fec4049  go1.4.2.src.tar.gz
-- 
2.5.0



---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---