]> git.pld-linux.org Git - packages/rust.git/blob - rust.spec
- started update to 1.18.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}-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 %global 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 License:        (ASL 2.0 or MIT) and (BSD and ISC and MIT)
32 # ^ written as: (rust itself) and (bundled libraries)
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:  llvm-devel
46 BuildRequires:  python
47 BuildRequires:  zlib-devel
48 %if %{without bootstrap}
49 BuildRequires:  cargo >= %{bootstrap_cargo}
50 BuildRequires:  %{name} < %{version}-%{release}
51 BuildRequires:  %{name} >= %{bootstrap_rust}
52 %endif
53 # make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
54 BuildRequires:  procps
55 # TODO: work on unbundling these!
56 Provides:       bundled(hoedown) = 3.0.5
57 Provides:       bundled(jquery) = 2.1.4
58 Provides:       bundled(libbacktrace) = 6.1.0
59 Provides:       bundled(miniz) = 1.14
60 # The C compiler is needed at runtime just for linking.  Someday rustc might
61 # invoke the linker directly, and then we'll only need binutils.
62 # https://github.com/rust-lang/rust/issues/11937
63 Requires:       gcc
64 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
65 # Only x86_64 and i686 are Tier 1 platforms at this time.
66 # https://doc.rust-lang.org/stable/book/getting-started.html#tier-1
67 ExclusiveArch:  %{x8664} %{ix86} %{arm}
68
69 %define rust_triple %{_target_cpu}-unknown-linux-gnu
70
71 %if %{without bootstrap}
72 %define local_rust_root %{_prefix}
73 %else
74 %define bootstrap_root rust-%{bootstrap_rust}-%{rust_triple}
75 %define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
76 %endif
77
78 # ALL Rust libraries are private, because they don't keep an ABI.
79 %global _privatelibs lib.*-[[:xdigit:]]{8}[.]so.*
80 %global __provides_exclude ^(%{_privatelibs})$
81 %global __requires_exclude ^(%{_privatelibs})$
82
83 %description
84 Rust is a systems programming language that runs blazingly fast,
85 prevents segfaults, and guarantees thread safety.
86
87 This package includes the Rust compiler, standard library, and
88 documentation generator.
89
90 %package gdb
91 Summary:        GDB pretty printers for Rust
92 Requires:       gdb
93 %if "%{_rpmversion}" >= "5"
94 BuildArch:      noarch
95 %endif
96
97 %description gdb
98 This package includes the rust-gdb script, which allows easier
99 debugging of Rust programs.
100
101 %package doc
102 Summary:        Documentation for Rust
103 # NOT BuildArch:      noarch
104 # Note, while docs are mostly noarch, some things do vary by target_arch.
105 # Koji will fail the build in rpmdiff if two architectures build a noarch
106 # subpackage differently, so instead we have to keep its arch.
107
108 %description doc
109 This package includes HTML documentation for the Rust programming
110 language and its standard library.
111
112 %prep
113 %setup -q -n %{rustc_package}
114 %if %{with bootstrap}
115 %ifarch %{x8664}
116 tar xf %{SOURCE1}
117 %endif
118 %ifarch %{ix86}
119 tar xf %{SOURCE2}
120 %endif
121 %{__mv} %{bootstrap_root} %{bootstrap_root}-root
122 %{bootstrap_root}-root/install.sh \
123         --components=cargo,rustc,rust-std-%{rust_triple} \
124         --prefix=%{local_rust_root} \
125         --disable-ldconfig
126 test -f %{local_rust_root}/bin/cargo
127 test -f %{local_rust_root}/bin/rustc
128 %endif
129
130 # unbundle
131 rm -r src/jemalloc/
132 rm -r src/llvm/
133
134 # extract bundled licenses for packaging
135 cp -p src/rt/hoedown/LICENSE src/rt/hoedown/LICENSE-hoedown
136 sed -e '/*\//q' src/libbacktrace/backtrace.h \
137         >src/libbacktrace/LICENSE-libbacktrace
138
139 # rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
140 sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
141         src/etc/rust-gdb
142
143 # These tests assume that alloc_jemalloc is present
144 sed -i -e '1i // ignore-test jemalloc is disabled' \
145         src/test/compile-fail/allocator-dylib-is-system.rs \
146         src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs \
147         src/test/run-pass/allocator-default.rs
148
149 # Fedora's LLVM doesn't support any mips targets -- see "llc -version".
150 # Fixed properly by Rust PR36344, which should be released in 1.13.
151 sed -i -e '/target=mips/,+1s/^/# unsupported /' \
152         src/test/run-make/atomic-lock-free/Makefile
153
154 %if %{without bootstrap}
155 # The hardcoded stage0 "lib" is inappropriate when using Fedora's own rustc
156 sed -i -e '/^HLIB_RELATIVE/s/lib$/$$(CFG_LIBDIR_RELATIVE)/' mk/main.mk
157 %endif
158
159 %build
160 %configure \
161         --disable-option-checking \
162         --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \
163         --enable-local-rust --local-rust-root=%{local_rust_root} \
164         --llvm-root=%{_prefix} --disable-codegen-tests \
165         --disable-jemalloc \
166         --disable-rpath \
167         --enable-debuginfo \
168         --enable-vendor \
169         --release-channel=%{channel}
170
171 ./x.py dist
172
173 %install
174 rm -rf $RPM_BUILD_ROOT
175 %{__make} install \
176         VERBOSE=1 \
177         DESTDIR=$RPM_BUILD_ROOT
178
179 # Remove installer artifacts (manifests, uninstall scripts, etc.)
180 find $RPM_BUILD_ROOT%{_libdir}/rustlib/ -maxdepth 1 -type f -exec rm -v '{}' '+'
181
182 # We don't want to ship the target shared libraries for lack of any Rust ABI.
183 find $RPM_BUILD_ROOT%{_libdir}/rustlib/ -type f -name '*.so' -exec rm -v '{}' '+'
184
185 # The remaining shared libraries should be executable for debuginfo extraction.
186 find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
187
188 # They also don't need the .rustc metadata anymore, so they won't support linking.
189 # (but direct section removal breaks dynamic symbols -- leave it for now...)
190 #find $RPM_BUILD_ROOT/%{_libdir}/ -type f -name '*.so' -exec objcopy -R .rustc '{}' ';'
191
192 # FIXME: __os_install_post will strip the rlibs
193 # -- should we find a way to preserve debuginfo?
194
195 # Remove unwanted documentation files (we already package them)
196 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
197 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
198 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
199 rm $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
200
201 # Sanitize the HTML documentation
202 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
203 find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
204
205 # Move rust-gdb's python scripts so they're noarch
206 install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
207 mv -v $RPM_BUILD_ROOT%{_libdir}/rustlib%{_sysconfdir} $RPM_BUILD_ROOT%{_datadir}/%{name}/
208
209 %clean
210 rm -rf $RPM_BUILD_ROOT
211
212 %post   -p /sbin/ldconfig
213 %postun -p /sbin/ldconfig
214
215 %files
216 %defattr(644,root,root,755)
217 %doc COPYRIGHT LICENSE-APACHE LICENSE-MIT
218 %doc src/libbacktrace/LICENSE-libbacktrace
219 %doc src/rt/hoedown/LICENSE-hoedown
220 %doc README.md
221 %attr(755,root,root) %{_bindir}/rustc
222 %attr(755,root,root) %{_bindir}/rustdoc
223 %{_mandir}/man1/rustc.1*
224 %{_mandir}/man1/rustdoc.1*
225 %{_libdir}/lib*
226 %dir %{_libdir}/rustlib
227 %{_libdir}/rustlib/%{rust_triple}
228
229 %files gdb
230 %defattr(644,root,root,755)
231 %attr(755,root,root) %{_bindir}/rust-gdb
232 %{_datadir}/%{name}
233
234 %files doc
235 %defattr(644,root,root,755)
236 %dir %{_docdir}/%{name}
237 %doc %{_docdir}/%{name}/html/FiraSans-LICENSE.txt
238 %doc %{_docdir}/%{name}/html/Heuristica-LICENSE.txt
239 %doc %{_docdir}/%{name}/html/LICENSE-APACHE.txt
240 %doc %{_docdir}/%{name}/html/LICENSE-MIT.txt
241 %doc %{_docdir}/%{name}/html/SourceCodePro-LICENSE.txt
242 %doc %{_docdir}/%{name}/html/SourceSerifPro-LICENSE.txt
243 %doc %{_docdir}/%{name}/html/
This page took 0.045317 seconds and 4 git commands to generate.