]> git.pld-linux.org Git - projects/template-specs.git/commitdiff
Add rust template with crate vendoring example
authorElan Ruusamäe <glen@pld-linux.org>
Wed, 17 Mar 2021 14:08:02 +0000 (16:08 +0200)
committerElan Ruusamäe <glen@pld-linux.org>
Wed, 17 Mar 2021 14:08:02 +0000 (16:08 +0200)
rust.spec [new file with mode: 0644]

diff --git a/rust.spec b/rust.spec
new file mode 100644 (file)
index 0000000..cbaecb8
--- /dev/null
+++ b/rust.spec
@@ -0,0 +1,58 @@
+Summary:       Template to show how to vendor crates
+Name:          rust-crate-template
+Version:       1.0
+Release:       0.1
+License:       Apache v2.0
+Group:         Applications
+Source0:       https://github.com/NAME/NAME/archive/v%{version}/%{name}-%{version}.tar.gz
+# Source0-md5: 959298871877c4a50e8e2789d23530c7
+# cd NAME-%{version}
+# cargo vendor
+# cd ..
+# tar cJf NAME-crates-%{version}.tar.xz NAME-%{version}/{vendor,Cargo.lock}
+Source1:       %{name}-crates-%{version}.tar.xz
+# Source1-md5: -
+URL:           -
+BuildRequires: cargo
+BuildRequires: rust
+BuildRoot:     %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+
+%prep
+%setup -q
+
+# Use our offline registry
+export CARGO_HOME="$(pwd)/.cargo"
+
+mkdir -p "$CARGO_HOME"
+cat >.cargo/config <<EOF
+[source.crates-io]
+registry = 'https://github.com/rust-lang/crates.io-index'
+replace-with = 'vendored-sources'
+
+[source.vendored-sources]
+directory = '$PWD/vendor'
+EOF
+
+%build
+export CARGO_HOME="$(pwd)/.cargo"
+
+cargo -v build \
+%ifarch x32
+       --target x86_64-unknown-linux-gnux32 \
+%endif
+       --release \
+       --frozen
+
+%install
+rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT%{_bindir}
+cp -p target/release/* $RPM_BUILD_ROOT%{_bindir}
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_bindir}/*
This page took 0.143791 seconds and 4 git commands to generate.