]> git.pld-linux.org Git - packages/golang.git/blob - golang.spec
up to 1.18.6 (fixes CVE-2022-27664)
[packages/golang.git] / golang.spec
1 # NOTE: build needs >128 processes limit
2 # TODO
3 # - allow disabling tests (currently bcond exists just for showing which are test deps)
4 # - add verbose build output (currently dummy bcond)
5 # - setup GOMAXPROCS=2 from _smp_mflags
6 # - fix CC containing spaces (ccache)
7 # - check if hg use at build time can be dropped
8 # - build all target archs, subpackage them: http://golang.org/doc/install/source#environment
9 #   or choose only useful crosscompilers?
10 # - subpackage -src files?
11
12 # Conditional build:
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
16 %bcond_without  ext_linker      # Build golang using external/internal (close to cgo disabled) linking
17 %bcond_without  cgo             # cgo (importing C libraries) support
18 %bcond_with     bootstrap       # bootstrap build
19
20 %ifnarch %{ix86} %{x8664} %{arm} aarch64 mips64 mips64le ppc64le
21 %undefine       with_shared
22 %undefine       with_ext_linker
23 %undefine       with_cgo
24 %endif
25
26 Summary:        Go compiler and tools
27 Summary(pl.UTF-8):      Kompilator języka Go i narzędzia
28 Name:           golang
29 Version:        1.18.6
30 Release:        1
31 # source tree includes several copies of Mark.Twain-Tom.Sawyer.txt under Public Domain
32 License:        BSD and Public Domain
33 Group:          Development/Languages
34 # Source0Download: https://golang.org/dl/
35 Source0:        https://storage.googleapis.com/golang/go%{version}.src.tar.gz
36 # Source0-md5:  c22dfda9edbbfcc23e598121db8533c8
37 Patch0:         ca-certs.patch
38 Patch1:         0001-Don-t-use-the-bundled-tzdata-at-runtime-except-for-t.patch
39 URL:            https://golang.org/
40 BuildRequires:  bash
41 BuildRequires:  rpm-build >= 4.6
42 BuildRequires:  rpm-pythonprov
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
49 %if %{with tests}
50 BuildRequires:  glibc-static
51 BuildRequires:  hostname
52 BuildRequires:  pcre-devel
53 BuildRequires:  rpmbuild(macros) >= 2.007
54 BuildRequires:  tzdata
55 %endif
56 Requires:       ca-certificates
57 Conflicts:      gcc-go
58 ExclusiveArch:  %{ix86} %{x8664} %{armv5} %{armv6} %{armv7} aarch64 mips mipsel mips64 mips64el ppc64 ppc64le riscv64 s390x
59 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
60
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
65
66 %define goroot %{_libdir}/%{name}
67
68 %ifarch %{ix86}
69 %define GOARCH 386
70 %endif
71 %ifarch %{x8664}
72 %define GOARCH amd64
73 %endif
74 %ifarch %{armv5}
75 %define GOARCH arm
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
85 %endif
86 %ifarch aarch64
87 %define GOARCH arm64
88 %endif
89 %ifarch mipsel
90 %define GOARCH mipsle
91 %endif
92 %ifarch mips64el
93 %define GOARCH mips64le
94 %endif
95 %ifarch mips mips64 ppc64 ppc64le riscv64 s390x
96 %define GOARCH %{_arch}
97 %endif
98
99 %description
100 Go is an open source programming environment that makes it easy to
101 build simple, reliable, and efficient software.
102
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
107 %package shared
108 Summary:        Golang shared object libraries
109 Summary(pl.UTF-8):      Biblioteki obiektów współdzielonych dla języka Go
110 Group:          Libraries
111 Requires:       %{name} = %{version}-%{release}
112
113 %description shared
114 Golang shared object libraries.
115
116 %description shared -l pl.UTF-8
117 Biblioteki obiektów współdzielonych dla języka Go.
118
119 %package doc
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
124 Group:          Documentation
125 BuildArch:      noarch
126
127 %description doc
128 Documentation for Go language.
129
130 %description doc -l fr.UTF-8
131 Documentation pour Go.
132
133 %description doc -l it.UTF-8
134 Documentazione di Go.
135
136 %description doc -l pl.UTF-8
137 Dokumentacja do języka Go.
138
139 %prep
140 %setup -qc
141 %{__mv} go/* .
142 %patch0 -p1
143 %patch1 -p1
144
145 # clean patch backups
146 find . -name '*.orig' | xargs -r %{__rm}
147
148 cat > env.sh <<'EOF'
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}
159
160 export GOOS=linux
161 export GOARCH=%{GOARCH}
162 %{?GOARM:export GOARM=%{GOARM}}
163 %ifarch %{ix86}
164 %ifarch %{x86_with_sse2}
165 export GO386=sse2
166 %else
167 export GO386=softfloat
168 %endif
169 %endif
170 %if %{without ext_linker}
171 export GO_LDFLAGS="-linkmode internal"
172 %endif
173 %if %{with cgo}
174 export CGO_ENABLED=1
175 %else
176 export CGO_ENABLED=0
177 %endif
178
179 # use our gcc options for this build, but store gcc as default for compiler
180 export CFLAGS="%{rpmcflags}"
181 export LDFLAGS="%{rpmldflags}"
182
183 CC="%{__cc}"
184 export CC="${CC#ccache }"
185 export CC_FOR_TARGET="$CC"
186 EOF
187
188 grep -rl '#!.*env bash' . | xargs %{__sed} -i -e '1{
189         s,^#!.*bin/env bash,#!%{__bash},
190 }'
191
192 %if 0
193 # optflags for go tools build
194 nflags="\"$(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
197 %endif
198
199 %build
200 . ./env.sh
201 cd src
202 ./make.bash --no-clean
203 cd ..
204
205 # build shared std lib
206 %if %{with shared}
207 GOROOT=$(pwd) PATH=$(pwd)/bin:$PATH go install -buildmode=shared std
208 %endif
209
210 %install
211 rm -rf $RPM_BUILD_ROOT
212 GOROOT=$RPM_BUILD_ROOT%{goroot}
213
214 install -d $GOROOT/{misc,lib,src}
215 install -d $RPM_BUILD_ROOT%{_bindir}
216
217 cp -a pkg lib bin src VERSION $GOROOT
218 cp -a misc/cgo $GOROOT/misc
219
220 # kill Win32 and Plan9 scripts
221 find $GOROOT -name '*.bat' -o -name '*.rc' | xargs %{__rm}
222
223 # https://github.com/golang/go/issues/4749
224 find $GOROOT/src | xargs touch -r $GOROOT/VERSION
225 # and level out all the built archives
226 touch $GOROOT/pkg
227 find $GOROOT/pkg | xargs touch -r $GOROOT/pkg
228
229 ln -sf %{_libdir}/%{name}/bin/go $RPM_BUILD_ROOT%{_bindir}/go
230 ln -sf %{_libdir}/%{name}/bin/gofmt $RPM_BUILD_ROOT%{_bindir}/gofmt
231 ln -sf %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/cgo $RPM_BUILD_ROOT%{_bindir}/cgo
232
233 # FIXME: do we need whole sources, including build scripts?
234 # for now, remove only non-Linux stuff
235 %{__rm} \
236         $RPM_BUILD_ROOT%{_libdir}/%{name}/src/syscall/{mksyscall,mksysctl_openbsd,mksysnum_{dragonfly,freebsd,netbsd,openbsd}}.pl
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*}
240 find $RPM_BUILD_ROOT%{_libdir}/%{name} -name testdata -prune | xargs %{__rm} -r
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
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
247 %{__sed} -i -e '1s,/usr/bin/env perl,/usr/bin/perl,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/syscall/*.pl
248
249 %clean
250 rm -rf $RPM_BUILD_ROOT
251
252 %files
253 %defattr(644,root,root,755)
254 %doc AUTHORS CONTRIBUTORS LICENSE
255 %attr(755,root,root) %{_bindir}/cgo
256 %attr(755,root,root) %{_bindir}/go
257 %attr(755,root,root) %{_bindir}/gofmt
258 %dir %{_libdir}/%{name}
259 %{_libdir}/%{name}/VERSION
260 %dir %{_libdir}/%{name}/bin
261 %attr(755,root,root) %{_libdir}/%{name}/bin/go
262 %attr(755,root,root) %{_libdir}/%{name}/bin/gofmt
263
264 %{_libdir}/%{name}/lib
265 %{_libdir}/%{name}/misc
266 %{_libdir}/%{name}/src
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}
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
275 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/buildid
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
287 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/test2json
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
291 %{_libdir}/%{name}/pkg/include
292
293 %if %{with shared}
294 %files shared
295 %defattr(644,root,root,755)
296 %{_libdir}/%{name}/pkg/linux_%{GOARCH}_dynlink
297 %endif
298
299 %files doc
300 %defattr(644,root,root,755)
301 %doc doc/*
This page took 0.131452 seconds and 4 git commands to generate.