]> git.pld-linux.org Git - packages/cargo.git/blame - cargo.spec
- pl, cleanup, completion packages
[packages/cargo.git] / cargo.spec
CommitLineData
fd992278
JR
1#
2# Conditional build:
8e5324db 3%bcond_with bootstrap # bootstrap using precompiled binaries
fd992278 4%bcond_without tests # build without tests
3cb37687 5
8e5324db
JB
6%define cargo_version %{version}
7%define cargo_bootstrap 0.18.0
3cb37687
JR
8
9Summary: Rust's package manager and build tool
8e5324db 10Summary(pl.UTF-8): Zarządca pakietów i narzędzie do budowania
3cb37687
JR
11Name: cargo
12Version: 0.19.0
35c0b166 13Release: 1
8e5324db
JB
14License: Apache v2.0 or MIT
15Group: Development/Tools
3cb37687 16Source0: https://github.com/rust-lang/cargo/archive/%{cargo_version}/%{name}-%{cargo_version}.tar.gz
fd992278 17# Source0-md5: e46e9f565df765b63f641c0d933297d7
3cb37687
JR
18# submodule, bundled for local installation only, not distributed
19%define rust_installer 4f994850808a572e2cc8d43f968893c8e942e9bf
20Source1: https://github.com/rust-lang/rust-installer/archive/%{rust_installer}/rust-installer-%{rust_installer}.tar.gz
fd992278
JR
21# Source1-md5: a222edd3ab08779f527aafe862207027
22Source2: https://static.rust-lang.org/dist/cargo-%{cargo_bootstrap}-x86_64-unknown-linux-gnu.tar.gz
23# Source2-md5: d2cbab6378c1f60b483efa0f076a8f81
24Source3: https://static.rust-lang.org/dist/cargo-%{cargo_bootstrap}-i686-unknown-linux-gnu.tar.gz
25# Source3-md5: 1ad24c241a2f5e3c4bf83855766fab35
3cb37687
JR
26# Use vendored crate dependencies so we can build offline.
27# Created using https://github.com/alexcrichton/cargo-vendor/ 0.1.7
28# It's so big because some of the -sys crates include the C library source they
29# want to link to. With our -devel buildreqs in place, they'll be used instead.
30# FIXME: These should all eventually be packaged on their own!
fd992278
JR
31Source4: %{name}-%{version}-vendor.tar.xz
32# Source4-md5: c8025d6ba2aa668c0bafc468ec354630
33Patch0: use-system-libgit2.patch
3cb37687 34URL: https://crates.io/
fd992278 35%{!?with_bootstrap:BuildRequires: %{name} >= 0.13.0}
3cb37687
JR
36BuildRequires: cmake
37BuildRequires: gcc
38BuildRequires: rust
39# Indirect dependencies for vendored -sys crates above
40BuildRequires: curl-devel
41BuildRequires: libgit2-devel >= 0.24
42BuildRequires: libssh2-devel
43BuildRequires: openssl-devel
44BuildRequires: pkgconfig
45BuildRequires: zlib-devel
46Requires: rust
fd992278 47ExclusiveArch: %{x8664} %{ix86}
7f7cc5c5 48BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
3cb37687 49
8e5324db 50%define rust_triple %{_target_cpu}-unknown-linux-gnu
3cb37687 51
fd992278
JR
52%if %{with bootstrap}
53%define bootstrap_root cargo-%{cargo_bootstrap}-%{rust_triple}
54%define local_cargo %{_builddir}/%{name}-%{version}/%{bootstrap_root}/cargo/bin/cargo
55%else
56%define local_cargo %{_bindir}/%{name}
57%endif
58
59# This should eventually migrate to distro policy
60# Enable optimization, debuginfo, and link hardening.
61%define rustflags -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now
62
3cb37687
JR
63%description
64Cargo is a tool that allows Rust projects to declare their various
65dependencies and ensure that you'll always get a repeatable build.
66
8e5324db
JB
67%description -l pl.UTF-8
68Cargo to narzędzie pozwalające projektom w języku Rust deklarować ich
69zależności i zapewniające powtarzalność procesu budowania.
70
71%package -n bash-completion-cargo
72Summary: Bash completion for cargo command
73Summary(pl.UTF-8): Bashowe dopełnianie parametrów polecenia cargo
74Group: Applications/Shells
75Requires: %{name} = %{version}-%{release}
76Requires: bash-completion
77
78%description -n bash-completion-cargo
79Bash completion for cargo command.
80
81%description -n bash-completion-cargo -l pl.UTF-8
82Bashowe dopełnianie parametrów polecenia cargo.
83
84%package -n zsh-completion-cargo
85Summary: Zsh completion for cargo command
86Summary(pl.UTF-8): Dopełnianie parametrów polecenia cargo w powłoce Zsh
87Group: Applications/Shells
88Requires: %{name} = %{version}-%{release}
89Requires: bash-completion
90
91%description -n zsh-completion-cargo
92Zsh completion for cargo command.
93
94%description -n zsh-completion-cargo -l pl.UTF-8
95Dopełnianie parametrów polecenia cargo w powłoce Zsh.
96
3cb37687 97%prep
fd992278
JR
98%setup -q -n %{name}-%{cargo_version} -a1 -a4
99%if %{with bootstrap}
100%ifarch %{x8664}
101tar xf %{SOURCE2}
102%endif
103%ifarch %{ix86}
104tar xf %{SOURCE3}
105%endif
3cb37687
JR
106test -f '%{local_cargo}'
107%endif
fd992278 108%patch0 -p1
3cb37687 109
3cb37687 110rmdir src/rust-installer
8e5324db 111%{__mv} rust-installer-%{rust_installer} src/rust-installer
3cb37687 112
8e5324db 113# use our offline registry
fd992278 114export CARGO_HOME="`pwd`/.cargo"
fd992278
JR
115
116mkdir -p "$CARGO_HOME"
3cb37687
JR
117cat >.cargo/config <<EOF
118[source.crates-io]
119registry = 'https://github.com/rust-lang/crates.io-index'
120replace-with = 'vendored-sources'
121
122[source.vendored-sources]
fd992278 123directory = '$PWD/vendor'
3cb37687
JR
124EOF
125
3cb37687 126%build
8e5324db
JB
127# use our offline registry and custom rustc flags
128export CARGO_HOME="`pwd`/.cargo"
129export RUSTFLAGS="%{rustflags}"
130
3cb37687
JR
131# convince libgit2-sys to use the distro libgit2
132export LIBGIT2_SYS_USE_PKG_CONFIG=1
133
3cb37687 134%configure \
8e5324db
JB
135 --build=%{rust_triple} \
136 --host=%{rust_triple} \
137 --target=%{rust_triple} \
3cb37687 138 --cargo=%{local_cargo} \
8e5324db
JB
139 --rustc=%{_bindir}/rustc \
140 --rustdoc=%{_bindir}/rustdoc \
141 --disable-cross-tests \
142 --disable-option-checking \
143 --release-channel=stable
3cb37687
JR
144
145%{__make}
146
147%install
148rm -rf $RPM_BUILD_ROOT
fd992278 149export CARGO_HOME="`pwd`/.cargo"
3cb37687
JR
150export RUSTFLAGS="%{rustflags}"
151
152%{__make} install \
153 DESTDIR=$RPM_BUILD_ROOT
154
155# Remove installer artifacts (manifests, uninstall scripts, etc.)
8e5324db 156%{__rm} -rv $RPM_BUILD_ROOT%{_prefix}/lib/
3cb37687
JR
157
158# Fix the etc/ location
8e5324db
JB
159# (ugh: prepare-image supports /etc outside /usr, but install doesn't!)
160%{__mv} -v $RPM_BUILD_ROOT%{_prefix}/%{_sysconfdir} $RPM_BUILD_ROOT%{_sysconfdir}
3cb37687
JR
161
162# Remove unwanted documentation files (we already package them)
8e5324db 163%{__rm} -r $RPM_BUILD_ROOT%{_docdir}/%{name}/
3cb37687
JR
164
165# Create the path for crate-devel packages
166install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
167
168%clean
169rm -rf $RPM_BUILD_ROOT
170
171%files
172%defattr(644,root,root,755)
8e5324db 173%doc LICENSE-APACHE LICENSE-MIT LICENSE-THIRD-PARTY README.md
3cb37687
JR
174%attr(755,root,root) %{_bindir}/cargo
175%{_mandir}/man1/cargo*.1*
3cb37687
JR
176%dir %{_datadir}/cargo
177%dir %{_datadir}/cargo/registry
8e5324db
JB
178
179%files -n bash-completion-cargo
180%defattr(644,root,root,755)
181%{_sysconfdir}/bash_completion.d/cargo
182
183%files -n zsh-completion-cargo
184%defattr(644,root,root,755)
185%{zsh_compdir}/_cargo
This page took 0.09386 seconds and 4 git commands to generate.