]> git.pld-linux.org Git - packages/rust.git/blob - rust.spec
- fix non-bootstrap prep
[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 #
5 # Conditional build:
6 %bcond_with     bootstrap
7 %bcond_with     tests           # build without tests
8
9 # The channel can be stable, beta, or nightly
10 %define         channel         stable
11
12 %if "%{channel}" == "stable"
13 %define         rustc_package   rustc-%{version}-src
14 %else
15 %define         rustc_package   rustc-%{channel}-src
16 %endif
17
18 # To bootstrap from scratch, set the channel and date from src/stage0.txt
19 # e.g. 1.10.0 wants rustc: 1.9.0-2016-05-24
20 # or nightly wants some beta-YYYY-MM-DD
21 %define         bootstrap_rust  1.17.0
22 %define         bootstrap_cargo 0.18.0
23 %define         bootstrap_date  2017-04-27
24
25 Summary:        The Rust Programming Language
26 Name:           rust
27 Version:        1.18.0
28 Release:        0.2
29 # Licenses: (rust itself) and (bundled libraries)
30 License:        (ASL 2.0 or MIT) and (BSD and ISC and MIT)
31 Group:          Development/Languages
32 Source0:        https://static.rust-lang.org/dist/%{rustc_package}.tar.gz
33 # Source0-md5:  c37c0cd9d500f6a9d1f2f44401351f88
34 Source1:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.gz
35 # Source1-md5:  98e8f479515969123b4c203191104a54
36 Source2:        https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.gz
37 # Source2-md5:  2d5de850c32aa8d40c8c21abacf749f8
38 URL:            https://www.rust-lang.org/
39 BuildRequires:  cmake
40 BuildRequires:  curl
41 BuildRequires:  gcc
42 BuildRequires:  libstdc++-devel
43 BuildRequires:  libstdc++-devel
44 BuildRequires:  llvm-devel
45 BuildRequires:  ncurses-devel
46 BuildRequires:  python
47 BuildRequires:  zlib-devel
48 %if %{without bootstrap}
49 BuildRequires:  %{name} < %{version}-%{release}
50 BuildRequires:  %{name} >= %{bootstrap_rust}
51 BuildRequires:  cargo >= %{bootstrap_cargo}
52 %endif
53 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
54 BuildRequires:  procps
55 # The C compiler is needed at runtime just for linking.  Someday rustc might
56 # invoke the linker directly, and then we'll only need binutils.
57 # https://github.com/rust-lang/rust/issues/11937
58 Requires:       gcc
59 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
60 # Only x86_64 and i686 are Tier 1 platforms at this time.
61 # https://doc.rust-lang.org/stable/book/getting-started.html#tier-1
62 ExclusiveArch:  %{x8664} %{ix86}
63
64 %define         rust_triple     %{_target_cpu}-unknown-linux-gnu
65
66 %if %{without bootstrap}
67 %define         local_rust_root %{_prefix}
68 %else
69 %define         bootstrap_root  rust-%{bootstrap_rust}-%{rust_triple}
70 %define         local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
71 %endif
72
73 # once_call/once_callable non-function libstdc++ symbols
74 %define         skip_post_check_so      'librustc_llvm-.*\.so.*'
75
76 # ALL Rust libraries are private, because they don't keep an ABI.
77 %define         _noautoreqfiles         lib.*-[[:xdigit:]]{8}[.]so.*
78 %define         _noautoprovfiles        lib.*-[[:xdigit:]]{8}[.]so.*
79
80 %description
81 Rust is a systems programming language that runs blazingly fast,
82 prevents segfaults, and guarantees thread safety.
83
84 This package includes the Rust compiler, standard library, and
85 documentation generator.
86
87 %package debugger-common
88 Summary:        Common debugger pretty printers for Rust
89 Group:          Development/Debuggers
90 BuildArch:      noarch
91
92 %description debugger-common
93 This package includes the common functionality for %{name}-gdb and
94 %{name}-lldb.
95
96 %package gdb
97 Summary:        GDB pretty printers for Rust
98 Group:          Development/Debuggers
99 Requires:       %{name}-debugger-common = %{version}-%{release}
100 Requires:       gdb
101 BuildArch:      noarch
102
103 %description gdb
104 This package includes the rust-gdb script, which allows easier
105 debugging of Rust programs.
106
107 %package lldb
108 Summary:        LLDB pretty printers for Rust
109 Group:          Development/Debuggers
110 Requires:       %{name}-debugger-common = %{version}-%{release}
111 Requires:       lldb
112 Requires:       python-lldb
113 BuildArch:      noarch
114
115 %description lldb
116 This package includes the rust-lldb script, which allows easier
117 debugging of Rust programs.
118
119 %package doc
120 Summary:        Documentation for Rust
121 Group:          Documentation
122 BuildArch:      noarch
123
124 %description doc
125 This package includes HTML documentation for the Rust programming
126 language and its standard library.
127
128 %prep
129 %setup -q -n %{rustc_package}
130 %if %{with bootstrap}
131 %ifarch %{x8664}
132 tar xf %{SOURCE1}
133 %endif
134 %ifarch %{ix86}
135 tar xf %{SOURCE2}
136 %endif
137 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
138 %{bootstrap_root}-root/install.sh \
139         --components=cargo,rustc,rust-std-%{rust_triple} \
140         --prefix=%{local_rust_root} \
141         --disable-ldconfig
142 test -f %{local_rust_root}/bin/cargo
143 test -f %{local_rust_root}/bin/rustc
144 %endif
145
146 # unbundle
147 rm -r src/jemalloc/
148 rm -r src/llvm/
149
150 # extract bundled licenses for packaging
151 cp -p src/rt/hoedown/LICENSE src/rt/hoedown/LICENSE-hoedown
152 sed -e '/*\//q' src/libbacktrace/backtrace.h \
153         >src/libbacktrace/LICENSE-libbacktrace
154
155 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
156 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
157         src/etc/rust-gdb
158
159 # These tests assume that alloc_jemalloc is present
160 sed -i -e '1i // ignore-test jemalloc is disabled' \
161         src/test/compile-fail/allocator-dylib-is-system.rs \
162         src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs \
163         src/test/run-pass/allocator-default.rs
164
165 # Fedora's LLVM doesn't support any mips targets -- see "llc -version".
166 # Fixed properly by Rust PR36344, which should be released in 1.13.
167 sed -i -e '/target=mips/,+1s/^/# unsupported /' \
168         src/test/run-make/atomic-lock-free/Makefile
169
170 %build
171 %configure \
172         --disable-option-checking \
173         --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \
174         --enable-local-rust --local-rust-root=%{local_rust_root} \
175         --llvm-root=%{_prefix} --disable-codegen-tests \
176         --disable-jemalloc \
177         --disable-rpath \
178         --enable-debuginfo \
179         --enable-vendor \
180         --release-channel=%{channel}
181
182 ./x.py dist
183
184 %{?with_tests:./x.py test}
185
186 %install
187 rm -rf $RPM_BUILD_ROOT
188
189 DESTDIR=$RPM_BUILD_ROOT ./x.py dist --install
190
191 # The shared libraries should be executable for debuginfo extraction.
192 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
193
194 # The libdir libraries are identical to those under rustlib/.  It's easier on
195 # library loading if we keep them in libdir, but we do need them in rustlib/
196 # to support dynamic linking for compiler plugins, so we'll symlink.
197 (cd "$RPM_BUILD_ROOT%{_libdir}/rustlib/%{rust_triple}/lib" &&
198         find ../../../../%{_lib} -maxdepth 1 -name '*.so' \
199         -exec ln -v -f -s -t . '{}' '+')
200
201 # Remove installer artifacts (manifests, uninstall scripts, etc.)
202 find $RPM_BUILD_ROOT%{_libdir}/rustlib/ -maxdepth 1 -type f -exec rm -v '{}' '+'
203
204 # FIXME: __os_install_post will strip the rlibs
205 # -- should we find a way to preserve debuginfo?
206
207 # Remove unwanted documentation files (we already package them)
208 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
209 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
210 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
211 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
212
213 # Sanitize the HTML documentation
214 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
215 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
216
217 # Move rust-gdb's python scripts so they're noarch
218 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
219 mv -v $RPM_BUILD_ROOT%{_libdir}/rustlib%{_sysconfdir} $RPM_BUILD_ROOT%{_datadir}/%{name}/
220
221 %clean
222 rm -rf $RPM_BUILD_ROOT
223
224 %post   -p /sbin/ldconfig
225 %postun -p /sbin/ldconfig
226
227 %files
228 %defattr(644,root,root,755)
229 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT
230 %doc src/libbacktrace/LICENSE-libbacktrace
231 %doc src/rt/hoedown/LICENSE-hoedown
232 %doc README.md
233 %attr(755,root,root) %{_bindir}/rustc
234 %attr(755,root,root) %{_bindir}/rustdoc
235 %{_mandir}/man1/rustc.1*
236 %{_mandir}/man1/rustdoc.1*
237 %{_libdir}/lib*
238 %dir %{_libdir}/rustlib
239 %{_libdir}/rustlib/%{rust_triple}
240
241 %files debugger-common
242 %defattr(644,root,root,755)
243 %dir %{_datadir}/%{name}
244 %dir %{_datadir}/%{name}/etc
245 %{_datadir}/%{name}/etc/debugger_*.py*
246
247 %files lldb
248 %defattr(644,root,root,755)
249 %attr(755,root,root) %{_bindir}/rust-lldb
250 %{_datadir}/%{name}/etc/lldb_*.py*
251
252 %files gdb
253 %defattr(644,root,root,755)
254 %attr(755,root,root) %{_bindir}/rust-gdb
255 %{_datadir}/%{name}/etc/gdb_*.py*
256
257 %files doc
258 %defattr(644,root,root,755)
259 %dir %{_docdir}/%{name}
260 %doc %{_docdir}/%{name}/html
This page took 0.080428 seconds and 4 git commands to generate.