diff mbox series

UBUNTU: [Packaging] add linux-bpf-dev package

Message ID 20240822171056.1638495-1-luca.boccassi@gmail.com
State New
Headers show
Series UBUNTU: [Packaging] add linux-bpf-dev package | expand

Commit Message

Luca Boccassi Aug. 22, 2024, 5:10 p.m. UTC
From: Luca Boccassi <bluca@debian.org>

BugLink: https://bugs.launchpad.net/bugs/2050083

Add a new binary linux-bpf-dev package that ships a generated vmlinux.h
header. This can be used by packages building CO-RE BPF programs instead
of generating it at build time based on the kernel running on the package
build system, which might or might not match the kernel that is actually
shipped. It ensures that a matching header can always be used.

Matches changes in Debian, including the package name and header installation
location, so that we do not have to ifdef:

https://salsa.debian.org/kernel-team/linux/-/commit/f52d006f3915ac4358dc8c98aa417477ebee026e

This is already used by systemd to build various CO-RE programs, and
right now on Ubuntu due to the lack of this package the header is
generated from sysfs in the build system where the systemd packages are
built.

Signed-off-by: Luca Boccassi <bluca@debian.org>
---
As requested by Timo at: https://lists.ubuntu.com/archives/kernel-team/2024-August/153047.html
second version uses ifeq ($(do_tools_bpftool),true) instead of checking for armhf

 debian/control.d/linux-bpf-dev.stub | 7 +++++++
 debian/rules                        | 1 +
 debian/rules.d/2-binary-arch.mk     | 8 ++++++++
 3 files changed, 16 insertions(+)
 create mode 100644 debian/control.d/linux-bpf-dev.stub

Comments

Luca Boccassi Sept. 3, 2024, 11:44 a.m. UTC | #1
On Thu, 22 Aug 2024 at 18:10, <luca.boccassi@gmail.com> wrote:
>
> From: Luca Boccassi <bluca@debian.org>
>
> BugLink: https://bugs.launchpad.net/bugs/2050083
>
> Add a new binary linux-bpf-dev package that ships a generated vmlinux.h
> header. This can be used by packages building CO-RE BPF programs instead
> of generating it at build time based on the kernel running on the package
> build system, which might or might not match the kernel that is actually
> shipped. It ensures that a matching header can always be used.
>
> Matches changes in Debian, including the package name and header installation
> location, so that we do not have to ifdef:
>
> https://salsa.debian.org/kernel-team/linux/-/commit/f52d006f3915ac4358dc8c98aa417477ebee026e
>
> This is already used by systemd to build various CO-RE programs, and
> right now on Ubuntu due to the lack of this package the header is
> generated from sysfs in the build system where the systemd packages are
> built.
>
> Signed-off-by: Luca Boccassi <bluca@debian.org>
> ---
> As requested by Timo at: https://lists.ubuntu.com/archives/kernel-team/2024-August/153047.html
> second version uses ifeq ($(do_tools_bpftool),true) instead of checking for armhf
>
>  debian/control.d/linux-bpf-dev.stub | 7 +++++++
>  debian/rules                        | 1 +
>  debian/rules.d/2-binary-arch.mk     | 8 ++++++++
>  3 files changed, 16 insertions(+)
>  create mode 100644 debian/control.d/linux-bpf-dev.stub
>
> diff --git a/debian/control.d/linux-bpf-dev.stub b/debian/control.d/linux-bpf-dev.stub
> new file mode 100644
> index 000000000000..2967299aec18
> --- /dev/null
> +++ b/debian/control.d/linux-bpf-dev.stub
> @@ -0,0 +1,7 @@
> +Package: linux-bpf-dev
> +Architecture: amd64 armhf arm64 i386 ppc64el riscv64 s390x
> +Depends: ${misc:Depends}
> +Multi-Arch: same
> +Description: Headers for BPF development
> + The vmlinux.h header is provided to allow userspace to build BPF CO-RE
> + programs targeting the packaged kernel.
> diff --git a/debian/rules b/debian/rules
> index 43eae8d5aaa8..5fd39b2b0bcc 100755
> --- a/debian/rules
> +++ b/debian/rules
> @@ -175,6 +175,7 @@ ifeq ($(src_pkg_name),linux)
>         control_files += debian/control.d/linux-tools-host.stub
>         control_files += debian/control.d/linux-source.stub
>         control_files += debian/control.d/linux-doc.stub
> +       control_files += debian/control.d/linux-bpf-dev.stub
>  endif
>
>  # Calculate Ubuntu Compatible Signing levels
> diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
> index cda3522d7b5b..bb9beb2b381b 100644
> --- a/debian/rules.d/2-binary-arch.mk
> +++ b/debian/rules.d/2-binary-arch.mk
> @@ -616,6 +616,9 @@ endif
>  ifeq ($(do_cloud_tools),true)
>         $(call dh_all,$(pkgcloud))
>  endif
> +ifeq ($(do_tools_bpftool),true)
> +       $(call dh_all,linux-bpf-dev)
> +endif
>
>  #
>  # per-architecture packages
> @@ -661,6 +664,7 @@ endif
>  ifeq ($(do_tools_bpftool),true)
>         mv $(builddirpa)/tools/bpf/bpftool/vmlinux $(builddirpa)/vmlinux
>         $(kmake) NO_LIBTRACEEVENT=1 CROSS_COMPILE=$(CROSS_COMPILE) -C $(builddirpa)/tools/bpf/bpftool
> +       $(builddirpa)/tools/bpf/bpftool/bpftool btf dump file $(builddirpa)/vmlinux format c > $(builddirpa)/vmlinux.h
>         rm -f $(builddirpa)/vmlinux
>  endif
>  ifeq ($(do_tools_x86),true)
> @@ -713,6 +717,10 @@ endif
>  ifeq ($(do_tools_bpftool),true)
>         install -m755 $(builddirpa)/tools/bpf/bpftool/bpftool $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
>  endif
> +ifeq ($(do_tools_bpftool),true)
> +       install -d -m755 $(CURDIR)/debian/linux-bpf-dev/usr/include/$(DEB_HOST_MULTIARCH)/linux/
> +       install -m644 $(builddirpa)/vmlinux.h $(CURDIR)/debian/linux-bpf-dev/usr/include/$(DEB_HOST_MULTIARCH)/linux/vmlinux.h
> +endif
>  ifeq ($(do_tools_x86),true)
>         install -m755 \
>                 $(addprefix $(builddirpa)/tools/power/x86/, x86_energy_perf_policy/x86_energy_perf_policy turbostat/turbostat) \

