3 %bcond_with bootstrap # bootstrap using precompiled binaries
4 %bcond_without tests # build without tests
6 %define cargo_version %{version}
7 %define cargo_bootstrap 0.18.0
9 Summary: Rust's package manager and build tool
10 Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania
14 License: Apache v2.0 or MIT
15 Group: Development/Tools
16 Source0: https://github.com/rust-lang/cargo/archive/%{cargo_version}/%{name}-%{cargo_version}.tar.gz
17 # Source0-md5: e46e9f565df765b63f641c0d933297d7
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
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
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!
31 Source4: %{name}-%{version}-vendor.tar.xz
32 # Source4-md5: c8025d6ba2aa668c0bafc468ec354630
33 Patch0: use-system-libgit2.patch
34 URL: https://crates.io/
35 %{!?with_bootstrap:BuildRequires: %{name} >= 0.13.0}
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
47 ExclusiveArch: %{x8664} %{ix86}
48 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
50 %define rust_triple %{_target_cpu}-unknown-linux-gnu
53 %define bootstrap_root cargo-%{cargo_bootstrap}-%{rust_triple}
54 %define local_cargo %{_builddir}/%{name}-%{version}/%{bootstrap_root}/cargo/bin/cargo
56 %define local_cargo %{_bindir}/%{name}
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
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.
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.
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
78 %description -n bash-completion-cargo
79 Bash completion for cargo command.
81 %description -n bash-completion-cargo -l pl.UTF-8
82 Bashowe dopełnianie parametrów polecenia cargo.
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
91 %description -n zsh-completion-cargo
92 Zsh completion for cargo command.
94 %description -n zsh-completion-cargo -l pl.UTF-8
95 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
98 %setup -q -n %{name}-%{cargo_version} -a1 -a4
106 test -f '%{local_cargo}'
110 rmdir src/rust-installer
111 %{__mv} rust-installer-%{rust_installer} src/rust-installer
113 # use our offline registry
114 export CARGO_HOME="`pwd`/.cargo"
116 mkdir -p "$CARGO_HOME"
117 cat >.cargo/config <<EOF
119 registry = 'https://github.com/rust-lang/crates.io-index'
120 replace-with = 'vendored-sources'
122 [source.vendored-sources]
123 directory = '$PWD/vendor'
127 # use our offline registry and custom rustc flags
128 export CARGO_HOME="`pwd`/.cargo"
129 export RUSTFLAGS="%{rustflags}"
131 # convince libgit2-sys to use the distro libgit2
132 export LIBGIT2_SYS_USE_PKG_CONFIG=1
135 --build=%{rust_triple} \
136 --host=%{rust_triple} \
137 --target=%{rust_triple} \
138 --cargo=%{local_cargo} \
139 --rustc=%{_bindir}/rustc \
140 --rustdoc=%{_bindir}/rustdoc \
141 --disable-cross-tests \
142 --disable-option-checking \
143 --release-channel=stable
148 rm -rf $RPM_BUILD_ROOT
149 export CARGO_HOME="`pwd`/.cargo"
150 export RUSTFLAGS="%{rustflags}"
153 DESTDIR=$RPM_BUILD_ROOT
155 # Remove installer artifacts (manifests, uninstall scripts, etc.)
156 %{__rm} -rv $RPM_BUILD_ROOT%{_prefix}/lib/
158 # Fix the etc/ location
159 # (ugh: prepare-image supports /etc outside /usr, but install doesn't!)
160 %{__mv} -v $RPM_BUILD_ROOT%{_prefix}/%{_sysconfdir} $RPM_BUILD_ROOT%{_sysconfdir}
162 # Remove unwanted documentation files (we already package them)
163 %{__rm} -r $RPM_BUILD_ROOT%{_docdir}/%{name}/
165 # Create the path for crate-devel packages
166 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
169 rm -rf $RPM_BUILD_ROOT
172 %defattr(644,root,root,755)
173 %doc LICENSE-APACHE LICENSE-MIT LICENSE-THIRD-PARTY README.md
174 %attr(755,root,root) %{_bindir}/cargo
175 %{_mandir}/man1/cargo*.1*
176 %dir %{_datadir}/cargo
177 %dir %{_datadir}/cargo/registry
179 %files -n bash-completion-cargo
180 %defattr(644,root,root,755)
181 %{_sysconfdir}/bash_completion.d/cargo
183 %files -n zsh-completion-cargo
184 %defattr(644,root,root,755)
185 %{zsh_compdir}/_cargo