diff --git a/.gitignore b/.gitignore index 6e66f0c..d4ec74a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /resctl-demo-2.1.2.crate +/resctl-demo-2.1.2-vendor.tar.gz diff --git a/rust-resctl-demo.spec b/rust-resctl-demo.spec index 47e37f5..49eefc9 100644 --- a/rust-resctl-demo.spec +++ b/rust-resctl-demo.spec @@ -4,6 +4,15 @@ %global crate resctl-demo +%if 0%{?el8} +# disabling this as it chokes on the vendored dependencies +%undefine __brp_mangle_shebangs +# el8 doesn't have these macros +%global __crates_url https://crates.io/api/v1/crates/ +%global crates_source %{__crates_url}%{crate}/%{version}/download#/%{crate}-%{version}.crate +%global version_no_tilde %{version} +%endif + Name: rust-%{crate} Version: 2.1.2 Release: %autorelease @@ -13,10 +22,16 @@ Summary: Guided tour of Linux resource control with live demos License: ASL 2.0 and BSD and MIT URL: https://crates.io/crates/resctl-demo Source: %{crates_source} +# Vendored dependencies for EPEL, update with ./update-vendor-tarball.sh +Source1: %{crate}-%{version}-vendor.tar.gz ExclusiveArch: %{rust_arches} +%if 0%{?el8} +BuildRequires: rust-toolset +%else BuildRequires: rust-packaging +%endif %global _description %{expand: resctl-demo demonstrates and documents various aspects of resource control @@ -40,10 +55,14 @@ Requires: gnuplot %prep %autosetup -n %{crate}-%{version_no_tilde} -p1 +%if 0%{?el8} +%cargo_prep -V 1 +%else %cargo_prep %generate_buildrequires %cargo_generate_buildrequires +%endif %build %cargo_build diff --git a/sources b/sources index 30e5a48..1b09b16 100644 --- a/sources +++ b/sources @@ -1 +1,2 @@ SHA512 (resctl-demo-2.1.2.crate) = 76d7c962aa0611fa1dc750e856499c20b53224078a8ddfe2fe1dc6e580aca6c4147becc45216a19722f8da52959e262271509c44fe2e7582c783cc4005981246 +SHA512 (resctl-demo-2.1.2-vendor.tar.gz) = f9f4adeeb2e147744ae0121b6b41ca25b527083139142f8c71be2428dae5fd67d11600f3bd299da51ec5c68087338de80b8be01d0273df90c1aabcd798cd60b3 diff --git a/update-vendor-tarball.sh b/update-vendor-tarball.sh new file mode 100755 index 0000000..ae9b8c0 --- /dev/null +++ b/update-vendor-tarball.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +name='resctl-demo' +specfile="rust-${name}.spec" +version=$(rpm -q --qf '%{VERSION}\n' --specfile "$specfile" | head -1) +nv="${name}-${version}" +crate="${nv}.crate" +vendor_tarball="${nv}-vendor.tar.gz" + +if [ -f "$vendor_tarball" ]; then + echo "${vendor_tarball} already exists, aborting" + exit 1 +fi + +[ -f "$crate" ] || spectool -g "$specfile" +tardir="$PWD" +workdir=$(mktemp -d) +trap 'rm -rf "$workdir"' EXIT + +tar xvzf "$tardir/$crate" -C "$workdir" +(cd "${workdir}/${nv}" && \ + cargo vendor && \ + tar cvzf "${tardir}/${vendor_tarball}" vendor/) + +exit 0