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