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