[PATCH V2 5/6][SRU][OEM-5.14/Jammy/Unstable/OEM-5.17] UBUNTU: [Packaging] support build dkms as standalone package
Dimitri John Ledkov
dimitri.ledkov at canonical.com
Tue Apr 26 15:17:38 UTC 2022
On Fri, 22 Apr 2022 at 18:11, You-Sheng Yang <vicamo.yang at canonical.com> wrote:
>
> 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
Should it also include variant in the name? or will that be done in
src:linux-meta? (i.e. linux-meta generating meta
linux-modules-MODULE-FLAVOUR-VARIANT depends on
linux-modules-MODULE-FLAVOUR)
Should this package be actually built here, or in meta, i.e.
src:linux-meta only? (i.e. this package is not produced, and
src:linux-meta builds linux-modules-MODULE-FLAVOUR-VARIANT that
directly depends on the correct
linux-modules-MODULE-PKGVER-ABINUM-FLAVOUR)
Given it is desired to have this package as opt-in, we will need it as
a top-level opt-in metapackage built by meta too. In the same way we
have all other linux-$stuff-FLAVOUR-VARIANT (ie.
linux-tools-generic-64k linux-tools-generic-64k-hwe-22.04
linux-tools-generic-64k-hwe-22.04-edge).
It does potentially mean that linux-meta needs to gain
update-dkms-versions script too, such that it can autogenerate
linux-modules-MODULE-FLAVOUR-VARIANT opt-in metas for the standalone
things. And such that we can roll VARIANTS by rebuilding meta only
correctly, for the standalone dkms to follow. It somehow feels more
correct for the meta package have variant encoded and build by
linux-meta.
> +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)); \
This needs to be adjusted for type=built-in and type=standalone
packages. With /kernel becoming $(dkms_$(_m)_subdir) variable name,
which for type=built-in modules is set to "kernel" and for
type=standalone is set to "ubuntu".
That way our depmod will correctly use built-in module, or prefer the
standalone one when it is installed, or prefer the dkms one if one
installs that (dkms installs into /updates path).
Note this distinction is new here, and matters, because previous
vendored dkms modules, pretended to be built-in as no stock copies of
those exist. Unlike iwlwifi.
Quick demo:
Currently in /etc/depmod.d/ubuntu.conf we specify the search path as:
search updates ubuntu built-in
And currently the paths are as follows:
built-in: /lib/modules/5.15.0-27-generic/kernel/drivers/net/wireless/intel/iwlwifi/iwlwifi.ko
backport-iwlwifi-dkms installs:
/lib/modules/5.15.0-27-generic/updates/dkms/iwlwifi.ko
with these patches, when one installs just modules & modules-extra the
built-in iwlwifi ends up being picked by depmod:
# dpkg-query -W | grep 5.17
linux-image-unsigned-5.17.0-8-generic 5.17.0-8.8
linux-modules-5.17.0-8-generic 5.17.0-8.8
linux-modules-extra-5.17.0-8-generic 5.17.0-8.8
# modinfo -k 5.17.0-8-generic -F filename iwlwifi
/lib/modules/5.17.0-8-generic/kernel/drivers/net/wireless/intel/iwlwifi/iwlwifi.ko
But after installing iwlwifi package
# apt install linux-modules-iwlwifi-5.17.0-8-generic 5.17.0-8.8
# modinfo -k 5.17.0-8-generic -F filename iwlwifi
/lib/modules/5.17.0-8-generic/kernel/drivers/net/wireless/intel/iwlwifi/iwlwifi.ko
depmod still points at the built-in one, because it basically ignores it.
To allow co-installing built-in, standalone, and dkms versions of the
iwlwifi module, we must ensure that they build and install .ko into
built-in, ubuntu, updates paths.
When i rebuilt linux-modules-iwlwifi-5.17.0-8-generic to use /ubuntu/
path, and installed it, depmod correctly pointed me the standalone
module:
# dpkg -L linux-modules-iwlwifi-5.17.0-8-generic | grep iwlwifi.ko
/lib/modules/5.17.0-8-generic/ubuntu/iwlwifi/iwlwifi.ko
# modinfo -k 5.17.0-8-generic -F filename iwlwifi
/lib/modules/5.17.0-8-generic/ubuntu/iwlwifi/iwlwifi.ko
How did you test this? Or did you expect for something else to ship a
depmod.d snippet to activate the standalone module? Imho, standalone
modules should be built with /ubuntu path passed to the build-dkms
module, such that installing them, auto-enables them as the default
module.
> ) \
> )
>
> @@ -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
>
>
> --
> kernel-team mailing list
> kernel-team at lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
More information about the kernel-team
mailing list