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