packaging: Add bpftool subpackage and build target 98/320898/1 accepted/tizen/unified/20250312.014644 accepted/tizen/unified/20250312.041117 accepted/tizen/unified/x/20250312.054013
authorMichal Wilczynski <m.wilczynski@samsung.com>
Mon, 10 Mar 2025 15:13:26 +0000 (16:13 +0100)
committerMichal Wilczynski <m.wilczynski@samsung.com>
Mon, 10 Mar 2025 18:02:09 +0000 (19:02 +0100)
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 <m.wilczynski@samsung.com>
packaging/linux-bpif3.manifest [new file with mode: 0644]
packaging/linux-bpif3.spec

diff --git a/packaging/linux-bpif3.manifest b/packaging/linux-bpif3.manifest
new file mode 100644 (file)
index 0000000..017d22d
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+    <domain name="_"/>
+ </request>
+</manifest>
index 35e5488804575a40b6e1b6146e5fd9c9670b8b8a..180ee6361e394315373cd4117303b7080c76d000 100644 (file)
@@ -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