From d3b26f7ade577f3b4f3c72e3075cac6847b65dd0 Mon Sep 17 00:00:00 2001 From: Michal Wilczynski Date: Mon, 10 Mar 2025 16:13:26 +0100 Subject: [PATCH] packaging: Add bpftool subpackage and build target Update the linux-rpi4.spec file to build and package bpftool as a separate subpackage, named linux-kernel-bpftool. By doing so, bpftool (and its dependencies) can be managed more flexibly. The bpftool utility is crucial for managing, loading, and debugging eBPF programs, making it easier to inspect and troubleshoot eBPF-related features. Changes: - Add a dedicated build target for bpftool under tools/bpf/bpftool. - Install bpftool and supporting files into /usr/sbin. - Create a new subpackage (linux-kernel-bpftool) that provides the bpftool binary. The skeleton generation capability of bpftool is specifically required for our resourced eBPF build, ensuring that the compiled BPF object can be integrated seamlessly with user space. This will simplify building and maintaining eBPF programs for low-memory monitoring or other functionalities. Add required manifest file for userspace utility bpftool. Change-Id: Ie8f83923c537915d7f313fa84e49fe2eaa0877dc Signed-off-by: Michal Wilczynski --- packaging/linux-bpif3.manifest | 5 +++++ packaging/linux-bpif3.spec | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 packaging/linux-bpif3.manifest diff --git a/packaging/linux-bpif3.manifest b/packaging/linux-bpif3.manifest new file mode 100644 index 000000000000..017d22d3aff3 --- /dev/null +++ b/packaging/linux-bpif3.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/linux-bpif3.spec b/packaging/linux-bpif3.spec index 35e548880457..180ee6361e39 100644 --- a/packaging/linux-bpif3.spec +++ b/packaging/linux-bpif3.spec @@ -17,6 +17,7 @@ Group: System/Kernel Vendor: The Linux Community URL: https://www.kernel.org Source0: linux-kernel-%{version}.tar.xz +Source1001: linux-bpif3.manifest BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root %define fullVersion %{version}-%{target_board} @@ -26,6 +27,8 @@ BuildRequires: module-init-tools BuildRequires: bison BuildRequires: flex BuildRequires: pkgconfig(openssl3) +BuildRequires: libelf-devel +BuildRequires: python3 BuildRequires: rsync # kernel @@ -70,8 +73,22 @@ This package provides userspaces headers from the Linux kernel. These headers are used by the installed headers for GNU glibc and other system libraries. +%package -n linux-kernel-bpftool +Summary: The bpftool utility +Group: System/Kernel +Provides: bpftool = %{version} + +%description -n linux-kernel-bpftool +This package provides bpftool. Bpftool is a command-line utility designed +for managing, inspecting, debugging, and generating skeletons for eBPF +programs within the Linux kernel. Its skeleton generation feature +("bpftool gen skeleton") enables easier integration of compiled BPF +objects with user-space applications, making bpftool a critical component +for building and running eBPF-based monitoring and instrumentation. + %prep %setup -q -n linux-kernel-%{version} +cp %{SOURCE1001} . %build %{?asan:/usr/bin/gcc-unforce-options} @@ -92,6 +109,9 @@ make %{?_smp_mflags} # Build modules make modules %{?_smp_mflags} +# Build bpftool +WERROR=0 make -s -C tools/bpf/bpftool %{?_smp_mflags} + %install QA_SKIP_BUILD_ROOT="DO_NOT_WANT"; export QA_SKIP_BUILD_ROOT @@ -110,6 +130,10 @@ install -m 644 arch/%{buildarch}/boot/Image %{buildroot}/boot/ # Install modules make INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=%{buildroot} modules_install +# Install bpftool +mkdir -p %{buildroot}/usr/sbin +install -m 755 tools/bpf/bpftool/bpftool %{buildroot}/usr/sbin/ + # Copy files for devel package mkdir -p %{buildroot}/boot/kernel/devel/kernel-devel-%{variant} rsync -r \ @@ -154,3 +178,8 @@ rm -rf %{buildroot} %files -n %{variant}-linux-kernel-headers /usr/include/* + +%files -n linux-kernel-bpftool +%manifest linux-bpif3.manifest +%license COPYING +/usr/sbin/bpftool -- 2.34.1