]>
Commit | Line | Data |
---|---|---|
602caf80 ER |
1 | # TODO |
2 | # - allow disabling tests (currently bcond exists just for showing which are test deps) | |
30cbf052 ER |
3 | # - add verbose build output (currently dummy bcond) |
4 | # - setup GOMAXPROCS=2 from _smp_mflags | |
f77d9896 | 5 | # - fix CC containing spaces (ccache) |
8dbb36e3 | 6 | # - check if hg use at build time can be dropped |
70d9b5f7 | 7 | # - build all target archs, subpackage them: http://golang.org/doc/install/source#environment |
e5417350 | 8 | # or choose only useful crosscompilers? |
70d9b5f7 | 9 | # - subpackage -src files? |
602caf80 ER |
10 | |
11 | # Conditional build: | |
c1200160 ER |
12 | %bcond_without verbose # verbose build (V=1) |
13 | %bcond_without tests # build without tests [nop actually] | |
14 | %bcond_without shared # Build golang shared objects for stdlib | |
e5417350 JB |
15 | %bcond_without ext_linker # Build golang using external/internal (close to cgo disabled) linking |
16 | %bcond_without cgo # cgo (importing C libraries) support | |
c5489fe6 | 17 | %bcond_with bootstrap # bootstrap build |
c1200160 | 18 | |
d26aefac | 19 | %ifnarch %{ix86} %{x8664} %{arm} aarch64 mips64 mips64le ppc64le |
c1200160 ER |
20 | %undefine with_shared |
21 | %undefine with_ext_linker | |
b327c497 | 22 | %undefine with_cgo |
c1200160 | 23 | %endif |
602caf80 | 24 | |
2ecef135 | 25 | Summary: Go compiler and tools |
78dbb97f | 26 | Summary(pl.UTF-8): Kompilator języka Go i narzędzia |
2ecef135 | 27 | Name: golang |
b0774e68 | 28 | Version: 1.10.8 |
641563f5 | 29 | Release: 1 |
c1200160 ER |
30 | # source tree includes several copies of Mark.Twain-Tom.Sawyer.txt under Public Domain |
31 | License: BSD and Public Domain | |
2ecef135 | 32 | Group: Development/Languages |
70d9b5f7 | 33 | # Source0Download: https://golang.org/dl/ |
9d6ee79b | 34 | Source0: https://storage.googleapis.com/golang/go%{version}.src.tar.gz |
b0774e68 | 35 | # Source0-md5: 1a5f93f2aa6e894dbd4bed2cf88f71f2 |
c6ce79b1 | 36 | Patch0: ca-certs.patch |
2a683cca | 37 | Patch1: 0001-Don-t-use-the-bundled-tzdata-at-runtime-except-for-t.patch |
78dbb97f | 38 | URL: http://golang.org/ |
811d7a98 | 39 | BuildRequires: bash |
30cbf052 | 40 | BuildRequires: rpm-pythonprov |
c1200160 ER |
41 | # The compiler is written in Go. Needs go(1.4+) compiler for build. |
42 | %if %{with bootstrap} | |
43 | BuildRequires: gcc-go >= 6:5 | |
44 | %else | |
45 | BuildRequires: golang >= 1.4 | |
46 | %endif | |
602caf80 | 47 | %if %{with tests} |
c1200160 | 48 | BuildRequires: glibc-static |
602caf80 | 49 | BuildRequires: hostname |
c1200160 | 50 | BuildRequires: pcre-devel |
672135e3 | 51 | BuildRequires: tzdata |
602caf80 | 52 | %endif |
c6ce79b1 | 53 | Requires: ca-certificates |
c21ac8b8 | 54 | Conflicts: gcc-go |
d26aefac | 55 | ExclusiveArch: %{ix86} %{x8664} %{arm} aarch64 mips64 mips64le ppc64 ppc64le s390x |
2ecef135 PG |
56 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) |
57 | ||
aa2bf46a JB |
58 | %define no_install_post_strip 1 |
59 | %define no_install_post_chrpath 1 | |
60 | %define _enable_debug_packages 0 | |
61 | %define _noautoreqfiles %{_libdir}/%{name}/src | |
2502d5f0 | 62 | |
c1200160 ER |
63 | %define goroot %{_libdir}/%{name} |
64 | ||
2502d5f0 ER |
65 | %ifarch %{ix86} |
66 | %define GOARCH 386 | |
67 | %endif | |
68 | %ifarch %{x8664} | |
69 | %define GOARCH amd64 | |
70 | %endif | |
e5417350 JB |
71 | %ifarch %{arm} |
72 | %define GOARCH arm | |
73 | %endif | |
74 | %ifarch aarch64 | |
75 | %define GOARCH arm64 | |
76 | %endif | |
77 | %ifarch mips64 | |
78 | %define GOARCH mips64x | |
79 | %endif | |
d26aefac | 80 | %ifarch ppc64 ppc64le s390x |
e5417350 JB |
81 | %define GOARCH %{_arch} |
82 | %endif | |
2502d5f0 | 83 | |
2ecef135 | 84 | %description |
510be9c2 PG |
85 | Go is an open source programming environment that makes it easy to |
86 | build simple, reliable, and efficient software. | |
2ecef135 | 87 | |
78dbb97f JB |
88 | %description -l pl.UTF-8 |
89 | Go to mające otwarte źródła środowisko do programowania, pozwalające | |
90 | na łatwe tworzenie prostych, pewnych i wydajnych programów. | |
91 | ||
b327c497 ER |
92 | %package shared |
93 | Summary: Golang shared object libraries | |
e5417350 | 94 | Summary(pl.UTF-8): Biblioteki obiektów współdzielonych dla języka Go |
b327c497 ER |
95 | Group: Libraries |
96 | Requires: %{name} = %{version}-%{release} | |
97 | ||
98 | %description shared | |
e5417350 JB |
99 | Golang shared object libraries. |
100 | ||
101 | %description shared -l pl.UTF-8 | |
102 | Biblioteki obiektów współdzielonych dla języka Go. | |
b327c497 | 103 | |
c278766b | 104 | %package doc |
e5417350 JB |
105 | Summary: Documentation for Go language |
106 | Summary(fr.UTF-8): Documentation pour Go | |
107 | Summary(it.UTF-8): Documentazione di Go | |
108 | Summary(pl.UTF-8): Dokumentacja do języka Go | |
c278766b ER |
109 | Group: Documentation |
110 | %if "%{_rpmversion}" >= "5" | |
111 | BuildArch: noarch | |
112 | %endif | |
113 | ||
114 | %description doc | |
e5417350 | 115 | Documentation for Go language. |
c278766b ER |
116 | |
117 | %description doc -l fr.UTF-8 | |
e5417350 | 118 | Documentation pour Go. |
c278766b ER |
119 | |
120 | %description doc -l it.UTF-8 | |
e5417350 | 121 | Documentazione di Go. |
c278766b ER |
122 | |
123 | %description doc -l pl.UTF-8 | |
e5417350 | 124 | Dokumentacja do języka Go. |
c278766b | 125 | |
2ecef135 | 126 | %prep |
c6ce79b1 | 127 | %setup -qc |
e5417350 | 128 | %{__mv} go/* . |
c6ce79b1 | 129 | %patch0 -p1 |
2a683cca | 130 | %patch1 -p1 |
2ecef135 | 131 | |
8022af93 JB |
132 | # clean patch backups |
133 | find . -name '*.orig' | xargs -r %{__rm} | |
134 | ||
811d7a98 | 135 | cat > env.sh <<'EOF' |
c1200160 ER |
136 | # bootstrap compiler GOROOT |
137 | %if %{with bootstrap} | |
138 | export GOROOT_BOOTSTRAP=%{_prefix} | |
139 | %else | |
140 | export GOROOT_BOOTSTRAP=%{goroot} | |
141 | %endif | |
142 | export GOROOT_FINAL=%{goroot} | |
143 | ||
144 | export GOHOSTOS=linux | |
145 | export GOHOSTARCH=%{GOARCH} | |
811d7a98 ER |
146 | |
147 | export GOOS=linux | |
811d7a98 | 148 | export GOARCH=%{GOARCH} |
c1200160 ER |
149 | %if %{without external_linker} |
150 | export GO_LDFLAGS="-linkmode internal" | |
151 | %endif | |
b327c497 ER |
152 | %if %{with cgo} |
153 | export CGO_ENABLED=1 | |
154 | %else | |
c1200160 ER |
155 | export CGO_ENABLED=0 |
156 | %endif | |
157 | ||
158 | # use our gcc options for this build, but store gcc as default for compiler | |
159 | export CFLAGS="%{rpmcflags}" | |
160 | export LDFLAGS="%{rpmldflags}" | |
161 | ||
811d7a98 ER |
162 | CC="%{__cc}" |
163 | export CC="${CC#ccache }" | |
c1200160 | 164 | export CC_FOR_TARGET="$CC" |
811d7a98 ER |
165 | EOF |
166 | ||
c1200160 | 167 | %if 0 |
d5759e4c JB |
168 | # optflags for go tools build |
169 | nflags="\"$(echo '%{rpmcflags}' | sed -e 's/^[ ]*//;s/[ ]*$//;s/[ ]\+/ /g' -e 's/ /\",\"/g')\"" | |
170 | %{__sed} -i -e "s/\"-O2\"/$nflags/" src/cmd/dist/build.c | |
171 | # NOTE: optflags used in gcc calls from go compiler are in src/cmd/go/build.go | |
c1200160 | 172 | %endif |
2ecef135 | 173 | |
811d7a98 ER |
174 | %build |
175 | . ./env.sh | |
811d7a98 | 176 | cd src |
c1200160 ER |
177 | ./make.bash --no-clean |
178 | cd .. | |
179 | ||
180 | # build shared std lib | |
181 | %if %{with shared} | |
182 | GOROOT=$(pwd) PATH=$(pwd)/bin:$PATH go install -buildmode=shared std | |
183 | %endif | |
2ecef135 PG |
184 | |
185 | %install | |
186 | rm -rf $RPM_BUILD_ROOT | |
c1200160 | 187 | GOROOT=$RPM_BUILD_ROOT%{goroot} |
2ecef135 | 188 | |
3fcc5b17 ER |
189 | install -d $GOROOT/{misc,lib,src} |
190 | install -d $RPM_BUILD_ROOT%{_bindir} | |
2ecef135 | 191 | |
c1200160 | 192 | cp -a pkg lib bin src VERSION $GOROOT |
2ecef135 | 193 | cp -a misc/cgo $GOROOT/misc |
c1200160 | 194 | |
aa2bf46a JB |
195 | # kill Win32 and Plan9 scripts |
196 | find $GOROOT -name '*.bat' -o -name '*.rc' | xargs %{__rm} | |
2ecef135 | 197 | |
c1200160 ER |
198 | # https://github.com/golang/go/issues/4749 |
199 | find $GOROOT/src | xargs touch -r $GOROOT/VERSION | |
200 | # and level out all the built archives | |
201 | touch $GOROOT/pkg | |
202 | find $GOROOT/pkg | xargs touch -r $GOROOT/pkg | |
203 | ||
2ecef135 | 204 | ln -sf %{_libdir}/%{name}/bin/go $RPM_BUILD_ROOT%{_bindir}/go |
2ecef135 | 205 | ln -sf %{_libdir}/%{name}/bin/gofmt $RPM_BUILD_ROOT%{_bindir}/gofmt |
2ecef135 | 206 | ln -sf %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/cgo $RPM_BUILD_ROOT%{_bindir}/cgo |
2ecef135 | 207 | |
8022af93 JB |
208 | # FIXME: do we need whole sources, including build scripts? |
209 | # for now, remove only non-Linux stuff | |
210 | %{__rm} $RPM_BUILD_ROOT%{_libdir}/%{name}/src/androidtest.bash \ | |
211 | $RPM_BUILD_ROOT%{_libdir}/%{name}/src/syscall/{mksyscall_solaris,mksysctl_openbsd,mksysnum_{darwin,dragonfly,freebsd,netbsd,openbsd}}.pl | |
212 | # ...and tests | |
213 | %{__rm} -r $RPM_BUILD_ROOT%{_libdir}/%{name}/src/internal/trace \ | |
214 | $RPM_BUILD_ROOT%{_libdir}/%{name}/misc/cgo/{errors,fortran,test*} | |
215 | ||
216 | # unenvize remaining scripts | |
217 | %{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/*.bash | |
218 | %{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/syscall/*.sh | |
219 | %{__sed} -i -e '1s,/usr/bin/env perl,/usr/bin/perl,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/syscall/*.pl | |
2ecef135 | 220 | |
2ecef135 PG |
221 | %clean |
222 | rm -rf $RPM_BUILD_ROOT | |
223 | ||
224 | %files | |
225 | %defattr(644,root,root,755) | |
c1200160 | 226 | %doc AUTHORS CONTRIBUTORS LICENSE |
d5759e4c | 227 | %attr(755,root,root) %{_bindir}/cgo |
d5759e4c | 228 | %attr(755,root,root) %{_bindir}/go |
d5759e4c | 229 | %attr(755,root,root) %{_bindir}/gofmt |
2ecef135 | 230 | %dir %{_libdir}/%{name} |
c1200160 | 231 | %{_libdir}/%{name}/VERSION |
2ecef135 | 232 | %dir %{_libdir}/%{name}/bin |
8022af93 JB |
233 | %attr(755,root,root) %{_libdir}/%{name}/bin/go |
234 | %attr(755,root,root) %{_libdir}/%{name}/bin/gofmt | |
2ecef135 | 235 | |
2ecef135 PG |
236 | %{_libdir}/%{name}/lib |
237 | %{_libdir}/%{name}/misc | |
3fcc5b17 | 238 | %{_libdir}/%{name}/src |
2ecef135 PG |
239 | %dir %{_libdir}/%{name}/pkg |
240 | %{_libdir}/%{name}/pkg/linux_%{GOARCH} | |
241 | %{_libdir}/%{name}/pkg/obj | |
242 | %dir %{_libdir}/%{name}/pkg/tool | |
243 | %dir %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH} | |
8022af93 JB |
244 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/addr2line |
245 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/api | |
246 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/asm | |
2a683cca | 247 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/buildid |
8022af93 JB |
248 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/cgo |
249 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/compile | |
250 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/cover | |
251 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/dist | |
252 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/doc | |
253 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/fix | |
254 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/link | |
255 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/nm | |
256 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/objdump | |
257 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/pack | |
258 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/pprof | |
2a683cca | 259 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/test2json |
8022af93 JB |
260 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/trace |
261 | %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/vet | |
262 | ||
263 | %dir %{_libdir}/%{name}/pkg/bootstrap | |
264 | %dir %{_libdir}/%{name}/pkg/bootstrap/bin | |
265 | %attr(755,root,root) %{_libdir}/%{name}/pkg/bootstrap/bin/asm | |
2a683cca | 266 | %attr(755,root,root) %{_libdir}/%{name}/pkg/bootstrap/bin/cgo |
8022af93 JB |
267 | %attr(755,root,root) %{_libdir}/%{name}/pkg/bootstrap/bin/compile |
268 | %attr(755,root,root) %{_libdir}/%{name}/pkg/bootstrap/bin/link | |
269 | %{_libdir}/%{name}/pkg/bootstrap/pkg | |
270 | %{_libdir}/%{name}/pkg/bootstrap/src | |
c1200160 ER |
271 | %{_libdir}/%{name}/pkg/include |
272 | ||
b327c497 ER |
273 | %if %{with shared} |
274 | %files shared | |
275 | %defattr(644,root,root,755) | |
276 | %{_libdir}/%{name}/pkg/linux_%{GOARCH}_dynlink | |
277 | %endif | |
278 | ||
c278766b ER |
279 | %files doc |
280 | %defattr(644,root,root,755) | |
281 | %doc doc/* |