]> git.pld-linux.org Git - packages/cargo.git/blob - cargo.spec
- rel 1
[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
48 %define rust_triple %{_target_cpu}-unknown-linux-gnu
49
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
61 %description
62 Cargo is a tool that allows Rust projects to declare their various
63 dependencies and ensure that you'll always get a repeatable build.
64
65 %prep
66 %setup -q -n %{name}-%{cargo_version} -a1 -a4
67 %if %{with bootstrap}
68 %ifarch %{x8664}
69 tar xf %{SOURCE2}
70 %endif
71 %ifarch %{ix86}
72 tar xf %{SOURCE3}
73 %endif
74 test -f '%{local_cargo}'
75 %endif
76 %patch0 -p1
77
78 rmdir src/rust-installer
79 mv rust-installer-%{rust_installer} src/rust-installer
80
81 # use our offline registry and custom rustc flags
82 export CARGO_HOME="`pwd`/.cargo"
83 export RUSTFLAGS="%{rustflags}"
84
85 mkdir -p "$CARGO_HOME"
86 cat >.cargo/config <<EOF
87 [source.crates-io]
88 registry = 'https://github.com/rust-lang/crates.io-index'
89 replace-with = 'vendored-sources'
90
91 [source.vendored-sources]
92 directory = '$PWD/vendor'
93 EOF
94
95 %build
96 # convince libgit2-sys to use the distro libgit2
97 export LIBGIT2_SYS_USE_PKG_CONFIG=1
98
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
110 rm -rf $RPM_BUILD_ROOT
111 export CARGO_HOME="`pwd`/.cargo"
112 export RUSTFLAGS="%{rustflags}"
113
114 %{__make} install \
115         DESTDIR=$RPM_BUILD_ROOT
116
117 # Remove installer artifacts (manifests, uninstall scripts, etc.)
118 rm -rv $RPM_BUILD_ROOT%{_prefix}/lib/
119
120 # Fix the etc/ location
121 mv -v $RPM_BUILD_ROOT%{_prefix}/%{_sysconfdir} $RPM_BUILD_ROOT%{_sysconfdir}
122
123 # Remove unwanted documentation files (we already package them)
124 rm -r $RPM_BUILD_ROOT%{_docdir}/%{name}/
125
126 # Create the path for crate-devel packages
127 install -d $RPM_BUILD_ROOT%{_datadir}/cargo/registry
128
129 %clean
130 rm -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.098086 seconds and 3 git commands to generate.