]>
Commit | Line | Data |
---|---|---|
1 | # TODO | |
2 | # - consider a rust-std package containing .../rustlib/$target | |
3 | # This might allow multilib cross-compilation to work naturally. | |
4 | # - package additional tools | |
5 | # | |
6 | # Conditional build: | |
7 | %bcond_with bootstrap # bootstrap using precompiled binaries | |
8 | %bcond_with full_debuginfo # full debuginfo vs only std debuginfo (full takes gigabytes of memory to build) | |
9 | %bcond_without system_llvm # system LLVM | |
10 | %bcond_without rustc # rustc building | |
11 | %bcond_without cargo # cargo building | |
12 | %bcond_with tests # build without tests | |
13 | ||
14 | # The channel can be stable, beta, or nightly | |
15 | %define channel stable | |
16 | ||
17 | %if "%{channel}" == "stable" | |
18 | %define rustc_package rustc-%{version}-src | |
19 | %else | |
20 | %define rustc_package rustc-%{channel}-src | |
21 | %endif | |
22 | ||
23 | # To bootstrap from scratch, set the channel and date from src/stage0.txt | |
24 | # e.g. 1.10.0 wants rustc: 1.9.0-2016-05-24 | |
25 | # or nightly wants some beta-YYYY-MM-DD | |
26 | %define bootstrap_rust 1.36.0 | |
27 | %define bootstrap_cargo 0.37.0 | |
28 | %define bootstrap_date 2019-07-04 | |
29 | ||
30 | %ifarch x32 | |
31 | %undefine with_cargo | |
32 | %undefine with_rustc | |
33 | %endif | |
34 | Summary: The Rust Programming Language | |
35 | Summary(pl.UTF-8): Język programowania Rust | |
36 | Name: rust | |
37 | Version: 1.37.0 | |
38 | Release: 1 | |
39 | # Licenses: (rust itself) and (bundled libraries) | |
40 | License: (Apache v2.0 or MIT) and (BSD and ISC and MIT) | |
41 | Group: Development/Languages | |
42 | Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.gz | |
43 | # Source0-md5: e67432b37150f13e186ebfb67e5192fb | |
44 | Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.gz | |
45 | # Source1-md5: 487d17bbb86891f58160ccf6f0347b49 | |
46 | Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.gz | |
47 | # Source2-md5: 5f969ed3c9ef2a7e2a8011be7eb796c3 | |
48 | URL: https://www.rust-lang.org/ | |
49 | # for src/compiler-rt | |
50 | BuildRequires: cmake >= 3.4.3 | |
51 | BuildRequires: curl | |
52 | BuildRequires: libstdc++-devel | |
53 | %{?with_system_llvm:BuildRequires: llvm-devel} | |
54 | BuildRequires: ncurses-devel | |
55 | BuildRequires: python >= 1:2.7 | |
56 | BuildRequires: zlib-devel | |
57 | %if %{without bootstrap} | |
58 | BuildRequires: %{name} >= %{bootstrap_rust} | |
59 | BuildRequires: cargo >= %{bootstrap_cargo} | |
60 | BuildConflicts: %{name} > %{version} | |
61 | %endif | |
62 | # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs | |
63 | BuildRequires: procps | |
64 | # The C compiler is needed at runtime just for linking. Someday rustc might | |
65 | # invoke the linker directly, and then we'll only need binutils. | |
66 | # https://github.com/rust-lang/rust/issues/11937 | |
67 | Requires: gcc | |
68 | # Only x86_64 and i686 are Tier 1 platforms at this time. | |
69 | # x32 is Tier 2, only rust-std is available (no rustc or cargo). | |
70 | # https://doc.rust-lang.org/stable/book/getting-started.html#tier-1 | |
71 | ExclusiveArch: %{x8664} %{ix86} x32 | |
72 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) | |
73 | ||
74 | %ifarch x32 | |
75 | %define rust_triple x86_64-unknown-linux-gnux32 | |
76 | %define rust_bootstrap_triple x86_64-unknown-linux-gnu | |
77 | %else | |
78 | %define rust_triple %{_target_cpu}-unknown-linux-gnu | |
79 | %define rust_bootstrap_triple %{_target_cpu}-unknown-linux-gnu | |
80 | %endif | |
81 | ||
82 | %if %{without bootstrap} | |
83 | %define local_rust_root %{_prefix} | |
84 | %else | |
85 | %define bootstrap_root rust-%{bootstrap_rust}-%{rust_bootstrap_triple} | |
86 | %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root} | |
87 | %endif | |
88 | ||
89 | # We're going to override --libdir when configuring to get rustlib into a | |
90 | # common path, but we'll fix the shared libraries during install. | |
91 | # Without this ugly hack, rust would not be able to build itself | |
92 | # for non-bootstrap build, lib64 is just too complicated for it. | |
93 | %define common_libdir %{_prefix}/lib | |
94 | %define rustlibdir %{common_libdir}/rustlib | |
95 | ||
96 | # once_call/once_callable non-function libstdc++ symbols | |
97 | %define skip_post_check_so 'librustc.*llvm.*\.so.*' | |
98 | ||
99 | # ALL Rust libraries are private, because they don't keep an ABI. | |
100 | %define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.* | |
101 | %define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.* | |
102 | ||
103 | %description | |
104 | Rust is a systems programming language that runs blazingly fast, | |
105 | prevents segfaults, and guarantees thread safety. | |
106 | ||
107 | This package includes the Rust compiler, standard library, and | |
108 | documentation generator. | |
109 | ||
110 | %description -l pl.UTF-8 | |
111 | Rust to systemowy język programowania działający bardzo szybko, | |
112 | zapobiegający naruszeniom ochrony pamięci i gwarantujący | |
113 | bezpieczną wielowątkowość. | |
114 | ||
115 | %package debugger-common | |
116 | Summary: Common debugger pretty printers for Rust | |
117 | Summary(pl.UTF-8): Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów | |
118 | Group: Development/Debuggers | |
119 | BuildArch: noarch | |
120 | ||
121 | %description debugger-common | |
122 | This package includes the common functionality for rust-gdb and | |
123 | rust-lldb. | |
124 | ||
125 | %description debugger-common -l pl.UTF-8 | |
126 | Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb. | |
127 | ||
128 | %package gdb | |
129 | Summary: GDB pretty printers for Rust | |
130 | Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w GDB | |
131 | Group: Development/Debuggers | |
132 | Requires: %{name}-debugger-common = %{version}-%{release} | |
133 | Requires: gdb | |
134 | BuildArch: noarch | |
135 | ||
136 | %description gdb | |
137 | This package includes the rust-gdb script, which allows easier | |
138 | debugging of Rust programs. | |
139 | ||
140 | %description gdb -l pl.UTF-8 | |
141 | Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze | |
142 | odpluskwianie programów w języku Rust. | |
143 | ||
144 | %package lldb | |
145 | Summary: LLDB pretty printers for Rust | |
146 | Summary(pl.UTF-8): Ładne wypisywanie struktur Rusta w LLDB | |
147 | Group: Development/Debuggers | |
148 | Requires: %{name}-debugger-common = %{version}-%{release} | |
149 | Requires: lldb | |
150 | BuildArch: noarch | |
151 | ||
152 | %description lldb | |
153 | This package includes the rust-lldb script, which allows easier | |
154 | debugging of Rust programs. | |
155 | ||
156 | %description lldb -l pl.UTF-8 | |
157 | Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze | |
158 | odpluskwianie programów w języku Rust. | |
159 | ||
160 | %package doc | |
161 | Summary: Documentation for Rust | |
162 | Summary(pl.UTF-8): Dokumentacja do Rusta | |
163 | Group: Documentation | |
164 | BuildArch: noarch | |
165 | ||
166 | %description doc | |
167 | This package includes HTML documentation for the Rust programming | |
168 | language and its standard library. | |
169 | ||
170 | %description doc -l pl.UTF-8 | |
171 | Ten pakiet zawiera dokumentację w formacie HTML do języka | |
172 | programowania Rust i jego biblioteki standardowej. | |
173 | ||
174 | %package -n cargo | |
175 | Summary: Rust's package manager and build tool | |
176 | Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania | |
177 | Group: Development/Tools | |
178 | Requires: %{name} | |
179 | ||
180 | %description -n cargo | |
181 | Cargo is a tool that allows Rust projects to declare their various | |
182 | dependencies and ensure that you'll always get a repeatable build. | |
183 | ||
184 | %description -n cargo -l pl.UTF-8 | |
185 | Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich | |
186 | zależności i zapewniające powtarzalność procesu budowania. | |
187 | ||
188 | %package -n bash-completion-cargo | |
189 | Summary: Bash completion for cargo command | |
190 | Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo | |
191 | Group: Applications/Shells | |
192 | Requires: %{name} = %{version}-%{release} | |
193 | Requires: bash-completion | |
194 | ||
195 | %description -n bash-completion-cargo | |
196 | Bash completion for cargo command. | |
197 | ||
198 | %description -n bash-completion-cargo -l pl.UTF-8 | |
199 | Bashowe dopełnianie parametrów polecenia cargo. | |
200 | ||
201 | %package -n zsh-completion-cargo | |
202 | Summary: Zsh completion for cargo command | |
203 | Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh | |
204 | Group: Applications/Shells | |
205 | Requires: %{name} = %{version}-%{release} | |
206 | Requires: zsh | |
207 | ||
208 | %description -n zsh-completion-cargo | |
209 | Zsh completion for cargo command. | |
210 | ||
211 | %description -n zsh-completion-cargo -l pl.UTF-8 | |
212 | Dopełnianie parametrów polecenia cargo w powłoce Zsh. | |
213 | ||
214 | %prep | |
215 | %setup -q -n %{rustc_package} | |
216 | ||
217 | %if %{with bootstrap} | |
218 | %ifarch %{x8664} x32 | |
219 | tar xf %{SOURCE1} | |
220 | %endif | |
221 | %ifarch %{ix86} | |
222 | tar xf %{SOURCE2} | |
223 | %endif | |
224 | %{__mv} %{bootstrap_root} %{bootstrap_root}-root | |
225 | %{bootstrap_root}-root/install.sh \ | |
226 | --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \ | |
227 | --prefix=%{local_rust_root} \ | |
228 | --disable-ldconfig | |
229 | test -f %{local_rust_root}/bin/cargo | |
230 | test -f %{local_rust_root}/bin/rustc | |
231 | %endif | |
232 | ||
233 | # unbundle | |
234 | # We're disabling jemalloc, but rust-src still wants it. | |
235 | #%{__rm} -r src/jemalloc | |
236 | %{?with_system_llvm:%{__rm} -r src/llvm-project} | |
237 | ||
238 | # extract bundled licenses for packaging | |
239 | sed -e '/*\//q' vendor/backtrace-sys/src/libbacktrace/backtrace.h \ | |
240 | >vendor/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace | |
241 | ||
242 | # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch | |
243 | sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \ | |
244 | src/etc/rust-gdb | |
245 | ||
246 | # The configure macro will modify some autoconf-related files, which upsets | |
247 | # cargo when it tries to verify checksums in those files. If we just truncate | |
248 | # that file list, cargo won't have anything to complain about. | |
249 | find vendor -name .cargo-checksum.json \ | |
250 | -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+' | |
251 | ||
252 | %build | |
253 | %configure \ | |
254 | --build=%{rust_triple} \ | |
255 | --host=%{rust_triple} \ | |
256 | --target=%{rust_triple} \ | |
257 | --libdir=%{common_libdir} \ | |
258 | --disable-codegen-tests \ | |
259 | --disable-debuginfo-lines \ | |
260 | %if %{with full_debuginfo} | |
261 | --disable-debuginfo-only-std \ | |
262 | --enable-debuginfo \ | |
263 | %else | |
264 | --enable-debuginfo-only-std \ | |
265 | --disable-debuginfo \ | |
266 | %endif | |
267 | --disable-jemalloc \ | |
268 | --disable-option-checking \ | |
269 | --disable-rpath \ | |
270 | --enable-extended \ | |
271 | --enable-llvm-link-shared \ | |
272 | --enable-vendor \ | |
273 | --local-rust-root=%{local_rust_root} \ | |
274 | --llvm-root=%{_prefix} \ | |
275 | --release-channel=%{channel} | |
276 | ||
277 | RUST_BACKTRACE=full \ | |
278 | ./x.py dist --verbose | |
279 | ||
280 | %{?with_tests:./x.py test} | |
281 | ||
282 | %install | |
283 | rm -rf $RPM_BUILD_ROOT | |
284 | ||
285 | DESTDIR=$RPM_BUILD_ROOT ./x.py install | |
286 | DESTDIR=$RPM_BUILD_ROOT ./x.py install src | |
287 | ||
288 | # Make sure the shared libraries are in the proper libdir | |
289 | %if "%{_libdir}" != "%{common_libdir}" | |
290 | mkdir -p %{buildroot}%{_libdir} | |
291 | find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \ | |
292 | -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+' | |
293 | %endif | |
294 | ||
295 | # The shared libraries should be executable for debuginfo extraction. | |
296 | find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+' | |
297 | ||
298 | # The libdir libraries are identical to those under rustlib/. It's easier on | |
299 | # library loading if we keep them in libdir, but we do need them in rustlib/ | |
300 | # to support dynamic linking for compiler plugins, so we'll symlink. | |
301 | (cd "$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib" && | |
302 | find ../../../../%{_lib} -maxdepth 1 -name '*.so' \ | |
303 | -exec ln -v -f -s -t . '{}' '+') | |
304 | ||
305 | # Remove installer artifacts (manifests, uninstall scripts, etc.) | |
306 | find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+' | |
307 | ||
308 | # FIXME: __os_install_post will strip the rlibs | |
309 | # -- should we find a way to preserve debuginfo? | |
310 | ||
311 | # Remove unwanted documentation files (we already package them) | |
312 | %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md | |
313 | %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT | |
314 | %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE | |
315 | %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT | |
316 | ||
317 | # Sanitize the HTML documentation | |
318 | find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete | |
319 | find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+' | |
320 | ||
321 | # Move rust-gdb's python scripts so they're noarch | |
322 | install -d $RPM_BUILD_ROOT%{_datadir}/%{name} | |
323 | %{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name} | |
324 | ||
325 | # We don't need stdlib source | |
326 | %{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src | |
327 | ||
328 | # Create the path for crate-devel packages | |
329 | install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry | |
330 | ||
331 | %clean | |
332 | rm -rf $RPM_BUILD_ROOT | |
333 | ||
334 | %post -p /sbin/ldconfig | |
335 | %postun -p /sbin/ldconfig | |
336 | ||
337 | %files | |
338 | %defattr(644,root,root,755) | |
339 | %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md vendor/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace | |
340 | %attr(755,root,root) %{_bindir}/miri | |
341 | %attr(755,root,root) %{_bindir}/rls | |
342 | %attr(755,root,root) %{_bindir}/rustc | |
343 | %attr(755,root,root) %{_bindir}/rustdoc | |
344 | %attr(755,root,root) %{_bindir}/rustfmt | |
345 | %attr(755,root,root) %{_libdir}/libarena-*.so | |
346 | %attr(755,root,root) %{_libdir}/libfmt_macros-*.so | |
347 | %attr(755,root,root) %{_libdir}/libgraphviz-*.so | |
348 | %attr(755,root,root) %{_libdir}/librustc*-*.so | |
349 | %attr(755,root,root) %{_libdir}/libserialize-*.so | |
350 | %attr(755,root,root) %{_libdir}/libstd-*.so | |
351 | %attr(755,root,root) %{_libdir}/libsyntax-*.so | |
352 | %attr(755,root,root) %{_libdir}/libsyntax_ext-*.so | |
353 | %attr(755,root,root) %{_libdir}/libsyntax_pos-*.so | |
354 | %attr(755,root,root) %{_libdir}/libterm-*.so | |
355 | %attr(755,root,root) %{_libdir}/libtest-*.so | |
356 | %{_mandir}/man1/rustc.1* | |
357 | %{_mandir}/man1/rustdoc.1* | |
358 | %dir %{rustlibdir} | |
359 | %dir %{rustlibdir}/%{rust_triple} | |
360 | %{rustlibdir}/%{rust_triple}/analysis | |
361 | %dir %{rustlibdir}/%{rust_triple}/codegen-backends | |
362 | %attr(755,root,root) %{rustlibdir}/%{rust_triple}/codegen-backends/*.so | |
363 | %dir %{rustlibdir}/%{rust_triple}/lib | |
364 | %attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so | |
365 | %{rustlibdir}/%{rust_triple}/lib/*.rlib | |
366 | ||
367 | %files debugger-common | |
368 | %defattr(644,root,root,755) | |
369 | %dir %{_datadir}/%{name} | |
370 | %dir %{_datadir}/%{name}/etc | |
371 | %{_datadir}/%{name}/etc/debugger_*.py* | |
372 | ||
373 | %files lldb | |
374 | %defattr(644,root,root,755) | |
375 | %attr(755,root,root) %{_bindir}/rust-lldb | |
376 | %{_datadir}/%{name}/etc/lldb_*.py* | |
377 | ||
378 | %files gdb | |
379 | %defattr(644,root,root,755) | |
380 | %attr(755,root,root) %{_bindir}/rust-gdb | |
381 | %attr(755,root,root) %{_bindir}/rust-gdbgui | |
382 | %{_datadir}/%{name}/etc/gdb_*.py* | |
383 | ||
384 | %files doc | |
385 | %defattr(644,root,root,755) | |
386 | %dir %{_docdir}/%{name} | |
387 | %doc %{_docdir}/%{name}/html | |
388 | ||
389 | %files -n cargo | |
390 | %defattr(644,root,root,755) | |
391 | %attr(755,root,root) %{_bindir}/cargo | |
392 | %attr(755,root,root) %{_bindir}/cargo-clippy | |
393 | %attr(755,root,root) %{_bindir}/cargo-fmt | |
394 | %attr(755,root,root) %{_bindir}/cargo-miri | |
395 | %attr(755,root,root) %{_bindir}/clippy-driver | |
396 | %{_mandir}/man1/cargo*.1* | |
397 | %dir %{_datadir}/cargo | |
398 | %dir %{_datadir}/cargo/registry | |
399 | ||
400 | %files -n bash-completion-cargo | |
401 | %defattr(644,root,root,755) | |
402 | %{_sysconfdir}/bash_completion.d/cargo | |
403 | ||
404 | %files -n zsh-completion-cargo | |
405 | %defattr(644,root,root,755) | |
406 | %{zsh_compdir}/_cargo |