]> git.pld-linux.org Git - projects/template-specs.git/blob - rust.spec
Add rust template with crate vendoring example
[projects/template-specs.git] / rust.spec
1 Summary:        Template to show how to vendor crates
2 Name:           rust-crate-template
3 Version:        1.0
4 Release:        0.1
5 License:        Apache v2.0
6 Group:          Applications
7 Source0:        https://github.com/NAME/NAME/archive/v%{version}/%{name}-%{version}.tar.gz
8 # Source0-md5:  959298871877c4a50e8e2789d23530c7
9 # cd NAME-%{version}
10 # cargo vendor
11 # cd ..
12 # tar cJf NAME-crates-%{version}.tar.xz NAME-%{version}/{vendor,Cargo.lock}
13 Source1:        %{name}-crates-%{version}.tar.xz
14 # Source1-md5:  -
15 URL:            -
16 BuildRequires:  cargo
17 BuildRequires:  rust
18 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
19
20 %description
21
22 %prep
23 %setup -q
24
25 # Use our offline registry
26 export CARGO_HOME="$(pwd)/.cargo"
27
28 mkdir -p "$CARGO_HOME"
29 cat >.cargo/config <<EOF
30 [source.crates-io]
31 registry = 'https://github.com/rust-lang/crates.io-index'
32 replace-with = 'vendored-sources'
33
34 [source.vendored-sources]
35 directory = '$PWD/vendor'
36 EOF
37
38 %build
39 export CARGO_HOME="$(pwd)/.cargo"
40
41 cargo -v build \
42 %ifarch x32
43         --target x86_64-unknown-linux-gnux32 \
44 %endif
45         --release \
46         --frozen
47
48 %install
49 rm -rf $RPM_BUILD_ROOT
50 install -d $RPM_BUILD_ROOT%{_bindir}
51 cp -p target/release/* $RPM_BUILD_ROOT%{_bindir}
52
53 %clean
54 rm -rf $RPM_BUILD_ROOT
55
56 %files
57 %defattr(644,root,root,755)
58 %attr(755,root,root) %{_bindir}/*
This page took 0.100674 seconds and 4 git commands to generate.