aboutsummaryrefslogtreecommitdiffstats
path: root/main/go/APKBUILD
blob: a0c4b6063b3a3ea17d1dd8b5ac0ea97d78401139 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Eivind Uggedal <eivind@uggedal.com>
pkgname=go
pkgver=1.5
# This should be the latest commit on the corresponding release branch
_toolsver="d02228d1857b9f49cd0252788516ff5584266eb6"
pkgrel=0
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"
options="!strip"
install=""
subpackages="$pkgname-doc $pkgname-tools $pkgname-cross"
source="http://golang.org/dl/go${pkgver}.src.tar.gz
	golang-tools-$pkgver.tar.gz::https://github.com/golang/tools/archive/${_toolsver}.tar.gz"

_gotools="cover vet godoc"
_gocross="darwin freebsd openbsd windows"

_builddir="$srcdir"/$pkgname
_tooldir="$srcdir"/tools-${_toolsver}

build() {
	cd "$_builddir/src"

	export GOPATH="$srcdir"
	export GOROOT="$_builddir"
	export GOBIN="$GOROOT"/bin
	export GOROOT_FINAL=/usr/lib/go
	export GOROOT_BOOTSTRAP=/usr/lib/go

	case "$CARCH" in
	x86)	export GOARCH="386" ;;
	x86_64)	export GOARCH="amd64" ;;
	arm*)	export GOARCH="arm" ;;
	*)	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 "$pkgdir"/usr/share/doc/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.
	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 "$subpkgdir"/usr/lib/go/pkg/tool/linux_$GOARCH
	install -Dm755 "$_builddir"/bin/godoc \
		"$pkgdir"/usr/lib/go/pkg/tool/linux_$GOARCH/$tool

	for tool in $_gotools; do
		mv "$pkgdir"/usr/lib/go/pkg/tool/linux_$GOARCH/$tool \
			"$subpkgdir"/usr/lib/go/pkg/tool/linux_$GOARCH/$tool || return 1
	done
}

cross() {
	pkgdesk="Go cross compilers"
	depends="$pkgname"

	mkdir -p "$subpkgdir"/usr/lib/go/pkg/tool
	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}_* \
			"$subpkgdir"/usr/lib/go/pkg || return 1
	done
}

md5sums="3f072baece07fa42d18376419afad323  go1.5.src.tar.gz
c64b28ba5df8499bcc19adc995da991a  golang-tools-1.5.tar.gz"
sha256sums="be81abec996d5126c05f2d36facc8e58a94d9183a56f026fc9441401d80062db  go1.5.src.tar.gz
80db6fc563df50eb924dbf4f96cef287fc6b89cc8b98595c1dac3c80a118f290  golang-tools-1.5.tar.gz"
sha512sums="dac657d3ce8226e247449ce8b0bf34bcacd2479764e29f04562bd07af0bd054a4b3b8d309898dc0775450005c9d077fd4cebb3d1831c9a09d3f093579e32d54f  go1.5.src.tar.gz
80813c2da74c7b25fa2cfd15b2505757e7f466469ac701cb22d190dc83a607f091c4dea207a2e371e53d7a1f5459e7b53e5eea53c95565e958a6eb7fcb212359  golang-tools-1.5.tar.gz"