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