]> git.pld-linux.org Git - packages/golang.git/blob - golang.spec
8e1072bbe92eb054ea01b3e709a843af4fe58d80
[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.20.1
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://go.dev/dl/
35 Source0:        https://storage.googleapis.com/golang/go%{version}.src.tar.gz
36 # Source0-md5:  06544356f41811af9e73797d6962793c
37 Patch0:         ca-certs.patch
38 URL:            https://go.dev/
39 BuildRequires:  bash
40 BuildRequires:  rpm-build >= 4.6
41 BuildRequires:  rpm-pythonprov
42 # The compiler is written in Go. Needs go(1.4+) compiler for build.
43 %if %{with bootstrap}
44 BuildRequires:  gcc-go >= 6:5
45 %else
46 BuildRequires:  golang >= 1.4
47 %endif
48 %if %{with tests}
49 BuildRequires:  glibc-static
50 BuildRequires:  hostname
51 BuildRequires:  pcre-devel
52 BuildRequires:  rpmbuild(macros) >= 2.007
53 BuildRequires:  tzdata
54 %endif
55 Requires:       ca-certificates
56 Conflicts:      gcc-go
57 ExclusiveArch:  %{ix86} %{x8664} %{armv5} %{armv6} %{armv7} aarch64 mips mipsel mips64 mips64el ppc64 ppc64le riscv64 s390x
58 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
59
60 %define         no_install_post_strip   1
61 %define         no_install_post_chrpath 1
62 %define         _enable_debug_packages  0
63 %define         _noautoreqfiles         %{_libdir}/%{name}/src
64
65 %define goroot %{_libdir}/%{name}
66
67 %ifarch %{ix86}
68 %define GOARCH 386
69 %endif
70 %ifarch %{x8664}
71 %define GOARCH amd64
72 %endif
73 %ifarch %{armv5}
74 %define GOARCH arm
75 %define GOARM 5
76 %endif
77 %ifarch %{armv6}
78 %define GOARCH arm
79 %define GOARM 6
80 %endif
81 %ifarch %{armv7}
82 %define GOARCH arm
83 %define GOARM 7
84 %endif
85 %ifarch aarch64
86 %define GOARCH arm64
87 %endif
88 %ifarch mipsel
89 %define GOARCH mipsle
90 %endif
91 %ifarch mips64el
92 %define GOARCH mips64le
93 %endif
94 %ifarch mips mips64 ppc64 ppc64le riscv64 s390x
95 %define GOARCH %{_arch}
96 %endif
97
98 %description
99 Go is an open source programming environment that makes it easy to
100 build simple, reliable, and efficient software.
101
102 %description -l pl.UTF-8
103 Go to mające otwarte źródła środowisko do programowania, pozwalające
104 na łatwe tworzenie prostych, pewnych i wydajnych programów.
105
106 %package shared
107 Summary:        Golang shared object libraries
108 Summary(pl.UTF-8):      Biblioteki obiektów współdzielonych dla języka Go
109 Group:          Libraries
110 Requires:       %{name} = %{version}-%{release}
111
112 %description shared
113 Golang shared object libraries.
114
115 %description shared -l pl.UTF-8
116 Biblioteki obiektów współdzielonych dla języka Go.
117
118 %package doc
119 Summary:        Documentation for Go language
120 Summary(fr.UTF-8):      Documentation pour Go
121 Summary(it.UTF-8):      Documentazione di Go
122 Summary(pl.UTF-8):      Dokumentacja do języka Go
123 Group:          Documentation
124 BuildArch:      noarch
125
126 %description doc
127 Documentation for Go language.
128
129 %description doc -l fr.UTF-8
130 Documentation pour Go.
131
132 %description doc -l it.UTF-8
133 Documentazione di Go.
134
135 %description doc -l pl.UTF-8
136 Dokumentacja do języka Go.
137
138 %prep
139 %setup -qc
140 %{__mv} go/* .
141 %patch0 -p1
142
143 # clean patch backups
144 find . -name '*.orig' | xargs -r %{__rm}
145
146 cat > env.sh <<'EOF'
147 # bootstrap compiler GOROOT
148 %if %{with bootstrap}
149 export GOROOT_BOOTSTRAP=%{_prefix}
150 %else
151 export GOROOT_BOOTSTRAP=%{goroot}
152 %endif
153 export GOROOT_FINAL=%{goroot}
154
155 export GOHOSTOS=linux
156 export GOHOSTARCH=%{GOARCH}
157
158 export GOOS=linux
159 export GOARCH=%{GOARCH}
160 %{?GOARM:export GOARM=%{GOARM}}
161 %ifarch %{ix86}
162 %ifarch %{x86_with_sse2}
163 export GO386=sse2
164 %else
165 export GO386=softfloat
166 %endif
167 %endif
168 %if %{without ext_linker}
169 export GO_LDFLAGS="-linkmode internal"
170 %endif
171 %if %{with cgo}
172 export CGO_ENABLED=1
173 %else
174 export CGO_ENABLED=0
175 %endif
176
177 # use our gcc options for this build, but store gcc as default for compiler
178 export CFLAGS="%{rpmcflags}"
179 export LDFLAGS="%{rpmldflags}"
180
181 CC="%{__cc}"
182 export CC="${CC#ccache }"
183 export CC_FOR_TARGET="$CC"
184 EOF
185
186 grep -rl '#!.*env bash' . | xargs %{__sed} -i -e '1{
187         s,^#!.*bin/env bash,#!%{__bash},
188 }'
189
190 %if 0
191 # optflags for go tools build
192 nflags="\"$(echo '%{rpmcflags}' | sed -e 's/^[  ]*//;s/[        ]*$//;s/[       ]\+/ /g' -e 's/ /\",\"/g')\""
193 %{__sed} -i -e "s/\"-O2\"/$nflags/" src/cmd/dist/build.c
194 # NOTE: optflags used in gcc calls from go compiler are in src/cmd/go/build.go
195 %endif
196
197 %build
198 . ./env.sh
199 cd src
200 ./make.bash
201 cd ..
202
203 # build shared std lib
204 %if %{with shared}
205 GOROOT=$(pwd) PATH=$(pwd)/bin:$PATH go install -buildmode=shared std
206 %endif
207
208 %install
209 rm -rf $RPM_BUILD_ROOT
210 GOROOT=$RPM_BUILD_ROOT%{goroot}
211
212 install -d $GOROOT/{misc,lib,src}
213 install -d $RPM_BUILD_ROOT%{_bindir}
214
215 cp -a pkg lib bin src VERSION $GOROOT
216 cp -a misc/cgo $GOROOT/misc
217
218 # kill Win32 and Plan9 scripts
219 find $GOROOT -name '*.bat' -o -name '*.rc' | xargs %{__rm}
220
221 # https://github.com/golang/go/issues/4749
222 find $GOROOT/src | xargs touch -r $GOROOT/VERSION
223 # and level out all the built archives
224 touch $GOROOT/pkg
225 find $GOROOT/pkg | xargs touch -r $GOROOT/pkg
226
227 ln -sf %{_libdir}/%{name}/bin/go $RPM_BUILD_ROOT%{_bindir}/go
228 ln -sf %{_libdir}/%{name}/bin/gofmt $RPM_BUILD_ROOT%{_bindir}/gofmt
229 ln -sf %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/cgo $RPM_BUILD_ROOT%{_bindir}/cgo
230
231 # FIXME: do we need whole sources, including build scripts?
232 # for now, remove only non-Linux stuff
233 %{__rm} \
234         $RPM_BUILD_ROOT%{_libdir}/%{name}/src/syscall/{mksyscall,mksysctl_openbsd,mksysnum_{dragonfly,freebsd,netbsd,openbsd}}.pl
235 # ...and tests
236 %{__rm} -r $RPM_BUILD_ROOT%{_libdir}/%{name}/src/internal/trace \
237            $RPM_BUILD_ROOT%{_libdir}/%{name}/misc/cgo/{errors,fortran,test*}
238 find $RPM_BUILD_ROOT%{_libdir}/%{name} -name testdata -prune | xargs %{__rm} -r
239
240 # unenvize remaining scripts
241 %{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/*.bash
242 %{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/syscall/*.sh
243 %{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/cmd/vendor/golang.org/x/sys/unix/*.sh
244 %{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/cmd/go/*.sh
245 %{__sed} -i -e '1s,/usr/bin/env perl,/usr/bin/perl,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/syscall/*.pl
246
247 %clean
248 rm -rf $RPM_BUILD_ROOT
249
250 %files
251 %defattr(644,root,root,755)
252 %doc CONTRIBUTING.md LICENSE README.md
253 %attr(755,root,root) %{_bindir}/cgo
254 %attr(755,root,root) %{_bindir}/go
255 %attr(755,root,root) %{_bindir}/gofmt
256 %dir %{_libdir}/%{name}
257 %{_libdir}/%{name}/VERSION
258 %dir %{_libdir}/%{name}/bin
259 %attr(755,root,root) %{_libdir}/%{name}/bin/go
260 %attr(755,root,root) %{_libdir}/%{name}/bin/gofmt
261
262 %{_libdir}/%{name}/lib
263 %{_libdir}/%{name}/misc
264 %{_libdir}/%{name}/src
265 %dir %{_libdir}/%{name}/pkg
266 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/addr2line
267 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/asm
268 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/buildid
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}/covdata
272 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/cover
273 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/dist
274 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/doc
275 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/fix
276 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/link
277 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/nm
278 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/objdump
279 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/pack
280 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/pprof
281 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/test2json
282 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/trace
283 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/vet
284
285 %{_libdir}/%{name}/pkg/include
286
287 %if %{with shared}
288 %files shared
289 %defattr(644,root,root,755)
290 %{_libdir}/%{name}/pkg/linux_%{GOARCH}_dynlink
291 %endif
292
293 %files doc
294 %defattr(644,root,root,755)
295 %doc doc/*
This page took 0.064639 seconds and 2 git commands to generate.