]> git.pld-linux.org Git - packages/cargo.git/blob - cargo.spec
- release 3, builds
[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:        3
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 Patch2:         %{name}-url-buildfix.patch
34 URL:            https://crates.io/
35 %{!?with_bootstrap:BuildRequires:       %{name} >= 0.13.0}
36 BuildRequires:  cmake
37 BuildRequires:  gcc
38 BuildRequires:  rust
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
46 Requires:       rust
47 ExclusiveArch:  %{x8664} %{ix86} x32
48 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
49
50 %ifarch x32
51 %define         rust_triple     x86_64-unknown-linux-gnux32
52 %else
53 %define         rust_triple     %{_target_cpu}-unknown-linux-gnu
54 %endif
55
56 %if %{with bootstrap}
57 %define         bootstrap_root  cargo-%{cargo_bootstrap}-%{rust_triple}
58 %define         local_cargo     %{_builddir}/%{name}-%{version}/%{bootstrap_root}/cargo/bin/cargo
59 %else
60 %define         local_cargo     %{_bindir}/%{name}
61 %endif
62
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
66
67 %description
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.
70
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.
74
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
81
82 %description -n bash-completion-cargo
83 Bash completion for cargo command.
84
85 %description -n bash-completion-cargo -l pl.UTF-8
86 Bashowe dopełnianie parametrów polecenia cargo.
87
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
94
95 %description -n zsh-completion-cargo
96 Zsh completion for cargo command.
97
98 %description -n zsh-completion-cargo -l pl.UTF-8
99 Dopełnianie parametrów polecenia cargo w powłoce Zsh.
100
101 %prep
102 %setup -q -n %{name}-%{cargo_version} -a4
103 %ifarch x32
104 %patch0 -p1
105 %endif
106
107 %patch1 -p1
108 %patch2 -p1
109
110 %if %{with bootstrap}
111 %ifarch %{x8664}
112 tar xf %{SOURCE2}
113 %endif
114 %ifarch %{ix86}
115 tar xf %{SOURCE3}
116 %endif
117 test -f '%{local_cargo}'
118 %endif
119
120 # use our offline registry
121 export CARGO_HOME="`pwd`/.cargo"
122
123 mkdir -p "$CARGO_HOME"
124 cat >.cargo/config <<EOF
125 [source.crates-io]
126 registry = 'https://github.com/rust-lang/crates.io-index'
127 replace-with = 'vendored-sources'
128
129 [source.vendored-sources]
130 directory = '$PWD/vendor'
131 EOF
132
133 %build
134 # use our offline registry and custom rustc flags
135 export CARGO_HOME="`pwd`/.cargo"
136 export RUSTFLAGS="%{rustflags}"
137
138 # convince libgit2-sys to use the distro libgit2
139 export LIBGIT2_SYS_USE_PKG_CONFIG=1
140
141 %{local_cargo} build --release
142
143 %install
144 rm -rf $RPM_BUILD_ROOT
145 export CARGO_HOME="`pwd`/.cargo"
146 export RUSTFLAGS="%{rustflags}"
147
148 %{local_cargo} install --root $RPM_BUILD_ROOT%{_prefix}
149 rm $RPM_BUILD_ROOT%{_prefix}/.crates.toml
150
151 install -d $RPM_BUILD_ROOT%{_mandir}/man1
152 install -p src%{_sysconfdir}/man/cargo*.1 $RPM_BUILD_ROOT%{_mandir}/man1
153
154 install -p src%{_sysconfdir}/cargo.bashcomp.sh \
155   -D $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d/cargo
156
157 install -p src%{_sysconfdir}/_cargo \
158   -D $RPM_BUILD_ROOT%{zsh_compdir}/_cargo
159
160 # Create the path for crate-devel packages
161 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
162
163 %clean
164 rm -rf $RPM_BUILD_ROOT
165
166 %files
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
173
174 %files -n bash-completion-cargo
175 %defattr(644,root,root,755)
176 %{_sysconfdir}/bash_completion.d/cargo
177
178 %files -n zsh-completion-cargo
179 %defattr(644,root,root,755)
180 %{zsh_compdir}/_cargo
This page took 0.040455 seconds and 4 git commands to generate.