[PATCH 1/4][SRU][OEM-5.14/Jammy/OEM-5.17/unstable] UBUNTU: [Packaging] add common rules for dkms builds

You-Sheng Yang vicamo.yang at canonical.com
Tue Apr 19 17:23:04 UTC 2022


From: "You-Sheng Yang (vicamo)" <vicamo.yang at canonical.com>

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

Signed-off-by: You-Sheng Yang (vicamo) <vicamo.yang at canonical.com>
---
 debian/rules                    | 4 ----
 debian/rules.d/0-common-vars.mk | 8 ++++++++
 debian/rules.d/2-binary-arch.mk | 7 +++----
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/debian/rules b/debian/rules
index eca69cdc98a3..948711203ccc 100755
--- a/debian/rules
+++ b/debian/rules
@@ -112,10 +112,6 @@ endif
 # Either tools package needs the common source preparation
 do_any_tools=$(sort $(filter-out false,$(do_linux_tools) $(do_cloud_tools)))
 
-# Versions of dkms packages.
-dkms_zfs_linux_version=$(shell gawk '/^zfs-linux / { print $$2; }' debian/dkms-versions)
-dkms_v4l2loopback_version=$(shell gawk '/^v4l2loopback / { print $$2; }' debian/dkms-versions)
-
 # NVIDIA DKMS package gross series split into desktop and server.
 nvidia_desktop_series=$(shell sed -n -e 's/^nvidia-graphics-drivers-\([0-9][0-9]*\) .*/\1/p' debian/dkms-versions)
 nvidia_server_series=$(shell sed -n -e 's/^nvidia-graphics-drivers-\([0-9][0-9]*-server\) .*/\1/p' debian/dkms-versions)
diff --git a/debian/rules.d/0-common-vars.mk b/debian/rules.d/0-common-vars.mk
index 78f8a0f16e3a..9596c98ae374 100644
--- a/debian/rules.d/0-common-vars.mk
+++ b/debian/rules.d/0-common-vars.mk
@@ -285,3 +285,11 @@ custom_override = \
 
 # selftests that Ubuntu cares about
 ubuntu_selftests = breakpoints cpu-hotplug efivarfs memfd memory-hotplug mount net ptrace seccomp timers powerpc user ftrace
+
+# DKMS
+_all_dkms_versions = $(shell gawk '{ print $$1 ":" $$2 }' debian/dkms-versions)
+dkms_srcpkg_to_module = $(if $(filter zfs-linux,$(1)),zfs,$(1))
+$(foreach _v,$(_all_dkms_versions),$(eval dkms_$(call dkms_srcpkg_to_module,$(firstword $(subst :, ,$(_v))))_version = $(word 2,$(subst :, ,$(_v)))))
+all_dkms_modules = $(foreach _v,$(_all_dkms_versions),$(call dkms_srcpkg_to_module,$(firstword $(subst :, ,$(_v)))))
+dkms_v4l2loopback_deb_path = pool/universe/v/v4l2loopback/v4l2loopback-dkms_$(dkms_v4l2loopback_version)_all.deb
+dkms_zfs_deb_path = pool/universe/z/zfs-linux/zfs-dkms_$(dkms_zfs_version)_all.deb
diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index c4906036ceb8..957445a4b83b 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -117,8 +117,8 @@ $(stampdir)/stamp-install-%: MODSECKEY=$(builddir)/build-$*/certs/signing_key.pe
 $(stampdir)/stamp-install-%: MODPUBKEY=$(builddir)/build-$*/certs/signing_key.x509
 $(stampdir)/stamp-install-%: build_dir=$(builddir)/build-$*
 $(stampdir)/stamp-install-%: dkms_dir=$(call dkms_dir_prefix,$(builddir)/build-$*)
-$(stampdir)/stamp-install-%: enable_zfs = $(call custom_override,do_zfs,$*)
-$(stampdir)/stamp-install-%: enable_v4l2loopback = $(call custom_override,do_v4l2loopback,$*)
+$(foreach _m,$(all_dkms_modules), \
+  $(eval $$(stampdir)/stamp-install-%: enable_$(_m) = $$(call custom_override,do_$(_m),$$*)))
 $(stampdir)/stamp-install-%: dbgpkgdir_dkms = $(if $(filter true,$(skipdbg)),"",$(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/kernel)
 $(stampdir)/stamp-install-%: $(stampdir)/stamp-build-% $(stampdir)/stamp-install-headers
 	@echo Debug: $@ kernel_file $(kernel_file) kernfile $(kernfile) install_file $(install_file) instfile $(instfile)
@@ -412,8 +412,7 @@ endif
 	install -d $(dkms_dir) $(dkms_dir)/headers $(dkms_dir)/build $(dkms_dir)/source
 	cp -rp "$(hdrdir)" "$(indep_hdrdir)" "$(dkms_dir)/headers"
 
-	$(if $(filter true,$(enable_zfs)),$(call build_dkms, $(mods_pkg_name)-$*, $(pkgdir)/lib/modules/$(abi_release)-$*/kernel, $(dbgpkgdir_dkms), zfs, pool/universe/z/zfs-linux/zfs-dkms_$(dkms_zfs_linux_version)_all.deb))
-	$(if $(filter true,$(enable_v4l2loopback)),$(call build_dkms, $(mods_pkg_name)-$*, $(pkgdir)/lib/modules/$(abi_release)-$*/kernel, $(dbgpkgdir_dkms), v4l2loopback, pool/universe/v/v4l2loopback/v4l2loopback-dkms_$(dkms_v4l2loopback_version)_all.deb))
+	$(foreach _m,$(all_dkms_modules),$(if $(filter true,$(enable_$(_m))),$(call build_dkms, $(mods_pkg_name)-$*, $(pkgdir)/lib/modules/$(abi_release)-$*/kernel, $(dbgpkgdir_dkms),$(_m),$(dkms_$(_m)_deb_path))))
 
 
 ifneq ($(skipdbg),true)
-- 
2.34.1




More information about the kernel-team mailing list