]>
Commit | Line | Data |
---|---|---|
fd992278 JR |
1 | # |
2 | # Conditional build: | |
8e5324db | 3 | %bcond_with bootstrap # bootstrap using precompiled binaries |
fd992278 | 4 | %bcond_without tests # build without tests |
3cb37687 | 5 | |
8e5324db JB |
6 | %define cargo_version %{version} |
7 | %define cargo_bootstrap 0.18.0 | |
3cb37687 JR |
8 | |
9 | Summary: Rust's package manager and build tool | |
8e5324db | 10 | Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania |
3cb37687 JR |
11 | Name: cargo |
12 | Version: 0.19.0 | |
35c0b166 | 13 | Release: 1 |
8e5324db JB |
14 | License: Apache v2.0 or MIT |
15 | Group: Development/Tools | |
3cb37687 | 16 | Source0: https://github.com/rust-lang/cargo/archive/%{cargo_version}/%{name}-%{cargo_version}.tar.gz |
fd992278 | 17 | # Source0-md5: e46e9f565df765b63f641c0d933297d7 |
3cb37687 JR |
18 | # submodule, bundled for local installation only, not distributed |
19 | %define rust_installer 4f994850808a572e2cc8d43f968893c8e942e9bf | |
20 | Source1: https://github.com/rust-lang/rust-installer/archive/%{rust_installer}/rust-installer-%{rust_installer}.tar.gz | |
fd992278 JR |
21 | # Source1-md5: a222edd3ab08779f527aafe862207027 |
22 | Source2: https://static.rust-lang.org/dist/cargo-%{cargo_bootstrap}-x86_64-unknown-linux-gnu.tar.gz | |
23 | # Source2-md5: d2cbab6378c1f60b483efa0f076a8f81 | |
24 | Source3: https://static.rust-lang.org/dist/cargo-%{cargo_bootstrap}-i686-unknown-linux-gnu.tar.gz | |
25 | # Source3-md5: 1ad24c241a2f5e3c4bf83855766fab35 | |
3cb37687 JR |
26 | # Use vendored crate dependencies so we can build offline. |
27 | # Created using https://github.com/alexcrichton/cargo-vendor/ 0.1.7 | |
28 | # It's so big because some of the -sys crates include the C library source they | |
29 | # want to link to. With our -devel buildreqs in place, they'll be used instead. | |
30 | # FIXME: These should all eventually be packaged on their own! | |
fd992278 JR |
31 | Source4: %{name}-%{version}-vendor.tar.xz |
32 | # Source4-md5: c8025d6ba2aa668c0bafc468ec354630 | |
33 | Patch0: use-system-libgit2.patch | |
3cb37687 | 34 | URL: https://crates.io/ |
fd992278 | 35 | %{!?with_bootstrap:BuildRequires: %{name} >= 0.13.0} |
3cb37687 JR |
36 | BuildRequires: cmake |
37 | BuildRequires: gcc | |
38 | BuildRequires: rust | |
39 | # Indirect dependencies for vendored -sys crates above | |
40 | BuildRequires: curl-devel | |
41 | BuildRequires: libgit2-devel >= 0.24 | |
42 | BuildRequires: libssh2-devel | |
43 | BuildRequires: openssl-devel | |
44 | BuildRequires: pkgconfig | |
45 | BuildRequires: zlib-devel | |
46 | Requires: rust | |
fd992278 | 47 | ExclusiveArch: %{x8664} %{ix86} |
7f7cc5c5 | 48 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) |
3cb37687 | 49 | |
8e5324db | 50 | %define rust_triple %{_target_cpu}-unknown-linux-gnu |
3cb37687 | 51 | |
fd992278 JR |
52 | %if %{with bootstrap} |
53 | %define bootstrap_root cargo-%{cargo_bootstrap}-%{rust_triple} | |
54 | %define local_cargo %{_builddir}/%{name}-%{version}/%{bootstrap_root}/cargo/bin/cargo | |
55 | %else | |
56 | %define local_cargo %{_bindir}/%{name} | |
57 | %endif | |
58 | ||
59 | # This should eventually migrate to distro policy | |
60 | # Enable optimization, debuginfo, and link hardening. | |
61 | %define rustflags -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now | |
62 | ||
3cb37687 JR |
63 | %description |
64 | Cargo is a tool that allows Rust projects to declare their various | |
65 | dependencies and ensure that you'll always get a repeatable build. | |
66 | ||
8e5324db JB |
67 | %description -l pl.UTF-8 |
68 | Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich | |
69 | zależności i zapewniające powtarzalność procesu budowania. | |
70 | ||
71 | %package -n bash-completion-cargo | |
72 | Summary: Bash completion for cargo command | |
73 | Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo | |
74 | Group: Applications/Shells | |
75 | Requires: %{name} = %{version}-%{release} | |
76 | Requires: bash-completion | |
77 | ||
78 | %description -n bash-completion-cargo | |
79 | Bash completion for cargo command. | |
80 | ||
81 | %description -n bash-completion-cargo -l pl.UTF-8 | |
82 | Bashowe dopełnianie parametrów polecenia cargo. | |
83 | ||
84 | %package -n zsh-completion-cargo | |
85 | Summary: Zsh completion for cargo command | |
86 | Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh | |
87 | Group: Applications/Shells | |
88 | Requires: %{name} = %{version}-%{release} | |
89 | Requires: bash-completion | |
90 | ||
91 | %description -n zsh-completion-cargo | |
92 | Zsh completion for cargo command. | |
93 | ||
94 | %description -n zsh-completion-cargo -l pl.UTF-8 | |
95 | Dopełnianie parametrów polecenia cargo w powłoce Zsh. | |
96 | ||
3cb37687 | 97 | %prep |
fd992278 JR |
98 | %setup -q -n %{name}-%{cargo_version} -a1 -a4 |
99 | %if %{with bootstrap} | |
100 | %ifarch %{x8664} | |
101 | tar xf %{SOURCE2} | |
102 | %endif | |
103 | %ifarch %{ix86} | |
104 | tar xf %{SOURCE3} | |
105 | %endif | |
3cb37687 JR |
106 | test -f '%{local_cargo}' |
107 | %endif | |
fd992278 | 108 | %patch0 -p1 |
3cb37687 | 109 | |
3cb37687 | 110 | rmdir src/rust-installer |
8e5324db | 111 | %{__mv} rust-installer-%{rust_installer} src/rust-installer |
3cb37687 | 112 | |
8e5324db | 113 | # use our offline registry |
fd992278 | 114 | export CARGO_HOME="`pwd`/.cargo" |
fd992278 JR |
115 | |
116 | mkdir -p "$CARGO_HOME" | |
3cb37687 JR |
117 | cat >.cargo/config <<EOF |
118 | [source.crates-io] | |
119 | registry = 'https://github.com/rust-lang/crates.io-index' | |
120 | replace-with = 'vendored-sources' | |
121 | ||
122 | [source.vendored-sources] | |
fd992278 | 123 | directory = '$PWD/vendor' |
3cb37687 JR |
124 | EOF |
125 | ||
3cb37687 | 126 | %build |
8e5324db JB |
127 | # use our offline registry and custom rustc flags |
128 | export CARGO_HOME="`pwd`/.cargo" | |
129 | export RUSTFLAGS="%{rustflags}" | |
130 | ||
3cb37687 JR |
131 | # convince libgit2-sys to use the distro libgit2 |
132 | export LIBGIT2_SYS_USE_PKG_CONFIG=1 | |
133 | ||
3cb37687 | 134 | %configure \ |
8e5324db JB |
135 | --build=%{rust_triple} \ |
136 | --host=%{rust_triple} \ | |
137 | --target=%{rust_triple} \ | |
3cb37687 | 138 | --cargo=%{local_cargo} \ |
8e5324db JB |
139 | --rustc=%{_bindir}/rustc \ |
140 | --rustdoc=%{_bindir}/rustdoc \ | |
141 | --disable-cross-tests \ | |
142 | --disable-option-checking \ | |
143 | --release-channel=stable | |
3cb37687 JR |
144 | |
145 | %{__make} | |
146 | ||
147 | %install | |
148 | rm -rf $RPM_BUILD_ROOT | |
fd992278 | 149 | export CARGO_HOME="`pwd`/.cargo" |
3cb37687 JR |
150 | export RUSTFLAGS="%{rustflags}" |
151 | ||
152 | %{__make} install \ | |
153 | DESTDIR=$RPM_BUILD_ROOT | |
154 | ||
155 | # Remove installer artifacts (manifests, uninstall scripts, etc.) | |
8e5324db | 156 | %{__rm} -rv $RPM_BUILD_ROOT%{_prefix}/lib/ |
3cb37687 JR |
157 | |
158 | # Fix the etc/ location | |
8e5324db JB |
159 | # (ugh: prepare-image supports /etc outside /usr, but install doesn't!) |
160 | %{__mv} -v $RPM_BUILD_ROOT%{_prefix}/%{_sysconfdir} $RPM_BUILD_ROOT%{_sysconfdir} | |
3cb37687 JR |
161 | |
162 | # Remove unwanted documentation files (we already package them) | |
8e5324db | 163 | %{__rm} -r $RPM_BUILD_ROOT%{_docdir}/%{name}/ |
3cb37687 JR |
164 | |
165 | # Create the path for crate-devel packages | |
166 | install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry | |
167 | ||
168 | %clean | |
169 | rm -rf $RPM_BUILD_ROOT | |
170 | ||
171 | %files | |
172 | %defattr(644,root,root,755) | |
8e5324db | 173 | %doc LICENSE-APACHE LICENSE-MIT LICENSE-THIRD-PARTY README.md |
3cb37687 JR |
174 | %attr(755,root,root) %{_bindir}/cargo |
175 | %{_mandir}/man1/cargo*.1* | |
3cb37687 JR |
176 | %dir %{_datadir}/cargo |
177 | %dir %{_datadir}/cargo/registry | |
8e5324db JB |
178 | |
179 | %files -n bash-completion-cargo | |
180 | %defattr(644,root,root,755) | |
181 | %{_sysconfdir}/bash_completion.d/cargo | |
182 | ||
183 | %files -n zsh-completion-cargo | |
184 | %defattr(644,root,root,755) | |
185 | %{zsh_compdir}/_cargo |