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