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: 3a781687f7ac248d83efc4cfa642a260
18 Source2: https://static.rust-lang.org/dist/%{name}-%{cargo_bootstrap}-x86_64-unknown-linux-gnu.tar.gz
19 # Source2-md5: d2cbab6378c1f60b483efa0f076a8f81
20 Source3: https://static.rust-lang.org/dist/%{name}-%{cargo_bootstrap}-i686-unknown-linux-gnu.tar.gz
21 # Source3-md5: 1ad24c241a2f5e3c4bf83855766fab35
22 # Use vendored crate dependencies so we can build offline.
23 # Created using https://github.com/alexcrichton/cargo-vendor/ 0.1.13
24 # It's so big because some of the -sys crates include the C library source they
25 # want to link to. With our -devel buildreqs in place, they'll be used instead.
26 # FIXME: These should all eventually be packaged on their own!
27 Source4: %{name}-%{version}-vendor.tar.xz
28 # Source4-md5: 0e0595ee6ced6164052633df6a8a9eab
29 URL: https://crates.io/
30 %{!?with_bootstrap:BuildRequires: %{name} >= 0.13.0}
34 # Indirect dependencies for vendored -sys crates above
35 BuildRequires: curl-devel
36 BuildRequires: libgit2-devel >= 0.24
37 BuildRequires: libssh2-devel
38 BuildRequires: openssl-devel
39 BuildRequires: pkgconfig
40 BuildRequires: zlib-devel
42 ExclusiveArch: %{x8664} %{ix86}
43 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
45 %define rust_triple %{_target_cpu}-unknown-linux-gnu
48 %define bootstrap_root cargo-%{cargo_bootstrap}-%{rust_triple}
49 %define local_cargo %{_builddir}/%{name}-%{version}/%{bootstrap_root}/cargo/bin/cargo
51 %define local_cargo %{_bindir}/%{name}
54 # This should eventually migrate to distro policy
55 # Enable optimization, debuginfo, and link hardening.
56 %define rustflags -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now
59 Cargo is a tool that allows Rust projects to declare their various
60 dependencies and ensure that you'll always get a repeatable build.
62 %description -l pl.UTF-8
63 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
64 zależności i zapewniające powtarzalność procesu budowania.
66 %package -n bash-completion-cargo
67 Summary: Bash completion for cargo command
68 Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo
69 Group: Applications/Shells
70 Requires: %{name} = %{version}-%{release}
71 Requires: bash-completion
73 %description -n bash-completion-cargo
74 Bash completion for cargo command.
76 %description -n bash-completion-cargo -l pl.UTF-8
77 Bashowe dopełnianie parametrów polecenia cargo.
79 %package -n zsh-completion-cargo
80 Summary: Zsh completion for cargo command
81 Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh
82 Group: Applications/Shells
83 Requires: %{name} = %{version}-%{release}
84 Requires: bash-completion
86 %description -n zsh-completion-cargo
87 Zsh completion for cargo command.
89 %description -n zsh-completion-cargo -l pl.UTF-8
90 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
93 %setup -q -n %{name}-%{cargo_version} -a4
101 test -f '%{local_cargo}'
104 # use our offline registry
105 export CARGO_HOME="`pwd`/.cargo"
107 mkdir -p "$CARGO_HOME"
108 cat >.cargo/config <<EOF
110 registry = 'https://github.com/rust-lang/crates.io-index'
111 replace-with = 'vendored-sources'
113 [source.vendored-sources]
114 directory = '$PWD/vendor'
118 # use our offline registry and custom rustc flags
119 export CARGO_HOME="`pwd`/.cargo"
120 export RUSTFLAGS="%{rustflags}"
122 # convince libgit2-sys to use the distro libgit2
123 export LIBGIT2_SYS_USE_PKG_CONFIG=1
125 %{local_cargo} build --release
128 rm -rf $RPM_BUILD_ROOT
129 export CARGO_HOME="`pwd`/.cargo"
130 export RUSTFLAGS="%{rustflags}"
132 %{local_cargo} install --root $RPM_BUILD_ROOT%{_prefix}
133 rm $RPM_BUILD_ROOT%{_prefix}/.crates.toml
135 install -d $RPM_BUILD_ROOT%{_mandir}/man1
136 install -p src%{_sysconfdir}/man/cargo*.1 $RPM_BUILD_ROOT%{_mandir}/man1
138 install -p src%{_sysconfdir}/cargo.bashcomp.sh \
139 -D $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d/cargo
141 install -p src%{_sysconfdir}/_cargo \
142 -D $RPM_BUILD_ROOT%{zsh_compdir}/_cargo
144 # Create the path for crate-devel packages
145 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
148 rm -rf $RPM_BUILD_ROOT
151 %defattr(644,root,root,755)
152 %doc LICENSE-APACHE LICENSE-MIT LICENSE-THIRD-PARTY README.md
153 %attr(755,root,root) %{_bindir}/cargo
154 %{_mandir}/man1/cargo*.1*
155 %dir %{_datadir}/cargo
156 %dir %{_datadir}/cargo/registry
158 %files -n bash-completion-cargo
159 %defattr(644,root,root,755)
160 %{_sysconfdir}/bash_completion.d/cargo
162 %files -n zsh-completion-cargo
163 %defattr(644,root,root,755)
164 %{zsh_compdir}/_cargo