From 8b1d918149da253f422e6960e210bfba69bfa501 Mon Sep 17 00:00:00 2001 From: Dimitri John Ledkov Date: Mon, 27 Feb 2023 14:49:51 +0000 Subject: [PATCH] UBUNTU: [Packaging] Support skipped dkms modules In recent releases we have fixed up most dkms modules to correctly detect, and skip building dkms modules when compiling against incompatible kernels. For example, trying to build a WiFi driver against a kernel without 80221 config enabled, results in dkms returning error code 9 skipped build, due to incompatibility. Our DKMS autopkgtests already honor such cases, and mark test results as passing for skipped {kernel, dkms-module} combinations. Improve kernel's dkms-build script to distinguish failed versus skipped builds, by propagating exact status code. For standalone skipped dkms modules, skip generating an empty deb packages. Also do not fail over missing make.log for the skipped dkms builds, which do not have one. This change will enable us to use a static list of dkms-versions across all kernels, without need to do anything special for cases were a vendored dkms module is declared incompatible in dkms.conf for a given kernel. For example, v4l2loopback incompatible with cloud kernels that do not enable CONFIG_VIDEO, or backports-iwlwifi incompatible with kvm kernel. This patch is tested against working, skipepd, and FTBFS dkms modules, which correctly built the full kernel, skipped some dkms modules, or failed the overall build. Signed-off-by: Dimitri John Ledkov Signed-off-by: Andrea Righi --- debian/rules.d/2-binary-arch.mk | 3 ++- debian/scripts/dkms-build | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk index 46ad5b36c40b..4c7096acd5a6 100644 --- a/debian/rules.d/2-binary-arch.mk +++ b/debian/rules.d/2-binary-arch.mk @@ -72,7 +72,7 @@ define build_dkms_sign = ) endef define build_dkms = - ARCH=$(build_arch) CROSS_COMPILE=$(CROSS_COMPILE) $(SHELL) $(DROOT)/scripts/dkms-build $(dkms_dir) $(abi_release)-$* '$(call build_dkms_sign,$(builddir)/build-$*)' $(1) $(2) $(3) $(4) $(5) + rc=0; ARCH=$(build_arch) CROSS_COMPILE=$(CROSS_COMPILE) $(SHELL) $(DROOT)/scripts/dkms-build $(dkms_dir) $(abi_release)-$* '$(call build_dkms_sign,$(builddir)/build-$*)' $(1) $(2) $(3) $(4) $(5) || rc=$$?; if [ "$$rc" = "9" ]; then echo do_$(4)_$*=false >> $(builddir)/skipped-dkms.mk; rc=0; fi; if [ "$$rc" != "0" ]; then exit $$rc; fi endef define install_control = @@ -613,6 +613,7 @@ endif $(call dh_all,linux-libc-dev) endif +-include $(builddir)/skipped-dkms.mk binary-%: pkgimg = $(bin_pkg_name)-$* binary-%: pkgimg_mods = $(mods_pkg_name)-$* binary-%: pkgimg_ex = $(mods_extra_pkg_name)-$* diff --git a/debian/scripts/dkms-build b/debian/scripts/dkms-build index 67566a47df9a..6690322476cc 100755 --- a/debian/scripts/dkms-build +++ b/debian/scripts/dkms-build @@ -166,14 +166,13 @@ $fakeroot /usr/sbin/dkms build --no-prepare-kernel --no-clean-kernel \ --sourcetree "$dkms_dir/source" \ --dkmstree "$dkms_dir/build" \ --kernelsourcedir "$dkms_dir/headers/linux-headers-$abi_flavour" \ - "$dkms_conf" || rc=1 + "$dkms_conf" || rc=$? # Find the log and add it to our own. for log in "$dkms_dir/build/$dkms_package/$dkms_version/$abi_flavour"/*/"log/make.log" "$dkms_dir/build/$dkms_package/$dkms_version/build/make.log" do - [ -f "$log" ] && break + [ -f "$log" ] && sed -e "s@$dkms_dir@<>@g" <"$log" done -sed -e "s@$dkms_dir@<>@g" <"$log" # If this build failed then exit here. [ "$rc" != 0 ] && exit "$rc"