From: Viktor Malik <vma...@redhat.com>

redhat/spec: Update bpftool versioning scheme

The upstream has changed the versioning scheme of bpftool [1].
Instead of following the kernel version, it is now deduced from the
libbpf version by adding +6 to the libbpf major version number.

This appropriately updates the bpftool sub-package version number. The
version is deduced automatically from the libbpf version, which can be
retrieved from tools/lib/bpf/libbpf.map.

One problem is that even though RPM allows to override sub-package
version, doing that overrides the internal %{version} macro. The macro
is used later throughout the specfile, so we reset it to its default
value (%{specversion}) at the end of the bpftool sub-package definition.

[1] https://lore.kernel.org/bpf/20220210104237.11649-3-quen...@isovalent.com/

Signed-off-by: Viktor Malik <vma...@redhat.com>

diff --git a/redhat/Makefile b/redhat/Makefile
index blahblah..blahblah 100644
--- a/redhat/Makefile
+++ b/redhat/Makefile
@@ -281,6 +281,12 @@ 
KABI_TARBALL:=$(SOURCES)/kernel-abi-stablelists-$(SPECKABIVERSION).tar.bz2
 KABIDW := $(REDHAT)/kabi-dwarf
 KABIDW_TARBALL:=$(SOURCES)/kernel-kabi-dw-$(SPECKABIVERSION).tar.bz2
 
+# Taken from tools/lib/bpf/Makefile
+BPFTOOLVERSION:=$(shell \
+       grep -oE '^LIBBPF_([0-9.]+)' $(TOPDIR)/tools/lib/bpf/libbpf.map | \
+       sort -rV | head -n1 | cut -d'_' -f2 | \
+       awk -F. -v OFS=. '{$$1 += 6 ; print}')
+
 # load Makefile variable settings from user-specified configuration file,
 # ~/.rhpkg.mk or $TOPDIR/.rhpkg.mk
 ifeq ("$(RHDISTGIT_CACHE)", "")
diff --git a/redhat/kernel.spec.template b/redhat/kernel.spec.template
index blahblah..blahblah 100755
--- a/redhat/kernel.spec.template
+++ b/redhat/kernel.spec.template
@@ -1091,23 +1091,31 @@ and root causes of unexpected results.
 
 %if %{with_bpftool}
 
+%define bpftoolversion %%BPFTOOLVERSION%%
+
 %package -n bpftool
 Summary: Inspection and simple manipulation of eBPF programs and maps
 License: GPLv2
+Version: %{bpftoolversion}
 %description -n bpftool
 This package contains the bpftool, which allows inspection and simple
 manipulation of eBPF programs and maps.
 
 %package -n bpftool-debuginfo
 Summary: Debug information for package bpftool
+Version: %{bpftoolversion}
 Group: Development/Debug
-Requires: %{name}-debuginfo-common-%{_target_cpu} = %{version}-%{release}
+Requires: %{name}-debuginfo-common-%{_target_cpu} = %{specversion}-%{release}
 AutoReqProv: no
 %description -n bpftool-debuginfo
 This package provides debug information for the bpftool package.
 
 %{expand:%%global _find_debuginfo_opts %{?_find_debuginfo_opts} -p 
'.*%%{_sbindir}/bpftool(\.debug)?|XXX' -o bpftool-debuginfo.list}
 
+# Setting "Version:" above overrides the internal {version} macro,
+# need to restore it here
+%define version %{specversion}
+
 # with_bpftool
 %endif
 
diff --git a/redhat/scripts/genspec/genspec.sh 
b/redhat/scripts/genspec/genspec.sh
index blahblah..blahblah 100755
--- a/redhat/scripts/genspec/genspec.sh
+++ b/redhat/scripts/genspec/genspec.sh
@@ -55,6 +55,7 @@ test -f "$SOURCES/$SPECFILE" &&
        s/%%SPECPATCHLIST_CHANGELOG%%/$SPECPATCHLIST_CHANGELOG/
        s/%%SPECVERSION%%/$SPECVERSION/
        s/%%SPECKABIVERSION%%/$SPECKABIVERSION/
+       s/%%BPFTOOLVERSION%%/$BPFTOOLVERSION/
        s/%%SPECTARFILE_RELEASE%%/$SPECTARFILE_RELEASE/
        s/%%SPECSELFTESTS_MUST_BUILD%%/$SPECSELFTESTS_MUST_BUILD/" 
"$SOURCES/$SPECFILE"
 test -n "$RHSELFTESTDATA" && test -f "$SOURCES/$SPECFILE" && sed -i -e "

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2295
_______________________________________________
kernel mailing list -- kernel@lists.fedoraproject.org
To unsubscribe send an email to kernel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/kernel@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to