]> git.pld-linux.org Git - packages/rust.git/blob - rust.spec
new, version 1.12.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
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}
15 %else
16 %define rustc_package rustc-%{channel}
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_channel 1.11.0
23 %define bootstrap_date 2016-08-16
24 %define bootstrap_base https://static.rust-lang.org/dist/%{bootstrap_date}/rustc-%{bootstrap_channel}
25
26 Summary:        The Rust Programming Language
27 Name:           rust
28 Version:        1.12.0
29 Release:        0.1
30 License:        (ASL 2.0 or MIT) and (BSD and ISC and MIT)
31 # ^ written as: (rust itself) and (bundled libraries)
32 Group:          Development/Languages
33 Source0:        https://static.rust-lang.org/dist/%{rustc_package}-src.tar.gz
34 %if %{with bootstrap}
35 Source1:        %{bootstrap_base}-x86_64-unknown-linux-gnu.tar.gz
36 Source2:        %{bootstrap_base}-i686-unknown-linux-gnu.tar.gz
37 %endif
38 URL:            https://www.rust-lang.org/
39 BuildRequires:  cmake
40 BuildRequires:  curl
41 BuildRequires:  gcc
42 BuildRequires:  libstdc++-devel
43 BuildRequires:  llvm-devel
44 BuildRequires:  python
45 BuildRequires:  zlib-devel
46 %if %{without bootstrap}
47 BuildRequires:  %{name} < %{version}-%{release}
48 BuildRequires:  %{name} >= %{bootstrap_channel}
49 %endif
50 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
51 BuildRequires:  procps
52 # TODO: work on unbundling these!
53 Provides:       bundled(hoedown) = 3.0.5
54 Provides:       bundled(jquery) = 2.1.4
55 Provides:       bundled(libbacktrace) = 6.1.0
56 Provides:       bundled(miniz) = 1.14
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 rustc-%{bootstrap_channel}-%{rust_triple}
72 %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}/rustc
73 %endif
74
75 # ALL Rust libraries are private, because they don't keep an ABI.
76 %global _privatelibs lib.*-[[:xdigit:]]{8}[.]so.*
77 %global __provides_exclude ^(%{_privatelibs})$
78 %global __requires_exclude ^(%{_privatelibs})$
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 gdb
88 Summary:        GDB pretty printers for Rust
89 Requires:       gdb
90 %if "%{_rpmversion}" >= "5"
91 BuildArch:      noarch
92 %endif
93
94 %description gdb
95 This package includes the rust-gdb script, which allows easier
96 debugging of Rust programs.
97
98 %package doc
99 Summary:        Documentation for Rust
100 # NOT BuildArch:      noarch
101 # Note, while docs are mostly noarch, some things do vary by target_arch.
102 # Koji will fail the build in rpmdiff if two architectures build a noarch
103 # subpackage differently, so instead we have to keep its arch.
104
105 %description doc
106 This package includes HTML documentation for the Rust programming
107 language and its standard library.
108
109 %prep
110 %setup -q -n %{rustc_package}
111 %if %{with bootstrap}
112 %ifarch %{x8664}
113 tar xf %{SOURCE1}
114 %endif
115 %ifarch %{ix86}
116 tar xf %{SOURCE2}
117 %endif
118 test -f %{local_rust_root}/bin/rustc
119 %endif
120
121 # unbundle
122 rm -r src/jemalloc/
123 rm -r src/llvm/
124
125 # extract bundled licenses for packaging
126 cp -p src/rt/hoedown/LICENSE src/rt/hoedown/LICENSE-hoedown
127 sed -e '/*\//q' src/libbacktrace/backtrace.h \
128         >src/libbacktrace/LICENSE-libbacktrace
129
130 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
131 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
132         src/etc/rust-gdb
133
134 # These tests assume that alloc_jemalloc is present
135 sed -i -e '1i // ignore-test jemalloc is disabled' \
136         src/test/compile-fail/allocator-dylib-is-system.rs \
137         src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs \
138         src/test/run-pass/allocator-default.rs
139
140 # Fedora's LLVM doesn't support any mips targets -- see "llc -version".
141 # Fixed properly by Rust PR36344, which should be released in 1.13.
142 sed -i -e '/target=mips/,+1s/^/# unsupported /' \
143         src/test/run-make/atomic-lock-free/Makefile
144
145 %if %{without bootstrap}
146 # The hardcoded stage0 "lib" is inappropriate when using Fedora's own rustc
147 sed -i -e '/^HLIB_RELATIVE/s/lib$/$$(CFG_LIBDIR_RELATIVE)/' mk/main.mk
148 %endif
149
150 %build
151 %configure \
152         --disable-option-checking \
153         --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \
154         --enable-local-rust --local-rust-root=%{local_rust_root} \
155         --llvm-root=%{_prefix} --disable-codegen-tests \
156         --disable-jemalloc \
157         --disable-rpath \
158         --enable-debuginfo \
159         --release-channel=%{channel}
160
161 %{__make} VERBOSE=1
162
163 %if %{with tests}
164 # Note, many of the tests execute in parallel threads,
165 # so it's better not to use a parallel make here.
166 %{__make} -j1 check-lite VERBOSE=1 -k
167 %endif
168
169
170 %install
171 rm -rf $RPM_BUILD_ROOT
172 %{__make} install \
173         VERBOSE=1 \
174         DESTDIR=$RPM_BUILD_ROOT
175
176 # Remove installer artifacts (manifests, uninstall scripts, etc.)
177 find $RPM_BUILD_ROOT%{_libdir}/rustlib/ -maxdepth 1 -type f -exec rm -v '{}' '+'
178
179 # We don't want to ship the target shared libraries for lack of any Rust ABI.
180 find $RPM_BUILD_ROOT%{_libdir}/rustlib/ -type f -name '*.so' -exec rm -v '{}' '+'
181
182 # The remaining shared libraries should be executable for debuginfo extraction.
183 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
184
185 # They also don't need the .rustc metadata anymore, so they won't support linking.
186 # (but direct section removal breaks dynamic symbols -- leave it for now...)
187 #find $RPM_BUILD_ROOT/%{_libdir}/ -type f -name '*.so' -exec objcopy -R .rustc '{}' ';'
188
189 # FIXME: __os_install_post will strip the rlibs
190 # -- should we find a way to preserve debuginfo?
191
192 # Remove unwanted documentation files (we already package them)
193 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
194 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
195 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
196 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
197
198 # Sanitize the HTML documentation
199 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
200 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
201
202 # Move rust-gdb's python scripts so they're noarch
203 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
204 mv -v $RPM_BUILD_ROOT%{_libdir}/rustlib%{_sysconfdir} $RPM_BUILD_ROOT%{_datadir}/%{name}/
205
206 %clean
207 rm -rf $RPM_BUILD_ROOT
208
209 %post   -p /sbin/ldconfig
210 %postun -p /sbin/ldconfig
211
212 %files
213 %defattr(644,root,root,755)
214 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT
215 %doc src/libbacktrace/LICENSE-libbacktrace
216 %doc src/rt/hoedown/LICENSE-hoedown
217 %doc README.md
218 %attr(755,root,root) %{_bindir}/rustc
219 %attr(755,root,root) %{_bindir}/rustdoc
220 %{_mandir}/man1/rustc.1*
221 %{_mandir}/man1/rustdoc.1*
222 %{_libdir}/lib*
223 %dir %{_libdir}/rustlib
224 %{_libdir}/rustlib/%{rust_triple}
225
226 %files gdb
227 %defattr(644,root,root,755)
228 %attr(755,root,root) %{_bindir}/rust-gdb
229 %{_datadir}/%{name}
230
231 %files doc
232 %defattr(644,root,root,755)
233 %dir %{_docdir}/%{name}
234 %doc %{_docdir}/%{name}/html/FiraSans-LICENSE.txt
235 %doc %{_docdir}/%{name}/html/Heuristica-LICENSE.txt
236 %doc %{_docdir}/%{name}/html/LICENSE-APACHE.txt
237 %doc %{_docdir}/%{name}/html/LICENSE-MIT.txt
238 %doc %{_docdir}/%{name}/html/SourceCodePro-LICENSE.txt
239 %doc %{_docdir}/%{name}/html/SourceSerifPro-LICENSE.txt
240 %doc %{_docdir}/%{name}/html/
This page took 0.050214 seconds and 4 git commands to generate.