[PATCH V2 5/6][SRU][OEM-5.14/Jammy/Unstable/OEM-5.17] UBUNTU: [Packaging] support build dkms as standalone package
You-Sheng Yang
vicamo.yang at canonical.com
Fri Apr 22 17:10:18 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/control.d/flavour-module.stub | 30 ++++++++++++++++++++++++++++
debian/rules | 3 ++-
debian/rules.d/0-common-vars.mk | 9 +++++++++
debian/rules.d/2-binary-arch.mk | 28 ++++++++++++++++++++++----
debian/scripts/control-create | 28 ++++++++++++++++++++++++++
5 files changed, 93 insertions(+), 5 deletions(-)
create mode 100644 debian/control.d/flavour-module.stub
diff --git a/debian/control.d/flavour-module.stub b/debian/control.d/flavour-module.stub
new file mode 100644
index 000000000000..80e7156b58fc
--- /dev/null
+++ b/debian/control.d/flavour-module.stub
@@ -0,0 +1,30 @@
+
+Package: linux-modules-MODULE-FLAVOUR
+Build-Profiles: <!stage1>
+Architecture: ARCH
+Section: kernel
+Provides: ${dkms:rprovides}
+Depends:
+ ${misc:Depends},
+ linux-modules-MODULE-PKGVER-ABINUM-FLAVOUR (= ${binary:Version}),
+Description: Extra drivers for MODULE for the FLAVOUR flavour
+ Install extra signed MODULE modules compatible with the FLAVOUR flavour.
+
+Package: linux-modules-MODULE-PKGVER-ABINUM-FLAVOUR
+Build-Profiles: <!stage1>
+Architecture: ARCH
+Section: kernel
+Priority: optional
+Depends:
+ ${misc:Depends},
+ linux-image-PKGVER-ABINUM-FLAVOUR | linux-image-unsigned-PKGVER-ABINUM-FLAVOUR,
+Built-Using: ${linux:BuiltUsing}
+Description: Linux kernel MODULE modules for version PKGVER-ABINUM
+ This package provides the Linux kernel MODULE modules for version
+ PKGVER-ABINUM.
+ .
+ You likely do not want to install this package directly. Instead, install the
+ one of the linux-modules-MODULE-FLAVOUR* meta-packages,
+ which will ensure that upgrades work correctly, and that supporting packages are
+ also installed.
+
diff --git a/debian/rules b/debian/rules
index 16623f8bd9b4..879ed4ed9ca7 100755
--- a/debian/rules
+++ b/debian/rules
@@ -101,7 +101,7 @@ ifneq ($(do_tools),true)
do_tools_host=
endif
-$(foreach _m,$(all_dkms_modules), \
+$(foreach _m,$(all_inline_dkms_modules), \
$(if $(filter true,$(do_$(_m))),, \
$(eval do_$(_m)_disable := $$(shell for m in $$$$(cat $(DROOT)/$(_m)-modules.ignore); do grep -qxF $$$$m $(prev_abidir)/../modules.ignore 2>/dev/null || echo $$$$m >> $(prev_abidir)/../modules.ignore; done)) \
) \
@@ -180,6 +180,7 @@ endif
$(DEBIAN)/control.stub: \
$(DROOT)/scripts/control-create \
$(control_files) \
+ $(DROOT)/control.d/flavour-module.stub \
$(DEBIAN)/changelog \
$(wildcard $(DEBIAN)/control.d/* $(DEBIAN)/sub-flavours/*.vars)
for i in $(control_files); do \
diff --git a/debian/rules.d/0-common-vars.mk b/debian/rules.d/0-common-vars.mk
index b3409ac3614d..129eaa36997a 100644
--- a/debian/rules.d/0-common-vars.mk
+++ b/debian/rules.d/0-common-vars.mk
@@ -311,4 +311,13 @@ $(foreach _line,$(shell gawk '{ OFS = "!"; $$1 = $$1; print }' $(DROOT)/dkms-ver
$(eval dkms_$(_m)_archs = __all__) \
) \
$(eval dkms_$(_m)_rprovides = $(patsubst rprovides=%,%,$(filter rprovides=%,$(_params)))) \
+ $(if $(filter standalone=1,$(_params)), \
+ $(eval all_standalone_dkms_modules += $(_m)) \
+ $(eval dkms_$(_m)_pkg_name = linux-modules-$(_m)-$(abi_release)) \
+ $(eval dkms_$(_m)_metapkg_name = linux-modules-$(_m)) \
+ $(eval dkms_$(_m)_rprovides += $(_m)-prebuilt-kernel) \
+ , \
+ $(eval all_inline_dkms_modules += $(_m)) \
+ $(eval dkms_$(_m)_pkg_name = $(mods_pkg_name)) \
+ ) \
)
diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index 7f22fc5d4b68..995f25ed4ae3 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -119,6 +119,7 @@ $(stampdir)/stamp-install-%: build_dir=$(builddir)/build-$*
$(stampdir)/stamp-install-%: dkms_dir=$(call dkms_dir_prefix,$(builddir)/build-$*)
$(foreach _m,$(all_dkms_modules), \
$(eval $$(stampdir)/stamp-install-%: enable_$(_m) = $$(filter true,$$(call custom_override,do_$(_m),$$*))) \
+ $(eval $$(stampdir)/stamp-install-%: dkms_$(_m)_pkgdir = $$(CURDIR)/debian/$(dkms_$(_m)_pkg_name)-$$*) \
)
$(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
@@ -127,6 +128,12 @@ $(stampdir)/stamp-install-%: $(stampdir)/stamp-build-% $(stampdir)/stamp-install
dh_prep -p$(bin_pkg_name)-$*
dh_prep -p$(mods_pkg_name)-$*
dh_prep -p$(hdrs_pkg_name)-$*
+ $(foreach _m,$(all_standalone_dkms_modules), \
+ $(if $(enable_$(_m)), \
+ dh_prep -p$(dkms_$(_m)_pkg_name)-$*; \
+ dh_prep -p$(dkms_$(_m)_metapkg_name)-$*; \
+ )\
+ )
ifneq ($(skipdbg),true)
dh_prep -p$(bin_pkg_name)-$*-dbgsym
endif
@@ -264,6 +271,12 @@ ifeq ($(do_extras_package),true)
$(call install_control,$(mods_extra_pkg_name)-$*,extra,postinst postrm); \
fi
endif
+ $(foreach _m,$(all_standalone_dkms_modules), \
+ $(if $(enable_$(_m)), \
+ install -d $(dkms_$(_m)_pkgdir)/usr/lib/linux/triggers; \
+ $(call install_control,$(dkms_$(_m)_pkg_name)-$*,extra,postinst postrm); \
+ ) \
+ )
# Install the full changelog.
ifeq ($(do_doc_package),true)
@@ -415,7 +428,7 @@ endif
$(foreach _m,$(all_dkms_modules), \
$(if $(enable_$(_m)), \
- $(call build_dkms,$(mods_pkg_name)-$*,$(pkgdir)/lib/modules/$(abi_release)-$*/kernel,$(dbgpkgdir_dkms),$(_m),$(dkms_$(_m)_debpath)); \
+ $(call build_dkms,$(dkms_$(_m)_pkg_name)-$*,$(dkms_$(_m)_pkgdir)/lib/modules/$(abi_release)-$*/kernel,$(dbgpkgdir_dkms),$(_m),$(dkms_$(_m)_debpath)); \
) \
)
@@ -567,7 +580,7 @@ define dh_all
dh_shlibdeps -p$(1) $(shlibdeps_opts)
dh_installdeb -p$(1)
dh_installdebconf -p$(1)
- $(lockme) dh_gencontrol -p$(1) -- -Vlinux:rprovides='$(rprovides)'
+ $(lockme) dh_gencontrol -p$(1) -- -Vlinux:rprovides='$(rprovides)' $(2)
dh_md5sums -p$(1)
dh_builddeb -p$(1)
endef
@@ -576,7 +589,7 @@ define newline
endef
define dh_all_inline
- $(subst ${newline},; \${newline},$(call dh_all,$(1)))
+ $(subst ${newline},; \${newline},$(call dh_all,$(1),$(2)))
endef
binary-arch-headers: install-arch-headers
@@ -604,7 +617,7 @@ binary-%: pkgcloud = $(cloud_flavour_pkg_name)-$*
$(foreach _m,$(all_dkms_modules), \
$(eval binary-%: enable_$(_m) = $$(filter true,$$(call custom_override,do_$(_m),$$*))) \
)
-binary-%: rprovides = $(foreach _m,$(all_dkms_modules),$(if $(enable_$(_m)),$(foreach _r,$(dkms_$(_m)_rprovides),$(_r)$(comma) )))
+binary-%: rprovides = $(foreach _m,$(all_inline_dkms_modules),$(if $(enable_$(_m)),$(foreach _r,$(dkms_$(_m)_rprovides),$(_r)$(comma) )))
binary-%: target_flavour = $*
binary-%: checks-%
@echo Debug: $@
@@ -629,6 +642,13 @@ ifeq ($(do_extras_package),true)
endif
endif
+ $(foreach _m,$(all_standalone_dkms_modules), \
+ $(if $(enable_$(_m)), \
+ $(call dh_all,$(dkms_$(_m)_pkg_name)-$*); \
+ $(call dh_all,$(dkms_$(_m)_metapkg_name)-$*,-Vdkms:rprovides='$(foreach _r,$(dkms_$(_m)_rprovides),$(_r)$(comma) )'); \
+ )\
+ )
+
$(call dh_all,$(pkgbldinfo))
$(call dh_all,$(pkghdr))
diff --git a/debian/scripts/control-create b/debian/scripts/control-create
index 2ab9e497515f..82a472855225 100755
--- a/debian/scripts/control-create
+++ b/debian/scripts/control-create
@@ -38,3 +38,31 @@ cat $stub | grep -v '^#' | sed \
-e "s#=SIGN-ME-PKG=#$sign_me_pkg#g" \
-e "s#=SIGN-ME-TXT=#$sign_me_txt#g" \
-e "s#=SIGN-PEER-PKG=#$sign_peer_pkg#g"
+
+while read package version extras
+do
+ module="$package"
+ module_archs=
+ standalone=
+
+ # Module arch parameters are skipped here, so a package section will
+ # be generated for each flavour, and its Architecture will be set to
+ # all architectures with that flavour. Even that is being generated,
+ # it doesn't follow all of them will be built. That's to work-around
+ # dkms_exclude/dkms_include that manipulates supported architectures
+ # in $(DEBIAN)/rules.d/$(arch).mk.
+ for param in $extras; do
+ case "$param" in
+ modulename=*) module="${param#modulename=}" ;;
+ standalone=1) standalone=1 ;;
+ *) continue ;;
+ esac
+ done
+
+ [ -n "$standalone" ] || continue
+
+ cat debian/control.d/flavour-module.stub | grep -v '^#' | sed \
+ -e "s#ARCH#$arch#g" \
+ -e "s#MODULE#$module#g" \
+ -e "s#FLAVOUR#$flavour#g"
+done <"debian/dkms-versions"
--
2.34.1
More information about the kernel-team
mailing list