Add precompiled .a files
[platform/upstream/golang.git] / packaging / golang.spec
1 # build ids are not currently generated:
2 # https://code.google.com/p/go/issues/detail?id=5238
3 #
4 # also, debuginfo extraction currently fails with
5 # "Failed to write file: invalid section alignment"
6 %global debug_package %{nil}
7
8 # we are shipping the full contents of src in the data subpackage, which
9 # contains binary-like things (ELF data for tests, etc)
10 %global _binaries_in_noarch_packages_terminate_build 0
11
12 # Do not check any files in doc or src for requires
13 %global __requires_exclude_from ^(%{_datadir}|/usr/lib)/%{name}/(doc|src)/.*$
14
15 # Don't alter timestamps of especially the .a files (or else go will rebuild later)
16 # Actually, don't strip at all since we are not even building debug packages and this corrupts the dwarf testdata
17 %global __strip /bin/true
18
19 # rpmbuild magic to keep from having meta dependency on libc.so.6
20 # %define _use_internal_dependency_generator 0
21 # %define __find_requires %{nil}
22 # %global __spec_install_post /usr/lib/rpm/check-rpaths   /usr/lib/rpm/check-buildroot  \
23 #  /usr/lib/rpm/brp-compress
24
25 %global golibdir %{_libdir}/golang
26
27 # Golang build options.
28
29 # Build golang using external/internal(close to cgo disabled) linking.
30 %ifarch %{ix86} x86_64 ppc64le %{arm} aarch64 s390x
31 %global external_linker 1
32 %else
33 %global external_linker 0
34 %endif
35
36 # Build golang with cgo enabled/disabled(later equals more or less to internal linking).
37 %ifarch %{ix86} x86_64 ppc64le %{arm} aarch64 s390x
38 %global cgo_enabled 1
39 %else
40 %global cgo_enabled 0
41 %endif
42
43 #%global golang_bootstrap 1
44
45 # Controls what ever we fail on failed tests
46 %ifarch x86_64
47 %global fail_on_tests 0
48 %else
49 %global fail_on_tests 1
50 %endif
51
52 %global shared 0
53
54 # Pre build std lib with -race enabled
55 # %ifarch x86_64
56 # %global race 1
57 # %else
58 %global race 0
59 # %endif
60
61 %global goroot          /usr/lib/%{name}
62 %global gopath          %{_datadir}/gocode
63 %global go_arches       %{ix86} x86_64 %{arm} aarch64 ppc64le
64 %global golibdir        %{_libdir}/golang
65
66 %ifarch x86_64
67 %global gohostarch  amd64
68 %endif
69 %ifarch %{ix86}
70 %global gohostarch  386
71 %endif
72 %ifarch %{arm}
73 %global gohostarch  arm
74 %endif
75 %ifarch aarch64
76 %global gohostarch  arm64
77 %endif
78 %ifarch ppc64
79 %global gohostarch  ppc64
80 %endif
81 %ifarch ppc64le
82 %global gohostarch  ppc64le
83 %endif
84 %ifarch s390x
85 %global gohostarch  s390x
86 %endif
87
88 %global go_api 1.21
89 %global go_version 1.21.4
90
91 Name:           golang
92 Version:        1.21.4
93 Release:        0
94 Summary:        The Go Programming Language
95 License:        BSD-3-Clause
96 URL:            http://golang.org/
97 Source0:        https://storage.googleapis.com/golang/go%{go_version}.src.tar.gz
98
99 Provides:       go = %{version}-%{release}
100 Provides:       go-srpm-macros
101
102 Provides: bundled(golang(golang.org/x/crypto/chacha20poly1305))
103 Provides: bundled(golang(golang.org/x/crypto/cryptobyte))
104 Provides: bundled(golang(golang.org/x/crypto/cryptobyte/asn1))
105 Provides: bundled(golang(golang.org/x/crypto/curve25519))
106 Provides: bundled(golang(golang.org/x/crypto/internal/chacha20))
107 Provides: bundled(golang(golang.org/x/crypto/poly1305))
108 Provides: bundled(golang(golang.org/x/net/dns/dnsmessage))
109 Provides: bundled(golang(golang.org/x/net/http/httpguts))
110 Provides: bundled(golang(golang.org/x/net/http/httpproxy))
111 Provides: bundled(golang(golang.org/x/net/http2/hpack))
112 Provides: bundled(golang(golang.org/x/net/idna))
113 Provides: bundled(golang(golang.org/x/net/internal/nettest))
114 Provides: bundled(golang(golang.org/x/net/nettest))
115 Provides: bundled(golang(golang.org/x/text/secure))
116 Provides: bundled(golang(golang.org/x/text/secure/bidirule))
117 Provides: bundled(golang(golang.org/x/text/transform))
118 Provides: bundled(golang(golang.org/x/text/unicode))
119 Provides: bundled(golang(golang.org/x/text/unicode/bidi))
120 Provides: bundled(golang(golang.org/x/text/unicode/norm))
121 Provides: bundled(golang(github.com/google/pprof/driver))
122 Provides: bundled(golang(github.com/google/pprof/internal/binutils))
123 Provides: bundled(golang(github.com/google/pprof/internal/driver))
124 Provides: bundled(golang(github.com/google/pprof/internal/elfexec))
125 Provides: bundled(golang(github.com/google/pprof/internal/graph))
126 Provides: bundled(golang(github.com/google/pprof/internal/measurement))
127 Provides: bundled(golang(github.com/google/pprof/internal/plugin))
128 Provides: bundled(golang(github.com/google/pprof/internal/proftest))
129 Provides: bundled(golang(github.com/google/pprof/internal/report))
130 Provides: bundled(golang(github.com/google/pprof/internal/symbolizer))
131 Provides: bundled(golang(github.com/google/pprof/internal/symbolz))
132 Provides: bundled(golang(github.com/google/pprof/profile))
133 Provides: bundled(golang(github.com/google/pprof/third.party/d3))
134 Provides: bundled(golang(github.com/google/pprof/third.party/d3flamegraph))
135 Provides: bundled(golang(github.com/google/pprof/third.party/svgpan))
136 Provides: bundled(golang(github.com/ianlancetaylor/demangle))
137 Provides: bundled(golang(golang.org/x/arch/arm/armasm))
138 Provides: bundled(golang(golang.org/x/arch/arm64/arm64asm))
139 Provides: bundled(golang(golang.org/x/arch/ppc64/ppc64asm))
140 Provides: bundled(golang(golang.org/x/arch/x86/x86asm))
141 Provides: bundled(golang(golang.org/x/crypto/ssh/terminal))
142 Provides: bundled(golang(golang.org/x/sys/unix))
143 Provides: bundled(golang(golang.org/x/sys/windows))
144 Provides: bundled(golang(golang.org/x/sys/windows/registry))
145
146 Requires:       %{name}-bin = %{version}-%{release}
147 Requires:       %{name}-src = %{version}-%{release}
148 Requires:       go-srpm-macros
149
150 # Having documentation separate was broken
151 Obsoletes:      %{name}-docs < 1.1-4
152
153 # RPM can't handle symlink -> dir with subpackages, so merge back
154 Obsoletes:      %{name}-data < 1.1.1-4
155
156 # go1.4 deprecates a few packages
157 Obsoletes:      %{name}-vim < 1.4
158 Obsoletes:      emacs-%{name} < 1.4
159
160 # These are the only RHEL/Fedora architectures that we compile this package for
161 ExclusiveArch:  %{go_arches}
162
163 Source10:       go%{version}.linux-386.tar.gz
164 Source11:       go%{version}.linux-amd64.tar.gz
165 Source12:       go%{version}.linux-armv6l.tar.gz
166 Source13:       go%{version}.linux-arm64.tar.gz
167
168 Source102:      macros.golang
169
170 %description
171 %{summary}.
172
173 %package       docs
174 Summary:       Golang compiler docs
175 Requires:      %{name} = %{version}-%{release}
176 BuildArch:     noarch
177 Obsoletes:     %{name}-docs < 1.1-4
178
179 %description   docs
180 %{summary}.
181
182 %package       misc
183 Summary:       Golang compiler miscellaneous sources
184 Requires:      %{name} = %{version}-%{release}
185 BuildArch:     noarch
186
187 %description   misc
188 %{summary}.
189
190 %package       tests
191 Summary:       Golang compiler tests for stdlib
192 Requires:      %{name} = %{version}-%{release}
193 BuildArch:     noarch
194
195 %description   tests
196 %{summary}.
197
198 %package        src
199 Summary:        Golang compiler source tree
200 BuildArch:      noarch
201 %description    src
202 %{summary}
203
204 %package        bin
205 Summary:        Golang core compiler tools
206 Requires:       go = %{version}-%{release}
207
208 %description    bin
209 %{summary}
210
211 %if %{shared}
212 %package        shared
213 Summary:        Golang shared object libraries
214
215 %description    shared
216 %{summary}.
217 %endif
218
219 %if %{race}
220 %package        race
221 Summary:        Golang std library with -race enabled
222
223 Requires:       %{name} = %{version}-%{release}
224
225 %description    race
226 %{summary}
227 %endif
228
229 %prep
230 %setup -q
231
232 %ifarch %{ix86}
233 gzip -dc %{SOURCE10} | tar -xvf -
234 %endif
235
236 %ifarch x86_64
237 gzip -dc %{SOURCE11} | tar -xvf -
238 %endif
239
240 %ifarch %{arm}
241 gzip -dc %{SOURCE12} | tar -xvf -
242 %endif
243
244 %ifarch aarch64
245 gzip -dc %{SOURCE13} | tar -xvf -
246 %endif
247
248 pushd go
249 mv -f * ../
250 popd
251
252 %build
253
254 %install
255 rm -rf $RPM_BUILD_ROOT
256 # remove GC build cache
257 rm -rf pkg/obj/go-build/*
258
259 # create the top level directories
260 mkdir -p $RPM_BUILD_ROOT%{_bindir}
261 mkdir -p $RPM_BUILD_ROOT%{goroot}
262
263 # install everything into libdir (until symlink problems are fixed)
264 # https://code.google.com/p/go/issues/detail?id=5830
265 cp -ap api bin codereview.cfg doc lib misc pkg src test VERSION \
266    $RPM_BUILD_ROOT%{goroot}
267
268 # bz1099206
269 find $RPM_BUILD_ROOT%{goroot}/src -exec touch -r $RPM_BUILD_ROOT%{goroot}/VERSION "{}" \;
270 # and level out all the built archives
271 touch $RPM_BUILD_ROOT%{goroot}/pkg
272 find $RPM_BUILD_ROOT%{goroot}/pkg -exec touch -r $RPM_BUILD_ROOT%{goroot}/pkg "{}" \;
273
274 export GOROOT=$RPM_BUILD_ROOT%{goroot}
275 GODEBUG=installgoroot=all $GOROOT/bin/go install std
276
277 # generate the spec file ownership of this source tree and packages
278 cwd=$(pwd)
279 src_list=$cwd/go-src.list
280 pkg_list=$cwd/go-pkg.list
281 shared_list=$cwd/go-shared.list
282 race_list=$cwd/go-race.list
283 misc_list=$cwd/go-misc.list
284 docs_list=$cwd/go-docs.list
285 tests_list=$cwd/go-tests.list
286 rm -f $src_list $pkg_list $docs_list $misc_list $tests_list $shared_list $race_list
287 touch $src_list $pkg_list $docs_list $misc_list $tests_list $shared_list $race_list
288 pushd $RPM_BUILD_ROOT%{goroot}
289     find src/ -type d -a \( ! -name testdata -a ! -ipath '*/testdata/*' \) -printf '%%%dir %{goroot}/%p\n' >> $src_list
290     find src/ ! -type d -a \( ! -ipath '*/testdata/*' -a ! -name '*_test.go' \) -printf '%{goroot}/%p\n' >> $src_list
291
292     find bin/ pkg/ -type d -a ! -path '*_dynlink/*' -a ! -path '*_race/*' -printf '%%%dir %{goroot}/%p\n' >> $pkg_list
293     find bin/ pkg/ ! -type d -a ! -path '*_dynlink/*' -a ! -path '*_race/*' -printf '%{goroot}/%p\n' >> $pkg_list
294
295     find doc/ -type d -printf '%%%dir %{goroot}/%p\n' >> $docs_list
296     find doc/ ! -type d -printf '%{goroot}/%p\n' >> $docs_list
297
298     find misc/ -type d -printf '%%%dir %{goroot}/%p\n' >> $misc_list
299     find misc/ ! -type d -printf '%{goroot}/%p\n' >> $misc_list
300
301 %if %{shared}
302     mkdir -p %{buildroot}/%{_libdir}/
303     mkdir -p %{buildroot}/%{golibdir}/
304     for file in $(find .  -iname "*.so" ); do
305         chmod 755 $file
306         mv  $file %{buildroot}/%{golibdir}
307         pushd $(dirname $file)
308         ln -fs %{golibdir}/$(basename $file) $(basename $file)
309         popd
310         echo "%%{goroot}/$file" >> $shared_list
311         echo "%%{golibdir}/$(basename $file)" >> $shared_list
312     done
313
314         find pkg/*_dynlink/ -type d -printf '%%%dir %{goroot}/%p\n' >> $shared_list
315         find pkg/*_dynlink/ ! -type d -printf '%{goroot}/%p\n' >> $shared_list
316 %endif
317
318 %if %{race}
319
320     find pkg/*_race/ -type d -printf '%%%dir %{goroot}/%p\n' >> $race_list
321     find pkg/*_race/ ! -type d -printf '%{goroot}/%p\n' >> $race_list
322
323 %endif
324
325     find test/ -type d -printf '%%%dir %{goroot}/%p\n' >> $tests_list
326     find test/ ! -type d -printf '%{goroot}/%p\n' >> $tests_list
327     find src/ -type d -a \( -name testdata -o -ipath '*/testdata/*' \) -printf '%%%dir %{goroot}/%p\n' >> $tests_list
328     find src/ ! -type d -a \( -ipath '*/testdata/*' -o -name '*_test.go' \) -printf '%{goroot}/%p\n' >> $tests_list
329     # this is only the zoneinfo.zip
330     find lib/ -type d -printf '%%%dir %{goroot}/%p\n' >> $tests_list
331     find lib/ ! -type d -printf '%{goroot}/%p\n' >> $tests_list
332 popd
333
334 # remove the doc Makefile
335 rm -rfv $RPM_BUILD_ROOT%{goroot}/doc/Makefile
336
337 # put binaries to bindir, linked to the arch we're building,
338 # leave the arch independent pieces in {goroot}
339 mkdir -p $RPM_BUILD_ROOT%{goroot}/bin/linux_%{gohostarch}
340 ln -sf %{goroot}/bin/go $RPM_BUILD_ROOT%{goroot}/bin/linux_%{gohostarch}/go
341 ln -sf %{goroot}/bin/gofmt $RPM_BUILD_ROOT%{goroot}/bin/linux_%{gohostarch}/gofmt
342
343 # ensure these exist and are owned
344 mkdir -p $RPM_BUILD_ROOT%{gopath}/src/github.com
345 mkdir -p $RPM_BUILD_ROOT%{gopath}/src/bitbucket.org
346 mkdir -p $RPM_BUILD_ROOT%{gopath}/src/code.google.com/p
347 mkdir -p $RPM_BUILD_ROOT%{gopath}/src/golang.org/x
348
349 rm -f $RPM_BUILD_ROOT%{_bindir}/go
350 ln -sf /usr/lib/golang/bin/go $RPM_BUILD_ROOT%{_bindir}/go
351 rm -f $RPM_BUILD_ROOT%{_bindir}/gofmt
352 ln -sf /usr/lib/golang/bin/gofmt $RPM_BUILD_ROOT%{_bindir}/gofmt
353
354 # rpm macros
355 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rpm
356 cp -av %{SOURCE102} $RPM_BUILD_ROOT%{_sysconfdir}/rpm/macros.golang
357
358 %check
359 #export GOROOT=$(pwd -P)
360 #export PATH="$GOROOT"/bin:"$PATH"
361 #cd src
362
363 #%if !%{external_linker}
364 #export GO_LDFLAGS="-linkmode internal"
365 #%endif
366
367 #%if !%{cgo_enabled} || !%{external_linker}
368 #export CGO_ENABLED=0
369 #%endif
370
371 # make sure to not timeout
372 #export GO_TEST_TIMEOUT_SCALE=2
373
374 #%if %{fail_on_tests}
375 #./run.bash --no-rebuild -v -v -v -k
376 #%else
377 #./run.bash --no-rebuild -v -v -v -k || :
378 ##%endif
379 #cd ..
380
381 %files
382 %doc PATENTS
383 %license LICENSE
384 # VERSION has to be present in the GOROOT, for `go install std` to work
385 %doc %{goroot}/VERSION
386 %dir %{goroot}/doc
387 %doc %{goroot}/doc/*
388
389 # go files
390 %dir %{goroot}
391 %exclude %{goroot}/bin/
392 %exclude %{goroot}/pkg/
393 %exclude %{goroot}/src/
394 %exclude %{goroot}/doc/
395 %exclude %{goroot}/misc/
396 %exclude %{goroot}/test/
397 %{goroot}/*
398
399 # ensure directory ownership, so they are cleaned up if empty
400 %dir %{gopath}
401 %dir %{gopath}/src
402 %dir %{gopath}/src/github.com/
403 %dir %{gopath}/src/bitbucket.org/
404 %dir %{gopath}/src/code.google.com/
405 %dir %{gopath}/src/code.google.com/p/
406 %dir %{gopath}/src/golang.org
407 %dir %{gopath}/src/golang.org/x
408
409 %{_sysconfdir}/rpm/macros.golang
410
411 %files -f go-src.list src
412
413 %files -f go-docs.list docs
414
415 %files -f go-misc.list misc
416
417 %files -f go-tests.list tests
418
419 %files -f go-pkg.list bin
420 %{_bindir}/go
421 %{_bindir}/gofmt
422
423 %if %{shared}
424 %files -f go-shared.list shared
425 %endif
426
427 %if %{race}
428 %files -f go-race.list race
429 %endif
430
431 %changelog