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