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