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