Hi,

Gentle ping. Anything else I can do for this patch? Thanks!
Timo Aaltonen Sept. 3, 2024, 11:48 a.m. UTC | #2
Luca Boccassi kirjoitti 3.9.2024 klo 14.44:
> On Thu, 22 Aug 2024 at 18:10, <luca.boccassi@gmail.com> wrote:
>>
>> From: Luca Boccassi <bluca@debian.org>
>>
>> BugLink: https://bugs.launchpad.net/bugs/2050083
>>
>> Add a new binary linux-bpf-dev package that ships a generated vmlinux.h
>> header. This can be used by packages building CO-RE BPF programs instead
>> of generating it at build time based on the kernel running on the package
>> build system, which might or might not match the kernel that is actually
>> shipped. It ensures that a matching header can always be used.
>>
>> Matches changes in Debian, including the package name and header installation
>> location, so that we do not have to ifdef:
>>
>> https://salsa.debian.org/kernel-team/linux/-/commit/f52d006f3915ac4358dc8c98aa417477ebee026e
>>
>> This is already used by systemd to build various CO-RE programs, and
>> right now on Ubuntu due to the lack of this package the header is
>> generated from sysfs in the build system where the systemd packages are
>> built.
>>
>> Signed-off-by: Luca Boccassi <bluca@debian.org>
>> ---
>> As requested by Timo at: https://lists.ubuntu.com/archives/kernel-team/2024-August/153047.html
>> second version uses ifeq ($(do_tools_bpftool),true) instead of checking for armhf
>>
>>   debian/control.d/linux-bpf-dev.stub | 7 +++++++
>>   debian/rules                        | 1 +
>>   debian/rules.d/2-binary-arch.mk     | 8 ++++++++
>>   3 files changed, 16 insertions(+)
>>   create mode 100644 debian/control.d/linux-bpf-dev.stub
>>
>> diff --git a/debian/control.d/linux-bpf-dev.stub b/debian/control.d/linux-bpf-dev.stub
>> new file mode 100644
>> index 000000000000..2967299aec18
>> --- /dev/null
>> +++ b/debian/control.d/linux-bpf-dev.stub
>> @@ -0,0 +1,7 @@
>> +Package: linux-bpf-dev
>> +Architecture: amd64 armhf arm64 i386 ppc64el riscv64 s390x
>> +Depends: ${misc:Depends}
>> +Multi-Arch: same
>> +Description: Headers for BPF development
>> + The vmlinux.h header is provided to allow userspace to build BPF CO-RE
>> + programs targeting the packaged kernel.
>> diff --git a/debian/rules b/debian/rules
>> index 43eae8d5aaa8..5fd39b2b0bcc 100755
>> --- a/debian/rules
>> +++ b/debian/rules
>> @@ -175,6 +175,7 @@ ifeq ($(src_pkg_name),linux)
>>          control_files += debian/control.d/linux-tools-host.stub
>>          control_files += debian/control.d/linux-source.stub
>>          control_files += debian/control.d/linux-doc.stub
>> +       control_files += debian/control.d/linux-bpf-dev.stub
>>   endif
>>
>>   # Calculate Ubuntu Compatible Signing levels
>> diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
>> index cda3522d7b5b..bb9beb2b381b 100644
>> --- a/debian/rules.d/2-binary-arch.mk
>> +++ b/debian/rules.d/2-binary-arch.mk
>> @@ -616,6 +616,9 @@ endif
>>   ifeq ($(do_cloud_tools),true)
>>          $(call dh_all,$(pkgcloud))
>>   endif
>> +ifeq ($(do_tools_bpftool),true)
>> +       $(call dh_all,linux-bpf-dev)
>> +endif
>>
>>   #
>>   # per-architecture packages
>> @@ -661,6 +664,7 @@ endif
>>   ifeq ($(do_tools_bpftool),true)
>>          mv $(builddirpa)/tools/bpf/bpftool/vmlinux $(builddirpa)/vmlinux
>>          $(kmake) NO_LIBTRACEEVENT=1 CROSS_COMPILE=$(CROSS_COMPILE) -C $(builddirpa)/tools/bpf/bpftool
>> +       $(builddirpa)/tools/bpf/bpftool/bpftool btf dump file $(builddirpa)/vmlinux format c > $(builddirpa)/vmlinux.h
>>          rm -f $(builddirpa)/vmlinux
>>   endif
>>   ifeq ($(do_tools_x86),true)
>> @@ -713,6 +717,10 @@ endif
>>   ifeq ($(do_tools_bpftool),true)
>>          install -m755 $(builddirpa)/tools/bpf/bpftool/bpftool $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
>>   endif
>> +ifeq ($(do_tools_bpftool),true)
>> +       install -d -m755 $(CURDIR)/debian/linux-bpf-dev/usr/include/$(DEB_HOST_MULTIARCH)/linux/
>> +       install -m644 $(builddirpa)/vmlinux.h $(CURDIR)/debian/linux-bpf-dev/usr/include/$(DEB_HOST_MULTIARCH)/linux/vmlinux.h
>> +endif
>>   ifeq ($(do_tools_x86),true)
>>          install -m755 \
>>                  $(addprefix $(builddirpa)/tools/power/x86/, x86_energy_perf_policy/x86_energy_perf_policy turbostat/turbostat) \
> 
> Hi,
> 
> Gentle ping. Anything else I can do for this patch? Thanks!
> 

