]> git.pld-linux.org Git - packages/cargo.git/blob - cargo.spec
add missing buildroot
[packages/cargo.git] / cargo.spec
1 #
2 # Conditional build:
3 %bcond_with     bootstrap
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 Name:           cargo
11 Version:        0.19.0
12 Release:        1
13 License:        ASL 2.0 or MIT
14 Group:          Development/Libraries
15 Source0:        https://github.com/rust-lang/cargo/archive/%{cargo_version}/%{name}-%{cargo_version}.tar.gz
16 # Source0-md5:  e46e9f565df765b63f641c0d933297d7
17 # submodule, bundled for local installation only, not distributed
18 %define rust_installer 4f994850808a572e2cc8d43f968893c8e942e9bf
19 Source1:        https://github.com/rust-lang/rust-installer/archive/%{rust_installer}/rust-installer-%{rust_installer}.tar.gz
20 # Source1-md5:  a222edd3ab08779f527aafe862207027
21 Source2:        https://static.rust-lang.org/dist/cargo-%{cargo_bootstrap}-x86_64-unknown-linux-gnu.tar.gz
22 # Source2-md5:  d2cbab6378c1f60b483efa0f076a8f81
23 Source3:        https://static.rust-lang.org/dist/cargo-%{cargo_bootstrap}-i686-unknown-linux-gnu.tar.gz
24 # Source3-md5:  1ad24c241a2f5e3c4bf83855766fab35
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!
30 Source4:        %{name}-%{version}-vendor.tar.xz
31 # Source4-md5:  c8025d6ba2aa668c0bafc468ec354630
32 Patch0:         use-system-libgit2.patch
33 URL:            https://crates.io/
34 %{!?with_bootstrap:BuildRequires:       %{name} >= 0.13.0}
35 BuildRequires:  cmake
36 BuildRequires:  gcc
37 BuildRequires:  rust
38 # Indirect dependencies for vendored -sys crates above
39 BuildRequires:  curl-devel
40 BuildRequires:  libgit2-devel >= 0.24
41 BuildRequires:  libssh2-devel
42 BuildRequires:  openssl-devel
43 BuildRequires:  pkgconfig
44 BuildRequires:  zlib-devel
45 Requires:       rust
46 ExclusiveArch:  %{x8664} %{ix86}
47 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
48
49 %define rust_triple %{_target_cpu}-unknown-linux-gnu
50
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
62 %description
63 Cargo is a tool that allows Rust projects to declare their various
64 dependencies and ensure that you'll always get a repeatable build.
65
66 %prep
67 %setup -q -n %{name}-%{cargo_version} -a1 -a4
68 %if %{with bootstrap}
69 %ifarch %{x8664}
70 tar xf %{SOURCE2}
71 %endif
72 %ifarch %{ix86}
73 tar xf %{SOURCE3}
74 %endif
75 test -f '%{local_cargo}'
76 %endif
77 %patch0 -p1
78
79 rmdir src/rust-installer
80 mv rust-installer-%{rust_installer} src/rust-installer
81
82 # use our offline registry and custom rustc flags
83 export CARGO_HOME="`pwd`/.cargo"
84 export RUSTFLAGS="%{rustflags}"
85
86 mkdir -p "$CARGO_HOME"
87 cat >.cargo/config <<EOF
88 [source.crates-io]
89 registry = 'https://github.com/rust-lang/crates.io-index'
90 replace-with = 'vendored-sources'
91
92 [source.vendored-sources]
93 directory = '$PWD/vendor'
94 EOF
95
96 %build
97 # convince libgit2-sys to use the distro libgit2
98 export LIBGIT2_SYS_USE_PKG_CONFIG=1
99
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
111 rm -rf $RPM_BUILD_ROOT
112 export CARGO_HOME="`pwd`/.cargo"
113 export RUSTFLAGS="%{rustflags}"
114
115 %{__make} install \
116         DESTDIR=$RPM_BUILD_ROOT
117
118 # Remove installer artifacts (manifests, uninstall scripts, etc.)
119 rm -rv $RPM_BUILD_ROOT%{_prefix}/lib/
120
121 # Fix the etc/ location
122 mv -v $RPM_BUILD_ROOT%{_prefix}/%{_sysconfdir} $RPM_BUILD_ROOT%{_sysconfdir}
123
124 # Remove unwanted documentation files (we already package them)
125 rm -r $RPM_BUILD_ROOT%{_docdir}/%{name}/
126
127 # Create the path for crate-devel packages
128 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
129
130 %clean
131 rm -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
140 #%{zsh_compdir}/_cargo
141 %dir %{_datadir}/cargo
142 %dir %{_datadir}/cargo/registry
This page took 0.056865 seconds and 3 git commands to generate.