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