]> git.pld-linux.org Git - projects/template-specs.git/blob - rust.spec
d792e2c4fbedf0be8f01be53d4e646164aec47cd
[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:  rpmbuild(macros) >= 2.003
18 BuildRequires:  rust
19 BuildRequires:  tar >= 1:1.22
20 BuildRequires:  xz
21 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
22
23 %description
24
25 %prep
26 %setup -q -b1
27
28 # Use our offline registry
29 export CARGO_HOME="$(pwd)/.cargo"
30
31 mkdir -p "$CARGO_HOME"
32 cat >.cargo/config <<EOF
33 [source.crates-io]
34 registry = 'https://github.com/rust-lang/crates.io-index'
35 replace-with = 'vendored-sources'
36
37 [source.vendored-sources]
38 directory = '$PWD/vendor'
39 EOF
40
41 %build
42 export CARGO_HOME="$(pwd)/.cargo"
43
44 %cargo_build \
45 %ifarch x32
46         --target x86_64-unknown-linux-gnux32 \
47 %endif
48         --frozen
49
50 %install
51 rm -rf $RPM_BUILD_ROOT
52 export CARGO_HOME="$(pwd)/.cargo"
53
54 %cargo_install \
55         --frozen \
56         --path . \
57         --root $RPM_BUILD_ROOT%{_prefix}
58
59 %{__rm} $RPM_BUILD_ROOT%{_prefix}/.crates.toml
60 %{__rm} $RPM_BUILD_ROOT%{_prefix}/.crates2.json
61
62 %clean
63 rm -rf $RPM_BUILD_ROOT
64
65 %files
66 %defattr(644,root,root,755)
67 %attr(755,root,root) %{_bindir}/*
This page took 0.04417 seconds and 2 git commands to generate.