[OE-core] [oe][RFT] Make kernel install update module dependencies with appropriate version

Ovidiu-Adrian Vancea ovidiu.vancea at ni.com
Tue May 24 07:48:06 UTC 2016


Updating the kernel ("opkg install kernel") does not update the modules because there is no version enforcement specifed in the OE recipe. Upon rebooting, the older version modules do not load and can leave hardware in a non-functioning state if their drivers are not built into the kernel.

We would like to make the kernel depend on modules using RRECOMMENDS so that they also update with the kernel.

I've been exploring two solutions and would like some feedback:

1. use the Version field from the kernel package on its rdepends, rrecommends, and rsuggests fields’ version. This would force the packages on which the kernel depends to be the same version as the kernel.
     -- deletes modules from previous kernel version
     -- version contains package build number (including git hash) and  package revision. This restricts the kernel and modules to always be built together.

2. append the KERNEL_VERSION to all kernel modules’ package name
     -- keeps modules from previous kernel version

[PATCH for solution 1]

in the recipe that inherits kernel.bbclass add the following line:
VERSION_KERNEL_MODULES = "1"

and the following OE-core patch:

diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass
index f1ad1d5..8468caf 100644
--- a/meta/classes/package_ipk.bbclass
+++ b/meta/classes/package_ipk.bbclass
@@ -196,6 +196,15 @@ python do_package_ipk () {
         rconflicts = bb.utils.explode_dep_versions2(localdata.getVar("RCONFLICTS", True) or "")
         debian_cmp_remap(rconflicts)
 
+        if (pkgname == "kernel") and (localdata.getVar("VERSION_KERNEL_MODULES", False) == "1"):
+            suffix = "="+localdata.getVar('PKGV', True)+"-"+localdata.getVar('PKGR', True)
+            for key in rdepends:
+                rdepends[key]    = suffix
+            for key in rsuggests:
+                rsuggests[key]   = suffix
+            for key in rrecommends:
+                rrecommends[key] = suffix
+
         if rdepends:
             ctrlfile.write("Depends: %s\n" % bb.utils.join_deps(rdepends))
         if rsuggests:


[PATCH for solution 2]

In the kernel recipe that inherits kernel.bbclass add the following two lines:

KERNEL_MODULES_SUFFIX = "-${KERNEL_VERSION}"
RRECOMMENDS_${KERNEL_PACKAGE_NAME} += "${KERNEL_PACKAGE_NAME}-modules${KERNEL_MODULES_SUFFIX}"

and the following OE-core patch:

diff --git a/meta/classes/kernel-module-split.bbclass b/meta/classes/kernel-module-split.bbclass
index e1a70e6..ae556ce 100644
--- a/meta/classes/kernel-module-split.bbclass
+++ b/meta/classes/kernel-module-split.bbclass
@@ -181,7 +181,11 @@ python split_kernel_module_packages () {
 
     module_deps = parse_depmod()
     module_regex = '^(.*)\.k?o$'
-    module_pattern = 'kernel-module-%s'
+    kernel_modules_suffix = d.getVar("KERNEL_MODULES_SUFFIX", True)
+    if kernel_modules_suffix is None:
+        module_pattern = '%s-module-%%s' % (kernel_package_name)
+    else:
+        module_pattern = '%s-module-%%s%s' % (kernel_package_name, kernel_modules_suffix)
 
     postinst = d.getVar('pkg_postinst_modules', True)
     postrm = d.getVar('pkg_postrm_modules', True)
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index c5355cf..15a2b3c 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -370,15 +370,18 @@ inherit cml1
 
 EXPORT_FUNCTIONS do_compile do_install do_configure
 
+KERNEL_MODULES_SUFFIX ?= ""
+KERNEL_MODULES_META_PACKAGE = "kernel-modules${KERNEL_MODULES_SUFFIX}"
+
 # kernel-base becomes kernel-${KERNEL_VERSION}
 # kernel-image becomes kernel-image-${KERNEL_VERSION}
-PACKAGES = "kernel kernel-base kernel-vmlinux kernel-image kernel-dev kernel-modules"
+PACKAGES = "kernel kernel-base kernel-vmlinux kernel-image kernel-dev ${KERNEL_MODULES_META_PACKAGE}"
 FILES_${PN} = ""
 FILES_kernel-base = "/lib/modules/${KERNEL_VERSION}/modules.order /lib/modules/${KERNEL_VERSION}/modules.builtin"
 FILES_kernel-image = "/boot/${KERNEL_IMAGETYPE}*"
 FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} /lib/modules/${KERNEL_VERSION}/build"
 FILES_kernel-vmlinux = "/boot/vmlinux*"
-FILES_kernel-modules = ""
+FILES_${KERNEL_MODULES_META_PACKAGE} = ""
 RDEPENDS_kernel = "kernel-base"
 # Allow machines to override this dependency if kernel image files are 
 # not wanted in images as standard
@@ -390,8 +393,8 @@ RPROVIDES_kernel-base += "kernel-${KERNEL_VERSION}"
 ALLOW_EMPTY_kernel = "1"
 ALLOW_EMPTY_kernel-base = "1"
 ALLOW_EMPTY_kernel-image = "1"
-ALLOW_EMPTY_kernel-modules = "1"
-DESCRIPTION_kernel-modules = "Kernel modules meta package"
+ALLOW_EMPTY_${KERNEL_MODULES_META_PACKAGE} = "1"
+DESCRIPTION_${KERNEL_MODULES_META_PACKAGE} = "Kernel modules meta package"
 
 pkg_postinst_kernel-base () {
        if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then




More information about the Openembedded-core mailing list