Gentoo Archives: gentoo-commits

From: William Hubbs <williamh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/go/
Date: Wed, 25 Nov 2015 00:46:40
Message-Id: 1448412297.bd0ca9eeb6ed3c7dad64cb44b65fea3012f587c6.williamh@gentoo
1 commit: bd0ca9eeb6ed3c7dad64cb44b65fea3012f587c6
2 Author: William Hubbs <williamh <AT> gentoo <DOT> org>
3 AuthorDate: Wed Nov 25 00:42:00 2015 +0000
4 Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
5 CommitDate: Wed Nov 25 00:44:57 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bd0ca9ee
7
8 dev-lang/go: rev bump to install binaries correctly
9
10 Now we install the binaries in /usr/lib/go along with the rest of the Go
11 tree and use symlinks in /usr/bin to point to them.
12
13 dev-lang/go/go-1.5.1-r1.ebuild | 213 +++++++++++++++++++++++++++++++++++++++++
14 1 file changed, 213 insertions(+)
15
16 diff --git a/dev-lang/go/go-1.5.1-r1.ebuild b/dev-lang/go/go-1.5.1-r1.ebuild
17 new file mode 100644
18 index 0000000..29d8207
19 --- /dev/null
20 +++ b/dev-lang/go/go-1.5.1-r1.ebuild
21 @@ -0,0 +1,213 @@
22 +# Copyright 1999-2015 Gentoo Foundation
23 +# Distributed under the terms of the GNU General Public License v2
24 +# $Id$
25 +
26 +EAPI=5
27 +
28 +export CBUILD=${CBUILD:-${CHOST}}
29 +export CTARGET=${CTARGET:-${CHOST}}
30 +
31 +inherit eutils toolchain-funcs
32 +
33 +if [[ ${PV} = 9999 ]]; then
34 + EGIT_REPO_URI="git://github.com/golang/go.git"
35 + inherit git-r3
36 +else
37 + SRC_URI="https://storage.googleapis.com/golang/go${PV}.src.tar.gz"
38 + # go-bootstrap-1.4 only supports go on amd64, arm and x86 architectures.
39 + # Allowing other bootstrap options would enable arm64 and ppc64 builds.
40 + KEYWORDS="-* ~amd64 ~arm ~x86 ~amd64-fbsd ~x86-fbsd ~x64-macos ~x86-macos"
41 +fi
42 +
43 +DESCRIPTION="A concurrent garbage collected and typesafe programming language"
44 +HOMEPAGE="http://www.golang.org"
45 +
46 +LICENSE="BSD"
47 +SLOT="0/${PV}"
48 +IUSE=""
49 +
50 +DEPEND=">=dev-lang/go-bootstrap-1.4.1"
51 +RDEPEND="!<dev-go/go-tools-0_pre20150902"
52 +
53 +# These test data objects have writable/executable stacks.
54 +QA_EXECSTACK="usr/lib/go/src/debug/elf/testdata/*.obj"
55 +
56 +REQUIRES_EXCLUDE="/usr/lib/go/src/debug/elf/testdata/*"
57 +
58 +# The tools in /usr/lib/go should not cause the multilib-strict check to fail.
59 +QA_MULTILIB_PATHS="usr/lib/go/pkg/tool/.*/.*"
60 +
61 +# The go language uses *.a files which are _NOT_ libraries and should not be
62 +# stripped. The test data objects should also be left alone and unstripped.
63 +STRIP_MASK="/usr/lib/go/pkg/*.a
64 + /usr/lib/go/src/debug/elf/testdata/*
65 + /usr/lib/go/src/debug/dwarf/testdata/*
66 + /usr/lib/go/src/runtime/race/*.syso"
67 +
68 +if [[ ${PV} != 9999 ]]; then
69 + S="${WORKDIR}"/go
70 +fi
71 +
72 +go_arch()
73 +{
74 + # By chance most portage arch names match Go
75 + local portage_arch=$(tc-arch $@)
76 + case "${portage_arch}" in
77 + x86) echo 386;;
78 + x64-*) echo amd64;;
79 + *) echo "${portage_arch}";;
80 + esac
81 +}
82 +
83 +go_arm()
84 +{
85 + case "${1:-${CHOST}}" in
86 + armv5*) echo 5;;
87 + armv6*) echo 6;;
88 + armv7*) echo 7;;
89 + *)
90 + die "unknown GOARM for ${1:-${CHOST}}"
91 + ;;
92 + esac
93 +}
94 +
95 +go_os()
96 +{
97 + case "${1:-${CHOST}}" in
98 + *-linux*) echo linux;;
99 + *-darwin*) echo darwin;;
100 + *-freebsd*) echo freebsd;;
101 + *-netbsd*) echo netbsd;;
102 + *-openbsd*) echo openbsd;;
103 + *-solaris*) echo solaris;;
104 + *-cygwin*|*-interix*|*-winnt*)
105 + echo windows
106 + ;;
107 + *)
108 + die "unknown GOOS for ${1:-${CHOST}}"
109 + ;;
110 + esac
111 +}
112 +
113 +go_tuple()
114 +{
115 + echo "$(go_os $@)_$(go_arch $@)"
116 +}
117 +
118 +go_cross_compile()
119 +{
120 + [[ $(go_tuple ${CBUILD}) != $(go_tuple) ]]
121 +}
122 +
123 +pkg_pretend()
124 +{
125 + # make.bash does not understand cross-compiling a cross-compiler
126 + if [[ $(go_tuple) != $(go_tuple ${CTARGET}) ]]; then
127 + die "CHOST CTARGET pair unsupported: CHOST=${CHOST} CTARGET=${CTARGET}"
128 + fi
129 +}
130 +
131 +src_prepare()
132 +{
133 + if [[ ${PV} != 9999 ]]; then
134 + sed -i -e 's/"-Werror",//g' src/cmd/dist/build.go ||
135 + die 'sed failed'
136 + fi
137 + epatch "${FILESDIR}"/${P}-darwin-sysctl.patch
138 + epatch_user
139 +}
140 +
141 +src_compile()
142 +{
143 + export GOROOT_BOOTSTRAP="${EPREFIX}"/usr/lib/go1.4
144 + export GOROOT_FINAL="${EPREFIX}"/usr/lib/go
145 + export GOROOT="$(pwd)"
146 + export GOBIN="${GOROOT}/bin"
147 +
148 + # Go's build script does not use BUILD/HOST/TARGET consistently. :(
149 + export GOHOSTARCH=$(go_arch ${CBUILD})
150 + export GOHOSTOS=$(go_os ${CBUILD})
151 + export CC=$(tc-getBUILD_CC)
152 +
153 + export GOARCH=$(go_arch)
154 + export GOOS=$(go_os)
155 + export CC_FOR_TARGET=$(tc-getCC)
156 + export CXX_FOR_TARGET=$(tc-getCXX)
157 + if [[ ${ARCH} == arm ]]; then
158 + export GOARM=$(go_arm)
159 + fi
160 +
161 + cd src
162 + ./make.bash || die "build failed"
163 +}
164 +
165 +src_test()
166 +{
167 + go_cross_compile && return 0
168 +
169 + cd src
170 + PATH="${GOBIN}:${PATH}" \
171 + ./run.bash -no-rebuild || die "tests failed"
172 +}
173 +
174 +src_install()
175 +{
176 + local bin_path f x
177 +
178 + dodir /usr/lib/go
179 + insinto /usr/lib/go
180 +
181 + # There is a known issue which requires the source tree to be installed [1].
182 + # Once this is fixed, we can consider using the doc use flag to control
183 + # installing the doc and src directories.
184 + # [1] https://golang.org/issue/2775
185 + doins -r bin doc lib pkg src
186 + fperms -R +x /usr/lib/go/bin /usr/lib/go/pkg/tool
187 +
188 + if go_cross_compile; then
189 + bin_path="bin/$(go_tuple)"
190 + else
191 + bin_path=bin
192 + fi
193 + for x in ${bin_path}/*; do
194 + f=${x##*/}
195 + einfo dosym ../lib/go/${bin_path}/${f} /usr/bin/${f}
196 + dosym ../lib/go/${bin_path}/${f} /usr/bin/${f}
197 + done
198 + dodoc AUTHORS CONTRIBUTORS PATENTS README.md
199 +}
200 +
201 +pkg_preinst()
202 +{
203 + has_version '<dev-lang/go-1.4' &&
204 + export had_support_files=true ||
205 + export had_support_files=false
206 +}
207 +
208 +pkg_postinst()
209 +{
210 + # If the go tool sees a package file timestamped older than a dependancy it
211 + # will rebuild that file. So, in order to stop go from rebuilding lots of
212 + # packages for every build we need to fix the timestamps. The compiler and
213 + # linker are also checked - so we need to fix them too.
214 + ebegin "fixing timestamps to avoid unnecessary rebuilds"
215 + tref="usr/lib/go/pkg/*/runtime.a"
216 + find "${EROOT}"usr/lib/go -type f \
217 + -exec touch -r "${EROOT}"${tref} {} \;
218 + eend $?
219 +
220 + if [[ ${PV} != 9999 && -n ${REPLACING_VERSIONS} &&
221 + ${REPLACING_VERSIONS} != ${PV} ]]; then
222 + elog "Release notes are located at http://golang.org/doc/go${PV}"
223 + fi
224 +
225 + if $had_support_files; then
226 + ewarn
227 + ewarn "All editor support, IDE support, shell completion"
228 + ewarn "support, etc has been removed from the go package"
229 + ewarn "upstream."
230 + ewarn "For more information on which support is available, see"
231 + ewarn "the following URL:"
232 + ewarn "https://github.com/golang/go/wiki/IDEsAndTextEditorPlugins"
233 + fi
234 +}