1 # NOTE: for versions >= 0.29 see rust.spec
4 %bcond_with bootstrap # bootstrap using precompiled binaries
5 %bcond_without tests # build without tests
7 %define cargo_version %{version}
8 %define cargo_bootstrap 0.18.0
10 Summary: Rust's package manager and build tool
11 Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania
15 License: Apache v2.0 or MIT
16 Group: Development/Tools
17 Source0: https://github.com/rust-lang/cargo/archive/%{cargo_version}/%{name}-%{cargo_version}.tar.gz
18 # Source0-md5: 9929f01186583c5c9f01b587356a7c92
19 Source2: https://static.rust-lang.org/dist/%{name}-%{cargo_bootstrap}-x86_64-unknown-linux-gnu.tar.gz
20 # Source2-md5: d2cbab6378c1f60b483efa0f076a8f81
21 Source3: https://static.rust-lang.org/dist/%{name}-%{cargo_bootstrap}-i686-unknown-linux-gnu.tar.gz
22 # Source3-md5: 1ad24c241a2f5e3c4bf83855766fab35
23 # Use vendored crate dependencies so we can build offline.
24 # Created using https://github.com/alexcrichton/cargo-vendor/ 0.1.13
25 # It's so big because some of the -sys crates include the C library source they
26 # want to link to. With our -devel buildreqs in place, they'll be used instead.
27 # FIXME: These should all eventually be packaged on their own!
28 # PLD: using sources vendored by Fedora
29 Source4: https://src.fedoraproject.org/repo/pkgs/cargo/%{name}-%{version}-vendor.tar.xz/sha512/6ed2a1644c9b18fc24ddad5350d41b6c36cd5b62de4cf0b748a57b589f4f0ac12f91461989158d58d0892bf6fc2c1626cf574e7e2b9da4b0e35f72dfd88f9048/%{name}-%{version}-vendor.tar.xz
30 # Source4-md5: bf5dd065f46ece6a0d30dbd3216508a0
32 Patch1: build_fix.patch
33 Patch2: %{name}-url-buildfix.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} x32
48 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
51 %define rust_triple x86_64-unknown-linux-gnux32
53 %define rust_triple %{_target_cpu}-unknown-linux-gnu
57 %define bootstrap_root cargo-%{cargo_bootstrap}-%{rust_triple}
58 %define local_cargo %{_builddir}/%{name}-%{version}/%{bootstrap_root}/cargo/bin/cargo
60 %define local_cargo %{_bindir}/%{name}
63 # This should eventually migrate to distro policy
64 # Enable optimization, debuginfo, and link hardening.
65 %define rustflags -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now
68 Cargo is a tool that allows Rust projects to declare their various
69 dependencies and ensure that you'll always get a repeatable build.
71 %description -l pl.UTF-8
72 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
73 zależności i zapewniające powtarzalność procesu budowania.
75 %package -n bash-completion-cargo
76 Summary: Bash completion for cargo command
77 Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo
78 Group: Applications/Shells
79 Requires: %{name} = %{version}-%{release}
80 Requires: bash-completion
82 %description -n bash-completion-cargo
83 Bash completion for cargo command.
85 %description -n bash-completion-cargo -l pl.UTF-8
86 Bashowe dopełnianie parametrów polecenia cargo.
88 %package -n zsh-completion-cargo
89 Summary: Zsh completion for cargo command
90 Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh
91 Group: Applications/Shells
92 Requires: %{name} = %{version}-%{release}
93 Requires: bash-completion
95 %description -n zsh-completion-cargo
96 Zsh completion for cargo command.
98 %description -n zsh-completion-cargo -l pl.UTF-8
99 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
102 %setup -q -n %{name}-%{cargo_version} -a4
110 %if %{with bootstrap}
117 test -f '%{local_cargo}'
120 # use our offline registry
121 export CARGO_HOME="`pwd`/.cargo"
123 mkdir -p "$CARGO_HOME"
124 cat >.cargo/config <<EOF
126 registry = 'https://github.com/rust-lang/crates.io-index'
127 replace-with = 'vendored-sources'
129 [source.vendored-sources]
130 directory = '$PWD/vendor'
134 # use our offline registry and custom rustc flags
135 export CARGO_HOME="`pwd`/.cargo"
136 export RUSTFLAGS="%{rustflags}"
138 # convince libgit2-sys to use the distro libgit2
139 export LIBGIT2_SYS_USE_PKG_CONFIG=1
141 %{local_cargo} build --release
144 rm -rf $RPM_BUILD_ROOT
145 export CARGO_HOME="`pwd`/.cargo"
146 export RUSTFLAGS="%{rustflags}"
148 %{local_cargo} install --root $RPM_BUILD_ROOT%{_prefix}
149 rm $RPM_BUILD_ROOT%{_prefix}/.crates.toml
151 install -d $RPM_BUILD_ROOT%{_mandir}/man1
152 install -p src%{_sysconfdir}/man/cargo*.1 $RPM_BUILD_ROOT%{_mandir}/man1
154 install -p src%{_sysconfdir}/cargo.bashcomp.sh \
155 -D $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d/cargo
157 install -p src%{_sysconfdir}/_cargo \
158 -D $RPM_BUILD_ROOT%{zsh_compdir}/_cargo
160 # Create the path for crate-devel packages
161 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
164 rm -rf $RPM_BUILD_ROOT
167 %defattr(644,root,root,755)
168 %doc LICENSE-APACHE LICENSE-MIT LICENSE-THIRD-PARTY README.md
169 %attr(755,root,root) %{_bindir}/cargo
170 %{_mandir}/man1/cargo*.1*
171 %dir %{_datadir}/cargo
172 %dir %{_datadir}/cargo/registry
174 %files -n bash-completion-cargo
175 %defattr(644,root,root,755)
176 %{_sysconfdir}/bash_completion.d/cargo
178 %files -n zsh-completion-cargo
179 %defattr(644,root,root,755)
180 %{zsh_compdir}/_cargo