]> git.pld-linux.org Git - packages/cargo.git/blob - cargo.spec
1e49740a6ec523e383c793e7a753903de646fe13
[packages/cargo.git] / cargo.spec
1 #
2 # Conditional build:
3 %bcond_with     bootstrap       # bootstrap using precompiled binaries
4 %bcond_without  tests           # build without tests
5
6 %define         cargo_version   %{version}
7 %define         cargo_bootstrap 0.18.0
8
9 Summary:        Rust's package manager and build tool
10 Summary(pl.UTF-8):      Zarządca pakietów i narzędzie do budowania
11 Name:           cargo
12 Version:        0.25.0
13 Release:        1
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:  063d1165c5137c126bdc199f60ff33dd
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 # PLD: using sources vendored by Fedora
28 Source4:        https://src.fedoraproject.org/repo/pkgs/cargo/%{name}-%{version}-vendor.tar.xz/sha512/301fdf0ceea482120fbf4b5037bc2dfe18cd3c39f42eaca4464ed1f356093f0f9fb3dae48d1fd72b964fd5f4c6be21fa79e548d0480a1834afe55c2d4e50bac7/%{name}-%{version}-vendor.tar.xz
29 # Source4-md5:  378dceb15dd78628d8664b7ca219f842
30 URL:            https://crates.io/
31 %{!?with_bootstrap:BuildRequires:       %{name} >= 0.13.0}
32 BuildRequires:  cmake
33 BuildRequires:  gcc
34 BuildRequires:  rust
35 # Indirect dependencies for vendored -sys crates above
36 BuildRequires:  curl-devel
37 BuildRequires:  libgit2-devel >= 0.24
38 BuildRequires:  libssh2-devel
39 BuildRequires:  openssl-devel
40 BuildRequires:  pkgconfig
41 BuildRequires:  zlib-devel
42 Requires:       rust
43 ExclusiveArch:  %{x8664} %{ix86}
44 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
45
46 %define         rust_triple     %{_target_cpu}-unknown-linux-gnu
47
48 %if %{with bootstrap}
49 %define         bootstrap_root  cargo-%{cargo_bootstrap}-%{rust_triple}
50 %define         local_cargo     %{_builddir}/%{name}-%{version}/%{bootstrap_root}/cargo/bin/cargo
51 %else
52 %define         local_cargo     %{_bindir}/%{name}
53 %endif
54
55 # This should eventually migrate to distro policy
56 # Enable optimization, debuginfo, and link hardening.
57 %define         rustflags       -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now
58
59 %description
60 Cargo is a tool that allows Rust projects to declare their various
61 dependencies and ensure that you'll always get a repeatable build.
62
63 %description -l pl.UTF-8
64 Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
65 zależności i zapewniające powtarzalność procesu budowania.
66
67 %package -n bash-completion-cargo
68 Summary:        Bash completion for cargo command
69 Summary(pl.UTF-8):      Bashowe dopełnianie parametrów polecenia cargo
70 Group:          Applications/Shells
71 Requires:       %{name} = %{version}-%{release}
72 Requires:       bash-completion
73
74 %description -n bash-completion-cargo
75 Bash completion for cargo command.
76
77 %description -n bash-completion-cargo -l pl.UTF-8
78 Bashowe dopełnianie parametrów polecenia cargo.
79
80 %package -n zsh-completion-cargo
81 Summary:        Zsh completion for cargo command
82 Summary(pl.UTF-8):      Dopełnianie parametrów polecenia cargo w powłoce Zsh
83 Group:          Applications/Shells
84 Requires:       %{name} = %{version}-%{release}
85 Requires:       bash-completion
86
87 %description -n zsh-completion-cargo
88 Zsh completion for cargo command.
89
90 %description -n zsh-completion-cargo -l pl.UTF-8
91 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
92
93 %prep
94 %setup -q -n %{name}-%{cargo_version} -a4
95 %if %{with bootstrap}
96 %ifarch %{x8664}
97 tar xf %{SOURCE2}
98 %endif
99 %ifarch %{ix86}
100 tar xf %{SOURCE3}
101 %endif
102 test -f '%{local_cargo}'
103 %endif
104
105 # use our offline registry
106 export CARGO_HOME="`pwd`/.cargo"
107
108 mkdir -p "$CARGO_HOME"
109 cat >.cargo/config <<EOF
110 [source.crates-io]
111 registry = 'https://github.com/rust-lang/crates.io-index'
112 replace-with = 'vendored-sources'
113
114 [source.vendored-sources]
115 directory = '$PWD/vendor'
116 EOF
117
118 %build
119 # use our offline registry and custom rustc flags
120 export CARGO_HOME="`pwd`/.cargo"
121 export RUSTFLAGS="%{rustflags}"
122
123 # convince libgit2-sys to use the distro libgit2
124 export LIBGIT2_SYS_USE_PKG_CONFIG=1
125
126 %{local_cargo} build --release
127
128 %install
129 rm -rf $RPM_BUILD_ROOT
130 export CARGO_HOME="`pwd`/.cargo"
131 export RUSTFLAGS="%{rustflags}"
132
133 %{local_cargo} install --root $RPM_BUILD_ROOT%{_prefix}
134 rm $RPM_BUILD_ROOT%{_prefix}/.crates.toml
135
136 install -d $RPM_BUILD_ROOT%{_mandir}/man1
137 install -p src%{_sysconfdir}/man/cargo*.1 $RPM_BUILD_ROOT%{_mandir}/man1
138
139 install -p src%{_sysconfdir}/cargo.bashcomp.sh \
140   -D $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d/cargo
141
142 install -p src%{_sysconfdir}/_cargo \
143   -D $RPM_BUILD_ROOT%{zsh_compdir}/_cargo
144
145 # Create the path for crate-devel packages
146 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
147
148 %clean
149 rm -rf $RPM_BUILD_ROOT
150
151 %files
152 %defattr(644,root,root,755)
153 %doc LICENSE-APACHE LICENSE-MIT LICENSE-THIRD-PARTY README.md
154 %attr(755,root,root) %{_bindir}/cargo
155 %{_mandir}/man1/cargo*.1*
156 %dir %{_datadir}/cargo
157 %dir %{_datadir}/cargo/registry
158
159 %files -n bash-completion-cargo
160 %defattr(644,root,root,755)
161 %{_sysconfdir}/bash_completion.d/cargo
162
163 %files -n zsh-completion-cargo
164 %defattr(644,root,root,755)
165 %{zsh_compdir}/_cargo
This page took 0.0602 seconds and 2 git commands to generate.