]> git.pld-linux.org Git - packages/golang.git/blame - golang.spec
up to 1.17.6 (fixes CVE-2021-44717 CVE-2021-44716)
[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
ccfc9e70 29Version: 1.17.6
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
ccfc9e70 36# Source0-md5: dc57f93f323e9f8189e5ffc1f223e346
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}}
c1200160
ER
163%if %{without external_linker}
164export GO_LDFLAGS="-linkmode internal"
165%endif
b327c497
ER
166%if %{with cgo}
167export CGO_ENABLED=1
168%else
c1200160
ER
169export CGO_ENABLED=0
170%endif
171
172# use our gcc options for this build, but store gcc as default for compiler
173export CFLAGS="%{rpmcflags}"
174export LDFLAGS="%{rpmldflags}"
175
811d7a98
ER
176CC="%{__cc}"
177export CC="${CC#ccache }"
c1200160 178export CC_FOR_TARGET="$CC"
811d7a98
ER
179EOF
180
59cf9949
JP
181grep -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
187nflags="\"$(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 194cd src
c1200160
ER
195./make.bash --no-clean
196cd ..
197
198# build shared std lib
199%if %{with shared}
200GOROOT=$(pwd) PATH=$(pwd)/bin:$PATH go install -buildmode=shared std
201%endif
2ecef135
PG
202
203%install
204rm -rf $RPM_BUILD_ROOT
c1200160 205GOROOT=$RPM_BUILD_ROOT%{goroot}
2ecef135 206
3fcc5b17
ER
207install -d $GOROOT/{misc,lib,src}
208install -d $RPM_BUILD_ROOT%{_bindir}
2ecef135 209
c1200160 210cp -a pkg lib bin src VERSION $GOROOT
2ecef135 211cp -a misc/cgo $GOROOT/misc
c1200160 212
aa2bf46a
JB
213# kill Win32 and Plan9 scripts
214find $GOROOT -name '*.bat' -o -name '*.rc' | xargs %{__rm}
2ecef135 215
c1200160
ER
216# https://github.com/golang/go/issues/4749
217find $GOROOT/src | xargs touch -r $GOROOT/VERSION
218# and level out all the built archives
219touch $GOROOT/pkg
220find $GOROOT/pkg | xargs touch -r $GOROOT/pkg
221
2ecef135 222ln -sf %{_libdir}/%{name}/bin/go $RPM_BUILD_ROOT%{_bindir}/go
2ecef135 223ln -sf %{_libdir}/%{name}/bin/gofmt $RPM_BUILD_ROOT%{_bindir}/gofmt
2ecef135 224ln -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 233find $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
243rm -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/*
This page took 0.108423 seconds and 4 git commands to generate.