]> git.pld-linux.org Git - packages/cargo.git/blame - cargo.spec
- cleaned up, seems building
[packages/cargo.git] / cargo.spec
CommitLineData
fd992278
JR
1#
2# Conditional build:
3%bcond_with bootstrap
4%bcond_without tests # build without tests
3cb37687
JR
5
6%define cargo_version %{version}
7%define cargo_bootstrap 0.18.0
8
9Summary: Rust's package manager and build tool
10Name: cargo
11Version: 0.19.0
12Release: 0.1
13License: ASL 2.0 or MIT
fd992278 14Group: Development/Libraries
3cb37687 15Source0: https://github.com/rust-lang/cargo/archive/%{cargo_version}/%{name}-%{cargo_version}.tar.gz
fd992278 16# Source0-md5: e46e9f565df765b63f641c0d933297d7
3cb37687
JR
17# submodule, bundled for local installation only, not distributed
18%define rust_installer 4f994850808a572e2cc8d43f968893c8e942e9bf
19Source1: https://github.com/rust-lang/rust-installer/archive/%{rust_installer}/rust-installer-%{rust_installer}.tar.gz
fd992278
JR
20# Source1-md5: a222edd3ab08779f527aafe862207027
21Source2: https://static.rust-lang.org/dist/cargo-%{cargo_bootstrap}-x86_64-unknown-linux-gnu.tar.gz
22# Source2-md5: d2cbab6378c1f60b483efa0f076a8f81
23Source3: https://static.rust-lang.org/dist/cargo-%{cargo_bootstrap}-i686-unknown-linux-gnu.tar.gz
24# Source3-md5: 1ad24c241a2f5e3c4bf83855766fab35
3cb37687
JR
25# Use vendored crate dependencies so we can build offline.
26# Created using https://github.com/alexcrichton/cargo-vendor/ 0.1.7
27# It's so big because some of the -sys crates include the C library source they
28# want to link to. With our -devel buildreqs in place, they'll be used instead.
29# FIXME: These should all eventually be packaged on their own!
fd992278
JR
30Source4: %{name}-%{version}-vendor.tar.xz
31# Source4-md5: c8025d6ba2aa668c0bafc468ec354630
32Patch0: use-system-libgit2.patch
3cb37687 33URL: https://crates.io/
fd992278 34%{!?with_bootstrap:BuildRequires: %{name} >= 0.13.0}
3cb37687
JR
35BuildRequires: cmake
36BuildRequires: gcc
37BuildRequires: rust
38# Indirect dependencies for vendored -sys crates above
39BuildRequires: curl-devel
40BuildRequires: libgit2-devel >= 0.24
41BuildRequires: libssh2-devel
42BuildRequires: openssl-devel
43BuildRequires: pkgconfig
44BuildRequires: zlib-devel
45Requires: rust
fd992278 46ExclusiveArch: %{x8664} %{ix86}
3cb37687
JR
47
48%define rust_triple %{_target_cpu}-unknown-linux-gnu
49
fd992278
JR
50%if %{with bootstrap}
51%define bootstrap_root cargo-%{cargo_bootstrap}-%{rust_triple}
52%define local_cargo %{_builddir}/%{name}-%{version}/%{bootstrap_root}/cargo/bin/cargo
53%else
54%define local_cargo %{_bindir}/%{name}
55%endif
56
57# This should eventually migrate to distro policy
58# Enable optimization, debuginfo, and link hardening.
59%define rustflags -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now
60
3cb37687
JR
61%description
62Cargo is a tool that allows Rust projects to declare their various
63dependencies and ensure that you'll always get a repeatable build.
64
65%prep
fd992278
JR
66%setup -q -n %{name}-%{cargo_version} -a1 -a4
67%if %{with bootstrap}
68%ifarch %{x8664}
69tar xf %{SOURCE2}
70%endif
71%ifarch %{ix86}
72tar xf %{SOURCE3}
73%endif
3cb37687
JR
74test -f '%{local_cargo}'
75%endif
fd992278 76%patch0 -p1
3cb37687 77
3cb37687
JR
78rmdir src/rust-installer
79mv rust-installer-%{rust_installer} src/rust-installer
80
fd992278
JR
81# use our offline registry and custom rustc flags
82export CARGO_HOME="`pwd`/.cargo"
83export RUSTFLAGS="%{rustflags}"
84
85mkdir -p "$CARGO_HOME"
3cb37687
JR
86cat >.cargo/config <<EOF
87[source.crates-io]
88registry = 'https://github.com/rust-lang/crates.io-index'
89replace-with = 'vendored-sources'
90
91[source.vendored-sources]
fd992278 92directory = '$PWD/vendor'
3cb37687
JR
93EOF
94
3cb37687
JR
95%build
96# convince libgit2-sys to use the distro libgit2
97export LIBGIT2_SYS_USE_PKG_CONFIG=1
98
3cb37687
JR
99%configure \
100 --disable-option-checking \
101 --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \
102 --rustc=%{_bindir}/rustc --rustdoc=%{_bindir}/rustdoc \
103 --cargo=%{local_cargo} \
104 --release-channel=stable \
105 --disable-cross-tests
106
107%{__make}
108
109%install
110rm -rf $RPM_BUILD_ROOT
fd992278 111export CARGO_HOME="`pwd`/.cargo"
3cb37687
JR
112export RUSTFLAGS="%{rustflags}"
113
114%{__make} install \
115 DESTDIR=$RPM_BUILD_ROOT
116
117# Remove installer artifacts (manifests, uninstall scripts, etc.)
118rm -rv $RPM_BUILD_ROOT%{_prefix}/lib/
119
120# Fix the etc/ location
121mv -v $RPM_BUILD_ROOT%{_prefix}/%{_sysconfdir} $RPM_BUILD_ROOT%{_sysconfdir}
122
123# Remove unwanted documentation files (we already package them)
fd992278 124rm -r $RPM_BUILD_ROOT%{_docdir}/%{name}/
3cb37687
JR
125
126# Create the path for crate-devel packages
127install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
128
129%clean
130rm -rf $RPM_BUILD_ROOT
131
132%files
133%defattr(644,root,root,755)
134%doc LICENSE-APACHE LICENSE-MIT LICENSE-THIRD-PARTY
135%doc README.md
136%attr(755,root,root) %{_bindir}/cargo
137%{_mandir}/man1/cargo*.1*
138%{_sysconfdir}/bash_completion.d/cargo
139%{zsh_compdir}/_cargo
140%dir %{_datadir}/cargo
141%dir %{_datadir}/cargo/registry
This page took 0.085618 seconds and 4 git commands to generate.