I've actually applied it today, though it didn't handle the armhf ftbfs 
but I'll fix that in a follow-up commit which is now going through 
test-builds.
diff mbox series

Patch

diff --git a/debian/control.d/linux-bpf-dev.stub b/debian/control.d/linux-bpf-dev.stub
new file mode 100644
index 000000000000..2967299aec18
--- /dev/null
+++ b/debian/control.d/linux-bpf-dev.stub
@@ -0,0 +1,7 @@ 
+Package: linux-bpf-dev
+Architecture: amd64 armhf arm64 i386 ppc64el riscv64 s390x
+Depends: ${misc:Depends}
+Multi-Arch: same
+Description: Headers for BPF development
+ The vmlinux.h header is provided to allow userspace to build BPF CO-RE
+ programs targeting the packaged kernel.
diff --git a/debian/rules b/debian/rules
index 43eae8d5aaa8..5fd39b2b0bcc 100755
--- a/debian/rules
+++ b/debian/rules
@@ -175,6 +175,7 @@  ifeq ($(src_pkg_name),linux)
 	control_files += debian/control.d/linux-tools-host.stub
 	control_files += debian/control.d/linux-source.stub
 	control_files += debian/control.d/linux-doc.stub
+	control_files += debian/control.d/linux-bpf-dev.stub
 endif
 
 # Calculate Ubuntu Compatible Signing levels
diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index cda3522d7b5b..bb9beb2b381b 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -616,6 +616,9 @@  endif
 ifeq ($(do_cloud_tools),true)
 	$(call dh_all,$(pkgcloud))
 endif
+ifeq ($(do_tools_bpftool),true)
+	$(call dh_all,linux-bpf-dev)
+endif
 
 #
 # per-architecture packages
@@ -661,6 +664,7 @@  endif
 ifeq ($(do_tools_bpftool),true)
 	mv $(builddirpa)/tools/bpf/bpftool/vmlinux $(builddirpa)/vmlinux
 	$(kmake) NO_LIBTRACEEVENT=1 CROSS_COMPILE=$(CROSS_COMPILE) -C $(builddirpa)/tools/bpf/bpftool
+	$(builddirpa)/tools/bpf/bpftool/bpftool btf dump file $(builddirpa)/vmlinux format c > $(builddirpa)/vmlinux.h
 	rm -f $(builddirpa)/vmlinux
 endif
 ifeq ($(do_tools_x86),true)
@@ -713,6 +717,10 @@  endif
 ifeq ($(do_tools_bpftool),true)
 	install -m755 $(builddirpa)/tools/bpf/bpftool/bpftool $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
 endif
+ifeq ($(do_tools_bpftool),true)
+	install -d -m755 $(CURDIR)/debian/linux-bpf-dev/usr/include/$(DEB_HOST_MULTIARCH)/linux/
+	install -m644 $(builddirpa)/vmlinux.h $(CURDIR)/debian/linux-bpf-dev/usr/include/$(DEB_HOST_MULTIARCH)/linux/vmlinux.h
+endif
 ifeq ($(do_tools_x86),true)
 	install -m755 \
 		$(addprefix $(builddirpa)/tools/power/x86/, x86_energy_perf_policy/x86_energy_perf_policy turbostat/turbostat) \