]> git.pld-linux.org Git - packages/golang.git/blame - golang.spec
up to 1.18.5 (fixes CVE-2022-32189)
[packages/golang.git] / golang.spec
CommitLineData
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 26Summary: Go compiler and tools
78dbb97f 27Summary(pl.UTF-8): Kompilator języka Go i narzędzia
2ecef135 28Name: golang
1326e0d9 29Version: 1.18.5
641563f5 30Release: 1
c1200160
ER
31# source tree includes several copies of Mark.Twain-Tom.Sawyer.txt under Public Domain
32License: BSD and Public Domain
2ecef135 33Group: Development/Languages
70d9b5f7 34# Source0Download: https://golang.org/dl/
9d6ee79b 35Source0: https://storage.googleapis.com/golang/go%{version}.src.tar.gz
1326e0d9 36# Source0-md5: 8aa3105925106f7fdfd966d12a83833a
c6ce79b1 37Patch0: ca-certs.patch
2a683cca 38Patch1: 0001-Don-t-use-the-bundled-tzdata-at-runtime-except-for-t.patch
7e2ec210 39URL: https://golang.org/
811d7a98 40BuildRequires: bash
ff5386bf 41BuildRequires: rpm-build >= 4.6
30cbf052 42BuildRequires: rpm-pythonprov
c1200160
ER
43# The compiler is written in Go. Needs go(1.4+) compiler for build.
44%if %{with bootstrap}
45BuildRequires: gcc-go >= 6:5
46%else
47BuildRequires: golang >= 1.4
48%endif
602caf80 49%if %{with tests}
c1200160 50BuildRequires: glibc-static
602caf80 51BuildRequires: hostname
c1200160 52BuildRequires: pcre-devel
9175da2c 53BuildRequires: rpmbuild(macros) >= 2.007
672135e3 54BuildRequires: tzdata
602caf80 55%endif
c6ce79b1 56Requires: ca-certificates
c21ac8b8 57Conflicts: gcc-go
a103298e 58ExclusiveArch: %{ix86} %{x8664} %{armv5} %{armv6} %{armv7} aarch64 mips mipsel mips64 mips64el ppc64 ppc64le riscv64 s390x
2ecef135
PG
59BuildRoot: %{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
100Go is an open source programming environment that makes it easy to
101build simple, reliable, and efficient software.
2ecef135 102
78dbb97f
JB
103%description -l pl.UTF-8
104Go to mające otwarte źródła środowisko do programowania, pozwalające
105na łatwe tworzenie prostych, pewnych i wydajnych programów.
106
b327c497
ER
107%package shared
108Summary: Golang shared object libraries
e5417350 109Summary(pl.UTF-8): Biblioteki obiektów współdzielonych dla języka Go
b327c497
ER
110Group: Libraries
111Requires: %{name} = %{version}-%{release}
112
113%description shared
e5417350
JB
114Golang shared object libraries.
115
116%description shared -l pl.UTF-8
117Biblioteki obiektów współdzielonych dla języka Go.
b327c497 118
c278766b 119%package doc
e5417350
JB
120Summary: Documentation for Go language
121Summary(fr.UTF-8): Documentation pour Go
122Summary(it.UTF-8): Documentazione di Go
123Summary(pl.UTF-8): Dokumentacja do języka Go
c278766b 124Group: Documentation
c278766b 125BuildArch: noarch
c278766b
ER
126
127%description doc
e5417350 128Documentation for Go language.
c278766b
ER
129
130%description doc -l fr.UTF-8
e5417350 131Documentation pour Go.
c278766b
ER
132
133%description doc -l it.UTF-8
e5417350 134Documentazione di Go.
c278766b
ER
135
136%description doc -l pl.UTF-8
e5417350 137Dokumentacja 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
146find . -name '*.orig' | xargs -r %{__rm}
147
811d7a98 148cat > env.sh <<'EOF'
c1200160
ER
149# bootstrap compiler GOROOT
150%if %{with bootstrap}
151export GOROOT_BOOTSTRAP=%{_prefix}
152%else
153export GOROOT_BOOTSTRAP=%{goroot}
154%endif
155export GOROOT_FINAL=%{goroot}
156
157export GOHOSTOS=linux
158export GOHOSTARCH=%{GOARCH}
811d7a98
ER
159
160export GOOS=linux
811d7a98 161export GOARCH=%{GOARCH}
9175da2c 162%{?GOARM:export GOARM=%{GOARM}}
75c1e8a5
JP
163%ifarch %{ix86}
164%ifarch %{x86_with_sse2}
165export GO386=sse2
166%else
167export GO386=softfloat
168%endif
169%endif
5121258d 170%if %{without ext_linker}
c1200160
ER
171export GO_LDFLAGS="-linkmode internal"
172%endif
b327c497
ER
173%if %{with cgo}
174export CGO_ENABLED=1
175%else
c1200160
ER
176export CGO_ENABLED=0
177%endif
178
179# use our gcc options for this build, but store gcc as default for compiler
180export CFLAGS="%{rpmcflags}"
181export LDFLAGS="%{rpmldflags}"
182
811d7a98
ER
183CC="%{__cc}"
184export CC="${CC#ccache }"
c1200160 185export CC_FOR_TARGET="$CC"
811d7a98
ER
186EOF
187
59cf9949
JP
188grep -rl '#!.*env bash' . | xargs %{__sed} -i -e '1{
189 s,^#!.*bin/env bash,#!%{__bash},
190}'
191
c1200160 192%if 0
d5759e4c
JB
193# optflags for go tools build
194nflags="\"$(echo '%{rpmcflags}' | sed -e 's/^[ ]*//;s/[ ]*$//;s/[ ]\+/ /g' -e 's/ /\",\"/g')\""
195%{__sed} -i -e "s/\"-O2\"/$nflags/" src/cmd/dist/build.c
196# NOTE: optflags used in gcc calls from go compiler are in src/cmd/go/build.go
c1200160 197%endif
2ecef135 198
811d7a98
ER
199%build
200. ./env.sh
811d7a98 201cd src
c1200160
ER
202./make.bash --no-clean
203cd ..
204
205# build shared std lib
206%if %{with shared}
207GOROOT=$(pwd) PATH=$(pwd)/bin:$PATH go install -buildmode=shared std
208%endif
2ecef135
PG
209
210%install
211rm -rf $RPM_BUILD_ROOT
c1200160 212GOROOT=$RPM_BUILD_ROOT%{goroot}
2ecef135 213
3fcc5b17
ER
214install -d $GOROOT/{misc,lib,src}
215install -d $RPM_BUILD_ROOT%{_bindir}
2ecef135 216
c1200160 217cp -a pkg lib bin src VERSION $GOROOT
2ecef135 218cp -a misc/cgo $GOROOT/misc
c1200160 219
aa2bf46a
JB
220# kill Win32 and Plan9 scripts
221find $GOROOT -name '*.bat' -o -name '*.rc' | xargs %{__rm}
2ecef135 222
c1200160
ER
223# https://github.com/golang/go/issues/4749
224find $GOROOT/src | xargs touch -r $GOROOT/VERSION
225# and level out all the built archives
226touch $GOROOT/pkg
227find $GOROOT/pkg | xargs touch -r $GOROOT/pkg
228
2ecef135 229ln -sf %{_libdir}/%{name}/bin/go $RPM_BUILD_ROOT%{_bindir}/go
2ecef135 230ln -sf %{_libdir}/%{name}/bin/gofmt $RPM_BUILD_ROOT%{_bindir}/gofmt
2ecef135 231ln -sf %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/cgo $RPM_BUILD_ROOT%{_bindir}/cgo
2ecef135 232
8022af93
JB
233# FIXME: do we need whole sources, including build scripts?
234# for now, remove only non-Linux stuff
a6eb3642 235%{__rm} \
59cf9949 236 $RPM_BUILD_ROOT%{_libdir}/%{name}/src/syscall/{mksyscall,mksysctl_openbsd,mksysnum_{dragonfly,freebsd,netbsd,openbsd}}.pl
8022af93
JB
237# ...and tests
238%{__rm} -r $RPM_BUILD_ROOT%{_libdir}/%{name}/src/internal/trace \
239 $RPM_BUILD_ROOT%{_libdir}/%{name}/misc/cgo/{errors,fortran,test*}
3b0cfb33 240find $RPM_BUILD_ROOT%{_libdir}/%{name} -name testdata -prune | xargs %{__rm} -r
8022af93
JB
241
242# unenvize remaining scripts
243%{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/*.bash
244%{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/syscall/*.sh
956ed359
JP
245%{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/cmd/vendor/golang.org/x/sys/unix/*.sh
246%{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/cmd/go/*.sh
8022af93 247%{__sed} -i -e '1s,/usr/bin/env perl,/usr/bin/perl,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/syscall/*.pl
2ecef135 248
2ecef135
PG
249%clean
250rm -rf $RPM_BUILD_ROOT
251
252%files
253%defattr(644,root,root,755)
c1200160 254%doc AUTHORS CONTRIBUTORS LICENSE
d5759e4c 255%attr(755,root,root) %{_bindir}/cgo
d5759e4c 256%attr(755,root,root) %{_bindir}/go
d5759e4c 257%attr(755,root,root) %{_bindir}/gofmt
2ecef135 258%dir %{_libdir}/%{name}
c1200160 259%{_libdir}/%{name}/VERSION
2ecef135 260%dir %{_libdir}/%{name}/bin
8022af93
JB
261%attr(755,root,root) %{_libdir}/%{name}/bin/go
262%attr(755,root,root) %{_libdir}/%{name}/bin/gofmt
2ecef135 263
2ecef135
PG
264%{_libdir}/%{name}/lib
265%{_libdir}/%{name}/misc
3fcc5b17 266%{_libdir}/%{name}/src
2ecef135
PG
267%dir %{_libdir}/%{name}/pkg
268%{_libdir}/%{name}/pkg/linux_%{GOARCH}
269%{_libdir}/%{name}/pkg/obj
270%dir %{_libdir}/%{name}/pkg/tool
271%dir %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}
8022af93
JB
272%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/addr2line
273%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/api
274%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/asm
2a683cca 275%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/buildid
8022af93
JB
276%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/cgo
277%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/compile
278%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/cover
279%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/dist
280%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/doc
281%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/fix
282%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/link
283%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/nm
284%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/objdump
285%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/pack
286%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/pprof
2a683cca 287%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/test2json
8022af93
JB
288%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/trace
289%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/vet
290
c1200160
ER
291%{_libdir}/%{name}/pkg/include
292
b327c497
ER
293%if %{with shared}
294%files shared
295%defattr(644,root,root,755)
296%{_libdir}/%{name}/pkg/linux_%{GOARCH}_dynlink
297%endif
298
c278766b
ER
299%files doc
300%defattr(644,root,root,755)
301%doc doc/*
This page took 0.115033 seconds and 4 git commands to generate.