]> git.pld-linux.org Git - packages/rust.git/blob - rust.spec
- relax internal deps
[packages/rust.git] / rust.spec
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_with     tests           # build without tests
11
12 # The channel can be stable, beta, or nightly
13 %define         channel         stable
14
15 %if "%{channel}" == "stable"
16 %define         rustc_package   rustc-%{version}-src
17 %else
18 %define         rustc_package   rustc-%{channel}-src
19 %endif
20
21 # To bootstrap from scratch, set the channel and date from src/stage0.txt
22 # e.g. 1.10.0 wants rustc: 1.9.0-2016-05-24
23 # or nightly wants some beta-YYYY-MM-DD
24 %define         bootstrap_rust  1.51.0
25 %define         bootstrap_cargo 1.51.0
26 %define         bootstrap_date  2021-03-25
27
28 %ifarch x32
29 %define         with_cross      1
30 %endif
31
32 %if %{without full_debuginfo}
33 %define         _enable_debug_packages  0
34 %endif
35
36 Summary:        The Rust Programming Language
37 Summary(pl.UTF-8):      Język programowania Rust
38 Name:           rust
39 Version:        1.52.1
40 Release:        1
41 # Licenses: (rust itself) and (bundled libraries)
42 License:        (Apache v2.0 or MIT) and (BSD and ISC and MIT)
43 Group:          Development/Languages
44 Source0:        https://static.rust-lang.org/dist/%{rustc_package}.tar.xz
45 # Source0-md5:  2df4835e3a15cc6f7e06fa4a986285d2
46 Source1:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.xz
47 # Source1-md5:  7640d6538716c6492e56f361e3af0631
48 Source2:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.xz
49 # Source2-md5:  64f117dc1ae1543c8910eaa9a971ddd4
50 Source3:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-aarch64-unknown-linux-gnu.tar.xz
51 # Source3-md5:  3ac79872671df7ea0215fd351f52ffcf
52 Source4:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-arm-unknown-linux-gnueabihf.tar.xz
53 # Source4-md5:  f624772d7c7ba2e83a51b4e9c1657f7b
54 Patch0:         %{name}-x32.patch
55 URL:            https://www.rust-lang.org/
56 # for src/compiler-rt
57 BuildRequires:  cmake >= 3.4.3
58 BuildRequires:  curl
59 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
60 BuildRequires:  procps
61 BuildRequires:  python >= 1:2.7
62 BuildRequires:  rpmbuild(macros) >= 1.752
63 %if %{without cross}
64 BuildRequires:  curl-devel
65 BuildRequires:  libgit2-devel >= 1.1.0
66 BuildRequires:  libstdc++-devel
67 %{?with_system_llvm:BuildRequires:      llvm-devel >= 9.0}
68 BuildRequires:  openssl-devel >= 1.0.1
69 BuildRequires:  tar >= 1:1.22
70 BuildRequires:  xz
71 BuildRequires:  zlib-devel
72 %endif
73 %if %{without bootstrap}
74 BuildRequires:  %{name} >= %{bootstrap_rust}
75 BuildRequires:  cargo >= %{bootstrap_cargo}
76 BuildConflicts: %{name} > %{version}
77 %endif
78 %ifarch x32
79 BuildRequires:  glibc-devel(x86-64)
80 BuildRequires:  glibc-devel(x86-x32)
81 %if "%{_host_cpu}" == "x86_64"
82 # building on x86_64 host with --target x32-pld-linux
83 BuildRequires:  curl-devel
84 BuildRequires:  gcc-multilib-x32
85 BuildRequires:  libgit2-devel >= 1.1.0
86 BuildRequires:  libstdc++-devel
87 %{?with_system_llvm:BuildRequires:      llvm-devel >= 9.0}
88 BuildRequires:  openssl-devel >= 1.0.1
89 BuildRequires:  zlib-devel
90 %else
91 # building x86_64-hosted crosscompiler on x32 host
92 BuildRequires:  curl-devel(x86-64)
93 BuildRequires:  curl-devel(x86-x32)
94 BuildRequires:  gcc-multilib-64
95 BuildRequires:  libgit2-devel(x86-64) >= 1.1.0
96 BuildRequires:  libgit2-devel(x86-x32) >= 1.1.0
97 BuildRequires:  libstdc++-multilib-64-devel
98 %if %{with system_llvm}
99 BuildRequires:  llvm-devel(x86-64) >= 9.0
100 BuildRequires:  llvm-devel(x86-x32) >= 9.0
101 %endif
102 BuildRequires:  openssl-devel(x86-64)
103 BuildRequires:  openssl-devel(x86-x32)
104 BuildRequires:  zlib-devel(x86-64)
105 BuildRequires:  zlib-devel(x86-x32)
106 %endif
107 %endif
108 # The C compiler is needed at runtime just for linking.  Someday rustc might
109 # invoke the linker directly, and then we'll only need binutils.
110 # https://github.com/rust-lang/rust/issues/11937
111 Requires:       gcc
112 Requires:       %{name}-std%{?_isa} = %{version}-%{release}
113 %ifarch x32
114 Requires:       %{name}-std(x86-64) = %{version}-%{release}
115 %endif
116 # Only x86_64 and i686 are Tier 1 platforms at this time.
117 # x32 is Tier 2, only rust-std is available (no rustc or cargo).
118 # https://doc.rust-lang.org/nightly/rustc/platform-support.html
119 ExclusiveArch:  %{x8664} %{ix86} x32 aarch64 armv6hl armv7hl armv7hnl
120 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
121
122 %ifarch x32
123 %define         rust_triple             x86_64-unknown-linux-gnux32
124 %define         rust_host_triple        x86_64-unknown-linux-gnu
125 %define         rust_bootstrap_triple   x86_64-unknown-linux-gnu
126 %else
127 %ifarch armv6hl armv7hl armv7hnl
128 %define         rust_triple             arm-unknown-linux-gnueabihf
129 %define         rust_host_triple        %{rust_triple}
130 %define         rust_bootstrap_triple   %{rust_triple}
131 %else
132 %define         rust_triple             %{_target_cpu}-unknown-linux-gnu
133 %define         rust_host_triple        %{rust_triple}
134 %define         rust_bootstrap_triple   %{rust_triple}
135 %endif
136 %endif
137
138 %if %{without bootstrap}
139 %define         local_rust_root %{_prefix}
140 %else
141 %define         bootstrap_root  rust-%{bootstrap_rust}-%{rust_bootstrap_triple}
142 %define         local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
143 %endif
144
145 # We're going to override --libdir when configuring to get rustlib into a
146 # common path, but we'll fix the shared libraries during install.
147 # Without this ugly hack, rust would not be able to build itself
148 # for non-bootstrap build, lib64 is just too complicated for it.
149 %define         common_libdir   %{_prefix}/lib
150 %define         rustlibdir      %{common_libdir}/rustlib
151
152 # once_call/once_callable non-function libstdc++ symbols
153 %define         skip_post_check_so      'librustc.*llvm.*\.so.*'
154
155 # ALL Rust libraries are private, because they don't keep an ABI.
156 %define         _noautoreqfiles         lib.*-[[:xdigit:]]{8}[.]so.*
157 %define         _noautoprovfiles        lib.*-[[:xdigit:]]{8}[.]so.*
158
159 %define         x_py { \
160         x_py() { \
161                 local cmd="$1"; \
162                 shift; \
163                 %{?__jobs:CARGO_BUILD_JOBS=%__jobs }./x.py "$cmd" %{?__jobs:-j %__jobs} "$@"; \
164         }; x_py }
165
166
167 %description
168 Rust is a systems programming language that runs blazingly fast,
169 prevents segfaults, and guarantees thread safety.
170
171 This package includes the Rust compiler, standard library, and
172 documentation generator.
173
174 %description -l pl.UTF-8
175 Rust to systemowy język programowania działający bardzo szybko,
176 zapobiegający naruszeniom ochrony pamięci i gwarantujący
177 bezpieczną wielowątkowość.
178
179 %package analysis
180 Summary:        Metadata about the standard library
181 Summary(pl.UTF-8):      Metadane o standardowej bibliotece
182 Group:          Development/Tools
183 Requires:       %{name} = %{version}-%{release}
184
185 %description analysis
186 Metadata about the standard library.
187
188 %description analysis -l pl.UTF-8
189 Metadane o standardowej bibliotece.
190
191 %package std
192 Summary:        Standard library for Rust
193 Summary(pl.UTF-8):      Standardowa biblioteka Rusta
194 Group:          Development/Tools
195 Requires:       %{name} = %{version}-%{release}
196
197 %description std
198 Standard library for Rust.
199
200 %description std -l pl.UTF-8
201 Standardowa biblioteka Rusta.
202
203 %package analyzer
204 Summary:        Implementation of Language Server Protocol for Rust
205 Summary(pl.UTF-8):      Implementacja Language Server Protocol dla Rusta
206 Group:          Development/Tools
207 Requires:       %{name} = %{version}-%{release}
208
209 %description analyzer
210 Implementation of Language Server Protocol for Rust.
211
212 %description analyzer -l pl.UTF-8
213 Implementacja Language Server Protocol dla Rusta.
214
215 %package debugger-common
216 Summary:        Common debugger pretty printers for Rust
217 Summary(pl.UTF-8):      Narzędzia wypisujące struktury Rusa wspólne dla różnych debuggerów
218 Group:          Development/Debuggers
219 BuildArch:      noarch
220
221 %description debugger-common
222 This package includes the common functionality for rust-gdb and
223 rust-lldb.
224
225 %description debugger-common -l pl.UTF-8
226 Ten pakiet zawiera wspólny kod dla pakietów rust-gdb i rust-lldb.
227
228 %package gdb
229 Summary:        GDB pretty printers for Rust
230 Summary(pl.UTF-8):      Ładne wypisywanie struktur Rusta w GDB
231 Group:          Development/Debuggers
232 Requires:       %{name}-debugger-common = %{version}-%{release}
233 Requires:       gdb
234 BuildArch:      noarch
235
236 %description gdb
237 This package includes the rust-gdb script, which allows easier
238 debugging of Rust programs.
239
240 %description gdb -l pl.UTF-8
241 Ten pakiet zawiera skrypt rust-gdb, pozwalający na łatwiejsze
242 odpluskwianie programów w języku Rust.
243
244 %package lldb
245 Summary:        LLDB pretty printers for Rust
246 Summary(pl.UTF-8):      Ładne wypisywanie struktur Rusta w LLDB
247 Group:          Development/Debuggers
248 Requires:       %{name}-debugger-common = %{version}-%{release}
249 Requires:       lldb
250 BuildArch:      noarch
251
252 %description lldb
253 This package includes the rust-lldb script, which allows easier
254 debugging of Rust programs.
255
256 %description lldb -l pl.UTF-8
257 Ten pakiet zawiera skrypt rust-lldb, pozwalający na łatwiejsze
258 odpluskwianie programów w języku Rust.
259
260 %package rls
261 Summary:        Rust Language Server for IDE integration
262 Summary(pl.UTF-8):      Rust Language Server do integracji z IDE
263 Group:          Development/Tools
264 Requires:       %{name} = %{version}-%{release}
265 Requires:       %{name}-analysis = %{version}-%{release}
266
267 %description rls
268 Rust Language Server for IDE integration.
269
270 %description rls -l pl.UTF-8
271 Rust Language Server do integracji z IDE.
272
273 %package doc
274 Summary:        Documentation for Rust
275 Summary(pl.UTF-8):      Dokumentacja do Rusta
276 Group:          Documentation
277 BuildArch:      noarch
278
279 %description doc
280 This package includes HTML documentation for the Rust programming
281 language and its standard library.
282
283 %description doc -l pl.UTF-8
284 Ten pakiet zawiera dokumentację w formacie HTML do języka
285 programowania Rust i jego biblioteki standardowej.
286
287 %package -n cargo
288 Summary:        Rust's package manager and build tool
289 Summary(pl.UTF-8):      Zarządca pakietów i narzędzie do budowania
290 Group:          Development/Tools
291 Requires:       %{name}%{?_isa}
292
293 %description -n cargo
294 Cargo is a tool that allows Rust projects to declare their various
295 dependencies and ensure that you'll always get a repeatable build.
296
297 %description -n cargo -l pl.UTF-8
298 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
299 zależności i zapewniające powtarzalność procesu budowania.
300
301 %package -n bash-completion-cargo
302 Summary:        Bash completion for cargo command
303 Summary(pl.UTF-8):      Bashowe dopełnianie parametrów polecenia cargo
304 Group:          Applications/Shells
305 Requires:       %{name} = %{version}-%{release}
306 Requires:       bash-completion
307
308 %description -n bash-completion-cargo
309 Bash completion for cargo command.
310
311 %description -n bash-completion-cargo -l pl.UTF-8
312 Bashowe dopełnianie parametrów polecenia cargo.
313
314 %package -n zsh-completion-cargo
315 Summary:        Zsh completion for cargo command
316 Summary(pl.UTF-8):      Dopełnianie parametrów polecenia cargo w powłoce Zsh
317 Group:          Applications/Shells
318 Requires:       %{name} = %{version}-%{release}
319 Requires:       zsh
320
321 %description -n zsh-completion-cargo
322 Zsh completion for cargo command.
323
324 %description -n zsh-completion-cargo -l pl.UTF-8
325 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
326
327 %prep
328 %setup -q -n %{rustc_package}
329 # irrelevant when not building rustc for x32
330 #%%patch0 -p1
331
332 %if %{with bootstrap}
333 %ifarch %{x8664} x32
334 tar xf %{SOURCE1}
335 %endif
336 %ifarch %{ix86}
337 tar xf %{SOURCE2}
338 %endif
339 %ifarch aarch64
340 tar xf %{SOURCE3}
341 %endif
342 %ifarch armv6hl armv7hl armv7hnl
343 tar xf %{SOURCE4}
344 %endif
345 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
346 %{bootstrap_root}-root/install.sh \
347         --components=cargo,rustc,rust-std-%{rust_bootstrap_triple} \
348         --prefix=%{local_rust_root} \
349         --disable-ldconfig
350 test -f %{local_rust_root}/bin/cargo
351 test -f %{local_rust_root}/bin/rustc
352 %endif
353
354 # unbundle
355 # We're disabling jemalloc, but rust-src still wants it.
356 #%{__rm} -r src/jemalloc
357 %if %{with system_llvm}
358 %{__rm} -r src/llvm-project
359 mkdir -p src/llvm-project/libunwind
360 %endif
361
362 # extract bundled licenses for packaging
363 sed -e '/*\//q' library/backtrace/crates/backtrace-sys/src/libbacktrace/backtrace.h \
364         >library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
365
366 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
367 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
368         src/etc/rust-gdb
369
370 # The configure macro will modify some autoconf-related files, which upsets
371 # cargo when it tries to verify checksums in those files.  If we just truncate
372 # that file list, cargo won't have anything to complain about.
373 find vendor -name .cargo-checksum.json \
374         -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
375
376 %build
377 %configure \
378         --build=%{rust_bootstrap_triple} \
379         --host=%{rust_host_triple} \
380         --target=%{rust_triple} \
381         --libdir=%{common_libdir} \
382         --disable-codegen-tests \
383         --disable-debuginfo-lines \
384 %if %{with full_debuginfo}
385         --disable-debuginfo-only-std \
386         --enable-debuginfo \
387 %else
388         --enable-debuginfo-only-std \
389         --disable-debuginfo \
390 %endif
391         --disable-jemalloc \
392         --disable-option-checking \
393         --disable-rpath \
394         --enable-extended \
395         --enable-llvm-link-shared \
396         --enable-vendor \
397         --local-rust-root=%{local_rust_root} \
398         --llvm-root=%{_prefix} \
399         --release-channel=%{channel}
400
401 export RUST_BACKTRACE=full
402 %x_py dist --verbose
403
404 %{?with_tests:%x_py test}
405
406 %install
407 rm -rf $RPM_BUILD_ROOT
408
409 export DESTDIR=$RPM_BUILD_ROOT
410 %x_py install
411
412 # Make sure the shared libraries are in the proper libdir
413 %if "%{_libdir}" != "%{common_libdir}"
414 mkdir -p %{buildroot}%{_libdir}
415 find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
416         -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
417 %endif
418
419 # The shared libraries should be executable for debuginfo extraction.
420 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
421
422 # The libdir libraries are identical to those under rustlib/.  It's easier on
423 # library loading if we keep them in libdir, but we do need them in rustlib/
424 # to support dynamic linking for compiler plugins, so we'll symlink.
425 (cd "$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib" &&
426         find ../../../../%{_lib} -maxdepth 1 -name '*.so' \
427         -exec ln -v -f -s -t . '{}' '+')
428
429 # Remove installer artifacts (manifests, uninstall scripts, etc.)
430 find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
431
432 # FIXME: __os_install_post will strip the rlibs
433 # -- should we find a way to preserve debuginfo?
434
435 # Remove unwanted documentation files (we already package them)
436 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
437 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
438 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
439 %{__rm} $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
440
441 # Sanitize the HTML documentation
442 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
443 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
444
445 # Move rust-gdb's python scripts so they're noarch
446 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
447 %{__mv} $RPM_BUILD_ROOT%{rustlibdir}/etc $RPM_BUILD_ROOT%{_datadir}/%{name}
448
449 # We don't need stdlib source
450 %{__rm} -r $RPM_BUILD_ROOT%{rustlibdir}/src
451
452 # Create the path for crate-devel packages
453 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
454
455 %clean
456 rm -rf $RPM_BUILD_ROOT
457
458 %post   -p /sbin/ldconfig
459 %postun -p /sbin/ldconfig
460
461 %files
462 %defattr(644,root,root,755)
463 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT README.md library/backtrace/crates/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace
464 %attr(755,root,root) %{_bindir}/miri
465 %attr(755,root,root) %{_bindir}/rustc
466 %attr(755,root,root) %{_bindir}/rustdoc
467 %attr(755,root,root) %{_bindir}/rustfmt
468 %attr(755,root,root) %{_libdir}/librustc*-*.so
469 %attr(755,root,root) %{_libdir}/libstd-*.so
470 %attr(755,root,root) %{_libdir}/libtest-*.so
471 %{_mandir}/man1/rustc.1*
472 %{_mandir}/man1/rustdoc.1*
473 %dir %{rustlibdir}
474
475 %files analysis
476 %defattr(644,root,root,755)
477 %{rustlibdir}/%{rust_triple}/analysis
478
479 %files std
480 %defattr(644,root,root,755)
481 %dir %{rustlibdir}/%{rust_triple}
482 %dir %{rustlibdir}/%{rust_triple}/lib
483 %attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so
484 %{rustlibdir}/%{rust_triple}/lib/*.rlib
485
486 %files analyzer
487 %defattr(644,root,root,755)
488 %attr(755,root,root) %{_bindir}/rust-analyzer
489
490 %files debugger-common
491 %defattr(644,root,root,755)
492 %dir %{_datadir}/%{name}
493 %dir %{_datadir}/%{name}/etc
494 %{_datadir}/%{name}/etc/lldb_commands
495 %{_datadir}/%{name}/etc/rust_types.py
496
497 %files lldb
498 %defattr(644,root,root,755)
499 %attr(755,root,root) %{_bindir}/rust-lldb
500 %{_datadir}/%{name}/etc/lldb_*.py*
501
502 %files gdb
503 %defattr(644,root,root,755)
504 %attr(755,root,root) %{_bindir}/rust-gdb
505 %attr(755,root,root) %{_bindir}/rust-gdbgui
506 %{_datadir}/%{name}/etc/gdb_*.py*
507
508 %files rls
509 %defattr(644,root,root,755)
510 %attr(755,root,root) %{_bindir}/rls
511
512 %files doc
513 %defattr(644,root,root,755)
514 %dir %{_docdir}/%{name}
515 %doc %{_docdir}/%{name}/html
516
517 %files -n cargo
518 %defattr(644,root,root,755)
519 %attr(755,root,root) %{_bindir}/cargo
520 %attr(755,root,root) %{_bindir}/cargo-clippy
521 %attr(755,root,root) %{_bindir}/cargo-fmt
522 %attr(755,root,root) %{_bindir}/cargo-miri
523 %attr(755,root,root) %{_bindir}/clippy-driver
524 %attr(755,root,root) %{_libexecdir}/cargo-credential-1password
525 %{_mandir}/man1/cargo*.1*
526 %dir %{_datadir}/cargo
527 %dir %{_datadir}/cargo/registry
528
529 %files -n bash-completion-cargo
530 %defattr(644,root,root,755)
531 %{_sysconfdir}/bash_completion.d/cargo
532
533 %files -n zsh-completion-cargo
534 %defattr(644,root,root,755)
535 %{zsh_compdir}/_cargo
This page took 0.110466 seconds and 3 git commands to generate.