]> git.pld-linux.org Git - packages/cargo.git/blame - cargo.spec
add missing buildroot
[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
35c0b166 12Release: 1
3cb37687 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}
7f7cc5c5 47BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
3cb37687
JR
48
49%define rust_triple %{_target_cpu}-unknown-linux-gnu
50
fd992278
JR
51%if %{with bootstrap}
52%define bootstrap_root cargo-%{cargo_bootstrap}-%{rust_triple}
53%define local_cargo %{_builddir}/%{name}-%{version}/%{bootstrap_root}/cargo/bin/cargo
54%else
55%define local_cargo %{_bindir}/%{name}
56%endif
57
58# This should eventually migrate to distro policy
59# Enable optimization, debuginfo, and link hardening.
60%define rustflags -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now
61
3cb37687
JR
62%description
63Cargo is a tool that allows Rust projects to declare their various
64dependencies and ensure that you'll always get a repeatable build.
65
66%prep
fd992278
JR
67%setup -q -n %{name}-%{cargo_version} -a1 -a4
68%if %{with bootstrap}
69%ifarch %{x8664}
70tar xf %{SOURCE2}
71%endif
72%ifarch %{ix86}
73tar xf %{SOURCE3}
74%endif
3cb37687
JR
75test -f '%{local_cargo}'
76%endif
fd992278 77%patch0 -p1
3cb37687 78
3cb37687
JR
79rmdir src/rust-installer
80mv rust-installer-%{rust_installer} src/rust-installer
81
fd992278
JR
82# use our offline registry and custom rustc flags
83export CARGO_HOME="`pwd`/.cargo"
84export RUSTFLAGS="%{rustflags}"
85
86mkdir -p "$CARGO_HOME"
3cb37687
JR
87cat >.cargo/config <<EOF
88[source.crates-io]
89registry = 'https://github.com/rust-lang/crates.io-index'
90replace-with = 'vendored-sources'
91
92[source.vendored-sources]
fd992278 93directory = '$PWD/vendor'
3cb37687
JR
94EOF
95
3cb37687
JR
96%build
97# convince libgit2-sys to use the distro libgit2
98export LIBGIT2_SYS_USE_PKG_CONFIG=1
99
3cb37687
JR
100%configure \
101 --disable-option-checking \
102 --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \
103 --rustc=%{_bindir}/rustc --rustdoc=%{_bindir}/rustdoc \
104 --cargo=%{local_cargo} \
105 --release-channel=stable \
106 --disable-cross-tests
107
108%{__make}
109
110%install
111rm -rf $RPM_BUILD_ROOT
fd992278 112export CARGO_HOME="`pwd`/.cargo"
3cb37687
JR
113export RUSTFLAGS="%{rustflags}"
114
115%{__make} install \
116 DESTDIR=$RPM_BUILD_ROOT
117
118# Remove installer artifacts (manifests, uninstall scripts, etc.)
119rm -rv $RPM_BUILD_ROOT%{_prefix}/lib/
120
121# Fix the etc/ location
122mv -v $RPM_BUILD_ROOT%{_prefix}/%{_sysconfdir} $RPM_BUILD_ROOT%{_sysconfdir}
123
124# Remove unwanted documentation files (we already package them)
fd992278 125rm -r $RPM_BUILD_ROOT%{_docdir}/%{name}/
3cb37687
JR
126
127# Create the path for crate-devel packages
128install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
129
130%clean
131rm -rf $RPM_BUILD_ROOT
132
133%files
134%defattr(644,root,root,755)
135%doc LICENSE-APACHE LICENSE-MIT LICENSE-THIRD-PARTY
136%doc README.md
137%attr(755,root,root) %{_bindir}/cargo
138%{_mandir}/man1/cargo*.1*
139%{_sysconfdir}/bash_completion.d/cargo
35c0b166 140#%{zsh_compdir}/_cargo
3cb37687
JR
141%dir %{_datadir}/cargo
142%dir %{_datadir}/cargo/registry
This page took 0.106925 seconds and 4 git commands to generate.