From 5d5bee3f52c9ed8bff54add35c6cdb88b3315754 Mon Sep 17 00:00:00 2001 From: Davide Cavalca Date: Thu, 1 Jul 2021 10:13:03 -0700 Subject: [PATCH] Add vendored dependencies for EPEL and make it build there --- .gitignore | 1 + rust-below.spec | 43 ++++++++++++++++++++++++++++++++++++++-- sources | 1 + update-vendor-tarball.sh | 25 +++++++++++++++++++++++ 4 files changed, 68 insertions(+), 2 deletions(-) create mode 100755 update-vendor-tarball.sh diff --git a/.gitignore b/.gitignore index 93b0b38..253db53 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /below-0.2.0.crate +/below-0.2.0-vendor.tar.gz diff --git a/rust-below.spec b/rust-below.spec index 23e3f5c..9b9200a 100644 --- a/rust-below.spec +++ b/rust-below.spec @@ -4,6 +4,14 @@ %global crate below +%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 +%endif + %global forgeurl https://github.com/facebookincubator/below %global commit 584fdef23f4c7a95a009b84746bb193b68843c1a @@ -25,10 +33,25 @@ Patch1: below-fix-tests.patch Source1: %{forgeurl}/raw/%{commit}/etc/below.service Source2: %{forgeurl}/raw/%{commit}/etc/logrotate.conf Source3: %{forgeurl}/raw/%{commit}/README.md#/README-upstream.md +# vendored dependencies for EPEL +# update with ./update-vendor-tarball.sh after bumping the specfile version +Source4: %{crate}-%{version}-vendor.tar.gz ExclusiveArch: %{rust_arches} +%if 0%{?el8} +BuildRequires: rust-toolset +# for libbpf-sys +BuildRequires: kernel-headers +BuildRequires: elfutils-libelf-devel +BuildRequires: libbpf-devel +BuildRequires: zlib-devel +# for libbpf-cargo +BuildRequires: clang +BuildRequires: rustfmt +%else BuildRequires: rust-packaging +%endif BuildRequires: systemd-rpm-macros %global _description %{expand: @@ -54,14 +77,16 @@ atop's design and style decisions.} %package -n %{crate} Summary: %{summary} +Recommends: logrotate + %description -n %{crate} %{_description} %files -n %{crate} %license LICENSE %doc README.md docs -%{_bindir}/%{crate} +%attr(755, root, root) %{_bindir}/%{crate} %{_unitdir}/%{crate}.service -%{_sysconfdir}/logrotate.d/%{crate}.conf +%config(noreplace) %{_sysconfdir}/logrotate.d/%{crate}.conf %dir %{_localstatedir}/log/%{crate} %post -n %{crate} @@ -74,12 +99,20 @@ Summary: %{summary} %systemd_postun_with_restart %{crate}.service %prep +%if 0%{?el8} +%setup -q -n %{crate}-%{version} +%patch1 -p1 +%cargo_prep -V 4 +%else %autosetup -n %{crate}-%{version_no_tilde} -p1 %cargo_prep +%endif cp -p %{SOURCE3} README.md +%if 0%{?fedora} %generate_buildrequires %cargo_generate_buildrequires +%endif %build %cargo_build @@ -97,6 +130,12 @@ install -d -m1777 %{buildroot}%{_localstatedir}/log/%{crate} %endif %changelog +* Wed Jun 30 2021 Davide Cavalca - 0.2.0-3 +- Add vendored dependencies for EPEL and make it build there +- Mark logrotate config file as a config(noreplace) +- Add recommends for logrotate +- Fix permissions for the below binary + * Mon Jun 28 2021 Davide Cavalca - 0.2.0-2 - Install upstream systemd unit - Install upstream logrotate config diff --git a/sources b/sources index e2480dd..eaba8cc 100644 --- a/sources +++ b/sources @@ -1 +1,2 @@ SHA512 (below-0.2.0.crate) = 4f72620ed5c66ead42b5ab50c2a7e975956a6511b23e41056a4452274b7bc8172729b0ff44d9ce524d43024471236d093111a7e9d44239efed0a5a1e38127944 +SHA512 (below-0.2.0-vendor.tar.gz) = 83bb10cc37c6f6e24c2fd0a0e7a7f9eb05894002f9f74d0e3aace5900f2c5b5aa9b964131fd94c9384b0e5366716f0f5a93d84fbcaae23c20ea3bb146a1470c1 diff --git a/update-vendor-tarball.sh b/update-vendor-tarball.sh new file mode 100755 index 0000000..ceaffd4 --- /dev/null +++ b/update-vendor-tarball.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +name='below' +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