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