All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] kernel: Add support for multiple kernel packages
@ 2017-07-05 17:33 Haris Okanovic
  2017-07-17 20:31 ` Wold, Saul
  0 siblings, 1 reply; 31+ messages in thread
From: Haris Okanovic @ 2017-07-05 17:33 UTC (permalink / raw)
  To: openembedded-core; +Cc: haris.okanovic, saul.wold, josh.hernstrom

Some distros may want to provide alternate kernel "flavors" via feeds or
within bootable images. For example, readily available builds which
provide certain diagnostic features can enable developers and testers to
more quickly resolve issues by avoiding lengthy kernel builds.

This change allows for building multiple flavors of the kernel and
module packages by templatizing kernel package names via a new
KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the old
name of "kernel", but can be overridden by certain recipes providing
alternate kernel flavors.

To maintain compatibility, recipes providing alternate kernel flavors
cannot be the "preferred provider" for virtual/kernel. This is because
OE puts the preferred provider's build and source at
"tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
"tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
"tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using the
default KERNEL_PACKAGE_NAME="kernel" follows the old semantics -- build
in the old location and may be preferred provider -- while recipes using
all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and don't
provide "virtual/kernel".

Testing:
 1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
    linux-yocto-tiny_4.9.bb so that it may build alongside
    the main kernel.
 2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel flavors.
 3. Verified image and modules IPKs exist for both:
    tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
    tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
 4. Verified linux-yocto is the "preferred provider", and was built in
    shared directory: tmp-glibc/work-shared/qemux86/kernel-*
 5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
    core-image-base.bb to include both kernel flavors.
 6. `bitbake core-image-base` to build an image.
 7. Verified image contains two bzImage's under /boot/, with
    "yocto-standard" selected to boot via symlink.

Discussion thread:
http://lists.openembedded.org/pipermail/openembedded-core/2015-December/thread.html#114122

Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
---
[PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to the
"work" directory in alternate kernel builds, instead of "work-shared",
so
that the two builds don't clobber each other.

[PATCH v3] An updated version of this change rebased onto the current
OE-core master. Changes:
 * Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
   kernel builds, since alternate kernels aren't the
   PREFERRED_PROVIDER for virtual/kernel by definition.
 * Remove "virtual/kernel" from PROVIDES in alternate kernel builds.

[PATCH v4] Another rebase onto master; no functional change.
Improved description and testing steps.
---
 meta/classes/kernel-module-split.bbclass  |  9 ++--
 meta/classes/kernel.bbclass               | 85 ++++++++++++++++++-------------
 meta/conf/documentation.conf              |  1 +
 meta/recipes-kernel/linux/linux-dtb.inc   |  2 +-
 meta/recipes-kernel/linux/linux-yocto.inc |  2 +-
 5 files changed, 59 insertions(+), 40 deletions(-)

diff --git a/meta/classes/kernel-module-split.bbclass b/meta/classes/kernel-module-split.bbclass
index 1035525dac..9716c5937b 100644
--- a/meta/classes/kernel-module-split.bbclass
+++ b/meta/classes/kernel-module-split.bbclass
@@ -30,7 +30,7 @@ do_install_append() {
 
 PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
 
-KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
+KERNEL_MODULES_META_PACKAGE ?= "${KERNEL_PACKAGE_NAME}-modules"
 
 KERNEL_MODULE_PACKAGE_PREFIX ?= ""
 KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
@@ -129,16 +129,19 @@ python split_kernel_module_packages () {
            postfix = format.split('%s')[1]
            d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
 
+    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True)
+    kernel_version = d.getVar("KERNEL_VERSION", True)
+
     module_regex = '^(.*)\.k?o$'
 
     module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
     module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
-    module_pattern = module_pattern_prefix + 'kernel-module-%s' + module_pattern_suffix
+    module_pattern = module_pattern_prefix + kernel_package_name + '-module-%s' + module_pattern_suffix
 
     postinst = d.getVar('pkg_postinst_modules')
     postrm = d.getVar('pkg_postrm_modules')
 
-    modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
+    modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='%s-%s' % (kernel_package_name, kernel_version))
     if modules:
         metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
         d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index 7670c7107a..7fa4509961 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -1,6 +1,8 @@
 inherit linux-kernel-base kernel-module-split
 
-PROVIDES += "virtual/kernel"
+KERNEL_PACKAGE_NAME ??= "kernel"
+
+PROVIDES += "${@ "virtual/kernel" if (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
 DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
 PACKAGE_WRITE_DEPS += "depmodwrapper-cross virtual/update-alternatives-native"
 
@@ -33,10 +35,23 @@ KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
 
 python __anonymous () {
 
+    # The default kernel recipe builds in a shared location defined by
+    # bitbake/distro confs: STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR.
+    # Set these variables to directories under ${WORKDIR} in alternate
+    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so that they
+    # may build in parallel with the default kernel without clobbering.
+    if d.getVar("KERNEL_PACKAGE_NAME", True) != "kernel":
+        workdir = d.getVar("WORKDIR", True)
+        sourceDir = os.path.join(workdir, 'kernel-source')
+        artifactsDir = os.path.join(workdir, 'kernel-build-artifacts')
+        d.setVar("STAGING_KERNEL_DIR", sourceDir)
+        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
+
     # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES
     type = d.getVar('KERNEL_IMAGETYPE') or ""
     alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
     types = d.getVar('KERNEL_IMAGETYPES') or ""
+    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
     if type not in types.split():
         types = (type + ' ' + types).strip()
     if alttype not in types.split():
@@ -53,22 +68,22 @@ python __anonymous () {
         typelower = type.lower()
         imagedest = d.getVar('KERNEL_IMAGEDEST')
 
-        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
+        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
 
-        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
+        d.setVar('FILES_' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
 
-        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' + typelower)
+        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' % (kname, typelower))
 
-        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' + typelower + '-${KERNEL_VERSION_PKG_NAME}')
+        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
 
-        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
+        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower), '1')
 
         priority = d.getVar('KERNEL_PRIORITY')
         postinst = '#!/bin/sh\n' + 'update-alternatives --install /' + imagedest + '/' + type + ' ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
-        d.setVar('pkg_postinst_kernel-image-' + typelower, postinst)
+        d.setVar('pkg_postinst_' + kname + '-image-' + typelower, postinst)
 
         postrm = '#!/bin/sh\n' + 'update-alternatives --remove' + ' ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n'
-        d.setVar('pkg_postrm_kernel-image-' + typelower, postrm)
+        d.setVar('pkg_postrm_%s-image-%s' % (kname, typelower), postrm)
 
     image = d.getVar('INITRAMFS_IMAGE')
     if image:
@@ -126,9 +141,9 @@ base_do_unpack_append () {
 
 inherit kernel-arch deploy
 
-PACKAGES_DYNAMIC += "^kernel-module-.*"
-PACKAGES_DYNAMIC += "^kernel-image-.*"
-PACKAGES_DYNAMIC += "^kernel-firmware-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
 
 export OS = "${TARGET_OS}"
 export CROSS_COMPILE = "${TARGET_PREFIX}"
@@ -371,9 +386,9 @@ do_shared_workdir_setscene () {
 
 emit_depmod_pkgdata() {
 	# Stash data for depmod
-	install -d ${PKGDESTWORK}/kernel-depmod/
-	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-depmod/kernel-abiversion
-	cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-${KERNEL_VERSION}
+	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
+	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-abiversion
+	cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/System.map-${KERNEL_VERSION}
 }
 
 PACKAGEFUNCS += "emit_depmod_pkgdata"
@@ -388,7 +403,7 @@ do_shared_workdir () {
 	# Store the kernel version in sysroots for module-base.bbclass
 	#
 
-	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
+	echo "${KERNEL_VERSION}" > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
 
 	# Copy files required for module builds
 	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
@@ -486,28 +501,28 @@ EXPORT_FUNCTIONS do_compile do_install do_configure
 
 # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
 FILES_${PN} = ""
-FILES_kernel-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
-FILES_kernel-image = ""
-FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
-FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
-FILES_kernel-modules = ""
-RDEPENDS_kernel = "kernel-base"
+FILES_${KERNEL_PACKAGE_NAME}-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
+FILES_${KERNEL_PACKAGE_NAME}-image = ""
+FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
+FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
+FILES_${KERNEL_PACKAGE_NAME}-modules = ""
+RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
 # Allow machines to override this dependency if kernel image files are
 # not wanted in images as standard
-RDEPENDS_kernel-base ?= "kernel-image"
-PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
-RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', 'kernel-vmlinux', '', d)}"
-PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSION}')}"
-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"
-
-pkg_postinst_kernel-base () {
+RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-image"
+PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
+RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
+PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitimize_package_name('${KERNEL_VERSION}')}"
+RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-${KERNEL_VERSION}"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
+DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta package"
+
+pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
 	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
 		mkdir -p $D/lib/modules/${KERNEL_VERSION}
 	fi
@@ -521,7 +536,7 @@ pkg_postinst_kernel-base () {
 PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
 
 python split_kernel_packages () {
-    do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
+    do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
 }
 
 # Many scripts want to look in arch/$arch/boot for the bootable
diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
index 35b9103b4a..e061b98de3 100644
--- a/meta/conf/documentation.conf
+++ b/meta/conf/documentation.conf
@@ -248,6 +248,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to build for a device, usually set b
 KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a device, usually set by the machine configuration files and defaults to KERNEL_IMAGETYPE."
 KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be auto-loaded during boot"
 KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the build system expects to find module_conf_* values that specify configuration for each of the modules"
+KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages. Defaults to 'kernel'."
 KERNEL_PATH[doc] = "The location of the kernel sources. This variable is set to the value of the STAGING_KERNEL_DIR within the module class (module.bbclass)."
 KERNEL_SRC[doc] = "The location of the kernel sources. This variable is set to the value of the STAGING_KERNEL_DIR within the module class (module.bbclass)."
 KFEATURE_DESCRIPTION[doc] = "Provides a short description of a configuration fragment. You use this variable in the .scc file that describes a configuration fragment file."
diff --git a/meta/recipes-kernel/linux/linux-dtb.inc b/meta/recipes-kernel/linux/linux-dtb.inc
index 0174c80d85..da6467bf9f 100644
--- a/meta/recipes-kernel/linux/linux-dtb.inc
+++ b/meta/recipes-kernel/linux/linux-dtb.inc
@@ -4,7 +4,7 @@ FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/devicetree*"
 PACKAGE_WRITE_DEPS += "virtual/update-alternatives-native"
 
 python __anonymous () {
-    d.appendVar("PACKAGES", " kernel-devicetree")
+    d.appendVar("PACKAGES", " ${KERNEL_PACKAGE_NAME}-devicetree")
 }
 
 normalize_dtb () {
diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc
index 637506a2a8..4e0ce029da 100644
--- a/meta/recipes-kernel/linux/linux-yocto.inc
+++ b/meta/recipes-kernel/linux/linux-yocto.inc
@@ -12,7 +12,7 @@ INC_PR = "r4"
 # PREFERRED_PROVIDER for virtual/kernel. This avoids network access required
 # by the use of AUTOREV SRCREVs, which are the default for this recipe.
 python () {
-    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != d.getVar("PN"):
+    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN", True):
         d.delVar("BB_DONT_CACHE")
         raise bb.parse.SkipPackage("Set PREFERRED_PROVIDER_virtual/kernel to %s to enable it" % (d.getVar("PN")))
 }
-- 
2.13.2



^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH v4] kernel: Add support for multiple kernel packages
  2017-07-05 17:33 [PATCH v4] kernel: Add support for multiple kernel packages Haris Okanovic
@ 2017-07-17 20:31 ` Wold, Saul
  2017-07-18 13:34   ` Haris Okanovic
  0 siblings, 1 reply; 31+ messages in thread
From: Wold, Saul @ 2017-07-17 20:31 UTC (permalink / raw)
  To: openembedded-core, haris.okanovic; +Cc: josh.hernstrom

On Wed, 2017-07-05 at 12:33 -0500, Haris Okanovic wrote:
> Some distros may want to provide alternate kernel "flavors" via feeds
> or
> within bootable images. For example, readily available builds which
> provide certain diagnostic features can enable developers and testers
> to
> more quickly resolve issues by avoiding lengthy kernel builds.
> 
> This change allows for building multiple flavors of the kernel and
> module packages by templatizing kernel package names via a new
> KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the
> old
> name of "kernel", but can be overridden by certain recipes providing
> alternate kernel flavors.
> 
> To maintain compatibility, recipes providing alternate kernel flavors
> cannot be the "preferred provider" for virtual/kernel. This is
> because
> OE puts the preferred provider's build and source at
> "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
> "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
> "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using
> the
> default KERNEL_PACKAGE_NAME="kernel" follows the old semantics --
> build
> in the old location and may be preferred provider -- while recipes
> using
> all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and
> don't
> provide "virtual/kernel".
> 
> Testing:
>  1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
>     linux-yocto-tiny_4.9.bb so that it may build alongside
>     the main kernel.
>  2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel
> flavors.
>  3. Verified image and modules IPKs exist for both:
>     tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>     tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
>  4. Verified linux-yocto is the "preferred provider", and was built
> in
>     shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>  5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
>     core-image-base.bb to include both kernel flavors.
>  6. `bitbake core-image-base` to build an image.
>  7. Verified image contains two bzImage's under /boot/, with
>     "yocto-standard" selected to boot via symlink.
> 
> Discussion thread:
> http://lists.openembedded.org/pipermail/openembedded-core/2015-Decemb
> er/thread.html#114122
> 
> Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
> Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
> Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
> Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
> Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
> Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
> ---
> [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to
> the
> "work" directory in alternate kernel builds, instead of "work-
> shared",
> so
> that the two builds don't clobber each other.
> 
> [PATCH v3] An updated version of this change rebased onto the current
> OE-core master. Changes:
>  * Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
>    kernel builds, since alternate kernels aren't the
>    PREFERRED_PROVIDER for virtual/kernel by definition.
>  * Remove "virtual/kernel" from PROVIDES in alternate kernel builds.
> 
> [PATCH v4] Another rebase onto master; no functional change.
> Improved description and testing steps.

So I finally had a chance to get back to this and test build with it, I
saw the following WARNING, which lead to the ERROR:

WARNING: Variable key FILES_${PN}-dev (${includedir} ${FILES_SOLIBSDEV}
${libdir}/*.la ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig
${datadir}/aclocal ${base_libdir}/*.o ${libdir}/${BPN}/*.la
${base_libdir}/*.la) replaces original key FILES_linux-yocto-dev
(/boot/System.map* /boot/Module.symvers* /boot/config*
${KERNEL_SRC_PATH}
${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build).
ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
do_package: QA Issue: linux-yocto: Files/directories were installed but
not shipped in any package:
  /boot/System.map-4.10.17-yocto-standard
  /boot/Module.symvers-4.10.17-yocto-standard
  /boot/config-4.10.17-yocto-standard
Please set FILES such that these items are packaged. Alternatively if
they are unneeded, avoid installing them or delete them within
do_install.
linux-yocto: 3 installed and not shipped files. [installed-vs-shipped]
ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
do_package: Fatal QA errors found, failing task.
ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
do_package: Function failed: do_package

Something seems to be causing the FILES_linux-yocto-dev info to be
overridden, I have not tracked down the culprit yet.

Sau!

> ---
>  meta/classes/kernel-module-split.bbclass  |  9 ++--
>  meta/classes/kernel.bbclass               | 85 ++++++++++++++++++---
> ----------
>  meta/conf/documentation.conf              |  1 +
>  meta/recipes-kernel/linux/linux-dtb.inc   |  2 +-
>  meta/recipes-kernel/linux/linux-yocto.inc |  2 +-
>  5 files changed, 59 insertions(+), 40 deletions(-)
> 
> diff --git a/meta/classes/kernel-module-split.bbclass
> b/meta/classes/kernel-module-split.bbclass
> index 1035525dac..9716c5937b 100644
> --- a/meta/classes/kernel-module-split.bbclass
> +++ b/meta/classes/kernel-module-split.bbclass
> @@ -30,7 +30,7 @@ do_install_append() {
>  
>  PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>  
> -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
> +KERNEL_MODULES_META_PACKAGE ?= "${KERNEL_PACKAGE_NAME}-modules"
>  
>  KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>  KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
> @@ -129,16 +129,19 @@ python split_kernel_module_packages () {
>             postfix = format.split('%s')[1]
>             d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
>  
> +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True)
> +    kernel_version = d.getVar("KERNEL_VERSION", True)
> +
>      module_regex = '^(.*)\.k?o$'
>  
>      module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>      module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
> -    module_pattern = module_pattern_prefix + 'kernel-module-%s' +
> module_pattern_suffix
> +    module_pattern = module_pattern_prefix + kernel_package_name +
> '-module-%s' + module_pattern_suffix
>  
>      postinst = d.getVar('pkg_postinst_modules')
>      postrm = d.getVar('pkg_postrm_modules')
>  
> -    modules = do_split_packages(d,
> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
> output_pattern=module_pattern, description='%s kernel module',
> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
> extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
> +    modules = do_split_packages(d,
> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
> output_pattern=module_pattern, description='%s kernel module',
> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
> extra_depends='%s-%s' % (kernel_package_name, kernel_version))
>      if modules:
>          metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>          d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
> diff --git a/meta/classes/kernel.bbclass
> b/meta/classes/kernel.bbclass
> index 7670c7107a..7fa4509961 100644
> --- a/meta/classes/kernel.bbclass
> +++ b/meta/classes/kernel.bbclass
> @@ -1,6 +1,8 @@
>  inherit linux-kernel-base kernel-module-split
>  
> -PROVIDES += "virtual/kernel"
> +KERNEL_PACKAGE_NAME ??= "kernel"
> +
> +PROVIDES += "${@ "virtual/kernel" if
> (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
>  DEPENDS += "virtual/${TARGET_PREFIX}binutils
> virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
>  PACKAGE_WRITE_DEPS += "depmodwrapper-cross virtual/update-
> alternatives-native"
>  
> @@ -33,10 +35,23 @@ KERNEL_VERSION_PKG_NAME[vardepvalue] =
> "${LINUX_VERSION}"
>  
>  python __anonymous () {
>  
> +    # The default kernel recipe builds in a shared location defined
> by
> +    # bitbake/distro confs: STAGING_KERNEL_DIR and
> STAGING_KERNEL_BUILDDIR.
> +    # Set these variables to directories under ${WORKDIR} in
> alternate
> +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so
> that they
> +    # may build in parallel with the default kernel without
> clobbering.
> +    if d.getVar("KERNEL_PACKAGE_NAME", True) != "kernel":
> +        workdir = d.getVar("WORKDIR", True)
> +        sourceDir = os.path.join(workdir, 'kernel-source')
> +        artifactsDir = os.path.join(workdir, 'kernel-build-
> artifacts')
> +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
> +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
> +
>      # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
> KERNEL_IMAGETYPES
>      type = d.getVar('KERNEL_IMAGETYPE') or ""
>      alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>      types = d.getVar('KERNEL_IMAGETYPES') or ""
> +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
>      if type not in types.split():
>          types = (type + ' ' + types).strip()
>      if alttype not in types.split():
> @@ -53,22 +68,22 @@ python __anonymous () {
>          typelower = type.lower()
>          imagedest = d.getVar('KERNEL_IMAGEDEST')
>  
> -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
> +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
>  
> -        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest
> + '/' + type + '-${KERNEL_VERSION_NAME}')
> +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' +
> imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
>  
> -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' +
> typelower)
> +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' %
> (kname, typelower))
>  
> -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' +
> typelower + '-${KERNEL_VERSION_PKG_NAME}')
> +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-
> %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>  
> -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
> +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower),
> '1')
>  
>          priority = d.getVar('KERNEL_PRIORITY')
>          postinst = '#!/bin/sh\n' + 'update-alternatives --install /'
> + imagedest + '/' + type + ' ' + type + ' ' + type + '-
> ${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
> -        d.setVar('pkg_postinst_kernel-image-' + typelower, postinst)
> +        d.setVar('pkg_postinst_' + kname + '-image-' + typelower,
> postinst)
>  
>          postrm = '#!/bin/sh\n' + 'update-alternatives --remove' + '
> ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n'
> -        d.setVar('pkg_postrm_kernel-image-' + typelower, postrm)
> +        d.setVar('pkg_postrm_%s-image-%s' % (kname, typelower),
> postrm)
>  
>      image = d.getVar('INITRAMFS_IMAGE')
>      if image:
> @@ -126,9 +141,9 @@ base_do_unpack_append () {
>  
>  inherit kernel-arch deploy
>  
> -PACKAGES_DYNAMIC += "^kernel-module-.*"
> -PACKAGES_DYNAMIC += "^kernel-image-.*"
> -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>  
>  export OS = "${TARGET_OS}"
>  export CROSS_COMPILE = "${TARGET_PREFIX}"
> @@ -371,9 +386,9 @@ do_shared_workdir_setscene () {
>  
>  emit_depmod_pkgdata() {
>  	# Stash data for depmod
> -	install -d ${PKGDESTWORK}/kernel-depmod/
> -	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
> depmod/kernel-abiversion
> -	cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-
> ${KERNEL_VERSION}
> +	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
> +	echo "${KERNEL_VERSION}" >
> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-
> abiversion
> +	cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
> depmod/System.map-${KERNEL_VERSION}
>  }
>  
>  PACKAGEFUNCS += "emit_depmod_pkgdata"
> @@ -388,7 +403,7 @@ do_shared_workdir () {
>  	# Store the kernel version in sysroots for module-
> base.bbclass
>  	#
>  
> -	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
> +	echo "${KERNEL_VERSION}" >
> $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>  
>  	# Copy files required for module builds
>  	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
> @@ -486,28 +501,28 @@ EXPORT_FUNCTIONS do_compile do_install
> do_configure
>  
>  # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base
> ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
> ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>  FILES_${PN} = ""
> -FILES_kernel-base =
> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
> -FILES_kernel-image = ""
> -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
> /boot/config* ${KERNEL_SRC_PATH}
> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
> -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
> -FILES_kernel-modules = ""
> -RDEPENDS_kernel = "kernel-base"
> +FILES_${KERNEL_PACKAGE_NAME}-base =
> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
> +FILES_${KERNEL_PACKAGE_NAME}-image = ""
> +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
> /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
> +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
> ${KERNEL_VERSION_NAME}"
> +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
> +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
>  # Allow machines to override this dependency if kernel image files
> are
>  # not wanted in images as standard
> -RDEPENDS_kernel-base ?= "kernel-image"
> -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNE
> L_VERSION}')}"
> -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE',
> 'vmlinux', 'kernel-vmlinux', '', d)}"
> -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSI
> ON}')}"
> -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"
> -
> -pkg_postinst_kernel-base () {
> +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-
> image"
> +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@
> legitimize_package_name('${KERNEL_VERSION}')}"
> +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNE
> L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
> +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitim
> ize_package_name('${KERNEL_VERSION}')}"
> +RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-
> ${KERNEL_VERSION}"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
> +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta
> package"
> +
> +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>  	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>  		mkdir -p $D/lib/modules/${KERNEL_VERSION}
>  	fi
> @@ -521,7 +536,7 @@ pkg_postinst_kernel-base () {
>  PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>  
>  python split_kernel_packages () {
> -    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-
> firmware-%s', description='Firmware for %s', recursive=True,
> extra_depends='')
> +    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
> output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
> description='Firmware for %s', recursive=True, extra_depends='')
>  }
>  
>  # Many scripts want to look in arch/$arch/boot for the bootable
> diff --git a/meta/conf/documentation.conf
> b/meta/conf/documentation.conf
> index 35b9103b4a..e061b98de3 100644
> --- a/meta/conf/documentation.conf
> +++ b/meta/conf/documentation.conf
> @@ -248,6 +248,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to
> build for a device, usually set b
>  KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a
> device, usually set by the machine configuration files and defaults
> to KERNEL_IMAGETYPE."
>  KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be
> auto-loaded during boot"
>  KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the
> build system expects to find module_conf_* values that specify
> configuration for each of the modules"
> +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
> Defaults to 'kernel'."
>  KERNEL_PATH[doc] = "The location of the kernel sources. This
> variable is set to the value of the STAGING_KERNEL_DIR within the
> module class (module.bbclass)."
>  KERNEL_SRC[doc] = "The location of the kernel sources. This variable
> is set to the value of the STAGING_KERNEL_DIR within the module class
> (module.bbclass)."
>  KFEATURE_DESCRIPTION[doc] = "Provides a short description of a
> configuration fragment. You use this variable in the .scc file that
> describes a configuration fragment file."
> diff --git a/meta/recipes-kernel/linux/linux-dtb.inc b/meta/recipes-
> kernel/linux/linux-dtb.inc
> index 0174c80d85..da6467bf9f 100644
> --- a/meta/recipes-kernel/linux/linux-dtb.inc
> +++ b/meta/recipes-kernel/linux/linux-dtb.inc
> @@ -4,7 +4,7 @@ FILES_kernel-devicetree =
> "/${KERNEL_IMAGEDEST}/devicetree*"
>  PACKAGE_WRITE_DEPS += "virtual/update-alternatives-native"
>  
>  python __anonymous () {
> -    d.appendVar("PACKAGES", " kernel-devicetree")
> +    d.appendVar("PACKAGES", " ${KERNEL_PACKAGE_NAME}-devicetree")
>  }
>  
>  normalize_dtb () {
> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
> b/meta/recipes-kernel/linux/linux-yocto.inc
> index 637506a2a8..4e0ce029da 100644
> --- a/meta/recipes-kernel/linux/linux-yocto.inc
> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
> @@ -12,7 +12,7 @@ INC_PR = "r4"
>  # PREFERRED_PROVIDER for virtual/kernel. This avoids network access
> required
>  # by the use of AUTOREV SRCREVs, which are the default for this
> recipe.
>  python () {
> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
> d.getVar("PN"):
> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
> d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN",
> True):
>          d.delVar("BB_DONT_CACHE")
>          raise bb.parse.SkipPackage("Set
> PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
> (d.getVar("PN")))
>  }

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v4] kernel: Add support for multiple kernel packages
  2017-07-17 20:31 ` Wold, Saul
@ 2017-07-18 13:34   ` Haris Okanovic
  2017-07-19 15:56     ` Wold, Saul
  0 siblings, 1 reply; 31+ messages in thread
From: Haris Okanovic @ 2017-07-18 13:34 UTC (permalink / raw)
  To: Wold, Saul, openembedded-core; +Cc: josh.hernstrom



On 07/17/2017 03:31 PM, Wold, Saul wrote:
> On Wed, 2017-07-05 at 12:33 -0500, Haris Okanovic wrote:
>> Some distros may want to provide alternate kernel "flavors" via feeds
>> or
>> within bootable images. For example, readily available builds which
>> provide certain diagnostic features can enable developers and testers
>> to
>> more quickly resolve issues by avoiding lengthy kernel builds.
>>
>> This change allows for building multiple flavors of the kernel and
>> module packages by templatizing kernel package names via a new
>> KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the
>> old
>> name of "kernel", but can be overridden by certain recipes providing
>> alternate kernel flavors.
>>
>> To maintain compatibility, recipes providing alternate kernel flavors
>> cannot be the "preferred provider" for virtual/kernel. This is
>> because
>> OE puts the preferred provider's build and source at
>> "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
>> "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
>> "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using
>> the
>> default KERNEL_PACKAGE_NAME="kernel" follows the old semantics --
>> build
>> in the old location and may be preferred provider -- while recipes
>> using
>> all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and
>> don't
>> provide "virtual/kernel".
>>
>> Testing:
>>   1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
>>      linux-yocto-tiny_4.9.bb so that it may build alongside
>>      the main kernel.
>>   2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel
>> flavors.
>>   3. Verified image and modules IPKs exist for both:
>>      tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>>      tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
>>   4. Verified linux-yocto is the "preferred provider", and was built
>> in
>>      shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>>   5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
>>      core-image-base.bb to include both kernel flavors.
>>   6. `bitbake core-image-base` to build an image.
>>   7. Verified image contains two bzImage's under /boot/, with
>>      "yocto-standard" selected to boot via symlink.
>>
>> Discussion thread:
>> http://lists.openembedded.org/pipermail/openembedded-core/2015-Decemb
>> er/thread.html#114122
>>
>> Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
>> Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
>> Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
>> Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
>> Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
>> Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
>> ---
>> [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to
>> the
>> "work" directory in alternate kernel builds, instead of "work-
>> shared",
>> so
>> that the two builds don't clobber each other.
>>
>> [PATCH v3] An updated version of this change rebased onto the current
>> OE-core master. Changes:
>>   * Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
>>     kernel builds, since alternate kernels aren't the
>>     PREFERRED_PROVIDER for virtual/kernel by definition.
>>   * Remove "virtual/kernel" from PROVIDES in alternate kernel builds.
>>
>> [PATCH v4] Another rebase onto master; no functional change.
>> Improved description and testing steps.
> 
> So I finally had a chance to get back to this and test build with it, I
> saw the following WARNING, which lead to the ERROR:
> 
> WARNING: Variable key FILES_${PN}-dev (${includedir} ${FILES_SOLIBSDEV}
> ${libdir}/*.la ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig
> ${datadir}/aclocal ${base_libdir}/*.o ${libdir}/${BPN}/*.la
> ${base_libdir}/*.la) replaces original key FILES_linux-yocto-dev
> (/boot/System.map* /boot/Module.symvers* /boot/config*
> ${KERNEL_SRC_PATH}
> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build).
> ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
> do_package: QA Issue: linux-yocto: Files/directories were installed but
> not shipped in any package:
>    /boot/System.map-4.10.17-yocto-standard
>    /boot/Module.symvers-4.10.17-yocto-standard
>    /boot/config-4.10.17-yocto-standard
> Please set FILES such that these items are packaged. Alternatively if
> they are unneeded, avoid installing them or delete them within
> do_install.
> linux-yocto: 3 installed and not shipped files. [installed-vs-shipped]
> ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
> do_package: Fatal QA errors found, failing task.
> ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
> do_package: Function failed: do_package
> 
> Something seems to be causing the FILES_linux-yocto-dev info to be
> overridden, I have not tracked down the culprit yet.
> 

`FILES_linux-yocto-dev` is set to the default value from OE's 
bitbake.conf. `FILES_kernel-dev` on the other hand is set by 
kernel.bbclass; when `KERNEL_PACKAGE_NAME` expands to `kernel`.

I think the real issue here is that QA checks care about 
`FILES_${PN}-dev` at all even though that particular package name isn't 
listed in `PACKAGES` variable. I.e. `FILES_${PN}-dev` should be 
disregarded since the `linux-yocto` recipe doesn't create package 
`${PN}-dev`.

Thoughts?

> Sau!
> 
>> ---
>>   meta/classes/kernel-module-split.bbclass  |  9 ++--
>>   meta/classes/kernel.bbclass               | 85 ++++++++++++++++++---
>> ----------
>>   meta/conf/documentation.conf              |  1 +
>>   meta/recipes-kernel/linux/linux-dtb.inc   |  2 +-
>>   meta/recipes-kernel/linux/linux-yocto.inc |  2 +-
>>   5 files changed, 59 insertions(+), 40 deletions(-)
>>
>> diff --git a/meta/classes/kernel-module-split.bbclass
>> b/meta/classes/kernel-module-split.bbclass
>> index 1035525dac..9716c5937b 100644
>> --- a/meta/classes/kernel-module-split.bbclass
>> +++ b/meta/classes/kernel-module-split.bbclass
>> @@ -30,7 +30,7 @@ do_install_append() {
>>   
>>   PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>>   
>> -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
>> +KERNEL_MODULES_META_PACKAGE ?= "${KERNEL_PACKAGE_NAME}-modules"
>>   
>>   KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>>   KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
>> @@ -129,16 +129,19 @@ python split_kernel_module_packages () {
>>              postfix = format.split('%s')[1]
>>              d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
>>   
>> +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True)
>> +    kernel_version = d.getVar("KERNEL_VERSION", True)
>> +
>>       module_regex = '^(.*)\.k?o$'
>>   
>>       module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>>       module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
>> -    module_pattern = module_pattern_prefix + 'kernel-module-%s' +
>> module_pattern_suffix
>> +    module_pattern = module_pattern_prefix + kernel_package_name +
>> '-module-%s' + module_pattern_suffix
>>   
>>       postinst = d.getVar('pkg_postinst_modules')
>>       postrm = d.getVar('pkg_postrm_modules')
>>   
>> -    modules = do_split_packages(d,
>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>> output_pattern=module_pattern, description='%s kernel module',
>> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
>> extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
>> +    modules = do_split_packages(d,
>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>> output_pattern=module_pattern, description='%s kernel module',
>> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
>> extra_depends='%s-%s' % (kernel_package_name, kernel_version))
>>       if modules:
>>           metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>>           d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
>> diff --git a/meta/classes/kernel.bbclass
>> b/meta/classes/kernel.bbclass
>> index 7670c7107a..7fa4509961 100644
>> --- a/meta/classes/kernel.bbclass
>> +++ b/meta/classes/kernel.bbclass
>> @@ -1,6 +1,8 @@
>>   inherit linux-kernel-base kernel-module-split
>>   
>> -PROVIDES += "virtual/kernel"
>> +KERNEL_PACKAGE_NAME ??= "kernel"
>> +
>> +PROVIDES += "${@ "virtual/kernel" if
>> (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
>>   DEPENDS += "virtual/${TARGET_PREFIX}binutils
>> virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
>>   PACKAGE_WRITE_DEPS += "depmodwrapper-cross virtual/update-
>> alternatives-native"
>>   
>> @@ -33,10 +35,23 @@ KERNEL_VERSION_PKG_NAME[vardepvalue] =
>> "${LINUX_VERSION}"
>>   
>>   python __anonymous () {
>>   
>> +    # The default kernel recipe builds in a shared location defined
>> by
>> +    # bitbake/distro confs: STAGING_KERNEL_DIR and
>> STAGING_KERNEL_BUILDDIR.
>> +    # Set these variables to directories under ${WORKDIR} in
>> alternate
>> +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so
>> that they
>> +    # may build in parallel with the default kernel without
>> clobbering.
>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) != "kernel":
>> +        workdir = d.getVar("WORKDIR", True)
>> +        sourceDir = os.path.join(workdir, 'kernel-source')
>> +        artifactsDir = os.path.join(workdir, 'kernel-build-
>> artifacts')
>> +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
>> +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
>> +
>>       # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
>> KERNEL_IMAGETYPES
>>       type = d.getVar('KERNEL_IMAGETYPE') or ""
>>       alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>>       types = d.getVar('KERNEL_IMAGETYPES') or ""
>> +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
>>       if type not in types.split():
>>           types = (type + ' ' + types).strip()
>>       if alttype not in types.split():
>> @@ -53,22 +68,22 @@ python __anonymous () {
>>           typelower = type.lower()
>>           imagedest = d.getVar('KERNEL_IMAGEDEST')
>>   
>> -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
>> +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
>>   
>> -        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest
>> + '/' + type + '-${KERNEL_VERSION_NAME}')
>> +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' +
>> imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
>>   
>> -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' +
>> typelower)
>> +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' %
>> (kname, typelower))
>>   
>> -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' +
>> typelower + '-${KERNEL_VERSION_PKG_NAME}')
>> +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-
>> %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>>   
>> -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
>> +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower),
>> '1')
>>   
>>           priority = d.getVar('KERNEL_PRIORITY')
>>           postinst = '#!/bin/sh\n' + 'update-alternatives --install /'
>> + imagedest + '/' + type + ' ' + type + ' ' + type + '-
>> ${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
>> -        d.setVar('pkg_postinst_kernel-image-' + typelower, postinst)
>> +        d.setVar('pkg_postinst_' + kname + '-image-' + typelower,
>> postinst)
>>   
>>           postrm = '#!/bin/sh\n' + 'update-alternatives --remove' + '
>> ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n'
>> -        d.setVar('pkg_postrm_kernel-image-' + typelower, postrm)
>> +        d.setVar('pkg_postrm_%s-image-%s' % (kname, typelower),
>> postrm)
>>   
>>       image = d.getVar('INITRAMFS_IMAGE')
>>       if image:
>> @@ -126,9 +141,9 @@ base_do_unpack_append () {
>>   
>>   inherit kernel-arch deploy
>>   
>> -PACKAGES_DYNAMIC += "^kernel-module-.*"
>> -PACKAGES_DYNAMIC += "^kernel-image-.*"
>> -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>>   
>>   export OS = "${TARGET_OS}"
>>   export CROSS_COMPILE = "${TARGET_PREFIX}"
>> @@ -371,9 +386,9 @@ do_shared_workdir_setscene () {
>>   
>>   emit_depmod_pkgdata() {
>>   	# Stash data for depmod
>> -	install -d ${PKGDESTWORK}/kernel-depmod/
>> -	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
>> depmod/kernel-abiversion
>> -	cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-
>> ${KERNEL_VERSION}
>> +	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
>> +	echo "${KERNEL_VERSION}" >
>> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-
>> abiversion
>> +	cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
>> depmod/System.map-${KERNEL_VERSION}
>>   }
>>   
>>   PACKAGEFUNCS += "emit_depmod_pkgdata"
>> @@ -388,7 +403,7 @@ do_shared_workdir () {
>>   	# Store the kernel version in sysroots for module-
>> base.bbclass
>>   	#
>>   
>> -	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
>> +	echo "${KERNEL_VERSION}" >
>> $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>>   
>>   	# Copy files required for module builds
>>   	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
>> @@ -486,28 +501,28 @@ EXPORT_FUNCTIONS do_compile do_install
>> do_configure
>>   
>>   # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base
>> ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
>> ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>>   FILES_${PN} = ""
>> -FILES_kernel-base =
>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>> -FILES_kernel-image = ""
>> -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
>> /boot/config* ${KERNEL_SRC_PATH}
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>> -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
>> -FILES_kernel-modules = ""
>> -RDEPENDS_kernel = "kernel-base"
>> +FILES_${KERNEL_PACKAGE_NAME}-base =
>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>> +FILES_${KERNEL_PACKAGE_NAME}-image = ""
>> +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
>> /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>> +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
>> ${KERNEL_VERSION_NAME}"
>> +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
>> +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
>>   # Allow machines to override this dependency if kernel image files
>> are
>>   # not wanted in images as standard
>> -RDEPENDS_kernel-base ?= "kernel-image"
>> -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNE
>> L_VERSION}')}"
>> -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE',
>> 'vmlinux', 'kernel-vmlinux', '', d)}"
>> -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSI
>> ON}')}"
>> -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"
>> -
>> -pkg_postinst_kernel-base () {
>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-
>> image"
>> +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@
>> legitimize_package_name('${KERNEL_VERSION}')}"
>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNE
>> L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
>> +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitim
>> ize_package_name('${KERNEL_VERSION}')}"
>> +RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-
>> ${KERNEL_VERSION}"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
>> +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta
>> package"
>> +
>> +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>>   	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>>   		mkdir -p $D/lib/modules/${KERNEL_VERSION}
>>   	fi
>> @@ -521,7 +536,7 @@ pkg_postinst_kernel-base () {
>>   PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>>   
>>   python split_kernel_packages () {
>> -    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-
>> firmware-%s', description='Firmware for %s', recursive=True,
>> extra_depends='')
>> +    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>> output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
>> description='Firmware for %s', recursive=True, extra_depends='')
>>   }
>>   
>>   # Many scripts want to look in arch/$arch/boot for the bootable
>> diff --git a/meta/conf/documentation.conf
>> b/meta/conf/documentation.conf
>> index 35b9103b4a..e061b98de3 100644
>> --- a/meta/conf/documentation.conf
>> +++ b/meta/conf/documentation.conf
>> @@ -248,6 +248,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to
>> build for a device, usually set b
>>   KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a
>> device, usually set by the machine configuration files and defaults
>> to KERNEL_IMAGETYPE."
>>   KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be
>> auto-loaded during boot"
>>   KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the
>> build system expects to find module_conf_* values that specify
>> configuration for each of the modules"
>> +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
>> Defaults to 'kernel'."
>>   KERNEL_PATH[doc] = "The location of the kernel sources. This
>> variable is set to the value of the STAGING_KERNEL_DIR within the
>> module class (module.bbclass)."
>>   KERNEL_SRC[doc] = "The location of the kernel sources. This variable
>> is set to the value of the STAGING_KERNEL_DIR within the module class
>> (module.bbclass)."
>>   KFEATURE_DESCRIPTION[doc] = "Provides a short description of a
>> configuration fragment. You use this variable in the .scc file that
>> describes a configuration fragment file."
>> diff --git a/meta/recipes-kernel/linux/linux-dtb.inc b/meta/recipes-
>> kernel/linux/linux-dtb.inc
>> index 0174c80d85..da6467bf9f 100644
>> --- a/meta/recipes-kernel/linux/linux-dtb.inc
>> +++ b/meta/recipes-kernel/linux/linux-dtb.inc
>> @@ -4,7 +4,7 @@ FILES_kernel-devicetree =
>> "/${KERNEL_IMAGEDEST}/devicetree*"
>>   PACKAGE_WRITE_DEPS += "virtual/update-alternatives-native"
>>   
>>   python __anonymous () {
>> -    d.appendVar("PACKAGES", " kernel-devicetree")
>> +    d.appendVar("PACKAGES", " ${KERNEL_PACKAGE_NAME}-devicetree")
>>   }
>>   
>>   normalize_dtb () {
>> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
>> b/meta/recipes-kernel/linux/linux-yocto.inc
>> index 637506a2a8..4e0ce029da 100644
>> --- a/meta/recipes-kernel/linux/linux-yocto.inc
>> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
>> @@ -12,7 +12,7 @@ INC_PR = "r4"
>>   # PREFERRED_PROVIDER for virtual/kernel. This avoids network access
>> required
>>   # by the use of AUTOREV SRCREVs, which are the default for this
>> recipe.
>>   python () {
>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
>> d.getVar("PN"):
>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>> d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN",
>> True):
>>           d.delVar("BB_DONT_CACHE")
>>           raise bb.parse.SkipPackage("Set
>> PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
>> (d.getVar("PN")))
>>   }


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v4] kernel: Add support for multiple kernel packages
  2017-07-18 13:34   ` Haris Okanovic
@ 2017-07-19 15:56     ` Wold, Saul
  2017-07-27 18:01       ` Rees, Kevron
                         ` (6 more replies)
  0 siblings, 7 replies; 31+ messages in thread
From: Wold, Saul @ 2017-07-19 15:56 UTC (permalink / raw)
  To: openembedded-core, haris.okanovic; +Cc: josh.hernstrom

On Tue, 2017-07-18 at 08:34 -0500, Haris Okanovic wrote:
> 
> On 07/17/2017 03:31 PM, Wold, Saul wrote:
> > 
> > On Wed, 2017-07-05 at 12:33 -0500, Haris Okanovic wrote:
> > > 
> > > Some distros may want to provide alternate kernel "flavors" via
> > > feeds
> > > or
> > > within bootable images. For example, readily available builds
> > > which
> > > provide certain diagnostic features can enable developers and
> > > testers
> > > to
> > > more quickly resolve issues by avoiding lengthy kernel builds.
> > > 
> > > This change allows for building multiple flavors of the kernel
> > > and
> > > module packages by templatizing kernel package names via a new
> > > KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to
> > > the
> > > old
> > > name of "kernel", but can be overridden by certain recipes
> > > providing
> > > alternate kernel flavors.
> > > 
> > > To maintain compatibility, recipes providing alternate kernel
> > > flavors
> > > cannot be the "preferred provider" for virtual/kernel. This is
> > > because
> > > OE puts the preferred provider's build and source at
> > > "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
> > > "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
> > > "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes
> > > using
> > > the
> > > default KERNEL_PACKAGE_NAME="kernel" follows the old semantics --
> > > build
> > > in the old location and may be preferred provider -- while
> > > recipes
> > > using
> > > all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and
> > > don't
> > > provide "virtual/kernel".
> > > 
> > > Testing:
> > >   1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
> > >      linux-yocto-tiny_4.9.bb so that it may build alongside
> > >      the main kernel.
> > >   2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel
> > > flavors.
> > >   3. Verified image and modules IPKs exist for both:
> > >      tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
> > >      tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-
> > > tiny
> > >   4. Verified linux-yocto is the "preferred provider", and was
> > > built
> > > in
> > >      shared directory: tmp-glibc/work-shared/qemux86/kernel-*
> > >   5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
> > >      core-image-base.bb to include both kernel flavors.
> > >   6. `bitbake core-image-base` to build an image.
> > >   7. Verified image contains two bzImage's under /boot/, with
> > >      "yocto-standard" selected to boot via symlink.
> > > 
> > > Discussion thread:
> > > http://lists.openembedded.org/pipermail/openembedded-core/2015-De
> > > cemb
> > > er/thread.html#114122
> > > 
> > > Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
> > > Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
> > > Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
> > > Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
> > > Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
> > > Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
> > > ---
> > > [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR
> > > to
> > > the
> > > "work" directory in alternate kernel builds, instead of "work-
> > > shared",
> > > so
> > > that the two builds don't clobber each other.
> > > 
> > > [PATCH v3] An updated version of this change rebased onto the
> > > current
> > > OE-core master. Changes:
> > >   * Remove PREFERRED_PROVIDER check in linux-yocto.inc in
> > > alternate
> > >     kernel builds, since alternate kernels aren't the
> > >     PREFERRED_PROVIDER for virtual/kernel by definition.
> > >   * Remove "virtual/kernel" from PROVIDES in alternate kernel
> > > builds.
> > > 
> > > [PATCH v4] Another rebase onto master; no functional change.
> > > Improved description and testing steps.
> > 
> > So I finally had a chance to get back to this and test build with
> > it, I
> > saw the following WARNING, which lead to the ERROR:
> > 
> > WARNING: Variable key FILES_${PN}-dev (${includedir}
> > ${FILES_SOLIBSDEV}
> > ${libdir}/*.la ${libdir}/*.o ${libdir}/pkgconfig
> > ${datadir}/pkgconfig
> > ${datadir}/aclocal ${base_libdir}/*.o ${libdir}/${BPN}/*.la
> > ${base_libdir}/*.la) replaces original key FILES_linux-yocto-dev
> > (/boot/System.map* /boot/Module.symvers* /boot/config*
> > ${KERNEL_SRC_PATH}
> > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build).
> > ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
> > do_package: QA Issue: linux-yocto: Files/directories were installed
> > but
> > not shipped in any package:
> >    /boot/System.map-4.10.17-yocto-standard
> >    /boot/Module.symvers-4.10.17-yocto-standard
> >    /boot/config-4.10.17-yocto-standard
> > Please set FILES such that these items are packaged. Alternatively
> > if
> > they are unneeded, avoid installing them or delete them within
> > do_install.
> > linux-yocto: 3 installed and not shipped files. [installed-vs-
> > shipped]
> > ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
> > do_package: Fatal QA errors found, failing task.
> > ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
> > do_package: Function failed: do_package
> > 
> > Something seems to be causing the FILES_linux-yocto-dev info to be
> > overridden, I have not tracked down the culprit yet.
> > 
> 
> `FILES_linux-yocto-dev` is set to the default value from OE's 
> bitbake.conf. `FILES_kernel-dev` on the other hand is set by 
> kernel.bbclass; when `KERNEL_PACKAGE_NAME` expands to `kernel`.
> 
> I think the real issue here is that QA checks care about 
> `FILES_${PN}-dev` at all even though that particular package name
> isn't 
> listed in `PACKAGES` variable. I.e. `FILES_${PN}-dev` should be 
> disregarded since the `linux-yocto` recipe doesn't create package 
> `${PN}-dev`.
> 
> Thoughts?
> 
It's hard to special case this. After you sent this, I realized what I
did was set the KERNEL_PACKAGE_NAME to linux-yocto and because the
KERNEL_PACKAGE_NAME matched the actual recipe name we got the strange
${PN} interaction, we might be able to add a test to flag that as an
error or warning in the kernel.bbclass.

I am also seeing an issue when I build a 4.9 kernel and then set-up a
4.10 kernel with the kernel-abiversion getting mis-matched from the
depmodwrapper.  Have you tested with different versions?  I know it
should work with a old kernel/userspace -> new kernel, but not from a
new kernel/userspace -> old kernel.

Sau!


> > 
> > Sau!
> > 
> > > 
> > > ---
> > >   meta/classes/kernel-module-split.bbclass  |  9 ++--
> > >   meta/classes/kernel.bbclass               | 85
> > > ++++++++++++++++++---
> > > ----------
> > >   meta/conf/documentation.conf              |  1 +
> > >   meta/recipes-kernel/linux/linux-dtb.inc   |  2 +-
> > >   meta/recipes-kernel/linux/linux-yocto.inc |  2 +-
> > >   5 files changed, 59 insertions(+), 40 deletions(-)
> > > 
> > > diff --git a/meta/classes/kernel-module-split.bbclass
> > > b/meta/classes/kernel-module-split.bbclass
> > > index 1035525dac..9716c5937b 100644
> > > --- a/meta/classes/kernel-module-split.bbclass
> > > +++ b/meta/classes/kernel-module-split.bbclass
> > > @@ -30,7 +30,7 @@ do_install_append() {
> > >   
> > >   PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
> > >   
> > > -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
> > > +KERNEL_MODULES_META_PACKAGE ?= "${KERNEL_PACKAGE_NAME}-modules"
> > >   
> > >   KERNEL_MODULE_PACKAGE_PREFIX ?= ""
> > >   KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
> > > @@ -129,16 +129,19 @@ python split_kernel_module_packages () {
> > >              postfix = format.split('%s')[1]
> > >              d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix,
> > > ''))
> > >   
> > > +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True)
> > > +    kernel_version = d.getVar("KERNEL_VERSION", True)
> > > +
> > >       module_regex = '^(.*)\.k?o$'
> > >   
> > >       module_pattern_prefix =
> > > d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
> > >       module_pattern_suffix =
> > > d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
> > > -    module_pattern = module_pattern_prefix + 'kernel-module-%s'
> > > +
> > > module_pattern_suffix
> > > +    module_pattern = module_pattern_prefix + kernel_package_name
> > > +
> > > '-module-%s' + module_pattern_suffix
> > >   
> > >       postinst = d.getVar('pkg_postinst_modules')
> > >       postrm = d.getVar('pkg_postrm_modules')
> > >   
> > > -    modules = do_split_packages(d,
> > > root='${nonarch_base_libdir}/modules', file_regex=module_regex,
> > > output_pattern=module_pattern, description='%s kernel module',
> > > postinst=postinst, postrm=postrm, recursive=True,
> > > hook=frob_metadata,
> > > extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
> > > +    modules = do_split_packages(d,
> > > root='${nonarch_base_libdir}/modules', file_regex=module_regex,
> > > output_pattern=module_pattern, description='%s kernel module',
> > > postinst=postinst, postrm=postrm, recursive=True,
> > > hook=frob_metadata,
> > > extra_depends='%s-%s' % (kernel_package_name, kernel_version))
> > >       if modules:
> > >           metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
> > >           d.appendVar('RDEPENDS_' + metapkg, ' '+'
> > > '.join(modules))
> > > diff --git a/meta/classes/kernel.bbclass
> > > b/meta/classes/kernel.bbclass
> > > index 7670c7107a..7fa4509961 100644
> > > --- a/meta/classes/kernel.bbclass
> > > +++ b/meta/classes/kernel.bbclass
> > > @@ -1,6 +1,8 @@
> > >   inherit linux-kernel-base kernel-module-split
> > >   
> > > -PROVIDES += "virtual/kernel"
> > > +KERNEL_PACKAGE_NAME ??= "kernel"
> > > +
> > > +PROVIDES += "${@ "virtual/kernel" if
> > > (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
> > >   DEPENDS += "virtual/${TARGET_PREFIX}binutils
> > > virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
> > >   PACKAGE_WRITE_DEPS += "depmodwrapper-cross virtual/update-
> > > alternatives-native"
> > >   
> > > @@ -33,10 +35,23 @@ KERNEL_VERSION_PKG_NAME[vardepvalue] =
> > > "${LINUX_VERSION}"
> > >   
> > >   python __anonymous () {
> > >   
> > > +    # The default kernel recipe builds in a shared location
> > > defined
> > > by
> > > +    # bitbake/distro confs: STAGING_KERNEL_DIR and
> > > STAGING_KERNEL_BUILDDIR.
> > > +    # Set these variables to directories under ${WORKDIR} in
> > > alternate
> > > +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel)
> > > so
> > > that they
> > > +    # may build in parallel with the default kernel without
> > > clobbering.
> > > +    if d.getVar("KERNEL_PACKAGE_NAME", True) != "kernel":
> > > +        workdir = d.getVar("WORKDIR", True)
> > > +        sourceDir = os.path.join(workdir, 'kernel-source')
> > > +        artifactsDir = os.path.join(workdir, 'kernel-build-
> > > artifacts')
> > > +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
> > > +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
> > > +
> > >       # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
> > > KERNEL_IMAGETYPES
> > >       type = d.getVar('KERNEL_IMAGETYPE') or ""
> > >       alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
> > >       types = d.getVar('KERNEL_IMAGETYPES') or ""
> > > +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
> > >       if type not in types.split():
> > >           types = (type + ' ' + types).strip()
> > >       if alttype not in types.split():
> > > @@ -53,22 +68,22 @@ python __anonymous () {
> > >           typelower = type.lower()
> > >           imagedest = d.getVar('KERNEL_IMAGEDEST')
> > >   
> > > -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' +
> > > typelower)
> > > +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname,
> > > typelower))
> > >   
> > > -        d.setVar('FILES_kernel-image-' + typelower, '/' +
> > > imagedest
> > > + '/' + type + '-${KERNEL_VERSION_NAME}')
> > > +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' +
> > > imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
> > >   
> > > -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-
> > > image-' +
> > > typelower)
> > > +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s'
> > > %
> > > (kname, typelower))
> > >   
> > > -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-
> > > ' +
> > > typelower + '-${KERNEL_VERSION_PKG_NAME}')
> > > +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-
> > > image-
> > > %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
> > >   
> > > -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
> > > +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower),
> > > '1')
> > >   
> > >           priority = d.getVar('KERNEL_PRIORITY')
> > >           postinst = '#!/bin/sh\n' + 'update-alternatives --
> > > install /'
> > > + imagedest + '/' + type + ' ' + type + ' ' + type + '-
> > > ${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
> > > -        d.setVar('pkg_postinst_kernel-image-' + typelower,
> > > postinst)
> > > +        d.setVar('pkg_postinst_' + kname + '-image-' +
> > > typelower,
> > > postinst)
> > >   
> > >           postrm = '#!/bin/sh\n' + 'update-alternatives --remove' 
> > > + '
> > > ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n'
> > > -        d.setVar('pkg_postrm_kernel-image-' + typelower, postrm)
> > > +        d.setVar('pkg_postrm_%s-image-%s' % (kname, typelower),
> > > postrm)
> > >   
> > >       image = d.getVar('INITRAMFS_IMAGE')
> > >       if image:
> > > @@ -126,9 +141,9 @@ base_do_unpack_append () {
> > >   
> > >   inherit kernel-arch deploy
> > >   
> > > -PACKAGES_DYNAMIC += "^kernel-module-.*"
> > > -PACKAGES_DYNAMIC += "^kernel-image-.*"
> > > -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
> > > +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
> > > +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
> > > +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
> > >   
> > >   export OS = "${TARGET_OS}"
> > >   export CROSS_COMPILE = "${TARGET_PREFIX}"
> > > @@ -371,9 +386,9 @@ do_shared_workdir_setscene () {
> > >   
> > >   emit_depmod_pkgdata() {
> > >   	# Stash data for depmod
> > > -	install -d ${PKGDESTWORK}/kernel-depmod/
> > > -	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
> > > depmod/kernel-abiversion
> > > -	cp ${B}/System.map ${PKGDESTWORK}/kernel-
> > > depmod/System.map-
> > > ${KERNEL_VERSION}
> > > +	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
> > > +	echo "${KERNEL_VERSION}" >
> > > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
> > > depmod/${KERNEL_PACKAGE_NAME}-
> > > abiversion
> > > +	cp ${B}/System.map
> > > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
> > > depmod/System.map-${KERNEL_VERSION}
> > >   }
> > >   
> > >   PACKAGEFUNCS += "emit_depmod_pkgdata"
> > > @@ -388,7 +403,7 @@ do_shared_workdir () {
> > >   	# Store the kernel version in sysroots for module-
> > > base.bbclass
> > >   	#
> > >   
> > > -	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
> > > +	echo "${KERNEL_VERSION}" >
> > > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
> > >   
> > >   	# Copy files required for module builds
> > >   	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
> > > @@ -486,28 +501,28 @@ EXPORT_FUNCTIONS do_compile do_install
> > > do_configure
> > >   
> > >   # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base
> > > ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
> > > ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
> > >   FILES_${PN} = ""
> > > -FILES_kernel-base =
> > > "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
> > > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
> > > -FILES_kernel-image = ""
> > > -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
> > > /boot/config* ${KERNEL_SRC_PATH}
> > > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
> > > -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
> > > -FILES_kernel-modules = ""
> > > -RDEPENDS_kernel = "kernel-base"
> > > +FILES_${KERNEL_PACKAGE_NAME}-base =
> > > "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
> > > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
> > > +FILES_${KERNEL_PACKAGE_NAME}-image = ""
> > > +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
> > > /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
> > > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
> > > +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
> > > ${KERNEL_VERSION_NAME}"
> > > +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
> > > +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
> > >   # Allow machines to override this dependency if kernel image
> > > files
> > > are
> > >   # not wanted in images as standard
> > > -RDEPENDS_kernel-base ?= "kernel-image"
> > > -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${K
> > > ERNE
> > > L_VERSION}')}"
> > > -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE'
> > > ,
> > > 'vmlinux', 'kernel-vmlinux', '', d)}"
> > > -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_V
> > > ERSI
> > > ON}')}"
> > > -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"
> > > -
> > > -pkg_postinst_kernel-base () {
> > > +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-
> > > image"
> > > +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-
> > > image-${@
> > > legitimize_package_name('${KERNEL_VERSION}')}"
> > > +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('K
> > > ERNE
> > > L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '',
> > > d)}"
> > > +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@leg
> > > itim
> > > ize_package_name('${KERNEL_VERSION}')}"
> > > +RPROVIDES_${KERNEL_PACKAGE_NAME}-base +=
> > > "${KERNEL_PACKAGE_NAME}-
> > > ${KERNEL_VERSION}"
> > > +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
> > > +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
> > > +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
> > > +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
> > > +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules
> > > meta
> > > package"
> > > +
> > > +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
> > >   	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
> > >   		mkdir -p $D/lib/modules/${KERNEL_VERSION}
> > >   	fi
> > > @@ -521,7 +536,7 @@ pkg_postinst_kernel-base () {
> > >   PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
> > >   
> > >   python split_kernel_packages () {
> > > -    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
> > > file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
> > > output_pattern='kernel-
> > > firmware-%s', description='Firmware for %s', recursive=True,
> > > extra_depends='')
> > > +    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
> > > file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
> > > output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
> > > description='Firmware for %s', recursive=True, extra_depends='')
> > >   }
> > >   
> > >   # Many scripts want to look in arch/$arch/boot for the bootable
> > > diff --git a/meta/conf/documentation.conf
> > > b/meta/conf/documentation.conf
> > > index 35b9103b4a..e061b98de3 100644
> > > --- a/meta/conf/documentation.conf
> > > +++ b/meta/conf/documentation.conf
> > > @@ -248,6 +248,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel
> > > to
> > > build for a device, usually set b
> > >   KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build
> > > for a
> > > device, usually set by the machine configuration files and
> > > defaults
> > > to KERNEL_IMAGETYPE."
> > >   KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need
> > > to be
> > > auto-loaded during boot"
> > >   KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which
> > > the
> > > build system expects to find module_conf_* values that specify
> > > configuration for each of the modules"
> > > +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
> > > Defaults to 'kernel'."
> > >   KERNEL_PATH[doc] = "The location of the kernel sources. This
> > > variable is set to the value of the STAGING_KERNEL_DIR within the
> > > module class (module.bbclass)."
> > >   KERNEL_SRC[doc] = "The location of the kernel sources. This
> > > variable
> > > is set to the value of the STAGING_KERNEL_DIR within the module
> > > class
> > > (module.bbclass)."
> > >   KFEATURE_DESCRIPTION[doc] = "Provides a short description of a
> > > configuration fragment. You use this variable in the .scc file
> > > that
> > > describes a configuration fragment file."
> > > diff --git a/meta/recipes-kernel/linux/linux-dtb.inc
> > > b/meta/recipes-
> > > kernel/linux/linux-dtb.inc
> > > index 0174c80d85..da6467bf9f 100644
> > > --- a/meta/recipes-kernel/linux/linux-dtb.inc
> > > +++ b/meta/recipes-kernel/linux/linux-dtb.inc
> > > @@ -4,7 +4,7 @@ FILES_kernel-devicetree =
> > > "/${KERNEL_IMAGEDEST}/devicetree*"
> > >   PACKAGE_WRITE_DEPS += "virtual/update-alternatives-native"
> > >   
> > >   python __anonymous () {
> > > -    d.appendVar("PACKAGES", " kernel-devicetree")
> > > +    d.appendVar("PACKAGES", " ${KERNEL_PACKAGE_NAME}-
> > > devicetree")
> > >   }
> > >   
> > >   normalize_dtb () {
> > > diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
> > > b/meta/recipes-kernel/linux/linux-yocto.inc
> > > index 637506a2a8..4e0ce029da 100644
> > > --- a/meta/recipes-kernel/linux/linux-yocto.inc
> > > +++ b/meta/recipes-kernel/linux/linux-yocto.inc
> > > @@ -12,7 +12,7 @@ INC_PR = "r4"
> > >   # PREFERRED_PROVIDER for virtual/kernel. This avoids network
> > > access
> > > required
> > >   # by the use of AUTOREV SRCREVs, which are the default for this
> > > recipe.
> > >   python () {
> > > -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
> > > d.getVar("PN"):
> > > +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
> > > d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) !=
> > > d.getVar("PN",
> > > True):
> > >           d.delVar("BB_DONT_CACHE")
> > >           raise bb.parse.SkipPackage("Set
> > > PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
> > > (d.getVar("PN")))
> > >   }

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v4] kernel: Add support for multiple kernel packages
  2017-07-19 15:56     ` Wold, Saul
@ 2017-07-27 18:01       ` Rees, Kevron
  2017-08-03 16:18         ` Ovidiu-Adrian Vancea
  2017-08-08 15:27         ` Haris Okanovic
  2017-08-08 15:26       ` Haris Okanovic
                         ` (5 subsequent siblings)
  6 siblings, 2 replies; 31+ messages in thread
From: Rees, Kevron @ 2017-07-27 18:01 UTC (permalink / raw)
  To: Wold, Saul; +Cc: haris.okanovic, josh.hernstrom, openembedded-core

On Wed, Jul 19, 2017 at 8:56 AM, Wold, Saul <saul.wold@intel.com> wrote:
> On Tue, 2017-07-18 at 08:34 -0500, Haris Okanovic wrote:
>>
>> On 07/17/2017 03:31 PM, Wold, Saul wrote:
>> >
>> > On Wed, 2017-07-05 at 12:33 -0500, Haris Okanovic wrote:
>> > >
>> > > Some distros may want to provide alternate kernel "flavors" via
>> > > feeds
>> > > or
>> > > within bootable images. For example, readily available builds
>> > > which
>> > > provide certain diagnostic features can enable developers and
>> > > testers
>> > > to
>> > > more quickly resolve issues by avoiding lengthy kernel builds.
>> > >
>> > > This change allows for building multiple flavors of the kernel
>> > > and
>> > > module packages by templatizing kernel package names via a new
>> > > KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to
>> > > the
>> > > old
>> > > name of "kernel", but can be overridden by certain recipes
>> > > providing
>> > > alternate kernel flavors.
>> > >
>> > > To maintain compatibility, recipes providing alternate kernel
>> > > flavors
>> > > cannot be the "preferred provider" for virtual/kernel. This is
>> > > because
>> > > OE puts the preferred provider's build and source at
>> > > "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
>> > > "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
>> > > "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes
>> > > using
>> > > the
>> > > default KERNEL_PACKAGE_NAME="kernel" follows the old semantics --
>> > > build
>> > > in the old location and may be preferred provider -- while
>> > > recipes
>> > > using
>> > > all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and
>> > > don't
>> > > provide "virtual/kernel".
>> > >
>> > > Testing:
>> > >   1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
>> > >      linux-yocto-tiny_4.9.bb so that it may build alongside
>> > >      the main kernel.
>> > >   2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel
>> > > flavors.
>> > >   3. Verified image and modules IPKs exist for both:
>> > >      tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>> > >      tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-
>> > > tiny
>> > >   4. Verified linux-yocto is the "preferred provider", and was
>> > > built
>> > > in
>> > >      shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>> > >   5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
>> > >      core-image-base.bb to include both kernel flavors.
>> > >   6. `bitbake core-image-base` to build an image.
>> > >   7. Verified image contains two bzImage's under /boot/, with
>> > >      "yocto-standard" selected to boot via symlink.
>> > >
>> > > Discussion thread:
>> > > http://lists.openembedded.org/pipermail/openembedded-core/2015-De
>> > > cemb
>> > > er/thread.html#114122
>> > >
>> > > Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
>> > > Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
>> > > Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
>> > > Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
>> > > Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
>> > > Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
>> > > ---
>> > > [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR
>> > > to
>> > > the
>> > > "work" directory in alternate kernel builds, instead of "work-
>> > > shared",
>> > > so
>> > > that the two builds don't clobber each other.
>> > >
>> > > [PATCH v3] An updated version of this change rebased onto the
>> > > current
>> > > OE-core master. Changes:
>> > >   * Remove PREFERRED_PROVIDER check in linux-yocto.inc in
>> > > alternate
>> > >     kernel builds, since alternate kernels aren't the
>> > >     PREFERRED_PROVIDER for virtual/kernel by definition.
>> > >   * Remove "virtual/kernel" from PROVIDES in alternate kernel
>> > > builds.
>> > >
>> > > [PATCH v4] Another rebase onto master; no functional change.
>> > > Improved description and testing steps.
>> >
>> > So I finally had a chance to get back to this and test build with
>> > it, I
>> > saw the following WARNING, which lead to the ERROR:
>> >
>> > WARNING: Variable key FILES_${PN}-dev (${includedir}
>> > ${FILES_SOLIBSDEV}
>> > ${libdir}/*.la ${libdir}/*.o ${libdir}/pkgconfig
>> > ${datadir}/pkgconfig
>> > ${datadir}/aclocal ${base_libdir}/*.o ${libdir}/${BPN}/*.la
>> > ${base_libdir}/*.la) replaces original key FILES_linux-yocto-dev
>> > (/boot/System.map* /boot/Module.symvers* /boot/config*
>> > ${KERNEL_SRC_PATH}
>> > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build).
>> > ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
>> > do_package: QA Issue: linux-yocto: Files/directories were installed
>> > but
>> > not shipped in any package:
>> >    /boot/System.map-4.10.17-yocto-standard
>> >    /boot/Module.symvers-4.10.17-yocto-standard
>> >    /boot/config-4.10.17-yocto-standard
>> > Please set FILES such that these items are packaged. Alternatively
>> > if
>> > they are unneeded, avoid installing them or delete them within
>> > do_install.
>> > linux-yocto: 3 installed and not shipped files. [installed-vs-
>> > shipped]
>> > ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
>> > do_package: Fatal QA errors found, failing task.
>> > ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
>> > do_package: Function failed: do_package
>> >
>> > Something seems to be causing the FILES_linux-yocto-dev info to be
>> > overridden, I have not tracked down the culprit yet.
>> >
>>
>> `FILES_linux-yocto-dev` is set to the default value from OE's
>> bitbake.conf. `FILES_kernel-dev` on the other hand is set by
>> kernel.bbclass; when `KERNEL_PACKAGE_NAME` expands to `kernel`.
>>
>> I think the real issue here is that QA checks care about
>> `FILES_${PN}-dev` at all even though that particular package name
>> isn't
>> listed in `PACKAGES` variable. I.e. `FILES_${PN}-dev` should be
>> disregarded since the `linux-yocto` recipe doesn't create package
>> `${PN}-dev`.
>>
>> Thoughts?
>>
> It's hard to special case this. After you sent this, I realized what I
> did was set the KERNEL_PACKAGE_NAME to linux-yocto and because the
> KERNEL_PACKAGE_NAME matched the actual recipe name we got the strange
> ${PN} interaction, we might be able to add a test to flag that as an
> error or warning in the kernel.bbclass.
>
> I am also seeing an issue when I build a 4.9 kernel and then set-up a
> 4.10 kernel with the kernel-abiversion getting mis-matched from the
> depmodwrapper.  Have you tested with different versions?  I know it
> should work with a old kernel/userspace -> new kernel, but not from a
> new kernel/userspace -> old kernel.
>

I've also hit this issue.  Here's the error message if that's helpful at all:

WARNING: core-image-base-1.0-r0 do_rootfs: [log_check]
core-image-base: found 2 warning messages in the logfile:
[log_check] warning:
%post(tiny-linux-4.10.17-yocto-tiny-4.10.17+git0+e92bd55409_6648a34e00-r0.qemux86)
scriptlet failed, exit status 1
[log_check] Warn: update-alternatives: bzImage has multiple providers
with the same priority, please check
/home/tripzero/Projects/poky-contrib/build/tmp/wo
rk/qemux86-poky-linux/core-image-base/1.0-r0/rootfs/usr/lib/opkg/alternatives/bzImage
for details

ERROR: core-image-base-1.0-r0 do_rootfs: [log_check] core-image-base:
found 1 error message in the logfile:
[log_check] Error: Kernel version 4.10.17-yocto-tiny does not match
kernel-abiversion (4.10.17-yocto-standard)



> Sau!
>
>
>> >
>> > Sau!
>> >
>> > >
>> > > ---
>> > >   meta/classes/kernel-module-split.bbclass  |  9 ++--
>> > >   meta/classes/kernel.bbclass               | 85
>> > > ++++++++++++++++++---
>> > > ----------
>> > >   meta/conf/documentation.conf              |  1 +
>> > >   meta/recipes-kernel/linux/linux-dtb.inc   |  2 +-
>> > >   meta/recipes-kernel/linux/linux-yocto.inc |  2 +-
>> > >   5 files changed, 59 insertions(+), 40 deletions(-)
>> > >
>> > > diff --git a/meta/classes/kernel-module-split.bbclass
>> > > b/meta/classes/kernel-module-split.bbclass
>> > > index 1035525dac..9716c5937b 100644
>> > > --- a/meta/classes/kernel-module-split.bbclass
>> > > +++ b/meta/classes/kernel-module-split.bbclass
>> > > @@ -30,7 +30,7 @@ do_install_append() {
>> > >
>> > >   PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>> > >
>> > > -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
>> > > +KERNEL_MODULES_META_PACKAGE ?= "${KERNEL_PACKAGE_NAME}-modules"
>> > >
>> > >   KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>> > >   KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
>> > > @@ -129,16 +129,19 @@ python split_kernel_module_packages () {
>> > >              postfix = format.split('%s')[1]
>> > >              d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix,
>> > > ''))
>> > >
>> > > +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True)
>> > > +    kernel_version = d.getVar("KERNEL_VERSION", True)
>> > > +
>> > >       module_regex = '^(.*)\.k?o$'
>> > >
>> > >       module_pattern_prefix =
>> > > d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>> > >       module_pattern_suffix =
>> > > d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
>> > > -    module_pattern = module_pattern_prefix + 'kernel-module-%s'
>> > > +
>> > > module_pattern_suffix
>> > > +    module_pattern = module_pattern_prefix + kernel_package_name
>> > > +
>> > > '-module-%s' + module_pattern_suffix
>> > >
>> > >       postinst = d.getVar('pkg_postinst_modules')
>> > >       postrm = d.getVar('pkg_postrm_modules')
>> > >
>> > > -    modules = do_split_packages(d,
>> > > root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>> > > output_pattern=module_pattern, description='%s kernel module',
>> > > postinst=postinst, postrm=postrm, recursive=True,
>> > > hook=frob_metadata,
>> > > extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
>> > > +    modules = do_split_packages(d,
>> > > root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>> > > output_pattern=module_pattern, description='%s kernel module',
>> > > postinst=postinst, postrm=postrm, recursive=True,
>> > > hook=frob_metadata,
>> > > extra_depends='%s-%s' % (kernel_package_name, kernel_version))
>> > >       if modules:
>> > >           metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>> > >           d.appendVar('RDEPENDS_' + metapkg, ' '+'
>> > > '.join(modules))
>> > > diff --git a/meta/classes/kernel.bbclass
>> > > b/meta/classes/kernel.bbclass
>> > > index 7670c7107a..7fa4509961 100644
>> > > --- a/meta/classes/kernel.bbclass
>> > > +++ b/meta/classes/kernel.bbclass
>> > > @@ -1,6 +1,8 @@
>> > >   inherit linux-kernel-base kernel-module-split
>> > >
>> > > -PROVIDES += "virtual/kernel"
>> > > +KERNEL_PACKAGE_NAME ??= "kernel"
>> > > +
>> > > +PROVIDES += "${@ "virtual/kernel" if
>> > > (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
>> > >   DEPENDS += "virtual/${TARGET_PREFIX}binutils
>> > > virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
>> > >   PACKAGE_WRITE_DEPS += "depmodwrapper-cross virtual/update-
>> > > alternatives-native"
>> > >
>> > > @@ -33,10 +35,23 @@ KERNEL_VERSION_PKG_NAME[vardepvalue] =
>> > > "${LINUX_VERSION}"
>> > >
>> > >   python __anonymous () {
>> > >
>> > > +    # The default kernel recipe builds in a shared location
>> > > defined
>> > > by
>> > > +    # bitbake/distro confs: STAGING_KERNEL_DIR and
>> > > STAGING_KERNEL_BUILDDIR.
>> > > +    # Set these variables to directories under ${WORKDIR} in
>> > > alternate
>> > > +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel)
>> > > so
>> > > that they
>> > > +    # may build in parallel with the default kernel without
>> > > clobbering.
>> > > +    if d.getVar("KERNEL_PACKAGE_NAME", True) != "kernel":
>> > > +        workdir = d.getVar("WORKDIR", True)
>> > > +        sourceDir = os.path.join(workdir, 'kernel-source')
>> > > +        artifactsDir = os.path.join(workdir, 'kernel-build-
>> > > artifacts')
>> > > +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
>> > > +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
>> > > +
>> > >       # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
>> > > KERNEL_IMAGETYPES
>> > >       type = d.getVar('KERNEL_IMAGETYPE') or ""
>> > >       alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>> > >       types = d.getVar('KERNEL_IMAGETYPES') or ""
>> > > +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
>> > >       if type not in types.split():
>> > >           types = (type + ' ' + types).strip()
>> > >       if alttype not in types.split():
>> > > @@ -53,22 +68,22 @@ python __anonymous () {
>> > >           typelower = type.lower()
>> > >           imagedest = d.getVar('KERNEL_IMAGEDEST')
>> > >
>> > > -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' +
>> > > typelower)
>> > > +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname,
>> > > typelower))
>> > >
>> > > -        d.setVar('FILES_kernel-image-' + typelower, '/' +
>> > > imagedest
>> > > + '/' + type + '-${KERNEL_VERSION_NAME}')
>> > > +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' +
>> > > imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
>> > >
>> > > -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-
>> > > image-' +
>> > > typelower)
>> > > +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s'
>> > > %
>> > > (kname, typelower))
>> > >
>> > > -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-
>> > > ' +
>> > > typelower + '-${KERNEL_VERSION_PKG_NAME}')
>> > > +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-
>> > > image-
>> > > %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>> > >
>> > > -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
>> > > +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower),
>> > > '1')
>> > >
>> > >           priority = d.getVar('KERNEL_PRIORITY')
>> > >           postinst = '#!/bin/sh\n' + 'update-alternatives --
>> > > install /'
>> > > + imagedest + '/' + type + ' ' + type + ' ' + type + '-
>> > > ${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
>> > > -        d.setVar('pkg_postinst_kernel-image-' + typelower,
>> > > postinst)
>> > > +        d.setVar('pkg_postinst_' + kname + '-image-' +
>> > > typelower,
>> > > postinst)
>> > >
>> > >           postrm = '#!/bin/sh\n' + 'update-alternatives --remove'
>> > > + '
>> > > ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n'
>> > > -        d.setVar('pkg_postrm_kernel-image-' + typelower, postrm)
>> > > +        d.setVar('pkg_postrm_%s-image-%s' % (kname, typelower),
>> > > postrm)
>> > >
>> > >       image = d.getVar('INITRAMFS_IMAGE')
>> > >       if image:
>> > > @@ -126,9 +141,9 @@ base_do_unpack_append () {
>> > >
>> > >   inherit kernel-arch deploy
>> > >
>> > > -PACKAGES_DYNAMIC += "^kernel-module-.*"
>> > > -PACKAGES_DYNAMIC += "^kernel-image-.*"
>> > > -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
>> > > +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
>> > > +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
>> > > +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>> > >
>> > >   export OS = "${TARGET_OS}"
>> > >   export CROSS_COMPILE = "${TARGET_PREFIX}"
>> > > @@ -371,9 +386,9 @@ do_shared_workdir_setscene () {
>> > >
>> > >   emit_depmod_pkgdata() {
>> > >           # Stash data for depmod
>> > > - install -d ${PKGDESTWORK}/kernel-depmod/
>> > > - echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
>> > > depmod/kernel-abiversion
>> > > - cp ${B}/System.map ${PKGDESTWORK}/kernel-
>> > > depmod/System.map-
>> > > ${KERNEL_VERSION}
>> > > + install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
>> > > + echo "${KERNEL_VERSION}" >
>> > > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
>> > > depmod/${KERNEL_PACKAGE_NAME}-
>> > > abiversion
>> > > + cp ${B}/System.map
>> > > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
>> > > depmod/System.map-${KERNEL_VERSION}
>> > >   }
>> > >
>> > >   PACKAGEFUNCS += "emit_depmod_pkgdata"
>> > > @@ -388,7 +403,7 @@ do_shared_workdir () {
>> > >           # Store the kernel version in sysroots for module-
>> > > base.bbclass
>> > >           #
>> > >
>> > > - echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
>> > > + echo "${KERNEL_VERSION}" >
>> > > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>> > >
>> > >           # Copy files required for module builds
>> > >           cp System.map $kerneldir/System.map-${KERNEL_VERSION}
>> > > @@ -486,28 +501,28 @@ EXPORT_FUNCTIONS do_compile do_install
>> > > do_configure
>> > >
>> > >   # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base
>> > > ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
>> > > ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>> > >   FILES_${PN} = ""
>> > > -FILES_kernel-base =
>> > > "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>> > > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>> > > -FILES_kernel-image = ""
>> > > -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
>> > > /boot/config* ${KERNEL_SRC_PATH}
>> > > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>> > > -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
>> > > -FILES_kernel-modules = ""
>> > > -RDEPENDS_kernel = "kernel-base"
>> > > +FILES_${KERNEL_PACKAGE_NAME}-base =
>> > > "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>> > > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>> > > +FILES_${KERNEL_PACKAGE_NAME}-image = ""
>> > > +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
>> > > /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
>> > > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>> > > +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
>> > > ${KERNEL_VERSION_NAME}"
>> > > +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
>> > > +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
>> > >   # Allow machines to override this dependency if kernel image
>> > > files
>> > > are
>> > >   # not wanted in images as standard
>> > > -RDEPENDS_kernel-base ?= "kernel-image"
>> > > -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${K
>> > > ERNE
>> > > L_VERSION}')}"
>> > > -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE'
>> > > ,
>> > > 'vmlinux', 'kernel-vmlinux', '', d)}"
>> > > -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_V
>> > > ERSI
>> > > ON}')}"
>> > > -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"
>> > > -
>> > > -pkg_postinst_kernel-base () {
>> > > +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-
>> > > image"
>> > > +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-
>> > > image-${@
>> > > legitimize_package_name('${KERNEL_VERSION}')}"
>> > > +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('K
>> > > ERNE
>> > > L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '',
>> > > d)}"
>> > > +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@leg
>> > > itim
>> > > ize_package_name('${KERNEL_VERSION}')}"
>> > > +RPROVIDES_${KERNEL_PACKAGE_NAME}-base +=
>> > > "${KERNEL_PACKAGE_NAME}-
>> > > ${KERNEL_VERSION}"
>> > > +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
>> > > +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
>> > > +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
>> > > +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
>> > > +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules
>> > > meta
>> > > package"
>> > > +
>> > > +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>> > >           if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>> > >                   mkdir -p $D/lib/modules/${KERNEL_VERSION}
>> > >           fi
>> > > @@ -521,7 +536,7 @@ pkg_postinst_kernel-base () {
>> > >   PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>> > >
>> > >   python split_kernel_packages () {
>> > > -    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>> > > file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>> > > output_pattern='kernel-
>> > > firmware-%s', description='Firmware for %s', recursive=True,
>> > > extra_depends='')
>> > > +    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>> > > file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>> > > output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
>> > > description='Firmware for %s', recursive=True, extra_depends='')
>> > >   }
>> > >
>> > >   # Many scripts want to look in arch/$arch/boot for the bootable
>> > > diff --git a/meta/conf/documentation.conf
>> > > b/meta/conf/documentation.conf
>> > > index 35b9103b4a..e061b98de3 100644
>> > > --- a/meta/conf/documentation.conf
>> > > +++ b/meta/conf/documentation.conf
>> > > @@ -248,6 +248,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel
>> > > to
>> > > build for a device, usually set b
>> > >   KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build
>> > > for a
>> > > device, usually set by the machine configuration files and
>> > > defaults
>> > > to KERNEL_IMAGETYPE."
>> > >   KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need
>> > > to be
>> > > auto-loaded during boot"
>> > >   KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which
>> > > the
>> > > build system expects to find module_conf_* values that specify
>> > > configuration for each of the modules"
>> > > +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
>> > > Defaults to 'kernel'."
>> > >   KERNEL_PATH[doc] = "The location of the kernel sources. This
>> > > variable is set to the value of the STAGING_KERNEL_DIR within the
>> > > module class (module.bbclass)."
>> > >   KERNEL_SRC[doc] = "The location of the kernel sources. This
>> > > variable
>> > > is set to the value of the STAGING_KERNEL_DIR within the module
>> > > class
>> > > (module.bbclass)."
>> > >   KFEATURE_DESCRIPTION[doc] = "Provides a short description of a
>> > > configuration fragment. You use this variable in the .scc file
>> > > that
>> > > describes a configuration fragment file."
>> > > diff --git a/meta/recipes-kernel/linux/linux-dtb.inc
>> > > b/meta/recipes-
>> > > kernel/linux/linux-dtb.inc
>> > > index 0174c80d85..da6467bf9f 100644
>> > > --- a/meta/recipes-kernel/linux/linux-dtb.inc
>> > > +++ b/meta/recipes-kernel/linux/linux-dtb.inc
>> > > @@ -4,7 +4,7 @@ FILES_kernel-devicetree =
>> > > "/${KERNEL_IMAGEDEST}/devicetree*"
>> > >   PACKAGE_WRITE_DEPS += "virtual/update-alternatives-native"
>> > >
>> > >   python __anonymous () {
>> > > -    d.appendVar("PACKAGES", " kernel-devicetree")
>> > > +    d.appendVar("PACKAGES", " ${KERNEL_PACKAGE_NAME}-
>> > > devicetree")
>> > >   }
>> > >
>> > >   normalize_dtb () {
>> > > diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
>> > > b/meta/recipes-kernel/linux/linux-yocto.inc
>> > > index 637506a2a8..4e0ce029da 100644
>> > > --- a/meta/recipes-kernel/linux/linux-yocto.inc
>> > > +++ b/meta/recipes-kernel/linux/linux-yocto.inc
>> > > @@ -12,7 +12,7 @@ INC_PR = "r4"
>> > >   # PREFERRED_PROVIDER for virtual/kernel. This avoids network
>> > > access
>> > > required
>> > >   # by the use of AUTOREV SRCREVs, which are the default for this
>> > > recipe.
>> > >   python () {
>> > > -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
>> > > d.getVar("PN"):
>> > > +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>> > > d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) !=
>> > > d.getVar("PN",
>> > > True):
>> > >           d.delVar("BB_DONT_CACHE")
>> > >           raise bb.parse.SkipPackage("Set
>> > > PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
>> > > (d.getVar("PN")))
>> > >   }
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v4] kernel: Add support for multiple kernel packages
  2017-07-27 18:01       ` Rees, Kevron
@ 2017-08-03 16:18         ` Ovidiu-Adrian Vancea
  2017-08-08 15:27           ` Haris Okanovic
  2017-08-08 15:27         ` Haris Okanovic
  1 sibling, 1 reply; 31+ messages in thread
From: Ovidiu-Adrian Vancea @ 2017-08-03 16:18 UTC (permalink / raw)
  To: haris.okanovic; +Cc: josh.hernstrom, Wold, Saul, openembedded-core

On Thu, 2017-07-27 at 11:01 -0700, Rees, Kevron wrote:
> On Wed, Jul 19, 2017 at 8:56 AM, Wold, Saul <saul.wold@intel.com>
> wrote:
> > On Tue, 2017-07-18 at 08:34 -0500, Haris Okanovic wrote:
> > > 
> > > On 07/17/2017 03:31 PM, Wold, Saul wrote:
> > > > 
> > > > On Wed, 2017-07-05 at 12:33 -0500, Haris Okanovic wrote:
> > > > > 
> > > > > Some distros may want to provide alternate kernel "flavors"
> > > > > via
> > > > > feeds
> > > > > or
> > > > > within bootable images. For example, readily available builds
> > > > > which
> > > > > provide certain diagnostic features can enable developers and
> > > > > testers
> > > > > to
> > > > > more quickly resolve issues by avoiding lengthy kernel
> > > > > builds.
> > > > > 
> > > > > This change allows for building multiple flavors of the
> > > > > kernel
> > > > > and
> > > > > module packages by templatizing kernel package names via a
> > > > > new
> > > > > KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults
> > > > > to
> > > > > the
> > > > > old
> > > > > name of "kernel", but can be overridden by certain recipes
> > > > > providing
> > > > > alternate kernel flavors.
> > > > > 
> > > > > To maintain compatibility, recipes providing alternate kernel
> > > > > flavors
> > > > > cannot be the "preferred provider" for virtual/kernel. This
> > > > > is
> > > > > because
> > > > > OE puts the preferred provider's build and source at
> > > > > "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
> > > > > "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
> > > > > "tmp-glibc/work/*/$PN/" like other recipes. Therefore,
> > > > > recipes
> > > > > using
> > > > > the
> > > > > default KERNEL_PACKAGE_NAME="kernel" follows the old
> > > > > semantics --
> > > > > build
> > > > > in the old location and may be preferred provider -- while
> > > > > recipes
> > > > > using
> > > > > all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR
> > > > > and
> > > > > don't
> > > > > provide "virtual/kernel".
> > > > > 
> > > > > Testing:
> > > > >   1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
> > > > >      linux-yocto-tiny_4.9.bb so that it may build alongside
> > > > >      the main kernel.
> > > > >   2. `bitbake linux-yocto linux-yocto-tiny` to build both
> > > > > kernel
> > > > > flavors.
> > > > >   3. Verified image and modules IPKs exist for both:
> > > > >      tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
> > > > >      tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-
> > > > > yocto-
> > > > > tiny
> > > > >   4. Verified linux-yocto is the "preferred provider", and
> > > > > was
> > > > > built
> > > > > in
> > > > >      shared directory: tmp-glibc/work-shared/qemux86/kernel-*
> > > > >   5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
> > > > >      core-image-base.bb to include both kernel flavors.
> > > > >   6. `bitbake core-image-base` to build an image.
> > > > >   7. Verified image contains two bzImage's under /boot/, with
> > > > >      "yocto-standard" selected to boot via symlink.
> > > > > 
> > > > > Discussion thread:
> > > > > https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.ope
> > > > > nembedded.org_pipermail_openembedded-2Dcore_2015-
> > > > > 2DDe&d=DwICAg&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r
> > > > > =35FLeGKBmrBGMHAhCV37-B4ddgcjLZXUChuxj5DD6Sk&m=-J-
> > > > > ERX3BXdjXgeeIE_ZNE7GozSVtUpP3Wt6FV_jtLtM&s=z_ITagkjX7-
> > > > > q9KHaytBdqTZeJYksmYYjciSiELDYIGE&e= 
> > > > > cemb
> > > > > er/thread.html#114122
> > > > > 
> > > > > Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
> > > > > Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
> > > > > Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
> > > > > Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
> > > > > Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
> > > > > Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
> > > > > ---
> > > > > [PATCH v2] Change STAGING_KERNEL_DIR and
> > > > > STAGING_KERNEL_BUILDDIR
> > > > > to
> > > > > the
> > > > > "work" directory in alternate kernel builds, instead of
> > > > > "work-
> > > > > shared",
> > > > > so
> > > > > that the two builds don't clobber each other.
> > > > > 
> > > > > [PATCH v3] An updated version of this change rebased onto the
> > > > > current
> > > > > OE-core master. Changes:
> > > > >   * Remove PREFERRED_PROVIDER check in linux-yocto.inc in
> > > > > alternate
> > > > >     kernel builds, since alternate kernels aren't the
> > > > >     PREFERRED_PROVIDER for virtual/kernel by definition.
> > > > >   * Remove "virtual/kernel" from PROVIDES in alternate kernel
> > > > > builds.
> > > > > 
> > > > > [PATCH v4] Another rebase onto master; no functional change.
> > > > > Improved description and testing steps.
> > > > 
> > > > So I finally had a chance to get back to this and test build
> > > > with
> > > > it, I
> > > > saw the following WARNING, which lead to the ERROR:
> > > > 
> > > > WARNING: Variable key FILES_${PN}-dev (${includedir}
> > > > ${FILES_SOLIBSDEV}
> > > > ${libdir}/*.la ${libdir}/*.o ${libdir}/pkgconfig
> > > > ${datadir}/pkgconfig
> > > > ${datadir}/aclocal ${base_libdir}/*.o ${libdir}/${BPN}/*.la
> > > > ${base_libdir}/*.la) replaces original key FILES_linux-yocto-
> > > > dev
> > > > (/boot/System.map* /boot/Module.symvers* /boot/config*
> > > > ${KERNEL_SRC_PATH}
> > > > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build).
> > > > ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
> > > > do_package: QA Issue: linux-yocto: Files/directories were
> > > > installed
> > > > but
> > > > not shipped in any package:
> > > >    /boot/System.map-4.10.17-yocto-standard
> > > >    /boot/Module.symvers-4.10.17-yocto-standard
> > > >    /boot/config-4.10.17-yocto-standard
> > > > Please set FILES such that these items are packaged.
> > > > Alternatively
> > > > if
> > > > they are unneeded, avoid installing them or delete them within
> > > > do_install.
> > > > linux-yocto: 3 installed and not shipped files. [installed-vs-
> > > > shipped]
> > > > ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
> > > > do_package: Fatal QA errors found, failing task.
> > > > ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
> > > > do_package: Function failed: do_package
> > > > 
> > > > Something seems to be causing the FILES_linux-yocto-dev info to
> > > > be
> > > > overridden, I have not tracked down the culprit yet.
> > > > 
> > > 
> > > `FILES_linux-yocto-dev` is set to the default value from OE's
> > > bitbake.conf. `FILES_kernel-dev` on the other hand is set by
> > > kernel.bbclass; when `KERNEL_PACKAGE_NAME` expands to `kernel`.
> > > 
> > > I think the real issue here is that QA checks care about
> > > `FILES_${PN}-dev` at all even though that particular package name
> > > isn't
> > > listed in `PACKAGES` variable. I.e. `FILES_${PN}-dev` should be
> > > disregarded since the `linux-yocto` recipe doesn't create package
> > > `${PN}-dev`.
> > > 
> > > Thoughts?
> > > 
> > 
> > It's hard to special case this. After you sent this, I realized
> > what I
> > did was set the KERNEL_PACKAGE_NAME to linux-yocto and because the
> > KERNEL_PACKAGE_NAME matched the actual recipe name we got the
> > strange
> > ${PN} interaction, we might be able to add a test to flag that as
> > an
> > error or warning in the kernel.bbclass.
> > 
> > I am also seeing an issue when I build a 4.9 kernel and then set-up 
> > a
> > 4.10 kernel with the kernel-abiversion getting mis-matched from the
> > depmodwrapper.  Have you tested with different versions?  I know it
> > should work with a old kernel/userspace -> new kernel, but not from
> > a
> > new kernel/userspace -> old kernel.
> > 
> 
> I've also hit this issue.  Here's the error message if that's helpful
> at all:
> 
> WARNING: core-image-base-1.0-r0 do_rootfs: [log_check]
> core-image-base: found 2 warning messages in the logfile:
> [log_check] warning:
> %post(tiny-linux-4.10.17-yocto-tiny-
> 4.10.17+git0+e92bd55409_6648a34e00-r0.qemux86)
> scriptlet failed, exit status 1
> [log_check] Warn: update-alternatives: bzImage has multiple providers
> with the same priority, please check
> /home/tripzero/Projects/poky-contrib/build/tmp/wo
> rk/qemux86-poky-linux/core-image-base/1.0-
> r0/rootfs/usr/lib/opkg/alternatives/bzImage
> for details
> 
> ERROR: core-image-base-1.0-r0 do_rootfs: [log_check] core-image-base:
> found 1 error message in the logfile:
> [log_check] Error: Kernel version 4.10.17-yocto-tiny does not match
> kernel-abiversion (4.10.17-yocto-standard)
> 
> 

When building multiple kernels (multiple recipes), because all inherit
kernel.bbclass, all of them end up in a crowded build/tmp-
glibc/deploy/images/<arch>/.
More problematic is that the symbolic links for the kernel images would
be overridden with the last run kernel build (only if they have the
same KERNEL_IMAGETYPE).
So if linux-yocto-tiny was built last, the kernel image symbolic link
would point to linux-yocto-tiny's kernel instead of the default one.
I suggest we only keep the default kernel's components in build/tmp-
glibc/deploy/images/<arch>/.

Any thoughts?

> 
> > Sau!
> > 
> > 
> > > > 
> > > > Sau!
> > > > 
> > > > > 
> > > > > ---
> > > > >   meta/classes/kernel-module-split.bbclass  |  9 ++--
> > > > >   meta/classes/kernel.bbclass               | 85
> > > > > ++++++++++++++++++---
> > > > > ----------
> > > > >   meta/conf/documentation.conf              |  1 +
> > > > >   meta/recipes-kernel/linux/linux-dtb.inc   |  2 +-
> > > > >   meta/recipes-kernel/linux/linux-yocto.inc |  2 +-
> > > > >   5 files changed, 59 insertions(+), 40 deletions(-)
> > > > > 
> > > > > diff --git a/meta/classes/kernel-module-split.bbclass
> > > > > b/meta/classes/kernel-module-split.bbclass
> > > > > index 1035525dac..9716c5937b 100644
> > > > > --- a/meta/classes/kernel-module-split.bbclass
> > > > > +++ b/meta/classes/kernel-module-split.bbclass
> > > > > @@ -30,7 +30,7 @@ do_install_append() {
> > > > > 
> > > > >   PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
> > > > > 
> > > > > -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
> > > > > +KERNEL_MODULES_META_PACKAGE ?= "${KERNEL_PACKAGE_NAME}-
> > > > > modules"
> > > > > 
> > > > >   KERNEL_MODULE_PACKAGE_PREFIX ?= ""
> > > > >   KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
> > > > > @@ -129,16 +129,19 @@ python split_kernel_module_packages ()
> > > > > {
> > > > >              postfix = format.split('%s')[1]
> > > > >              d.setVar('RPROVIDES_' + pkg,
> > > > > pkg.replace(postfix,
> > > > > ''))
> > > > > 
> > > > > +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME",
> > > > > True)
> > > > > +    kernel_version = d.getVar("KERNEL_VERSION", True)
> > > > > +
> > > > >       module_regex = '^(.*)\.k?o$'
> > > > > 
> > > > >       module_pattern_prefix =
> > > > > d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
> > > > >       module_pattern_suffix =
> > > > > d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
> > > > > -    module_pattern = module_pattern_prefix + 'kernel-module-
> > > > > %s'
> > > > > +
> > > > > module_pattern_suffix
> > > > > +    module_pattern = module_pattern_prefix +
> > > > > kernel_package_name
> > > > > +
> > > > > '-module-%s' + module_pattern_suffix
> > > > > 
> > > > >       postinst = d.getVar('pkg_postinst_modules')
> > > > >       postrm = d.getVar('pkg_postrm_modules')
> > > > > 
> > > > > -    modules = do_split_packages(d,
> > > > > root='${nonarch_base_libdir}/modules',
> > > > > file_regex=module_regex,
> > > > > output_pattern=module_pattern, description='%s kernel
> > > > > module',
> > > > > postinst=postinst, postrm=postrm, recursive=True,
> > > > > hook=frob_metadata,
> > > > > extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
> > > > > +    modules = do_split_packages(d,
> > > > > root='${nonarch_base_libdir}/modules',
> > > > > file_regex=module_regex,
> > > > > output_pattern=module_pattern, description='%s kernel
> > > > > module',
> > > > > postinst=postinst, postrm=postrm, recursive=True,
> > > > > hook=frob_metadata,
> > > > > extra_depends='%s-%s' % (kernel_package_name,
> > > > > kernel_version))
> > > > >       if modules:
> > > > >           metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
> > > > >           d.appendVar('RDEPENDS_' + metapkg, ' '+'
> > > > > '.join(modules))
> > > > > diff --git a/meta/classes/kernel.bbclass
> > > > > b/meta/classes/kernel.bbclass
> > > > > index 7670c7107a..7fa4509961 100644
> > > > > --- a/meta/classes/kernel.bbclass
> > > > > +++ b/meta/classes/kernel.bbclass
> > > > > @@ -1,6 +1,8 @@
> > > > >   inherit linux-kernel-base kernel-module-split
> > > > > 
> > > > > -PROVIDES += "virtual/kernel"
> > > > > +KERNEL_PACKAGE_NAME ??= "kernel"
> > > > > +
> > > > > +PROVIDES += "${@ "virtual/kernel" if
> > > > > (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else ""
> > > > > }"
> > > > >   DEPENDS += "virtual/${TARGET_PREFIX}binutils
> > > > > virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-
> > > > > native"
> > > > >   PACKAGE_WRITE_DEPS += "depmodwrapper-cross virtual/update-
> > > > > alternatives-native"
> > > > > 
> > > > > @@ -33,10 +35,23 @@ KERNEL_VERSION_PKG_NAME[vardepvalue] =
> > > > > "${LINUX_VERSION}"
> > > > > 
> > > > >   python __anonymous () {
> > > > > 
> > > > > +    # The default kernel recipe builds in a shared location
> > > > > defined
> > > > > by
> > > > > +    # bitbake/distro confs: STAGING_KERNEL_DIR and
> > > > > STAGING_KERNEL_BUILDDIR.
> > > > > +    # Set these variables to directories under ${WORKDIR} in
> > > > > alternate
> > > > > +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME !=
> > > > > kernel)
> > > > > so
> > > > > that they
> > > > > +    # may build in parallel with the default kernel without
> > > > > clobbering.
> > > > > +    if d.getVar("KERNEL_PACKAGE_NAME", True) != "kernel":
> > > > > +        workdir = d.getVar("WORKDIR", True)
> > > > > +        sourceDir = os.path.join(workdir, 'kernel-source')
> > > > > +        artifactsDir = os.path.join(workdir, 'kernel-build-
> > > > > artifacts')
> > > > > +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
> > > > > +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
> > > > > +
> > > > >       # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
> > > > > KERNEL_IMAGETYPES
> > > > >       type = d.getVar('KERNEL_IMAGETYPE') or ""
> > > > >       alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
> > > > >       types = d.getVar('KERNEL_IMAGETYPES') or ""
> > > > > +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or
> > > > > "kernel"
> > > > >       if type not in types.split():
> > > > >           types = (type + ' ' + types).strip()
> > > > >       if alttype not in types.split():
> > > > > @@ -53,22 +68,22 @@ python __anonymous () {
> > > > >           typelower = type.lower()
> > > > >           imagedest = d.getVar('KERNEL_IMAGEDEST')
> > > > > 
> > > > > -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' +
> > > > > typelower)
> > > > > +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname,
> > > > > typelower))
> > > > > 
> > > > > -        d.setVar('FILES_kernel-image-' + typelower, '/' +
> > > > > imagedest
> > > > > + '/' + type + '-${KERNEL_VERSION_NAME}')
> > > > > +        d.setVar('FILES_' + kname + '-image-' + typelower,
> > > > > '/' +
> > > > > imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
> > > > > 
> > > > > -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-
> > > > > image-' +
> > > > > typelower)
> > > > > +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-
> > > > > %s'
> > > > > %
> > > > > (kname, typelower))
> > > > > 
> > > > > -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-
> > > > > image-
> > > > > ' +
> > > > > typelower + '-${KERNEL_VERSION_PKG_NAME}')
> > > > > +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-
> > > > > image-
> > > > > %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
> > > > > 
> > > > > -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower,
> > > > > '1')
> > > > > +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname,
> > > > > typelower),
> > > > > '1')
> > > > > 
> > > > >           priority = d.getVar('KERNEL_PRIORITY')
> > > > >           postinst = '#!/bin/sh\n' + 'update-alternatives --
> > > > > install /'
> > > > > + imagedest + '/' + type + ' ' + type + ' ' + type + '-
> > > > > ${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
> > > > > -        d.setVar('pkg_postinst_kernel-image-' + typelower,
> > > > > postinst)
> > > > > +        d.setVar('pkg_postinst_' + kname + '-image-' +
> > > > > typelower,
> > > > > postinst)
> > > > > 
> > > > >           postrm = '#!/bin/sh\n' + 'update-alternatives --
> > > > > remove'
> > > > > + '
> > > > > ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' +
> > > > > '\n'
> > > > > -        d.setVar('pkg_postrm_kernel-image-' + typelower,
> > > > > postrm)
> > > > > +        d.setVar('pkg_postrm_%s-image-%s' % (kname,
> > > > > typelower),
> > > > > postrm)
> > > > > 
> > > > >       image = d.getVar('INITRAMFS_IMAGE')
> > > > >       if image:
> > > > > @@ -126,9 +141,9 @@ base_do_unpack_append () {
> > > > > 
> > > > >   inherit kernel-arch deploy
> > > > > 
> > > > > -PACKAGES_DYNAMIC += "^kernel-module-.*"
> > > > > -PACKAGES_DYNAMIC += "^kernel-image-.*"
> > > > > -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
> > > > > +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
> > > > > +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
> > > > > +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
> > > > > 
> > > > >   export OS = "${TARGET_OS}"
> > > > >   export CROSS_COMPILE = "${TARGET_PREFIX}"
> > > > > @@ -371,9 +386,9 @@ do_shared_workdir_setscene () {
> > > > > 
> > > > >   emit_depmod_pkgdata() {
> > > > >           # Stash data for depmod
> > > > > - install -d ${PKGDESTWORK}/kernel-depmod/
> > > > > - echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
> > > > > depmod/kernel-abiversion
> > > > > - cp ${B}/System.map ${PKGDESTWORK}/kernel-
> > > > > depmod/System.map-
> > > > > ${KERNEL_VERSION}
> > > > > + install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
> > > > > + echo "${KERNEL_VERSION}" >
> > > > > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
> > > > > depmod/${KERNEL_PACKAGE_NAME}-
> > > > > abiversion
> > > > > + cp ${B}/System.map
> > > > > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
> > > > > depmod/System.map-${KERNEL_VERSION}
> > > > >   }
> > > > > 
> > > > >   PACKAGEFUNCS += "emit_depmod_pkgdata"
> > > > > @@ -388,7 +403,7 @@ do_shared_workdir () {
> > > > >           # Store the kernel version in sysroots for module-
> > > > > base.bbclass
> > > > >           #
> > > > > 
> > > > > - echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
> > > > > + echo "${KERNEL_VERSION}" >
> > > > > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
> > > > > 
> > > > >           # Copy files required for module builds
> > > > >           cp System.map $kerneldir/System.map-
> > > > > ${KERNEL_VERSION}
> > > > > @@ -486,28 +501,28 @@ EXPORT_FUNCTIONS do_compile do_install
> > > > > do_configure
> > > > > 
> > > > >   # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-
> > > > > base
> > > > > ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
> > > > > ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
> > > > >   FILES_${PN} = ""
> > > > > -FILES_kernel-base =
> > > > > "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.ord
> > > > > er
> > > > > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.buil
> > > > > tin"
> > > > > -FILES_kernel-image = ""
> > > > > -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
> > > > > /boot/config* ${KERNEL_SRC_PATH}
> > > > > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
> > > > > -FILES_kernel-vmlinux = "/boot/vmlinux-
> > > > > ${KERNEL_VERSION_NAME}"
> > > > > -FILES_kernel-modules = ""
> > > > > -RDEPENDS_kernel = "kernel-base"
> > > > > +FILES_${KERNEL_PACKAGE_NAME}-base =
> > > > > "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.ord
> > > > > er
> > > > > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.buil
> > > > > tin"
> > > > > +FILES_${KERNEL_PACKAGE_NAME}-image = ""
> > > > > +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
> > > > > /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
> > > > > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
> > > > > +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
> > > > > ${KERNEL_VERSION_NAME}"
> > > > > +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
> > > > > +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-
> > > > > base"
> > > > >   # Allow machines to override this dependency if kernel
> > > > > image
> > > > > files
> > > > > are
> > > > >   # not wanted in images as standard
> > > > > -RDEPENDS_kernel-base ?= "kernel-image"
> > > > > -PKG_kernel-image = "kernel-image-${@legitimize_package_name(
> > > > > '${K
> > > > > ERNE
> > > > > L_VERSION}')}"
> > > > > -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGET
> > > > > YPE'
> > > > > ,
> > > > > 'vmlinux', 'kernel-vmlinux', '', d)}"
> > > > > -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERN
> > > > > EL_V
> > > > > ERSI
> > > > > ON}')}"
> > > > > -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"
> > > > > -
> > > > > -pkg_postinst_kernel-base () {
> > > > > +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?=
> > > > > "${KERNEL_PACKAGE_NAME}-
> > > > > image"
> > > > > +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-
> > > > > image-${@
> > > > > legitimize_package_name('${KERNEL_VERSION}')}"
> > > > > +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditiona
> > > > > l('K
> > > > > ERNE
> > > > > L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux',
> > > > > '',
> > > > > d)}"
> > > > > +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${
> > > > > @leg
> > > > > itim
> > > > > ize_package_name('${KERNEL_VERSION}')}"
> > > > > +RPROVIDES_${KERNEL_PACKAGE_NAME}-base +=
> > > > > "${KERNEL_PACKAGE_NAME}-
> > > > > ${KERNEL_VERSION}"
> > > > > +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
> > > > > +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
> > > > > +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
> > > > > +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
> > > > > +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules
> > > > > meta
> > > > > package"
> > > > > +
> > > > > +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
> > > > >           if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ];
> > > > > then
> > > > >                   mkdir -p $D/lib/modules/${KERNEL_VERSION}
> > > > >           fi
> > > > > @@ -521,7 +536,7 @@ pkg_postinst_kernel-base () {
> > > > >   PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
> > > > > 
> > > > >   python split_kernel_packages () {
> > > > > -    do_split_packages(d,
> > > > > root='${nonarch_base_libdir}/firmware',
> > > > > file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
> > > > > output_pattern='kernel-
> > > > > firmware-%s', description='Firmware for %s', recursive=True,
> > > > > extra_depends='')
> > > > > +    do_split_packages(d,
> > > > > root='${nonarch_base_libdir}/firmware',
> > > > > file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
> > > > > output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
> > > > > description='Firmware for %s', recursive=True,
> > > > > extra_depends='')
> > > > >   }
> > > > > 
> > > > >   # Many scripts want to look in arch/$arch/boot for the
> > > > > bootable
> > > > > diff --git a/meta/conf/documentation.conf
> > > > > b/meta/conf/documentation.conf
> > > > > index 35b9103b4a..e061b98de3 100644
> > > > > --- a/meta/conf/documentation.conf
> > > > > +++ b/meta/conf/documentation.conf
> > > > > @@ -248,6 +248,7 @@ KERNEL_IMAGETYPE[doc] = "The type of
> > > > > kernel
> > > > > to
> > > > > build for a device, usually set b
> > > > >   KERNEL_IMAGETYPES[doc] = "The list of types of kernel to
> > > > > build
> > > > > for a
> > > > > device, usually set by the machine configuration files and
> > > > > defaults
> > > > > to KERNEL_IMAGETYPE."
> > > > >   KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that
> > > > > need
> > > > > to be
> > > > > auto-loaded during boot"
> > > > >   KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for
> > > > > which
> > > > > the
> > > > > build system expects to find module_conf_* values that
> > > > > specify
> > > > > configuration for each of the modules"
> > > > > +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
> > > > > Defaults to 'kernel'."
> > > > >   KERNEL_PATH[doc] = "The location of the kernel sources.
> > > > > This
> > > > > variable is set to the value of the STAGING_KERNEL_DIR within
> > > > > the
> > > > > module class (module.bbclass)."
> > > > >   KERNEL_SRC[doc] = "The location of the kernel sources. This
> > > > > variable
> > > > > is set to the value of the STAGING_KERNEL_DIR within the
> > > > > module
> > > > > class
> > > > > (module.bbclass)."
> > > > >   KFEATURE_DESCRIPTION[doc] = "Provides a short description
> > > > > of a
> > > > > configuration fragment. You use this variable in the .scc
> > > > > file
> > > > > that
> > > > > describes a configuration fragment file."
> > > > > diff --git a/meta/recipes-kernel/linux/linux-dtb.inc
> > > > > b/meta/recipes-
> > > > > kernel/linux/linux-dtb.inc
> > > > > index 0174c80d85..da6467bf9f 100644
> > > > > --- a/meta/recipes-kernel/linux/linux-dtb.inc
> > > > > +++ b/meta/recipes-kernel/linux/linux-dtb.inc
> > > > > @@ -4,7 +4,7 @@ FILES_kernel-devicetree =
> > > > > "/${KERNEL_IMAGEDEST}/devicetree*"
> > > > >   PACKAGE_WRITE_DEPS += "virtual/update-alternatives-native"
> > > > > 
> > > > >   python __anonymous () {
> > > > > -    d.appendVar("PACKAGES", " kernel-devicetree")
> > > > > +    d.appendVar("PACKAGES", " ${KERNEL_PACKAGE_NAME}-
> > > > > devicetree")
> > > > >   }
> > > > > 
> > > > >   normalize_dtb () {
> > > > > diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
> > > > > b/meta/recipes-kernel/linux/linux-yocto.inc
> > > > > index 637506a2a8..4e0ce029da 100644
> > > > > --- a/meta/recipes-kernel/linux/linux-yocto.inc
> > > > > +++ b/meta/recipes-kernel/linux/linux-yocto.inc
> > > > > @@ -12,7 +12,7 @@ INC_PR = "r4"
> > > > >   # PREFERRED_PROVIDER for virtual/kernel. This avoids
> > > > > network
> > > > > access
> > > > > required
> > > > >   # by the use of AUTOREV SRCREVs, which are the default for
> > > > > this
> > > > > recipe.
> > > > >   python () {
> > > > > -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
> > > > > d.getVar("PN"):
> > > > > +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
> > > > > d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) !=
> > > > > d.getVar("PN",
> > > > > True):
> > > > >           d.delVar("BB_DONT_CACHE")
> > > > >           raise bb.parse.SkipPackage("Set
> > > > > PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
> > > > > (d.getVar("PN")))
> > > > >   }
> > 
> > --
> > _______________________________________________
> > Openembedded-core mailing list
> > Openembedded-core@lists.openembedded.org
> > https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembed
> > ded.org_mailman_listinfo_openembedded-
> > 2Dcore&d=DwICAg&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=35F
> > LeGKBmrBGMHAhCV37-B4ddgcjLZXUChuxj5DD6Sk&m=-J-
> > ERX3BXdjXgeeIE_ZNE7GozSVtUpP3Wt6FV_jtLtM&s=GFRD2nih1U_Vspzl1T_lId_e
> > dVf6o45jiD4I-J1ptR4&e= 


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v4] kernel: Add support for multiple kernel packages
  2017-07-19 15:56     ` Wold, Saul
  2017-07-27 18:01       ` Rees, Kevron
@ 2017-08-08 15:26       ` Haris Okanovic
  2017-08-08 15:34       ` [PATCH v5] " Haris Okanovic
                         ` (4 subsequent siblings)
  6 siblings, 0 replies; 31+ messages in thread
From: Haris Okanovic @ 2017-08-08 15:26 UTC (permalink / raw)
  To: Wold, Saul, openembedded-core; +Cc: josh.hernstrom



On 07/19/2017 10:56 AM, Wold, Saul wrote:
> On Tue, 2017-07-18 at 08:34 -0500, Haris Okanovic wrote:
>>
>> On 07/17/2017 03:31 PM, Wold, Saul wrote:
>>>
>>> On Wed, 2017-07-05 at 12:33 -0500, Haris Okanovic wrote:
>>>>
>>>> Some distros may want to provide alternate kernel "flavors" via
>>>> feeds
>>>> or
>>>> within bootable images. For example, readily available builds
>>>> which
>>>> provide certain diagnostic features can enable developers and
>>>> testers
>>>> to
>>>> more quickly resolve issues by avoiding lengthy kernel builds.
>>>>
>>>> This change allows for building multiple flavors of the kernel
>>>> and
>>>> module packages by templatizing kernel package names via a new
>>>> KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to
>>>> the
>>>> old
>>>> name of "kernel", but can be overridden by certain recipes
>>>> providing
>>>> alternate kernel flavors.
>>>>
>>>> To maintain compatibility, recipes providing alternate kernel
>>>> flavors
>>>> cannot be the "preferred provider" for virtual/kernel. This is
>>>> because
>>>> OE puts the preferred provider's build and source at
>>>> "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
>>>> "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
>>>> "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes
>>>> using
>>>> the
>>>> default KERNEL_PACKAGE_NAME="kernel" follows the old semantics --
>>>> build
>>>> in the old location and may be preferred provider -- while
>>>> recipes
>>>> using
>>>> all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and
>>>> don't
>>>> provide "virtual/kernel".
>>>>
>>>> Testing:
>>>>    1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
>>>>       linux-yocto-tiny_4.9.bb so that it may build alongside
>>>>       the main kernel.
>>>>    2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel
>>>> flavors.
>>>>    3. Verified image and modules IPKs exist for both:
>>>>       tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>>>>       tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-
>>>> tiny
>>>>    4. Verified linux-yocto is the "preferred provider", and was
>>>> built
>>>> in
>>>>       shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>>>>    5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
>>>>       core-image-base.bb to include both kernel flavors.
>>>>    6. `bitbake core-image-base` to build an image.
>>>>    7. Verified image contains two bzImage's under /boot/, with
>>>>       "yocto-standard" selected to boot via symlink.
>>>>
>>>> Discussion thread:
>>>> http://lists.openembedded.org/pipermail/openembedded-core/2015-De
>>>> cemb
>>>> er/thread.html#114122
>>>>
>>>> Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
>>>> Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
>>>> Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
>>>> Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
>>>> Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
>>>> Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
>>>> ---
>>>> [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR
>>>> to
>>>> the
>>>> "work" directory in alternate kernel builds, instead of "work-
>>>> shared",
>>>> so
>>>> that the two builds don't clobber each other.
>>>>
>>>> [PATCH v3] An updated version of this change rebased onto the
>>>> current
>>>> OE-core master. Changes:
>>>>    * Remove PREFERRED_PROVIDER check in linux-yocto.inc in
>>>> alternate
>>>>      kernel builds, since alternate kernels aren't the
>>>>      PREFERRED_PROVIDER for virtual/kernel by definition.
>>>>    * Remove "virtual/kernel" from PROVIDES in alternate kernel
>>>> builds.
>>>>
>>>> [PATCH v4] Another rebase onto master; no functional change.
>>>> Improved description and testing steps.
>>>
>>> So I finally had a chance to get back to this and test build with
>>> it, I
>>> saw the following WARNING, which lead to the ERROR:
>>>
>>> WARNING: Variable key FILES_${PN}-dev (${includedir}
>>> ${FILES_SOLIBSDEV}
>>> ${libdir}/*.la ${libdir}/*.o ${libdir}/pkgconfig
>>> ${datadir}/pkgconfig
>>> ${datadir}/aclocal ${base_libdir}/*.o ${libdir}/${BPN}/*.la
>>> ${base_libdir}/*.la) replaces original key FILES_linux-yocto-dev
>>> (/boot/System.map* /boot/Module.symvers* /boot/config*
>>> ${KERNEL_SRC_PATH}
>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build).
>>> ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
>>> do_package: QA Issue: linux-yocto: Files/directories were installed
>>> but
>>> not shipped in any package:
>>>     /boot/System.map-4.10.17-yocto-standard
>>>     /boot/Module.symvers-4.10.17-yocto-standard
>>>     /boot/config-4.10.17-yocto-standard
>>> Please set FILES such that these items are packaged. Alternatively
>>> if
>>> they are unneeded, avoid installing them or delete them within
>>> do_install.
>>> linux-yocto: 3 installed and not shipped files. [installed-vs-
>>> shipped]
>>> ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
>>> do_package: Fatal QA errors found, failing task.
>>> ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
>>> do_package: Function failed: do_package
>>>
>>> Something seems to be causing the FILES_linux-yocto-dev info to be
>>> overridden, I have not tracked down the culprit yet.
>>>
>>
>> `FILES_linux-yocto-dev` is set to the default value from OE's
>> bitbake.conf. `FILES_kernel-dev` on the other hand is set by
>> kernel.bbclass; when `KERNEL_PACKAGE_NAME` expands to `kernel`.
>>
>> I think the real issue here is that QA checks care about
>> `FILES_${PN}-dev` at all even though that particular package name
>> isn't
>> listed in `PACKAGES` variable. I.e. `FILES_${PN}-dev` should be
>> disregarded since the `linux-yocto` recipe doesn't create package
>> `${PN}-dev`.
>>
>> Thoughts?
>>
> It's hard to special case this. After you sent this, I realized what I
> did was set the KERNEL_PACKAGE_NAME to linux-yocto and because the
> KERNEL_PACKAGE_NAME matched the actual recipe name we got the strange
> ${PN} interaction, we might be able to add a test to flag that as an
> error or warning in the kernel.bbclass.
> 

Ah, I see what you mean now. There appears to be a bug in 
lib.bb.data.expandKeys(), where variables name are expanded 
alphabetically instead of definition order. Filed bug 
https://bugzilla.yoctoproject.org/show_bug.cgi?id=11905 for the issue; 
see example.

Unfortunately, I've not been able to workaround it yet. Adding a warning 
when `KERNEL_PACKAGE_NAME == PN` until bug # 11905 is resolved.

Posting a PATCH v5 shortly.

> I am also seeing an issue when I build a 4.9 kernel and then set-up a
> 4.10 kernel with the kernel-abiversion getting mis-matched from the
> depmodwrapper.  Have you tested with different versions?  I know it
> should work with a old kernel/userspace -> new kernel, but not from a
> new kernel/userspace -> old kernel.
>
I built linux-yocto-tiny version 4.9 and linux-yocto version 4.10 in 
parallel in the aforementioned test procedure. I'm not sure what you 
mean by "old kernel/userspace -> new kernel, but not from a
 > new kernel/userspace -> old kernel". Can you send me your build 
procedure -- I.e. sequence of bitbake commands?

> Sau!
> 
> 
>>>
>>> Sau!
>>>
>>>>
>>>> ---
>>>>    meta/classes/kernel-module-split.bbclass  |  9 ++--
>>>>    meta/classes/kernel.bbclass               | 85
>>>> ++++++++++++++++++---
>>>> ----------
>>>>    meta/conf/documentation.conf              |  1 +
>>>>    meta/recipes-kernel/linux/linux-dtb.inc   |  2 +-
>>>>    meta/recipes-kernel/linux/linux-yocto.inc |  2 +-
>>>>    5 files changed, 59 insertions(+), 40 deletions(-)
>>>>
>>>> diff --git a/meta/classes/kernel-module-split.bbclass
>>>> b/meta/classes/kernel-module-split.bbclass
>>>> index 1035525dac..9716c5937b 100644
>>>> --- a/meta/classes/kernel-module-split.bbclass
>>>> +++ b/meta/classes/kernel-module-split.bbclass
>>>> @@ -30,7 +30,7 @@ do_install_append() {
>>>>    
>>>>    PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>>>>    
>>>> -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
>>>> +KERNEL_MODULES_META_PACKAGE ?= "${KERNEL_PACKAGE_NAME}-modules"
>>>>    
>>>>    KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>>>>    KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
>>>> @@ -129,16 +129,19 @@ python split_kernel_module_packages () {
>>>>               postfix = format.split('%s')[1]
>>>>               d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix,
>>>> ''))
>>>>    
>>>> +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True)
>>>> +    kernel_version = d.getVar("KERNEL_VERSION", True)
>>>> +
>>>>        module_regex = '^(.*)\.k?o$'
>>>>    
>>>>        module_pattern_prefix =
>>>> d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>>>>        module_pattern_suffix =
>>>> d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
>>>> -    module_pattern = module_pattern_prefix + 'kernel-module-%s'
>>>> +
>>>> module_pattern_suffix
>>>> +    module_pattern = module_pattern_prefix + kernel_package_name
>>>> +
>>>> '-module-%s' + module_pattern_suffix
>>>>    
>>>>        postinst = d.getVar('pkg_postinst_modules')
>>>>        postrm = d.getVar('pkg_postrm_modules')
>>>>    
>>>> -    modules = do_split_packages(d,
>>>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>>>> output_pattern=module_pattern, description='%s kernel module',
>>>> postinst=postinst, postrm=postrm, recursive=True,
>>>> hook=frob_metadata,
>>>> extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
>>>> +    modules = do_split_packages(d,
>>>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>>>> output_pattern=module_pattern, description='%s kernel module',
>>>> postinst=postinst, postrm=postrm, recursive=True,
>>>> hook=frob_metadata,
>>>> extra_depends='%s-%s' % (kernel_package_name, kernel_version))
>>>>        if modules:
>>>>            metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>>>>            d.appendVar('RDEPENDS_' + metapkg, ' '+'
>>>> '.join(modules))
>>>> diff --git a/meta/classes/kernel.bbclass
>>>> b/meta/classes/kernel.bbclass
>>>> index 7670c7107a..7fa4509961 100644
>>>> --- a/meta/classes/kernel.bbclass
>>>> +++ b/meta/classes/kernel.bbclass
>>>> @@ -1,6 +1,8 @@
>>>>    inherit linux-kernel-base kernel-module-split
>>>>    
>>>> -PROVIDES += "virtual/kernel"
>>>> +KERNEL_PACKAGE_NAME ??= "kernel"
>>>> +
>>>> +PROVIDES += "${@ "virtual/kernel" if
>>>> (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
>>>>    DEPENDS += "virtual/${TARGET_PREFIX}binutils
>>>> virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
>>>>    PACKAGE_WRITE_DEPS += "depmodwrapper-cross virtual/update-
>>>> alternatives-native"
>>>>    
>>>> @@ -33,10 +35,23 @@ KERNEL_VERSION_PKG_NAME[vardepvalue] =
>>>> "${LINUX_VERSION}"
>>>>    
>>>>    python __anonymous () {
>>>>    
>>>> +    # The default kernel recipe builds in a shared location
>>>> defined
>>>> by
>>>> +    # bitbake/distro confs: STAGING_KERNEL_DIR and
>>>> STAGING_KERNEL_BUILDDIR.
>>>> +    # Set these variables to directories under ${WORKDIR} in
>>>> alternate
>>>> +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel)
>>>> so
>>>> that they
>>>> +    # may build in parallel with the default kernel without
>>>> clobbering.
>>>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) != "kernel":
>>>> +        workdir = d.getVar("WORKDIR", True)
>>>> +        sourceDir = os.path.join(workdir, 'kernel-source')
>>>> +        artifactsDir = os.path.join(workdir, 'kernel-build-
>>>> artifacts')
>>>> +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
>>>> +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
>>>> +
>>>>        # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
>>>> KERNEL_IMAGETYPES
>>>>        type = d.getVar('KERNEL_IMAGETYPE') or ""
>>>>        alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>>>>        types = d.getVar('KERNEL_IMAGETYPES') or ""
>>>> +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
>>>>        if type not in types.split():
>>>>            types = (type + ' ' + types).strip()
>>>>        if alttype not in types.split():
>>>> @@ -53,22 +68,22 @@ python __anonymous () {
>>>>            typelower = type.lower()
>>>>            imagedest = d.getVar('KERNEL_IMAGEDEST')
>>>>    
>>>> -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' +
>>>> typelower)
>>>> +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname,
>>>> typelower))
>>>>    
>>>> -        d.setVar('FILES_kernel-image-' + typelower, '/' +
>>>> imagedest
>>>> + '/' + type + '-${KERNEL_VERSION_NAME}')
>>>> +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' +
>>>> imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
>>>>    
>>>> -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-
>>>> image-' +
>>>> typelower)
>>>> +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s'
>>>> %
>>>> (kname, typelower))
>>>>    
>>>> -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-
>>>> ' +
>>>> typelower + '-${KERNEL_VERSION_PKG_NAME}')
>>>> +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-
>>>> image-
>>>> %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>>>>    
>>>> -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
>>>> +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower),
>>>> '1')
>>>>    
>>>>            priority = d.getVar('KERNEL_PRIORITY')
>>>>            postinst = '#!/bin/sh\n' + 'update-alternatives --
>>>> install /'
>>>> + imagedest + '/' + type + ' ' + type + ' ' + type + '-
>>>> ${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
>>>> -        d.setVar('pkg_postinst_kernel-image-' + typelower,
>>>> postinst)
>>>> +        d.setVar('pkg_postinst_' + kname + '-image-' +
>>>> typelower,
>>>> postinst)
>>>>    
>>>>            postrm = '#!/bin/sh\n' + 'update-alternatives --remove'
>>>> + '
>>>> ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n'
>>>> -        d.setVar('pkg_postrm_kernel-image-' + typelower, postrm)
>>>> +        d.setVar('pkg_postrm_%s-image-%s' % (kname, typelower),
>>>> postrm)
>>>>    
>>>>        image = d.getVar('INITRAMFS_IMAGE')
>>>>        if image:
>>>> @@ -126,9 +141,9 @@ base_do_unpack_append () {
>>>>    
>>>>    inherit kernel-arch deploy
>>>>    
>>>> -PACKAGES_DYNAMIC += "^kernel-module-.*"
>>>> -PACKAGES_DYNAMIC += "^kernel-image-.*"
>>>> -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
>>>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
>>>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
>>>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>>>>    
>>>>    export OS = "${TARGET_OS}"
>>>>    export CROSS_COMPILE = "${TARGET_PREFIX}"
>>>> @@ -371,9 +386,9 @@ do_shared_workdir_setscene () {
>>>>    
>>>>    emit_depmod_pkgdata() {
>>>>    	# Stash data for depmod
>>>> -	install -d ${PKGDESTWORK}/kernel-depmod/
>>>> -	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
>>>> depmod/kernel-abiversion
>>>> -	cp ${B}/System.map ${PKGDESTWORK}/kernel-
>>>> depmod/System.map-
>>>> ${KERNEL_VERSION}
>>>> +	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
>>>> +	echo "${KERNEL_VERSION}" >
>>>> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
>>>> depmod/${KERNEL_PACKAGE_NAME}-
>>>> abiversion
>>>> +	cp ${B}/System.map
>>>> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
>>>> depmod/System.map-${KERNEL_VERSION}
>>>>    }
>>>>    
>>>>    PACKAGEFUNCS += "emit_depmod_pkgdata"
>>>> @@ -388,7 +403,7 @@ do_shared_workdir () {
>>>>    	# Store the kernel version in sysroots for module-
>>>> base.bbclass
>>>>    	#
>>>>    
>>>> -	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
>>>> +	echo "${KERNEL_VERSION}" >
>>>> $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>>>>    
>>>>    	# Copy files required for module builds
>>>>    	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
>>>> @@ -486,28 +501,28 @@ EXPORT_FUNCTIONS do_compile do_install
>>>> do_configure
>>>>    
>>>>    # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base
>>>> ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
>>>> ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>>>>    FILES_${PN} = ""
>>>> -FILES_kernel-base =
>>>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>>>> -FILES_kernel-image = ""
>>>> -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
>>>> /boot/config* ${KERNEL_SRC_PATH}
>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>>>> -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
>>>> -FILES_kernel-modules = ""
>>>> -RDEPENDS_kernel = "kernel-base"
>>>> +FILES_${KERNEL_PACKAGE_NAME}-base =
>>>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>>>> +FILES_${KERNEL_PACKAGE_NAME}-image = ""
>>>> +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
>>>> /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>>>> +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
>>>> ${KERNEL_VERSION_NAME}"
>>>> +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
>>>> +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
>>>>    # Allow machines to override this dependency if kernel image
>>>> files
>>>> are
>>>>    # not wanted in images as standard
>>>> -RDEPENDS_kernel-base ?= "kernel-image"
>>>> -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${K
>>>> ERNE
>>>> L_VERSION}')}"
>>>> -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE'
>>>> ,
>>>> 'vmlinux', 'kernel-vmlinux', '', d)}"
>>>> -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_V
>>>> ERSI
>>>> ON}')}"
>>>> -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"
>>>> -
>>>> -pkg_postinst_kernel-base () {
>>>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-
>>>> image"
>>>> +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-
>>>> image-${@
>>>> legitimize_package_name('${KERNEL_VERSION}')}"
>>>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('K
>>>> ERNE
>>>> L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '',
>>>> d)}"
>>>> +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@leg
>>>> itim
>>>> ize_package_name('${KERNEL_VERSION}')}"
>>>> +RPROVIDES_${KERNEL_PACKAGE_NAME}-base +=
>>>> "${KERNEL_PACKAGE_NAME}-
>>>> ${KERNEL_VERSION}"
>>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
>>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
>>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
>>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
>>>> +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules
>>>> meta
>>>> package"
>>>> +
>>>> +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>>>>    	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>>>>    		mkdir -p $D/lib/modules/${KERNEL_VERSION}
>>>>    	fi
>>>> @@ -521,7 +536,7 @@ pkg_postinst_kernel-base () {
>>>>    PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>>>>    
>>>>    python split_kernel_packages () {
>>>> -    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>>>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>>>> output_pattern='kernel-
>>>> firmware-%s', description='Firmware for %s', recursive=True,
>>>> extra_depends='')
>>>> +    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>>>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>>>> output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
>>>> description='Firmware for %s', recursive=True, extra_depends='')
>>>>    }
>>>>    
>>>>    # Many scripts want to look in arch/$arch/boot for the bootable
>>>> diff --git a/meta/conf/documentation.conf
>>>> b/meta/conf/documentation.conf
>>>> index 35b9103b4a..e061b98de3 100644
>>>> --- a/meta/conf/documentation.conf
>>>> +++ b/meta/conf/documentation.conf
>>>> @@ -248,6 +248,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel
>>>> to
>>>> build for a device, usually set b
>>>>    KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build
>>>> for a
>>>> device, usually set by the machine configuration files and
>>>> defaults
>>>> to KERNEL_IMAGETYPE."
>>>>    KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need
>>>> to be
>>>> auto-loaded during boot"
>>>>    KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which
>>>> the
>>>> build system expects to find module_conf_* values that specify
>>>> configuration for each of the modules"
>>>> +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
>>>> Defaults to 'kernel'."
>>>>    KERNEL_PATH[doc] = "The location of the kernel sources. This
>>>> variable is set to the value of the STAGING_KERNEL_DIR within the
>>>> module class (module.bbclass)."
>>>>    KERNEL_SRC[doc] = "The location of the kernel sources. This
>>>> variable
>>>> is set to the value of the STAGING_KERNEL_DIR within the module
>>>> class
>>>> (module.bbclass)."
>>>>    KFEATURE_DESCRIPTION[doc] = "Provides a short description of a
>>>> configuration fragment. You use this variable in the .scc file
>>>> that
>>>> describes a configuration fragment file."
>>>> diff --git a/meta/recipes-kernel/linux/linux-dtb.inc
>>>> b/meta/recipes-
>>>> kernel/linux/linux-dtb.inc
>>>> index 0174c80d85..da6467bf9f 100644
>>>> --- a/meta/recipes-kernel/linux/linux-dtb.inc
>>>> +++ b/meta/recipes-kernel/linux/linux-dtb.inc
>>>> @@ -4,7 +4,7 @@ FILES_kernel-devicetree =
>>>> "/${KERNEL_IMAGEDEST}/devicetree*"
>>>>    PACKAGE_WRITE_DEPS += "virtual/update-alternatives-native"
>>>>    
>>>>    python __anonymous () {
>>>> -    d.appendVar("PACKAGES", " kernel-devicetree")
>>>> +    d.appendVar("PACKAGES", " ${KERNEL_PACKAGE_NAME}-
>>>> devicetree")
>>>>    }
>>>>    
>>>>    normalize_dtb () {
>>>> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
>>>> b/meta/recipes-kernel/linux/linux-yocto.inc
>>>> index 637506a2a8..4e0ce029da 100644
>>>> --- a/meta/recipes-kernel/linux/linux-yocto.inc
>>>> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
>>>> @@ -12,7 +12,7 @@ INC_PR = "r4"
>>>>    # PREFERRED_PROVIDER for virtual/kernel. This avoids network
>>>> access
>>>> required
>>>>    # by the use of AUTOREV SRCREVs, which are the default for this
>>>> recipe.
>>>>    python () {
>>>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
>>>> d.getVar("PN"):
>>>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>>>> d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) !=
>>>> d.getVar("PN",
>>>> True):
>>>>            d.delVar("BB_DONT_CACHE")
>>>>            raise bb.parse.SkipPackage("Set
>>>> PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
>>>> (d.getVar("PN")))
>>>>    }


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v4] kernel: Add support for multiple kernel packages
  2017-07-27 18:01       ` Rees, Kevron
  2017-08-03 16:18         ` Ovidiu-Adrian Vancea
@ 2017-08-08 15:27         ` Haris Okanovic
  1 sibling, 0 replies; 31+ messages in thread
From: Haris Okanovic @ 2017-08-08 15:27 UTC (permalink / raw)
  To: Rees, Kevron, Wold, Saul; +Cc: josh.hernstrom, openembedded-core



On 07/27/2017 01:01 PM, Rees, Kevron wrote:
> On Wed, Jul 19, 2017 at 8:56 AM, Wold, Saul <saul.wold@intel.com> wrote:
>> On Tue, 2017-07-18 at 08:34 -0500, Haris Okanovic wrote:
>>>
>>> On 07/17/2017 03:31 PM, Wold, Saul wrote:
>>>>
>>>> On Wed, 2017-07-05 at 12:33 -0500, Haris Okanovic wrote:
>>>>>
>>>>> Some distros may want to provide alternate kernel "flavors" via
>>>>> feeds
>>>>> or
>>>>> within bootable images. For example, readily available builds
>>>>> which
>>>>> provide certain diagnostic features can enable developers and
>>>>> testers
>>>>> to
>>>>> more quickly resolve issues by avoiding lengthy kernel builds.
>>>>>
>>>>> This change allows for building multiple flavors of the kernel
>>>>> and
>>>>> module packages by templatizing kernel package names via a new
>>>>> KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to
>>>>> the
>>>>> old
>>>>> name of "kernel", but can be overridden by certain recipes
>>>>> providing
>>>>> alternate kernel flavors.
>>>>>
>>>>> To maintain compatibility, recipes providing alternate kernel
>>>>> flavors
>>>>> cannot be the "preferred provider" for virtual/kernel. This is
>>>>> because
>>>>> OE puts the preferred provider's build and source at
>>>>> "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
>>>>> "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
>>>>> "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes
>>>>> using
>>>>> the
>>>>> default KERNEL_PACKAGE_NAME="kernel" follows the old semantics --
>>>>> build
>>>>> in the old location and may be preferred provider -- while
>>>>> recipes
>>>>> using
>>>>> all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and
>>>>> don't
>>>>> provide "virtual/kernel".
>>>>>
>>>>> Testing:
>>>>>    1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
>>>>>       linux-yocto-tiny_4.9.bb so that it may build alongside
>>>>>       the main kernel.
>>>>>    2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel
>>>>> flavors.
>>>>>    3. Verified image and modules IPKs exist for both:
>>>>>       tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>>>>>       tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-
>>>>> tiny
>>>>>    4. Verified linux-yocto is the "preferred provider", and was
>>>>> built
>>>>> in
>>>>>       shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>>>>>    5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
>>>>>       core-image-base.bb to include both kernel flavors.
>>>>>    6. `bitbake core-image-base` to build an image.
>>>>>    7. Verified image contains two bzImage's under /boot/, with
>>>>>       "yocto-standard" selected to boot via symlink.
>>>>>
>>>>> Discussion thread:
>>>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org_pipermail_openembedded-2Dcore_2015-2DDe&d=DwIBaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EXsasUKMXo4dlk7nFW3VDV8Z06QZKhwHTWyH5F0E6-c&s=vJgjJOYKOYNz18XjXjP-gc0MvGMrdm1Z8EbcLuaxFqA&e=
>>>>> cemb
>>>>> er/thread.html#114122
>>>>>
>>>>> Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
>>>>> Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
>>>>> Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
>>>>> Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
>>>>> Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
>>>>> Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
>>>>> ---
>>>>> [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR
>>>>> to
>>>>> the
>>>>> "work" directory in alternate kernel builds, instead of "work-
>>>>> shared",
>>>>> so
>>>>> that the two builds don't clobber each other.
>>>>>
>>>>> [PATCH v3] An updated version of this change rebased onto the
>>>>> current
>>>>> OE-core master. Changes:
>>>>>    * Remove PREFERRED_PROVIDER check in linux-yocto.inc in
>>>>> alternate
>>>>>      kernel builds, since alternate kernels aren't the
>>>>>      PREFERRED_PROVIDER for virtual/kernel by definition.
>>>>>    * Remove "virtual/kernel" from PROVIDES in alternate kernel
>>>>> builds.
>>>>>
>>>>> [PATCH v4] Another rebase onto master; no functional change.
>>>>> Improved description and testing steps.
>>>>
>>>> So I finally had a chance to get back to this and test build with
>>>> it, I
>>>> saw the following WARNING, which lead to the ERROR:
>>>>
>>>> WARNING: Variable key FILES_${PN}-dev (${includedir}
>>>> ${FILES_SOLIBSDEV}
>>>> ${libdir}/*.la ${libdir}/*.o ${libdir}/pkgconfig
>>>> ${datadir}/pkgconfig
>>>> ${datadir}/aclocal ${base_libdir}/*.o ${libdir}/${BPN}/*.la
>>>> ${base_libdir}/*.la) replaces original key FILES_linux-yocto-dev
>>>> (/boot/System.map* /boot/Module.symvers* /boot/config*
>>>> ${KERNEL_SRC_PATH}
>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build).
>>>> ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
>>>> do_package: QA Issue: linux-yocto: Files/directories were installed
>>>> but
>>>> not shipped in any package:
>>>>     /boot/System.map-4.10.17-yocto-standard
>>>>     /boot/Module.symvers-4.10.17-yocto-standard
>>>>     /boot/config-4.10.17-yocto-standard
>>>> Please set FILES such that these items are packaged. Alternatively
>>>> if
>>>> they are unneeded, avoid installing them or delete them within
>>>> do_install.
>>>> linux-yocto: 3 installed and not shipped files. [installed-vs-
>>>> shipped]
>>>> ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
>>>> do_package: Fatal QA errors found, failing task.
>>>> ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
>>>> do_package: Function failed: do_package
>>>>
>>>> Something seems to be causing the FILES_linux-yocto-dev info to be
>>>> overridden, I have not tracked down the culprit yet.
>>>>
>>>
>>> `FILES_linux-yocto-dev` is set to the default value from OE's
>>> bitbake.conf. `FILES_kernel-dev` on the other hand is set by
>>> kernel.bbclass; when `KERNEL_PACKAGE_NAME` expands to `kernel`.
>>>
>>> I think the real issue here is that QA checks care about
>>> `FILES_${PN}-dev` at all even though that particular package name
>>> isn't
>>> listed in `PACKAGES` variable. I.e. `FILES_${PN}-dev` should be
>>> disregarded since the `linux-yocto` recipe doesn't create package
>>> `${PN}-dev`.
>>>
>>> Thoughts?
>>>
>> It's hard to special case this. After you sent this, I realized what I
>> did was set the KERNEL_PACKAGE_NAME to linux-yocto and because the
>> KERNEL_PACKAGE_NAME matched the actual recipe name we got the strange
>> ${PN} interaction, we might be able to add a test to flag that as an
>> error or warning in the kernel.bbclass.
>>
>> I am also seeing an issue when I build a 4.9 kernel and then set-up a
>> 4.10 kernel with the kernel-abiversion getting mis-matched from the
>> depmodwrapper.  Have you tested with different versions?  I know it
>> should work with a old kernel/userspace -> new kernel, but not from a
>> new kernel/userspace -> old kernel.
>>
> 
> I've also hit this issue.  Here's the error message if that's helpful at all:
> 
> WARNING: core-image-base-1.0-r0 do_rootfs: [log_check]
> core-image-base: found 2 warning messages in the logfile:
> [log_check] warning:
> %post(tiny-linux-4.10.17-yocto-tiny-4.10.17+git0+e92bd55409_6648a34e00-r0.qemux86)
> scriptlet failed, exit status 1
> [log_check] Warn: update-alternatives: bzImage has multiple providers
> with the same priority, please check
> /home/tripzero/Projects/poky-contrib/build/tmp/wo
> rk/qemux86-poky-linux/core-image-base/1.0-r0/rootfs/usr/lib/opkg/alternatives/bzImage
> for details
> 
> ERROR: core-image-base-1.0-r0 do_rootfs: [log_check] core-image-base:
> found 1 error message in the logfile:
> [log_check] Error: Kernel version 4.10.17-yocto-tiny does not match
> kernel-abiversion (4.10.17-yocto-standard)
> 

See my earlier response to Saul.

Can you send me your build procedure -- I.e. sequence of bitbake commands?

> 
> 
>> Sau!
>>
>>
>>>>
>>>> Sau!
>>>>
>>>>>
>>>>> ---
>>>>>    meta/classes/kernel-module-split.bbclass  |  9 ++--
>>>>>    meta/classes/kernel.bbclass               | 85
>>>>> ++++++++++++++++++---
>>>>> ----------
>>>>>    meta/conf/documentation.conf              |  1 +
>>>>>    meta/recipes-kernel/linux/linux-dtb.inc   |  2 +-
>>>>>    meta/recipes-kernel/linux/linux-yocto.inc |  2 +-
>>>>>    5 files changed, 59 insertions(+), 40 deletions(-)
>>>>>
>>>>> diff --git a/meta/classes/kernel-module-split.bbclass
>>>>> b/meta/classes/kernel-module-split.bbclass
>>>>> index 1035525dac..9716c5937b 100644
>>>>> --- a/meta/classes/kernel-module-split.bbclass
>>>>> +++ b/meta/classes/kernel-module-split.bbclass
>>>>> @@ -30,7 +30,7 @@ do_install_append() {
>>>>>
>>>>>    PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>>>>>
>>>>> -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
>>>>> +KERNEL_MODULES_META_PACKAGE ?= "${KERNEL_PACKAGE_NAME}-modules"
>>>>>
>>>>>    KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>>>>>    KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
>>>>> @@ -129,16 +129,19 @@ python split_kernel_module_packages () {
>>>>>               postfix = format.split('%s')[1]
>>>>>               d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix,
>>>>> ''))
>>>>>
>>>>> +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True)
>>>>> +    kernel_version = d.getVar("KERNEL_VERSION", True)
>>>>> +
>>>>>        module_regex = '^(.*)\.k?o$'
>>>>>
>>>>>        module_pattern_prefix =
>>>>> d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>>>>>        module_pattern_suffix =
>>>>> d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
>>>>> -    module_pattern = module_pattern_prefix + 'kernel-module-%s'
>>>>> +
>>>>> module_pattern_suffix
>>>>> +    module_pattern = module_pattern_prefix + kernel_package_name
>>>>> +
>>>>> '-module-%s' + module_pattern_suffix
>>>>>
>>>>>        postinst = d.getVar('pkg_postinst_modules')
>>>>>        postrm = d.getVar('pkg_postrm_modules')
>>>>>
>>>>> -    modules = do_split_packages(d,
>>>>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>>>>> output_pattern=module_pattern, description='%s kernel module',
>>>>> postinst=postinst, postrm=postrm, recursive=True,
>>>>> hook=frob_metadata,
>>>>> extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
>>>>> +    modules = do_split_packages(d,
>>>>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>>>>> output_pattern=module_pattern, description='%s kernel module',
>>>>> postinst=postinst, postrm=postrm, recursive=True,
>>>>> hook=frob_metadata,
>>>>> extra_depends='%s-%s' % (kernel_package_name, kernel_version))
>>>>>        if modules:
>>>>>            metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>>>>>            d.appendVar('RDEPENDS_' + metapkg, ' '+'
>>>>> '.join(modules))
>>>>> diff --git a/meta/classes/kernel.bbclass
>>>>> b/meta/classes/kernel.bbclass
>>>>> index 7670c7107a..7fa4509961 100644
>>>>> --- a/meta/classes/kernel.bbclass
>>>>> +++ b/meta/classes/kernel.bbclass
>>>>> @@ -1,6 +1,8 @@
>>>>>    inherit linux-kernel-base kernel-module-split
>>>>>
>>>>> -PROVIDES += "virtual/kernel"
>>>>> +KERNEL_PACKAGE_NAME ??= "kernel"
>>>>> +
>>>>> +PROVIDES += "${@ "virtual/kernel" if
>>>>> (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
>>>>>    DEPENDS += "virtual/${TARGET_PREFIX}binutils
>>>>> virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
>>>>>    PACKAGE_WRITE_DEPS += "depmodwrapper-cross virtual/update-
>>>>> alternatives-native"
>>>>>
>>>>> @@ -33,10 +35,23 @@ KERNEL_VERSION_PKG_NAME[vardepvalue] =
>>>>> "${LINUX_VERSION}"
>>>>>
>>>>>    python __anonymous () {
>>>>>
>>>>> +    # The default kernel recipe builds in a shared location
>>>>> defined
>>>>> by
>>>>> +    # bitbake/distro confs: STAGING_KERNEL_DIR and
>>>>> STAGING_KERNEL_BUILDDIR.
>>>>> +    # Set these variables to directories under ${WORKDIR} in
>>>>> alternate
>>>>> +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel)
>>>>> so
>>>>> that they
>>>>> +    # may build in parallel with the default kernel without
>>>>> clobbering.
>>>>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) != "kernel":
>>>>> +        workdir = d.getVar("WORKDIR", True)
>>>>> +        sourceDir = os.path.join(workdir, 'kernel-source')
>>>>> +        artifactsDir = os.path.join(workdir, 'kernel-build-
>>>>> artifacts')
>>>>> +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
>>>>> +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
>>>>> +
>>>>>        # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
>>>>> KERNEL_IMAGETYPES
>>>>>        type = d.getVar('KERNEL_IMAGETYPE') or ""
>>>>>        alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>>>>>        types = d.getVar('KERNEL_IMAGETYPES') or ""
>>>>> +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
>>>>>        if type not in types.split():
>>>>>            types = (type + ' ' + types).strip()
>>>>>        if alttype not in types.split():
>>>>> @@ -53,22 +68,22 @@ python __anonymous () {
>>>>>            typelower = type.lower()
>>>>>            imagedest = d.getVar('KERNEL_IMAGEDEST')
>>>>>
>>>>> -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' +
>>>>> typelower)
>>>>> +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname,
>>>>> typelower))
>>>>>
>>>>> -        d.setVar('FILES_kernel-image-' + typelower, '/' +
>>>>> imagedest
>>>>> + '/' + type + '-${KERNEL_VERSION_NAME}')
>>>>> +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' +
>>>>> imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
>>>>>
>>>>> -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-
>>>>> image-' +
>>>>> typelower)
>>>>> +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s'
>>>>> %
>>>>> (kname, typelower))
>>>>>
>>>>> -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-
>>>>> ' +
>>>>> typelower + '-${KERNEL_VERSION_PKG_NAME}')
>>>>> +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-
>>>>> image-
>>>>> %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>>>>>
>>>>> -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
>>>>> +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower),
>>>>> '1')
>>>>>
>>>>>            priority = d.getVar('KERNEL_PRIORITY')
>>>>>            postinst = '#!/bin/sh\n' + 'update-alternatives --
>>>>> install /'
>>>>> + imagedest + '/' + type + ' ' + type + ' ' + type + '-
>>>>> ${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
>>>>> -        d.setVar('pkg_postinst_kernel-image-' + typelower,
>>>>> postinst)
>>>>> +        d.setVar('pkg_postinst_' + kname + '-image-' +
>>>>> typelower,
>>>>> postinst)
>>>>>
>>>>>            postrm = '#!/bin/sh\n' + 'update-alternatives --remove'
>>>>> + '
>>>>> ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n'
>>>>> -        d.setVar('pkg_postrm_kernel-image-' + typelower, postrm)
>>>>> +        d.setVar('pkg_postrm_%s-image-%s' % (kname, typelower),
>>>>> postrm)
>>>>>
>>>>>        image = d.getVar('INITRAMFS_IMAGE')
>>>>>        if image:
>>>>> @@ -126,9 +141,9 @@ base_do_unpack_append () {
>>>>>
>>>>>    inherit kernel-arch deploy
>>>>>
>>>>> -PACKAGES_DYNAMIC += "^kernel-module-.*"
>>>>> -PACKAGES_DYNAMIC += "^kernel-image-.*"
>>>>> -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
>>>>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
>>>>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
>>>>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>>>>>
>>>>>    export OS = "${TARGET_OS}"
>>>>>    export CROSS_COMPILE = "${TARGET_PREFIX}"
>>>>> @@ -371,9 +386,9 @@ do_shared_workdir_setscene () {
>>>>>
>>>>>    emit_depmod_pkgdata() {
>>>>>            # Stash data for depmod
>>>>> - install -d ${PKGDESTWORK}/kernel-depmod/
>>>>> - echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
>>>>> depmod/kernel-abiversion
>>>>> - cp ${B}/System.map ${PKGDESTWORK}/kernel-
>>>>> depmod/System.map-
>>>>> ${KERNEL_VERSION}
>>>>> + install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
>>>>> + echo "${KERNEL_VERSION}" >
>>>>> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
>>>>> depmod/${KERNEL_PACKAGE_NAME}-
>>>>> abiversion
>>>>> + cp ${B}/System.map
>>>>> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
>>>>> depmod/System.map-${KERNEL_VERSION}
>>>>>    }
>>>>>
>>>>>    PACKAGEFUNCS += "emit_depmod_pkgdata"
>>>>> @@ -388,7 +403,7 @@ do_shared_workdir () {
>>>>>            # Store the kernel version in sysroots for module-
>>>>> base.bbclass
>>>>>            #
>>>>>
>>>>> - echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
>>>>> + echo "${KERNEL_VERSION}" >
>>>>> $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>>>>>
>>>>>            # Copy files required for module builds
>>>>>            cp System.map $kerneldir/System.map-${KERNEL_VERSION}
>>>>> @@ -486,28 +501,28 @@ EXPORT_FUNCTIONS do_compile do_install
>>>>> do_configure
>>>>>
>>>>>    # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base
>>>>> ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
>>>>> ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>>>>>    FILES_${PN} = ""
>>>>> -FILES_kernel-base =
>>>>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>>>>> -FILES_kernel-image = ""
>>>>> -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
>>>>> /boot/config* ${KERNEL_SRC_PATH}
>>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>>>>> -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
>>>>> -FILES_kernel-modules = ""
>>>>> -RDEPENDS_kernel = "kernel-base"
>>>>> +FILES_${KERNEL_PACKAGE_NAME}-base =
>>>>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>>>>> +FILES_${KERNEL_PACKAGE_NAME}-image = ""
>>>>> +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
>>>>> /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
>>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>>>>> +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
>>>>> ${KERNEL_VERSION_NAME}"
>>>>> +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
>>>>> +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
>>>>>    # Allow machines to override this dependency if kernel image
>>>>> files
>>>>> are
>>>>>    # not wanted in images as standard
>>>>> -RDEPENDS_kernel-base ?= "kernel-image"
>>>>> -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${K
>>>>> ERNE
>>>>> L_VERSION}')}"
>>>>> -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE'
>>>>> ,
>>>>> 'vmlinux', 'kernel-vmlinux', '', d)}"
>>>>> -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_V
>>>>> ERSI
>>>>> ON}')}"
>>>>> -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"
>>>>> -
>>>>> -pkg_postinst_kernel-base () {
>>>>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-
>>>>> image"
>>>>> +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-
>>>>> image-${@
>>>>> legitimize_package_name('${KERNEL_VERSION}')}"
>>>>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('K
>>>>> ERNE
>>>>> L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '',
>>>>> d)}"
>>>>> +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@leg
>>>>> itim
>>>>> ize_package_name('${KERNEL_VERSION}')}"
>>>>> +RPROVIDES_${KERNEL_PACKAGE_NAME}-base +=
>>>>> "${KERNEL_PACKAGE_NAME}-
>>>>> ${KERNEL_VERSION}"
>>>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
>>>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
>>>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
>>>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
>>>>> +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules
>>>>> meta
>>>>> package"
>>>>> +
>>>>> +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>>>>>            if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>>>>>                    mkdir -p $D/lib/modules/${KERNEL_VERSION}
>>>>>            fi
>>>>> @@ -521,7 +536,7 @@ pkg_postinst_kernel-base () {
>>>>>    PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>>>>>
>>>>>    python split_kernel_packages () {
>>>>> -    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>>>>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>>>>> output_pattern='kernel-
>>>>> firmware-%s', description='Firmware for %s', recursive=True,
>>>>> extra_depends='')
>>>>> +    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>>>>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>>>>> output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
>>>>> description='Firmware for %s', recursive=True, extra_depends='')
>>>>>    }
>>>>>
>>>>>    # Many scripts want to look in arch/$arch/boot for the bootable
>>>>> diff --git a/meta/conf/documentation.conf
>>>>> b/meta/conf/documentation.conf
>>>>> index 35b9103b4a..e061b98de3 100644
>>>>> --- a/meta/conf/documentation.conf
>>>>> +++ b/meta/conf/documentation.conf
>>>>> @@ -248,6 +248,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel
>>>>> to
>>>>> build for a device, usually set b
>>>>>    KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build
>>>>> for a
>>>>> device, usually set by the machine configuration files and
>>>>> defaults
>>>>> to KERNEL_IMAGETYPE."
>>>>>    KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need
>>>>> to be
>>>>> auto-loaded during boot"
>>>>>    KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which
>>>>> the
>>>>> build system expects to find module_conf_* values that specify
>>>>> configuration for each of the modules"
>>>>> +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
>>>>> Defaults to 'kernel'."
>>>>>    KERNEL_PATH[doc] = "The location of the kernel sources. This
>>>>> variable is set to the value of the STAGING_KERNEL_DIR within the
>>>>> module class (module.bbclass)."
>>>>>    KERNEL_SRC[doc] = "The location of the kernel sources. This
>>>>> variable
>>>>> is set to the value of the STAGING_KERNEL_DIR within the module
>>>>> class
>>>>> (module.bbclass)."
>>>>>    KFEATURE_DESCRIPTION[doc] = "Provides a short description of a
>>>>> configuration fragment. You use this variable in the .scc file
>>>>> that
>>>>> describes a configuration fragment file."
>>>>> diff --git a/meta/recipes-kernel/linux/linux-dtb.inc
>>>>> b/meta/recipes-
>>>>> kernel/linux/linux-dtb.inc
>>>>> index 0174c80d85..da6467bf9f 100644
>>>>> --- a/meta/recipes-kernel/linux/linux-dtb.inc
>>>>> +++ b/meta/recipes-kernel/linux/linux-dtb.inc
>>>>> @@ -4,7 +4,7 @@ FILES_kernel-devicetree =
>>>>> "/${KERNEL_IMAGEDEST}/devicetree*"
>>>>>    PACKAGE_WRITE_DEPS += "virtual/update-alternatives-native"
>>>>>
>>>>>    python __anonymous () {
>>>>> -    d.appendVar("PACKAGES", " kernel-devicetree")
>>>>> +    d.appendVar("PACKAGES", " ${KERNEL_PACKAGE_NAME}-
>>>>> devicetree")
>>>>>    }
>>>>>
>>>>>    normalize_dtb () {
>>>>> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
>>>>> b/meta/recipes-kernel/linux/linux-yocto.inc
>>>>> index 637506a2a8..4e0ce029da 100644
>>>>> --- a/meta/recipes-kernel/linux/linux-yocto.inc
>>>>> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
>>>>> @@ -12,7 +12,7 @@ INC_PR = "r4"
>>>>>    # PREFERRED_PROVIDER for virtual/kernel. This avoids network
>>>>> access
>>>>> required
>>>>>    # by the use of AUTOREV SRCREVs, which are the default for this
>>>>> recipe.
>>>>>    python () {
>>>>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
>>>>> d.getVar("PN"):
>>>>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>>>>> d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) !=
>>>>> d.getVar("PN",
>>>>> True):
>>>>>            d.delVar("BB_DONT_CACHE")
>>>>>            raise bb.parse.SkipPackage("Set
>>>>> PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
>>>>> (d.getVar("PN")))
>>>>>    }
>> --
>> _______________________________________________
>> Openembedded-core mailing list
>> Openembedded-core@lists.openembedded.org
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org_mailman_listinfo_openembedded-2Dcore&d=DwIBaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EXsasUKMXo4dlk7nFW3VDV8Z06QZKhwHTWyH5F0E6-c&s=aB_EDwul_sqlOGvfQSdFA8PpByxlshLeXbBRePWTJHs&e=


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v4] kernel: Add support for multiple kernel packages
  2017-08-03 16:18         ` Ovidiu-Adrian Vancea
@ 2017-08-08 15:27           ` Haris Okanovic
  0 siblings, 0 replies; 31+ messages in thread
From: Haris Okanovic @ 2017-08-08 15:27 UTC (permalink / raw)
  To: Ovidiu-Adrian Vancea, openembedded-core; +Cc: Wold, Saul, josh.hernstrom



On 08/03/2017 11:18 AM, Ovidiu-Adrian Vancea wrote:
> On Thu, 2017-07-27 at 11:01 -0700, Rees, Kevron wrote:
>> On Wed, Jul 19, 2017 at 8:56 AM, Wold, Saul <saul.wold@intel.com>
>> wrote:
>>> On Tue, 2017-07-18 at 08:34 -0500, Haris Okanovic wrote:
>>>>
>>>> On 07/17/2017 03:31 PM, Wold, Saul wrote:
>>>>>
>>>>> On Wed, 2017-07-05 at 12:33 -0500, Haris Okanovic wrote:
>>>>>>
>>>>>> Some distros may want to provide alternate kernel "flavors"
>>>>>> via
>>>>>> feeds
>>>>>> or
>>>>>> within bootable images. For example, readily available builds
>>>>>> which
>>>>>> provide certain diagnostic features can enable developers and
>>>>>> testers
>>>>>> to
>>>>>> more quickly resolve issues by avoiding lengthy kernel
>>>>>> builds.
>>>>>>
>>>>>> This change allows for building multiple flavors of the
>>>>>> kernel
>>>>>> and
>>>>>> module packages by templatizing kernel package names via a
>>>>>> new
>>>>>> KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults
>>>>>> to
>>>>>> the
>>>>>> old
>>>>>> name of "kernel", but can be overridden by certain recipes
>>>>>> providing
>>>>>> alternate kernel flavors.
>>>>>>
>>>>>> To maintain compatibility, recipes providing alternate kernel
>>>>>> flavors
>>>>>> cannot be the "preferred provider" for virtual/kernel. This
>>>>>> is
>>>>>> because
>>>>>> OE puts the preferred provider's build and source at
>>>>>> "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
>>>>>> "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
>>>>>> "tmp-glibc/work/*/$PN/" like other recipes. Therefore,
>>>>>> recipes
>>>>>> using
>>>>>> the
>>>>>> default KERNEL_PACKAGE_NAME="kernel" follows the old
>>>>>> semantics --
>>>>>> build
>>>>>> in the old location and may be preferred provider -- while
>>>>>> recipes
>>>>>> using
>>>>>> all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR
>>>>>> and
>>>>>> don't
>>>>>> provide "virtual/kernel".
>>>>>>
>>>>>> Testing:
>>>>>>    1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
>>>>>>       linux-yocto-tiny_4.9.bb so that it may build alongside
>>>>>>       the main kernel.
>>>>>>    2. `bitbake linux-yocto linux-yocto-tiny` to build both
>>>>>> kernel
>>>>>> flavors.
>>>>>>    3. Verified image and modules IPKs exist for both:
>>>>>>       tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>>>>>>       tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-
>>>>>> yocto-
>>>>>> tiny
>>>>>>    4. Verified linux-yocto is the "preferred provider", and
>>>>>> was
>>>>>> built
>>>>>> in
>>>>>>       shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>>>>>>    5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
>>>>>>       core-image-base.bb to include both kernel flavors.
>>>>>>    6. `bitbake core-image-base` to build an image.
>>>>>>    7. Verified image contains two bzImage's under /boot/, with
>>>>>>       "yocto-standard" selected to boot via symlink.
>>>>>>
>>>>>> Discussion thread:
>>>>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.ope
>>>>>> nembedded.org_pipermail_openembedded-2Dcore_2015-
>>>>>> 2DDe&d=DwICAg&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r
>>>>>> =35FLeGKBmrBGMHAhCV37-B4ddgcjLZXUChuxj5DD6Sk&m=-J-
>>>>>> ERX3BXdjXgeeIE_ZNE7GozSVtUpP3Wt6FV_jtLtM&s=z_ITagkjX7-
>>>>>> q9KHaytBdqTZeJYksmYYjciSiELDYIGE&e=
>>>>>> cemb
>>>>>> er/thread.html#114122
>>>>>>
>>>>>> Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
>>>>>> Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
>>>>>> Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
>>>>>> Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
>>>>>> Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
>>>>>> Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
>>>>>> ---
>>>>>> [PATCH v2] Change STAGING_KERNEL_DIR and
>>>>>> STAGING_KERNEL_BUILDDIR
>>>>>> to
>>>>>> the
>>>>>> "work" directory in alternate kernel builds, instead of
>>>>>> "work-
>>>>>> shared",
>>>>>> so
>>>>>> that the two builds don't clobber each other.
>>>>>>
>>>>>> [PATCH v3] An updated version of this change rebased onto the
>>>>>> current
>>>>>> OE-core master. Changes:
>>>>>>    * Remove PREFERRED_PROVIDER check in linux-yocto.inc in
>>>>>> alternate
>>>>>>      kernel builds, since alternate kernels aren't the
>>>>>>      PREFERRED_PROVIDER for virtual/kernel by definition.
>>>>>>    * Remove "virtual/kernel" from PROVIDES in alternate kernel
>>>>>> builds.
>>>>>>
>>>>>> [PATCH v4] Another rebase onto master; no functional change.
>>>>>> Improved description and testing steps.
>>>>>
>>>>> So I finally had a chance to get back to this and test build
>>>>> with
>>>>> it, I
>>>>> saw the following WARNING, which lead to the ERROR:
>>>>>
>>>>> WARNING: Variable key FILES_${PN}-dev (${includedir}
>>>>> ${FILES_SOLIBSDEV}
>>>>> ${libdir}/*.la ${libdir}/*.o ${libdir}/pkgconfig
>>>>> ${datadir}/pkgconfig
>>>>> ${datadir}/aclocal ${base_libdir}/*.o ${libdir}/${BPN}/*.la
>>>>> ${base_libdir}/*.la) replaces original key FILES_linux-yocto-
>>>>> dev
>>>>> (/boot/System.map* /boot/Module.symvers* /boot/config*
>>>>> ${KERNEL_SRC_PATH}
>>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build).
>>>>> ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
>>>>> do_package: QA Issue: linux-yocto: Files/directories were
>>>>> installed
>>>>> but
>>>>> not shipped in any package:
>>>>>     /boot/System.map-4.10.17-yocto-standard
>>>>>     /boot/Module.symvers-4.10.17-yocto-standard
>>>>>     /boot/config-4.10.17-yocto-standard
>>>>> Please set FILES such that these items are packaged.
>>>>> Alternatively
>>>>> if
>>>>> they are unneeded, avoid installing them or delete them within
>>>>> do_install.
>>>>> linux-yocto: 3 installed and not shipped files. [installed-vs-
>>>>> shipped]
>>>>> ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
>>>>> do_package: Fatal QA errors found, failing task.
>>>>> ERROR: linux-yocto-4.10.17+gitAUTOINC+e92bd55409_6648a34e00-r0
>>>>> do_package: Function failed: do_package
>>>>>
>>>>> Something seems to be causing the FILES_linux-yocto-dev info to
>>>>> be
>>>>> overridden, I have not tracked down the culprit yet.
>>>>>
>>>>
>>>> `FILES_linux-yocto-dev` is set to the default value from OE's
>>>> bitbake.conf. `FILES_kernel-dev` on the other hand is set by
>>>> kernel.bbclass; when `KERNEL_PACKAGE_NAME` expands to `kernel`.
>>>>
>>>> I think the real issue here is that QA checks care about
>>>> `FILES_${PN}-dev` at all even though that particular package name
>>>> isn't
>>>> listed in `PACKAGES` variable. I.e. `FILES_${PN}-dev` should be
>>>> disregarded since the `linux-yocto` recipe doesn't create package
>>>> `${PN}-dev`.
>>>>
>>>> Thoughts?
>>>>
>>>
>>> It's hard to special case this. After you sent this, I realized
>>> what I
>>> did was set the KERNEL_PACKAGE_NAME to linux-yocto and because the
>>> KERNEL_PACKAGE_NAME matched the actual recipe name we got the
>>> strange
>>> ${PN} interaction, we might be able to add a test to flag that as
>>> an
>>> error or warning in the kernel.bbclass.
>>>
>>> I am also seeing an issue when I build a 4.9 kernel and then set-up
>>> a
>>> 4.10 kernel with the kernel-abiversion getting mis-matched from the
>>> depmodwrapper.  Have you tested with different versions?  I know it
>>> should work with a old kernel/userspace -> new kernel, but not from
>>> a
>>> new kernel/userspace -> old kernel.
>>>
>>
>> I've also hit this issue.  Here's the error message if that's helpful
>> at all:
>>
>> WARNING: core-image-base-1.0-r0 do_rootfs: [log_check]
>> core-image-base: found 2 warning messages in the logfile:
>> [log_check] warning:
>> %post(tiny-linux-4.10.17-yocto-tiny-
>> 4.10.17+git0+e92bd55409_6648a34e00-r0.qemux86)
>> scriptlet failed, exit status 1
>> [log_check] Warn: update-alternatives: bzImage has multiple providers
>> with the same priority, please check
>> /home/tripzero/Projects/poky-contrib/build/tmp/wo
>> rk/qemux86-poky-linux/core-image-base/1.0-
>> r0/rootfs/usr/lib/opkg/alternatives/bzImage
>> for details
>>
>> ERROR: core-image-base-1.0-r0 do_rootfs: [log_check] core-image-base:
>> found 1 error message in the logfile:
>> [log_check] Error: Kernel version 4.10.17-yocto-tiny does not match
>> kernel-abiversion (4.10.17-yocto-standard)
>>
>>
> 
> When building multiple kernels (multiple recipes), because all inherit
> kernel.bbclass, all of them end up in a crowded build/tmp-
> glibc/deploy/images/<arch>/.
> More problematic is that the symbolic links for the kernel images would
> be overridden with the last run kernel build (only if they have the
> same KERNEL_IMAGETYPE).
> So if linux-yocto-tiny was built last, the kernel image symbolic link
> would point to linux-yocto-tiny's kernel instead of the default one.
> I suggest we only keep the default kernel's components in build/tmp-
> glibc/deploy/images/<arch>/.
> 
> Any thoughts?
> 

Good catch. Added KERNEL_DEPLOYSUBDIR to namespace alternate kernel 
builds. Defaults to "" when KERNEL_PACKAGE_NAME == "kernel", which 
results in no change for default kernels -- I.e. artifacts still end up 
at DEPLOYDIR. Otherwise it becomes KERNEL_PACKAGE_NAME, which saves 
build artifacts of alternate kernels to DEPLOYDIR/KERNEL_PACKAGE_NAME/ 
instead so they won't collide.

Posting a PATCH v5 shortly.

>>
>>> Sau!
>>>
>>>
>>>>>
>>>>> Sau!
>>>>>
>>>>>>
>>>>>> ---
>>>>>>    meta/classes/kernel-module-split.bbclass  |  9 ++--
>>>>>>    meta/classes/kernel.bbclass               | 85
>>>>>> ++++++++++++++++++---
>>>>>> ----------
>>>>>>    meta/conf/documentation.conf              |  1 +
>>>>>>    meta/recipes-kernel/linux/linux-dtb.inc   |  2 +-
>>>>>>    meta/recipes-kernel/linux/linux-yocto.inc |  2 +-
>>>>>>    5 files changed, 59 insertions(+), 40 deletions(-)
>>>>>>
>>>>>> diff --git a/meta/classes/kernel-module-split.bbclass
>>>>>> b/meta/classes/kernel-module-split.bbclass
>>>>>> index 1035525dac..9716c5937b 100644
>>>>>> --- a/meta/classes/kernel-module-split.bbclass
>>>>>> +++ b/meta/classes/kernel-module-split.bbclass
>>>>>> @@ -30,7 +30,7 @@ do_install_append() {
>>>>>>
>>>>>>    PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>>>>>>
>>>>>> -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
>>>>>> +KERNEL_MODULES_META_PACKAGE ?= "${KERNEL_PACKAGE_NAME}-
>>>>>> modules"
>>>>>>
>>>>>>    KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>>>>>>    KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
>>>>>> @@ -129,16 +129,19 @@ python split_kernel_module_packages ()
>>>>>> {
>>>>>>               postfix = format.split('%s')[1]
>>>>>>               d.setVar('RPROVIDES_' + pkg,
>>>>>> pkg.replace(postfix,
>>>>>> ''))
>>>>>>
>>>>>> +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME",
>>>>>> True)
>>>>>> +    kernel_version = d.getVar("KERNEL_VERSION", True)
>>>>>> +
>>>>>>        module_regex = '^(.*)\.k?o$'
>>>>>>
>>>>>>        module_pattern_prefix =
>>>>>> d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>>>>>>        module_pattern_suffix =
>>>>>> d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
>>>>>> -    module_pattern = module_pattern_prefix + 'kernel-module-
>>>>>> %s'
>>>>>> +
>>>>>> module_pattern_suffix
>>>>>> +    module_pattern = module_pattern_prefix +
>>>>>> kernel_package_name
>>>>>> +
>>>>>> '-module-%s' + module_pattern_suffix
>>>>>>
>>>>>>        postinst = d.getVar('pkg_postinst_modules')
>>>>>>        postrm = d.getVar('pkg_postrm_modules')
>>>>>>
>>>>>> -    modules = do_split_packages(d,
>>>>>> root='${nonarch_base_libdir}/modules',
>>>>>> file_regex=module_regex,
>>>>>> output_pattern=module_pattern, description='%s kernel
>>>>>> module',
>>>>>> postinst=postinst, postrm=postrm, recursive=True,
>>>>>> hook=frob_metadata,
>>>>>> extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
>>>>>> +    modules = do_split_packages(d,
>>>>>> root='${nonarch_base_libdir}/modules',
>>>>>> file_regex=module_regex,
>>>>>> output_pattern=module_pattern, description='%s kernel
>>>>>> module',
>>>>>> postinst=postinst, postrm=postrm, recursive=True,
>>>>>> hook=frob_metadata,
>>>>>> extra_depends='%s-%s' % (kernel_package_name,
>>>>>> kernel_version))
>>>>>>        if modules:
>>>>>>            metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>>>>>>            d.appendVar('RDEPENDS_' + metapkg, ' '+'
>>>>>> '.join(modules))
>>>>>> diff --git a/meta/classes/kernel.bbclass
>>>>>> b/meta/classes/kernel.bbclass
>>>>>> index 7670c7107a..7fa4509961 100644
>>>>>> --- a/meta/classes/kernel.bbclass
>>>>>> +++ b/meta/classes/kernel.bbclass
>>>>>> @@ -1,6 +1,8 @@
>>>>>>    inherit linux-kernel-base kernel-module-split
>>>>>>
>>>>>> -PROVIDES += "virtual/kernel"
>>>>>> +KERNEL_PACKAGE_NAME ??= "kernel"
>>>>>> +
>>>>>> +PROVIDES += "${@ "virtual/kernel" if
>>>>>> (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else ""
>>>>>> }"
>>>>>>    DEPENDS += "virtual/${TARGET_PREFIX}binutils
>>>>>> virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-
>>>>>> native"
>>>>>>    PACKAGE_WRITE_DEPS += "depmodwrapper-cross virtual/update-
>>>>>> alternatives-native"
>>>>>>
>>>>>> @@ -33,10 +35,23 @@ KERNEL_VERSION_PKG_NAME[vardepvalue] =
>>>>>> "${LINUX_VERSION}"
>>>>>>
>>>>>>    python __anonymous () {
>>>>>>
>>>>>> +    # The default kernel recipe builds in a shared location
>>>>>> defined
>>>>>> by
>>>>>> +    # bitbake/distro confs: STAGING_KERNEL_DIR and
>>>>>> STAGING_KERNEL_BUILDDIR.
>>>>>> +    # Set these variables to directories under ${WORKDIR} in
>>>>>> alternate
>>>>>> +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME !=
>>>>>> kernel)
>>>>>> so
>>>>>> that they
>>>>>> +    # may build in parallel with the default kernel without
>>>>>> clobbering.
>>>>>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) != "kernel":
>>>>>> +        workdir = d.getVar("WORKDIR", True)
>>>>>> +        sourceDir = os.path.join(workdir, 'kernel-source')
>>>>>> +        artifactsDir = os.path.join(workdir, 'kernel-build-
>>>>>> artifacts')
>>>>>> +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
>>>>>> +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
>>>>>> +
>>>>>>        # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
>>>>>> KERNEL_IMAGETYPES
>>>>>>        type = d.getVar('KERNEL_IMAGETYPE') or ""
>>>>>>        alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>>>>>>        types = d.getVar('KERNEL_IMAGETYPES') or ""
>>>>>> +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or
>>>>>> "kernel"
>>>>>>        if type not in types.split():
>>>>>>            types = (type + ' ' + types).strip()
>>>>>>        if alttype not in types.split():
>>>>>> @@ -53,22 +68,22 @@ python __anonymous () {
>>>>>>            typelower = type.lower()
>>>>>>            imagedest = d.getVar('KERNEL_IMAGEDEST')
>>>>>>
>>>>>> -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' +
>>>>>> typelower)
>>>>>> +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname,
>>>>>> typelower))
>>>>>>
>>>>>> -        d.setVar('FILES_kernel-image-' + typelower, '/' +
>>>>>> imagedest
>>>>>> + '/' + type + '-${KERNEL_VERSION_NAME}')
>>>>>> +        d.setVar('FILES_' + kname + '-image-' + typelower,
>>>>>> '/' +
>>>>>> imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
>>>>>>
>>>>>> -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-
>>>>>> image-' +
>>>>>> typelower)
>>>>>> +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-
>>>>>> %s'
>>>>>> %
>>>>>> (kname, typelower))
>>>>>>
>>>>>> -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-
>>>>>> image-
>>>>>> ' +
>>>>>> typelower + '-${KERNEL_VERSION_PKG_NAME}')
>>>>>> +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-
>>>>>> image-
>>>>>> %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>>>>>>
>>>>>> -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower,
>>>>>> '1')
>>>>>> +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname,
>>>>>> typelower),
>>>>>> '1')
>>>>>>
>>>>>>            priority = d.getVar('KERNEL_PRIORITY')
>>>>>>            postinst = '#!/bin/sh\n' + 'update-alternatives --
>>>>>> install /'
>>>>>> + imagedest + '/' + type + ' ' + type + ' ' + type + '-
>>>>>> ${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
>>>>>> -        d.setVar('pkg_postinst_kernel-image-' + typelower,
>>>>>> postinst)
>>>>>> +        d.setVar('pkg_postinst_' + kname + '-image-' +
>>>>>> typelower,
>>>>>> postinst)
>>>>>>
>>>>>>            postrm = '#!/bin/sh\n' + 'update-alternatives --
>>>>>> remove'
>>>>>> + '
>>>>>> ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' +
>>>>>> '\n'
>>>>>> -        d.setVar('pkg_postrm_kernel-image-' + typelower,
>>>>>> postrm)
>>>>>> +        d.setVar('pkg_postrm_%s-image-%s' % (kname,
>>>>>> typelower),
>>>>>> postrm)
>>>>>>
>>>>>>        image = d.getVar('INITRAMFS_IMAGE')
>>>>>>        if image:
>>>>>> @@ -126,9 +141,9 @@ base_do_unpack_append () {
>>>>>>
>>>>>>    inherit kernel-arch deploy
>>>>>>
>>>>>> -PACKAGES_DYNAMIC += "^kernel-module-.*"
>>>>>> -PACKAGES_DYNAMIC += "^kernel-image-.*"
>>>>>> -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
>>>>>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
>>>>>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
>>>>>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>>>>>>
>>>>>>    export OS = "${TARGET_OS}"
>>>>>>    export CROSS_COMPILE = "${TARGET_PREFIX}"
>>>>>> @@ -371,9 +386,9 @@ do_shared_workdir_setscene () {
>>>>>>
>>>>>>    emit_depmod_pkgdata() {
>>>>>>            # Stash data for depmod
>>>>>> - install -d ${PKGDESTWORK}/kernel-depmod/
>>>>>> - echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
>>>>>> depmod/kernel-abiversion
>>>>>> - cp ${B}/System.map ${PKGDESTWORK}/kernel-
>>>>>> depmod/System.map-
>>>>>> ${KERNEL_VERSION}
>>>>>> + install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
>>>>>> + echo "${KERNEL_VERSION}" >
>>>>>> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
>>>>>> depmod/${KERNEL_PACKAGE_NAME}-
>>>>>> abiversion
>>>>>> + cp ${B}/System.map
>>>>>> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
>>>>>> depmod/System.map-${KERNEL_VERSION}
>>>>>>    }
>>>>>>
>>>>>>    PACKAGEFUNCS += "emit_depmod_pkgdata"
>>>>>> @@ -388,7 +403,7 @@ do_shared_workdir () {
>>>>>>            # Store the kernel version in sysroots for module-
>>>>>> base.bbclass
>>>>>>            #
>>>>>>
>>>>>> - echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
>>>>>> + echo "${KERNEL_VERSION}" >
>>>>>> $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>>>>>>
>>>>>>            # Copy files required for module builds
>>>>>>            cp System.map $kerneldir/System.map-
>>>>>> ${KERNEL_VERSION}
>>>>>> @@ -486,28 +501,28 @@ EXPORT_FUNCTIONS do_compile do_install
>>>>>> do_configure
>>>>>>
>>>>>>    # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-
>>>>>> base
>>>>>> ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
>>>>>> ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>>>>>>    FILES_${PN} = ""
>>>>>> -FILES_kernel-base =
>>>>>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.ord
>>>>>> er
>>>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.buil
>>>>>> tin"
>>>>>> -FILES_kernel-image = ""
>>>>>> -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
>>>>>> /boot/config* ${KERNEL_SRC_PATH}
>>>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>>>>>> -FILES_kernel-vmlinux = "/boot/vmlinux-
>>>>>> ${KERNEL_VERSION_NAME}"
>>>>>> -FILES_kernel-modules = ""
>>>>>> -RDEPENDS_kernel = "kernel-base"
>>>>>> +FILES_${KERNEL_PACKAGE_NAME}-base =
>>>>>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.ord
>>>>>> er
>>>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.buil
>>>>>> tin"
>>>>>> +FILES_${KERNEL_PACKAGE_NAME}-image = ""
>>>>>> +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
>>>>>> /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
>>>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>>>>>> +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
>>>>>> ${KERNEL_VERSION_NAME}"
>>>>>> +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
>>>>>> +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-
>>>>>> base"
>>>>>>    # Allow machines to override this dependency if kernel
>>>>>> image
>>>>>> files
>>>>>> are
>>>>>>    # not wanted in images as standard
>>>>>> -RDEPENDS_kernel-base ?= "kernel-image"
>>>>>> -PKG_kernel-image = "kernel-image-${@legitimize_package_name(
>>>>>> '${K
>>>>>> ERNE
>>>>>> L_VERSION}')}"
>>>>>> -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGET
>>>>>> YPE'
>>>>>> ,
>>>>>> 'vmlinux', 'kernel-vmlinux', '', d)}"
>>>>>> -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERN
>>>>>> EL_V
>>>>>> ERSI
>>>>>> ON}')}"
>>>>>> -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"
>>>>>> -
>>>>>> -pkg_postinst_kernel-base () {
>>>>>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?=
>>>>>> "${KERNEL_PACKAGE_NAME}-
>>>>>> image"
>>>>>> +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-
>>>>>> image-${@
>>>>>> legitimize_package_name('${KERNEL_VERSION}')}"
>>>>>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditiona
>>>>>> l('K
>>>>>> ERNE
>>>>>> L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux',
>>>>>> '',
>>>>>> d)}"
>>>>>> +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${
>>>>>> @leg
>>>>>> itim
>>>>>> ize_package_name('${KERNEL_VERSION}')}"
>>>>>> +RPROVIDES_${KERNEL_PACKAGE_NAME}-base +=
>>>>>> "${KERNEL_PACKAGE_NAME}-
>>>>>> ${KERNEL_VERSION}"
>>>>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
>>>>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
>>>>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
>>>>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
>>>>>> +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules
>>>>>> meta
>>>>>> package"
>>>>>> +
>>>>>> +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>>>>>>            if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ];
>>>>>> then
>>>>>>                    mkdir -p $D/lib/modules/${KERNEL_VERSION}
>>>>>>            fi
>>>>>> @@ -521,7 +536,7 @@ pkg_postinst_kernel-base () {
>>>>>>    PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>>>>>>
>>>>>>    python split_kernel_packages () {
>>>>>> -    do_split_packages(d,
>>>>>> root='${nonarch_base_libdir}/firmware',
>>>>>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>>>>>> output_pattern='kernel-
>>>>>> firmware-%s', description='Firmware for %s', recursive=True,
>>>>>> extra_depends='')
>>>>>> +    do_split_packages(d,
>>>>>> root='${nonarch_base_libdir}/firmware',
>>>>>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>>>>>> output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
>>>>>> description='Firmware for %s', recursive=True,
>>>>>> extra_depends='')
>>>>>>    }
>>>>>>
>>>>>>    # Many scripts want to look in arch/$arch/boot for the
>>>>>> bootable
>>>>>> diff --git a/meta/conf/documentation.conf
>>>>>> b/meta/conf/documentation.conf
>>>>>> index 35b9103b4a..e061b98de3 100644
>>>>>> --- a/meta/conf/documentation.conf
>>>>>> +++ b/meta/conf/documentation.conf
>>>>>> @@ -248,6 +248,7 @@ KERNEL_IMAGETYPE[doc] = "The type of
>>>>>> kernel
>>>>>> to
>>>>>> build for a device, usually set b
>>>>>>    KERNEL_IMAGETYPES[doc] = "The list of types of kernel to
>>>>>> build
>>>>>> for a
>>>>>> device, usually set by the machine configuration files and
>>>>>> defaults
>>>>>> to KERNEL_IMAGETYPE."
>>>>>>    KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that
>>>>>> need
>>>>>> to be
>>>>>> auto-loaded during boot"
>>>>>>    KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for
>>>>>> which
>>>>>> the
>>>>>> build system expects to find module_conf_* values that
>>>>>> specify
>>>>>> configuration for each of the modules"
>>>>>> +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
>>>>>> Defaults to 'kernel'."
>>>>>>    KERNEL_PATH[doc] = "The location of the kernel sources.
>>>>>> This
>>>>>> variable is set to the value of the STAGING_KERNEL_DIR within
>>>>>> the
>>>>>> module class (module.bbclass)."
>>>>>>    KERNEL_SRC[doc] = "The location of the kernel sources. This
>>>>>> variable
>>>>>> is set to the value of the STAGING_KERNEL_DIR within the
>>>>>> module
>>>>>> class
>>>>>> (module.bbclass)."
>>>>>>    KFEATURE_DESCRIPTION[doc] = "Provides a short description
>>>>>> of a
>>>>>> configuration fragment. You use this variable in the .scc
>>>>>> file
>>>>>> that
>>>>>> describes a configuration fragment file."
>>>>>> diff --git a/meta/recipes-kernel/linux/linux-dtb.inc
>>>>>> b/meta/recipes-
>>>>>> kernel/linux/linux-dtb.inc
>>>>>> index 0174c80d85..da6467bf9f 100644
>>>>>> --- a/meta/recipes-kernel/linux/linux-dtb.inc
>>>>>> +++ b/meta/recipes-kernel/linux/linux-dtb.inc
>>>>>> @@ -4,7 +4,7 @@ FILES_kernel-devicetree =
>>>>>> "/${KERNEL_IMAGEDEST}/devicetree*"
>>>>>>    PACKAGE_WRITE_DEPS += "virtual/update-alternatives-native"
>>>>>>
>>>>>>    python __anonymous () {
>>>>>> -    d.appendVar("PACKAGES", " kernel-devicetree")
>>>>>> +    d.appendVar("PACKAGES", " ${KERNEL_PACKAGE_NAME}-
>>>>>> devicetree")
>>>>>>    }
>>>>>>
>>>>>>    normalize_dtb () {
>>>>>> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
>>>>>> b/meta/recipes-kernel/linux/linux-yocto.inc
>>>>>> index 637506a2a8..4e0ce029da 100644
>>>>>> --- a/meta/recipes-kernel/linux/linux-yocto.inc
>>>>>> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
>>>>>> @@ -12,7 +12,7 @@ INC_PR = "r4"
>>>>>>    # PREFERRED_PROVIDER for virtual/kernel. This avoids
>>>>>> network
>>>>>> access
>>>>>> required
>>>>>>    # by the use of AUTOREV SRCREVs, which are the default for
>>>>>> this
>>>>>> recipe.
>>>>>>    python () {
>>>>>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
>>>>>> d.getVar("PN"):
>>>>>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>>>>>> d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) !=
>>>>>> d.getVar("PN",
>>>>>> True):
>>>>>>            d.delVar("BB_DONT_CACHE")
>>>>>>            raise bb.parse.SkipPackage("Set
>>>>>> PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
>>>>>> (d.getVar("PN")))
>>>>>>    }
>>>
>>> --
>>> _______________________________________________
>>> Openembedded-core mailing list
>>> Openembedded-core@lists.openembedded.org
>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembed
>>> ded.org_mailman_listinfo_openembedded-
>>> 2Dcore&d=DwICAg&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=35F
>>> LeGKBmrBGMHAhCV37-B4ddgcjLZXUChuxj5DD6Sk&m=-J-
>>> ERX3BXdjXgeeIE_ZNE7GozSVtUpP3Wt6FV_jtLtM&s=GFRD2nih1U_Vspzl1T_lId_e
>>> dVf6o45jiD4I-J1ptR4&e=


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH v5] kernel: Add support for multiple kernel packages
  2017-07-19 15:56     ` Wold, Saul
  2017-07-27 18:01       ` Rees, Kevron
  2017-08-08 15:26       ` Haris Okanovic
@ 2017-08-08 15:34       ` Haris Okanovic
  2017-08-14 21:29       ` [PATCH v6] " Haris Okanovic
                         ` (3 subsequent siblings)
  6 siblings, 0 replies; 31+ messages in thread
From: Haris Okanovic @ 2017-08-08 15:34 UTC (permalink / raw)
  To: openembedded-core; +Cc: haris.okanovic, saul.wold, josh.hernstrom

Some distros may want to provide alternate kernel "flavors" via feeds or
within bootable images. For example, readily available builds which
provide certain diagnostic features can enable developers and testers to
more quickly resolve issues by avoiding lengthy kernel builds.

This change allows for building multiple flavors of the kernel and
module packages by templatizing kernel package names via a new
KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the old
name of "kernel", but can be overridden by certain recipes providing
alternate kernel flavors.

To maintain compatibility, recipes providing alternate kernel flavors
cannot be the "preferred provider" for virtual/kernel. This is because
OE puts the preferred provider's build and source at
"tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
"tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
"tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using the
default KERNEL_PACKAGE_NAME="kernel" follows the old semantics -- build
in the old location and may be preferred provider -- while recipes using
all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and don't
provide "virtual/kernel".

Testing:
 1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
    linux-yocto-tiny_4.9.bb so that it may build alongside
    the main kernel.
 2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel flavors.
 3. Verified image and modules IPKs exist for both:
    tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
    tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
 4. Verified linux-yocto is the "preferred provider", and was built in
    shared directory: tmp-glibc/work-shared/qemux86/kernel-*
 5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
    core-image-base.bb to include both kernel flavors.
 6. `bitbake core-image-base` to build an image.
 7. Verified image contains two bzImage's under /boot/, with
    "yocto-standard" selected to boot via symlink.

Discussion thread:
http://lists.openembedded.org/pipermail/openembedded-core/2015-December/thread.html#114122

Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
---
[PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to the
"work" directory in alternate kernel builds, instead of "work-shared",
so
that the two builds don't clobber each other.

[PATCH v3] An updated version of this change rebased onto the current
OE-core master. Changes:
 - Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
   kernel builds, since alternate kernels aren't the
   PREFERRED_PROVIDER for virtual/kernel by definition.
 - Remove "virtual/kernel" from PROVIDES in alternate kernel builds.

[PATCH v4] Another rebase onto master; no functional change.
Improved description and testing steps.

[PATCH v5]
 - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
 - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions

https://github.com/harisokanovic/openembedded-core/tree/dev/hokanovi/multi-kernel-packages-v5
---
 meta/classes/kernel-module-split.bbclass  |   9 ++-
 meta/classes/kernel.bbclass               | 114 +++++++++++++++++++-----------
 meta/conf/documentation.conf              |   1 +
 meta/recipes-kernel/linux/linux-dtb.inc   |   2 +-
 meta/recipes-kernel/linux/linux-yocto.inc |   2 +-
 5 files changed, 81 insertions(+), 47 deletions(-)

diff --git a/meta/classes/kernel-module-split.bbclass b/meta/classes/kernel-module-split.bbclass
index 1035525dac..9716c5937b 100644
--- a/meta/classes/kernel-module-split.bbclass
+++ b/meta/classes/kernel-module-split.bbclass
@@ -30,7 +30,7 @@ do_install_append() {
 
 PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
 
-KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
+KERNEL_MODULES_META_PACKAGE ?= "${KERNEL_PACKAGE_NAME}-modules"
 
 KERNEL_MODULE_PACKAGE_PREFIX ?= ""
 KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
@@ -129,16 +129,19 @@ python split_kernel_module_packages () {
            postfix = format.split('%s')[1]
            d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
 
+    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True)
+    kernel_version = d.getVar("KERNEL_VERSION", True)
+
     module_regex = '^(.*)\.k?o$'
 
     module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
     module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
-    module_pattern = module_pattern_prefix + 'kernel-module-%s' + module_pattern_suffix
+    module_pattern = module_pattern_prefix + kernel_package_name + '-module-%s' + module_pattern_suffix
 
     postinst = d.getVar('pkg_postinst_modules')
     postrm = d.getVar('pkg_postrm_modules')
 
-    modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
+    modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='%s-%s' % (kernel_package_name, kernel_version))
     if modules:
         metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
         d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index 7670c7107a..0760bfb2c9 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -1,6 +1,9 @@
 inherit linux-kernel-base kernel-module-split
 
-PROVIDES += "virtual/kernel"
+KERNEL_PACKAGE_NAME ??= "kernel"
+KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
+
+PROVIDES += "${@ "virtual/kernel" if (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
 DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
 PACKAGE_WRITE_DEPS += "depmodwrapper-cross virtual/update-alternatives-native"
 
@@ -32,11 +35,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION')
 KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
 
 python __anonymous () {
+    pn = d.getVar("PN", True)
+    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
+
+    # XXX Remove this after bug 11905 is resolved
+    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
+    if kpn == pn:
+        bb.warn("Some packages (E.g. *-dev) might be missing due to "
+                "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
+
+    # The default kernel recipe builds in a shared location defined by
+    # bitbake/distro confs: STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR.
+    # Set these variables to directories under ${WORKDIR} in alternate
+    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so that they
+    # may build in parallel with the default kernel without clobbering.
+    if kpn != "kernel":
+        workdir = d.getVar("WORKDIR", True)
+        sourceDir = os.path.join(workdir, 'kernel-source')
+        artifactsDir = os.path.join(workdir, 'kernel-build-artifacts')
+        d.setVar("STAGING_KERNEL_DIR", sourceDir)
+        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
 
     # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES
     type = d.getVar('KERNEL_IMAGETYPE') or ""
     alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
     types = d.getVar('KERNEL_IMAGETYPES') or ""
+    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
     if type not in types.split():
         types = (type + ' ' + types).strip()
     if alttype not in types.split():
@@ -53,22 +77,22 @@ python __anonymous () {
         typelower = type.lower()
         imagedest = d.getVar('KERNEL_IMAGEDEST')
 
-        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
+        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
 
-        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
+        d.setVar('FILES_' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
 
-        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' + typelower)
+        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' % (kname, typelower))
 
-        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' + typelower + '-${KERNEL_VERSION_PKG_NAME}')
+        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
 
-        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
+        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower), '1')
 
         priority = d.getVar('KERNEL_PRIORITY')
         postinst = '#!/bin/sh\n' + 'update-alternatives --install /' + imagedest + '/' + type + ' ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
-        d.setVar('pkg_postinst_kernel-image-' + typelower, postinst)
+        d.setVar('pkg_postinst_' + kname + '-image-' + typelower, postinst)
 
         postrm = '#!/bin/sh\n' + 'update-alternatives --remove' + ' ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n'
-        d.setVar('pkg_postrm_kernel-image-' + typelower, postrm)
+        d.setVar('pkg_postrm_%s-image-%s' % (kname, typelower), postrm)
 
     image = d.getVar('INITRAMFS_IMAGE')
     if image:
@@ -126,9 +150,9 @@ base_do_unpack_append () {
 
 inherit kernel-arch deploy
 
-PACKAGES_DYNAMIC += "^kernel-module-.*"
-PACKAGES_DYNAMIC += "^kernel-image-.*"
-PACKAGES_DYNAMIC += "^kernel-firmware-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
 
 export OS = "${TARGET_OS}"
 export CROSS_COMPILE = "${TARGET_PREFIX}"
@@ -371,9 +395,9 @@ do_shared_workdir_setscene () {
 
 emit_depmod_pkgdata() {
 	# Stash data for depmod
-	install -d ${PKGDESTWORK}/kernel-depmod/
-	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-depmod/kernel-abiversion
-	cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-${KERNEL_VERSION}
+	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
+	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-abiversion
+	cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/System.map-${KERNEL_VERSION}
 }
 
 PACKAGEFUNCS += "emit_depmod_pkgdata"
@@ -388,7 +412,7 @@ do_shared_workdir () {
 	# Store the kernel version in sysroots for module-base.bbclass
 	#
 
-	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
+	echo "${KERNEL_VERSION}" > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
 
 	# Copy files required for module builds
 	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
@@ -486,28 +510,28 @@ EXPORT_FUNCTIONS do_compile do_install do_configure
 
 # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
 FILES_${PN} = ""
-FILES_kernel-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
-FILES_kernel-image = ""
-FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
-FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
-FILES_kernel-modules = ""
-RDEPENDS_kernel = "kernel-base"
+FILES_${KERNEL_PACKAGE_NAME}-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
+FILES_${KERNEL_PACKAGE_NAME}-image = ""
+FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
+FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
+FILES_${KERNEL_PACKAGE_NAME}-modules = ""
+RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
 # Allow machines to override this dependency if kernel image files are
 # not wanted in images as standard
-RDEPENDS_kernel-base ?= "kernel-image"
-PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
-RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', 'kernel-vmlinux', '', d)}"
-PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSION}')}"
-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"
-
-pkg_postinst_kernel-base () {
+RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-image"
+PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
+RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
+PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitimize_package_name('${KERNEL_VERSION}')}"
+RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-${KERNEL_VERSION}"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
+DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta package"
+
+pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
 	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
 		mkdir -p $D/lib/modules/${KERNEL_VERSION}
 	fi
@@ -521,7 +545,7 @@ pkg_postinst_kernel-base () {
 PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
 
 python split_kernel_packages () {
-    do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
+    do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
 }
 
 # Many scripts want to look in arch/$arch/boot for the bootable
@@ -604,21 +628,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-${MACHINE}.tgz"
 MODULE_TARBALL_DEPLOY ?= "1"
 
 kernel_do_deploy() {
+	deployDir="${DEPLOYDIR}"
+	if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
+		deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
+		mkdir "$deployDir"
+	fi
+
 	for type in ${KERNEL_IMAGETYPES} ; do
 		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
-		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${DEPLOYDIR}/${base_name}.bin
+		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} $deployDir/${base_name}.bin
 	done
 	if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
 		mkdir -p ${D}/lib
-		tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
-		ln -sf ${MODULE_TARBALL_BASE_NAME} ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
+		tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
+		ln -sf ${MODULE_TARBALL_BASE_NAME} $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
 	fi
 
 	for type in ${KERNEL_IMAGETYPES} ; do
 		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
 		symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
-		ln -sf ${base_name}.bin ${DEPLOYDIR}/${symlink_name}.bin
-		ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
+		ln -sf ${base_name}.bin $deployDir/${symlink_name}.bin
+		ln -sf ${base_name}.bin $deployDir/${type}
 	done
 
 	cd ${B}
@@ -628,8 +658,8 @@ kernel_do_deploy() {
 			echo "Copying deploy ${type} kernel-initramfs image and setting up links..."
 			initramfs_base_name=${type}-${INITRAMFS_BASE_NAME}
 			initramfs_symlink_name=${type}-initramfs-${MACHINE}
-			install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs ${DEPLOYDIR}/${initramfs_base_name}.bin
-			ln -sf ${initramfs_base_name}.bin ${DEPLOYDIR}/${initramfs_symlink_name}.bin
+			install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs $deployDir/${initramfs_base_name}.bin
+			ln -sf ${initramfs_base_name}.bin $deployDir/${initramfs_symlink_name}.bin
 		fi
 	done
 }
diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
index 35b9103b4a..e061b98de3 100644
--- a/meta/conf/documentation.conf
+++ b/meta/conf/documentation.conf
@@ -248,6 +248,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to build for a device, usually set b
 KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a device, usually set by the machine configuration files and defaults to KERNEL_IMAGETYPE."
 KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be auto-loaded during boot"
 KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the build system expects to find module_conf_* values that specify configuration for each of the modules"
+KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages. Defaults to 'kernel'."
 KERNEL_PATH[doc] = "The location of the kernel sources. This variable is set to the value of the STAGING_KERNEL_DIR within the module class (module.bbclass)."
 KERNEL_SRC[doc] = "The location of the kernel sources. This variable is set to the value of the STAGING_KERNEL_DIR within the module class (module.bbclass)."
 KFEATURE_DESCRIPTION[doc] = "Provides a short description of a configuration fragment. You use this variable in the .scc file that describes a configuration fragment file."
diff --git a/meta/recipes-kernel/linux/linux-dtb.inc b/meta/recipes-kernel/linux/linux-dtb.inc
index 0174c80d85..da6467bf9f 100644
--- a/meta/recipes-kernel/linux/linux-dtb.inc
+++ b/meta/recipes-kernel/linux/linux-dtb.inc
@@ -4,7 +4,7 @@ FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/devicetree*"
 PACKAGE_WRITE_DEPS += "virtual/update-alternatives-native"
 
 python __anonymous () {
-    d.appendVar("PACKAGES", " kernel-devicetree")
+    d.appendVar("PACKAGES", " ${KERNEL_PACKAGE_NAME}-devicetree")
 }
 
 normalize_dtb () {
diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc
index 637506a2a8..4e0ce029da 100644
--- a/meta/recipes-kernel/linux/linux-yocto.inc
+++ b/meta/recipes-kernel/linux/linux-yocto.inc
@@ -12,7 +12,7 @@ INC_PR = "r4"
 # PREFERRED_PROVIDER for virtual/kernel. This avoids network access required
 # by the use of AUTOREV SRCREVs, which are the default for this recipe.
 python () {
-    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != d.getVar("PN"):
+    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN", True):
         d.delVar("BB_DONT_CACHE")
         raise bb.parse.SkipPackage("Set PREFERRED_PROVIDER_virtual/kernel to %s to enable it" % (d.getVar("PN")))
 }
-- 
2.13.2



^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v6] kernel: Add support for multiple kernel packages
  2017-07-19 15:56     ` Wold, Saul
                         ` (2 preceding siblings ...)
  2017-08-08 15:34       ` [PATCH v5] " Haris Okanovic
@ 2017-08-14 21:29       ` Haris Okanovic
  2017-08-16 16:00         ` Wold, Saul
  2017-08-17 21:14       ` [PATCH v7] " Haris Okanovic
                         ` (2 subsequent siblings)
  6 siblings, 1 reply; 31+ messages in thread
From: Haris Okanovic @ 2017-08-14 21:29 UTC (permalink / raw)
  To: openembedded-core; +Cc: haris.okanovic, saul.wold, josh.hernstrom

Some distros may want to provide alternate kernel "flavors" via feeds or
within bootable images. For example, readily available builds which
provide certain diagnostic features can enable developers and testers to
more quickly resolve issues by avoiding lengthy kernel builds.

This change allows for building multiple flavors of the kernel and
module packages by templatizing kernel package names via a new
KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the old
name of "kernel", but can be overridden by certain recipes providing
alternate kernel flavors.

To maintain compatibility, recipes providing alternate kernel flavors
cannot be the "preferred provider" for virtual/kernel. This is because
OE puts the preferred provider's build and source at
"tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
"tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
"tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using the
default KERNEL_PACKAGE_NAME="kernel" follows the old semantics -- build
in the old location and may be preferred provider -- while recipes using
all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and don't
provide "virtual/kernel".

Testing:
 1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
    linux-yocto-tiny_4.9.bb so that it may build alongside
    the main kernel.
 2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel flavors.
 3. Verified image and modules IPKs exist for both:
    tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
    tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
 4. Verified linux-yocto is the "preferred provider", and was built in
    shared directory: tmp-glibc/work-shared/qemux86/kernel-*
 5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
    core-image-base.bb to include both kernel flavors.
 6. `bitbake core-image-base` to build an image.
 7. Verified image contains two bzImage's under /boot/, with
    "yocto-standard" selected to boot via symlink.

Discussion threads:
http://lists.openembedded.org/pipermail/openembedded-core/2015-December/thread.html#114122
http://lists.openembedded.org/pipermail/openembedded-core/2017-July/thread.html#139130

Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
---
[PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to the
"work" directory in alternate kernel builds, instead of "work-shared",
so
that the two builds don't clobber each other.

[PATCH v3] An updated version of this change rebased onto the current
OE-core master. Changes:
 - Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
   kernel builds, since alternate kernels aren't the
   PREFERRED_PROVIDER for virtual/kernel by definition.
 - Remove "virtual/kernel" from PROVIDES in alternate kernel builds.

[PATCH v4] Another rebase onto master; no functional change.
Improved description and testing steps.

[PATCH v5]
 - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
 - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions

[PATCH v6] Add KERNEL_PACKAGE_NAME to kernel-module-split.bbclass for
module recipes; fixes lttng-modules build.

https://github.com/harisokanovic/openembedded-core/tree/dev/hokanovi/multi-kernel-packages-v6
---
 meta/classes/kernel-module-split.bbclass  |  14 +++-
 meta/classes/kernel.bbclass               | 114 +++++++++++++++++++-----------
 meta/conf/documentation.conf              |   1 +
 meta/recipes-kernel/linux/linux-dtb.inc   |   2 +-
 meta/recipes-kernel/linux/linux-yocto.inc |   2 +-
 5 files changed, 86 insertions(+), 47 deletions(-)

diff --git a/meta/classes/kernel-module-split.bbclass b/meta/classes/kernel-module-split.bbclass
index 1035525dac..59f19f3de2 100644
--- a/meta/classes/kernel-module-split.bbclass
+++ b/meta/classes/kernel-module-split.bbclass
@@ -30,7 +30,12 @@ do_install_append() {
 
 PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
 
-KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
+# Default KERNEL_PACKAGE_NAME should match kernel.bbclass
+# Redefined here since some recipes only build modules and therefore
+# don't consume kernel.bbclass to get this default.
+KERNEL_PACKAGE_NAME ??= "kernel"
+
+KERNEL_MODULES_META_PACKAGE ?= "${KERNEL_PACKAGE_NAME}-modules"
 
 KERNEL_MODULE_PACKAGE_PREFIX ?= ""
 KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
@@ -129,16 +134,19 @@ python split_kernel_module_packages () {
            postfix = format.split('%s')[1]
            d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
 
+    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True)
+    kernel_version = d.getVar("KERNEL_VERSION", True)
+
     module_regex = '^(.*)\.k?o$'
 
     module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
     module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
-    module_pattern = module_pattern_prefix + 'kernel-module-%s' + module_pattern_suffix
+    module_pattern = module_pattern_prefix + kernel_package_name + '-module-%s' + module_pattern_suffix
 
     postinst = d.getVar('pkg_postinst_modules')
     postrm = d.getVar('pkg_postrm_modules')
 
-    modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
+    modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='%s-%s' % (kernel_package_name, kernel_version))
     if modules:
         metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
         d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index 7670c7107a..0760bfb2c9 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -1,6 +1,9 @@
 inherit linux-kernel-base kernel-module-split
 
-PROVIDES += "virtual/kernel"
+KERNEL_PACKAGE_NAME ??= "kernel"
+KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
+
+PROVIDES += "${@ "virtual/kernel" if (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
 DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
 PACKAGE_WRITE_DEPS += "depmodwrapper-cross virtual/update-alternatives-native"
 
@@ -32,11 +35,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION')
 KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
 
 python __anonymous () {
+    pn = d.getVar("PN", True)
+    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
+
+    # XXX Remove this after bug 11905 is resolved
+    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
+    if kpn == pn:
+        bb.warn("Some packages (E.g. *-dev) might be missing due to "
+                "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
+
+    # The default kernel recipe builds in a shared location defined by
+    # bitbake/distro confs: STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR.
+    # Set these variables to directories under ${WORKDIR} in alternate
+    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so that they
+    # may build in parallel with the default kernel without clobbering.
+    if kpn != "kernel":
+        workdir = d.getVar("WORKDIR", True)
+        sourceDir = os.path.join(workdir, 'kernel-source')
+        artifactsDir = os.path.join(workdir, 'kernel-build-artifacts')
+        d.setVar("STAGING_KERNEL_DIR", sourceDir)
+        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
 
     # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES
     type = d.getVar('KERNEL_IMAGETYPE') or ""
     alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
     types = d.getVar('KERNEL_IMAGETYPES') or ""
+    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
     if type not in types.split():
         types = (type + ' ' + types).strip()
     if alttype not in types.split():
@@ -53,22 +77,22 @@ python __anonymous () {
         typelower = type.lower()
         imagedest = d.getVar('KERNEL_IMAGEDEST')
 
-        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
+        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
 
-        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
+        d.setVar('FILES_' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
 
-        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' + typelower)
+        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' % (kname, typelower))
 
-        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' + typelower + '-${KERNEL_VERSION_PKG_NAME}')
+        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
 
-        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
+        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower), '1')
 
         priority = d.getVar('KERNEL_PRIORITY')
         postinst = '#!/bin/sh\n' + 'update-alternatives --install /' + imagedest + '/' + type + ' ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
-        d.setVar('pkg_postinst_kernel-image-' + typelower, postinst)
+        d.setVar('pkg_postinst_' + kname + '-image-' + typelower, postinst)
 
         postrm = '#!/bin/sh\n' + 'update-alternatives --remove' + ' ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n'
-        d.setVar('pkg_postrm_kernel-image-' + typelower, postrm)
+        d.setVar('pkg_postrm_%s-image-%s' % (kname, typelower), postrm)
 
     image = d.getVar('INITRAMFS_IMAGE')
     if image:
@@ -126,9 +150,9 @@ base_do_unpack_append () {
 
 inherit kernel-arch deploy
 
-PACKAGES_DYNAMIC += "^kernel-module-.*"
-PACKAGES_DYNAMIC += "^kernel-image-.*"
-PACKAGES_DYNAMIC += "^kernel-firmware-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
 
 export OS = "${TARGET_OS}"
 export CROSS_COMPILE = "${TARGET_PREFIX}"
@@ -371,9 +395,9 @@ do_shared_workdir_setscene () {
 
 emit_depmod_pkgdata() {
 	# Stash data for depmod
-	install -d ${PKGDESTWORK}/kernel-depmod/
-	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-depmod/kernel-abiversion
-	cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-${KERNEL_VERSION}
+	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
+	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-abiversion
+	cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/System.map-${KERNEL_VERSION}
 }
 
 PACKAGEFUNCS += "emit_depmod_pkgdata"
@@ -388,7 +412,7 @@ do_shared_workdir () {
 	# Store the kernel version in sysroots for module-base.bbclass
 	#
 
-	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
+	echo "${KERNEL_VERSION}" > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
 
 	# Copy files required for module builds
 	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
@@ -486,28 +510,28 @@ EXPORT_FUNCTIONS do_compile do_install do_configure
 
 # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
 FILES_${PN} = ""
-FILES_kernel-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
-FILES_kernel-image = ""
-FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
-FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
-FILES_kernel-modules = ""
-RDEPENDS_kernel = "kernel-base"
+FILES_${KERNEL_PACKAGE_NAME}-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
+FILES_${KERNEL_PACKAGE_NAME}-image = ""
+FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
+FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
+FILES_${KERNEL_PACKAGE_NAME}-modules = ""
+RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
 # Allow machines to override this dependency if kernel image files are
 # not wanted in images as standard
-RDEPENDS_kernel-base ?= "kernel-image"
-PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
-RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', 'kernel-vmlinux', '', d)}"
-PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSION}')}"
-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"
-
-pkg_postinst_kernel-base () {
+RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-image"
+PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
+RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
+PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitimize_package_name('${KERNEL_VERSION}')}"
+RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-${KERNEL_VERSION}"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
+DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta package"
+
+pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
 	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
 		mkdir -p $D/lib/modules/${KERNEL_VERSION}
 	fi
@@ -521,7 +545,7 @@ pkg_postinst_kernel-base () {
 PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
 
 python split_kernel_packages () {
-    do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
+    do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
 }
 
 # Many scripts want to look in arch/$arch/boot for the bootable
@@ -604,21 +628,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-${MACHINE}.tgz"
 MODULE_TARBALL_DEPLOY ?= "1"
 
 kernel_do_deploy() {
+	deployDir="${DEPLOYDIR}"
+	if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
+		deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
+		mkdir "$deployDir"
+	fi
+
 	for type in ${KERNEL_IMAGETYPES} ; do
 		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
-		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${DEPLOYDIR}/${base_name}.bin
+		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} $deployDir/${base_name}.bin
 	done
 	if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
 		mkdir -p ${D}/lib
-		tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
-		ln -sf ${MODULE_TARBALL_BASE_NAME} ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
+		tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
+		ln -sf ${MODULE_TARBALL_BASE_NAME} $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
 	fi
 
 	for type in ${KERNEL_IMAGETYPES} ; do
 		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
 		symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
-		ln -sf ${base_name}.bin ${DEPLOYDIR}/${symlink_name}.bin
-		ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
+		ln -sf ${base_name}.bin $deployDir/${symlink_name}.bin
+		ln -sf ${base_name}.bin $deployDir/${type}
 	done
 
 	cd ${B}
@@ -628,8 +658,8 @@ kernel_do_deploy() {
 			echo "Copying deploy ${type} kernel-initramfs image and setting up links..."
 			initramfs_base_name=${type}-${INITRAMFS_BASE_NAME}
 			initramfs_symlink_name=${type}-initramfs-${MACHINE}
-			install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs ${DEPLOYDIR}/${initramfs_base_name}.bin
-			ln -sf ${initramfs_base_name}.bin ${DEPLOYDIR}/${initramfs_symlink_name}.bin
+			install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs $deployDir/${initramfs_base_name}.bin
+			ln -sf ${initramfs_base_name}.bin $deployDir/${initramfs_symlink_name}.bin
 		fi
 	done
 }
diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
index 35b9103b4a..e061b98de3 100644
--- a/meta/conf/documentation.conf
+++ b/meta/conf/documentation.conf
@@ -248,6 +248,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to build for a device, usually set b
 KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a device, usually set by the machine configuration files and defaults to KERNEL_IMAGETYPE."
 KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be auto-loaded during boot"
 KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the build system expects to find module_conf_* values that specify configuration for each of the modules"
+KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages. Defaults to 'kernel'."
 KERNEL_PATH[doc] = "The location of the kernel sources. This variable is set to the value of the STAGING_KERNEL_DIR within the module class (module.bbclass)."
 KERNEL_SRC[doc] = "The location of the kernel sources. This variable is set to the value of the STAGING_KERNEL_DIR within the module class (module.bbclass)."
 KFEATURE_DESCRIPTION[doc] = "Provides a short description of a configuration fragment. You use this variable in the .scc file that describes a configuration fragment file."
diff --git a/meta/recipes-kernel/linux/linux-dtb.inc b/meta/recipes-kernel/linux/linux-dtb.inc
index 0174c80d85..da6467bf9f 100644
--- a/meta/recipes-kernel/linux/linux-dtb.inc
+++ b/meta/recipes-kernel/linux/linux-dtb.inc
@@ -4,7 +4,7 @@ FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/devicetree*"
 PACKAGE_WRITE_DEPS += "virtual/update-alternatives-native"
 
 python __anonymous () {
-    d.appendVar("PACKAGES", " kernel-devicetree")
+    d.appendVar("PACKAGES", " ${KERNEL_PACKAGE_NAME}-devicetree")
 }
 
 normalize_dtb () {
diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc
index 637506a2a8..4e0ce029da 100644
--- a/meta/recipes-kernel/linux/linux-yocto.inc
+++ b/meta/recipes-kernel/linux/linux-yocto.inc
@@ -12,7 +12,7 @@ INC_PR = "r4"
 # PREFERRED_PROVIDER for virtual/kernel. This avoids network access required
 # by the use of AUTOREV SRCREVs, which are the default for this recipe.
 python () {
-    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != d.getVar("PN"):
+    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN", True):
         d.delVar("BB_DONT_CACHE")
         raise bb.parse.SkipPackage("Set PREFERRED_PROVIDER_virtual/kernel to %s to enable it" % (d.getVar("PN")))
 }
-- 
2.13.2



^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH v6] kernel: Add support for multiple kernel packages
  2017-08-14 21:29       ` [PATCH v6] " Haris Okanovic
@ 2017-08-16 16:00         ` Wold, Saul
  2017-08-17 21:13           ` Haris Okanovic
  0 siblings, 1 reply; 31+ messages in thread
From: Wold, Saul @ 2017-08-16 16:00 UTC (permalink / raw)
  To: openembedded-core, haris.okanovic; +Cc: josh.hernstrom

On Mon, 2017-08-14 at 16:29 -0500, Haris Okanovic wrote:
> Some distros may want to provide alternate kernel "flavors" via feeds
> or
> within bootable images. For example, readily available builds which
> provide certain diagnostic features can enable developers and testers
> to
> more quickly resolve issues by avoiding lengthy kernel builds.
> 
> This change allows for building multiple flavors of the kernel and
> module packages by templatizing kernel package names via a new
> KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the
> old
> name of "kernel", but can be overridden by certain recipes providing
> alternate kernel flavors.
> 
> To maintain compatibility, recipes providing alternate kernel flavors
> cannot be the "preferred provider" for virtual/kernel. This is
> because
> OE puts the preferred provider's build and source at
> "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
> "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
> "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using
> the
> default KERNEL_PACKAGE_NAME="kernel" follows the old semantics --
> build
> in the old location and may be preferred provider -- while recipes
> using
> all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and
> don't
> provide "virtual/kernel".
> 
> Testing:
>  1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
>     linux-yocto-tiny_4.9.bb so that it may build alongside
>     the main kernel.
>  2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel
> flavors.
>  3. Verified image and modules IPKs exist for both:
>     tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>     tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
>  4. Verified linux-yocto is the "preferred provider", and was built
> in
>     shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>  5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
>     core-image-base.bb to include both kernel flavors.
>  6. `bitbake core-image-base` to build an image.
>  7. Verified image contains two bzImage's under /boot/, with
>     "yocto-standard" selected to boot via symlink.
> 
> Discussion threads:
> http://lists.openembedded.org/pipermail/openembedded-core/2015-Decemb
> er/thread.html#114122
> http://lists.openembedded.org/pipermail/openembedded-core/2017-July/t
> hread.html#139130
> 
> Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
> Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
> Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
> Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
> Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
> Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
> ---
> [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to
> the
> "work" directory in alternate kernel builds, instead of "work-
> shared",
> so
> that the two builds don't clobber each other.
> 
> [PATCH v3] An updated version of this change rebased onto the current
> OE-core master. Changes:
>  - Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
>    kernel builds, since alternate kernels aren't the
>    PREFERRED_PROVIDER for virtual/kernel by definition.
>  - Remove "virtual/kernel" from PROVIDES in alternate kernel builds.
> 
> [PATCH v4] Another rebase onto master; no functional change.
> Improved description and testing steps.
> 
> [PATCH v5]
>  - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
>  - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions
> 
> [PATCH v6] Add KERNEL_PACKAGE_NAME to kernel-module-split.bbclass for
> module recipes; fixes lttng-modules build.
> 
> https://github.com/harisokanovic/openembedded-core/tree/dev/hokanovi/
> multi-kernel-packages-v6
> ---
>  meta/classes/kernel-module-split.bbclass  |  14 +++-
>  meta/classes/kernel.bbclass               | 114 +++++++++++++++++++-
> ----------
>  meta/conf/documentation.conf              |   1 +
>  meta/recipes-kernel/linux/linux-dtb.inc   |   2 +-
>  meta/recipes-kernel/linux/linux-yocto.inc |   2 +-
>  5 files changed, 86 insertions(+), 47 deletions(-)
> 
> diff --git a/meta/classes/kernel-module-split.bbclass
> b/meta/classes/kernel-module-split.bbclass
> index 1035525dac..59f19f3de2 100644
> --- a/meta/classes/kernel-module-split.bbclass
> +++ b/meta/classes/kernel-module-split.bbclass
> @@ -30,7 +30,12 @@ do_install_append() {
>  
>  PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>  
> -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
> +# Default KERNEL_PACKAGE_NAME should match kernel.bbclass
> +# Redefined here since some recipes only build modules and therefore
> +# don't consume kernel.bbclass to get this default.
> +KERNEL_PACKAGE_NAME ??= "kernel"
> +
> +KERNEL_MODULES_META_PACKAGE ?= "${KERNEL_PACKAGE_NAME}-modules"
>  
Sorry, I missed that you sent this on Monday when I replied to your
"thoughts?" question from V5.

I think we should really be checking if KERNEL_PACKAGE_NAME is set
already when you use it and default to kernel if it does not exist
rather than having 2 places where KERNEL_PACKAGE_NAME is ??= set.

Sorry about the timing.

Sau!

>  KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>  KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
> @@ -129,16 +134,19 @@ python split_kernel_module_packages () {
>             postfix = format.split('%s')[1]
>             d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
>  
> +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True)
> +    kernel_version = d.getVar("KERNEL_VERSION", True)
> +
>      module_regex = '^(.*)\.k?o$'
>  
>      module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>      module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
> -    module_pattern = module_pattern_prefix + 'kernel-module-%s' +
> module_pattern_suffix
> +    module_pattern = module_pattern_prefix + kernel_package_name +
> '-module-%s' + module_pattern_suffix
>  
>      postinst = d.getVar('pkg_postinst_modules')
>      postrm = d.getVar('pkg_postrm_modules')
>  
> -    modules = do_split_packages(d,
> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
> output_pattern=module_pattern, description='%s kernel module',
> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
> extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
> +    modules = do_split_packages(d,
> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
> output_pattern=module_pattern, description='%s kernel module',
> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
> extra_depends='%s-%s' % (kernel_package_name, kernel_version))
>      if modules:
>          metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>          d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
> diff --git a/meta/classes/kernel.bbclass
> b/meta/classes/kernel.bbclass
> index 7670c7107a..0760bfb2c9 100644
> --- a/meta/classes/kernel.bbclass
> +++ b/meta/classes/kernel.bbclass
> @@ -1,6 +1,9 @@
>  inherit linux-kernel-base kernel-module-split
>  
> -PROVIDES += "virtual/kernel"
> +KERNEL_PACKAGE_NAME ??= "kernel"
> +KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME",
> True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
> +
> +PROVIDES += "${@ "virtual/kernel" if
> (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
>  DEPENDS += "virtual/${TARGET_PREFIX}binutils
> virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
>  PACKAGE_WRITE_DEPS += "depmodwrapper-cross virtual/update-
> alternatives-native"
>  
> @@ -32,11 +35,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_
> name(d.getVar('KERNEL_VERSION')
>  KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
>  
>  python __anonymous () {
> +    pn = d.getVar("PN", True)
> +    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
> +
> +    # XXX Remove this after bug 11905 is resolved
> +    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
> +    if kpn == pn:
> +        bb.warn("Some packages (E.g. *-dev) might be missing due to
> "
> +                "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
> +
> +    # The default kernel recipe builds in a shared location defined
> by
> +    # bitbake/distro confs: STAGING_KERNEL_DIR and
> STAGING_KERNEL_BUILDDIR.
> +    # Set these variables to directories under ${WORKDIR} in
> alternate
> +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so
> that they
> +    # may build in parallel with the default kernel without
> clobbering.
> +    if kpn != "kernel":
> +        workdir = d.getVar("WORKDIR", True)
> +        sourceDir = os.path.join(workdir, 'kernel-source')
> +        artifactsDir = os.path.join(workdir, 'kernel-build-
> artifacts')
> +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
> +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
>  
>      # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
> KERNEL_IMAGETYPES
>      type = d.getVar('KERNEL_IMAGETYPE') or ""
>      alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>      types = d.getVar('KERNEL_IMAGETYPES') or ""
> +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
>      if type not in types.split():
>          types = (type + ' ' + types).strip()
>      if alttype not in types.split():
> @@ -53,22 +77,22 @@ python __anonymous () {
>          typelower = type.lower()
>          imagedest = d.getVar('KERNEL_IMAGEDEST')
>  
> -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
> +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
>  
> -        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest
> + '/' + type + '-${KERNEL_VERSION_NAME}')
> +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' +
> imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
>  
> -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' +
> typelower)
> +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' %
> (kname, typelower))
>  
> -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' +
> typelower + '-${KERNEL_VERSION_PKG_NAME}')
> +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-
> %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>  
> -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
> +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower),
> '1')
>  
>          priority = d.getVar('KERNEL_PRIORITY')
>          postinst = '#!/bin/sh\n' + 'update-alternatives --install /'
> + imagedest + '/' + type + ' ' + type + ' ' + type + '-
> ${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
> -        d.setVar('pkg_postinst_kernel-image-' + typelower, postinst)
> +        d.setVar('pkg_postinst_' + kname + '-image-' + typelower,
> postinst)
>  
>          postrm = '#!/bin/sh\n' + 'update-alternatives --remove' + '
> ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n'
> -        d.setVar('pkg_postrm_kernel-image-' + typelower, postrm)
> +        d.setVar('pkg_postrm_%s-image-%s' % (kname, typelower),
> postrm)
>  
>      image = d.getVar('INITRAMFS_IMAGE')
>      if image:
> @@ -126,9 +150,9 @@ base_do_unpack_append () {
>  
>  inherit kernel-arch deploy
>  
> -PACKAGES_DYNAMIC += "^kernel-module-.*"
> -PACKAGES_DYNAMIC += "^kernel-image-.*"
> -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>  
>  export OS = "${TARGET_OS}"
>  export CROSS_COMPILE = "${TARGET_PREFIX}"
> @@ -371,9 +395,9 @@ do_shared_workdir_setscene () {
>  
>  emit_depmod_pkgdata() {
>  	# Stash data for depmod
> -	install -d ${PKGDESTWORK}/kernel-depmod/
> -	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
> depmod/kernel-abiversion
> -	cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-
> ${KERNEL_VERSION}
> +	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
> +	echo "${KERNEL_VERSION}" >
> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-
> abiversion
> +	cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
> depmod/System.map-${KERNEL_VERSION}
>  }
>  
>  PACKAGEFUNCS += "emit_depmod_pkgdata"
> @@ -388,7 +412,7 @@ do_shared_workdir () {
>  	# Store the kernel version in sysroots for module-
> base.bbclass
>  	#
>  
> -	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
> +	echo "${KERNEL_VERSION}" >
> $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>  
>  	# Copy files required for module builds
>  	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
> @@ -486,28 +510,28 @@ EXPORT_FUNCTIONS do_compile do_install
> do_configure
>  
>  # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base
> ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
> ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>  FILES_${PN} = ""
> -FILES_kernel-base =
> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
> -FILES_kernel-image = ""
> -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
> /boot/config* ${KERNEL_SRC_PATH}
> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
> -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
> -FILES_kernel-modules = ""
> -RDEPENDS_kernel = "kernel-base"
> +FILES_${KERNEL_PACKAGE_NAME}-base =
> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
> +FILES_${KERNEL_PACKAGE_NAME}-image = ""
> +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
> /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
> +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
> ${KERNEL_VERSION_NAME}"
> +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
> +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
>  # Allow machines to override this dependency if kernel image files
> are
>  # not wanted in images as standard
> -RDEPENDS_kernel-base ?= "kernel-image"
> -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNE
> L_VERSION}')}"
> -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE',
> 'vmlinux', 'kernel-vmlinux', '', d)}"
> -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSI
> ON}')}"
> -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"
> -
> -pkg_postinst_kernel-base () {
> +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-
> image"
> +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@
> legitimize_package_name('${KERNEL_VERSION}')}"
> +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNE
> L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
> +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitim
> ize_package_name('${KERNEL_VERSION}')}"
> +RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-
> ${KERNEL_VERSION}"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
> +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta
> package"
> +
> +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>  	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>  		mkdir -p $D/lib/modules/${KERNEL_VERSION}
>  	fi
> @@ -521,7 +545,7 @@ pkg_postinst_kernel-base () {
>  PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>  
>  python split_kernel_packages () {
> -    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-
> firmware-%s', description='Firmware for %s', recursive=True,
> extra_depends='')
> +    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
> output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
> description='Firmware for %s', recursive=True, extra_depends='')
>  }
>  
>  # Many scripts want to look in arch/$arch/boot for the bootable
> @@ -604,21 +628,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-
> ${MACHINE}.tgz"
>  MODULE_TARBALL_DEPLOY ?= "1"
>  
>  kernel_do_deploy() {
> +	deployDir="${DEPLOYDIR}"
> +	if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
> +		deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
> +		mkdir "$deployDir"
> +	fi
> +
>  	for type in ${KERNEL_IMAGETYPES} ; do
>  		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
> -		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
> ${DEPLOYDIR}/${base_name}.bin
> +		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
> $deployDir/${base_name}.bin
>  	done
>  	if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e
> '^CONFIG_MODULES=y$' .config); then
>  		mkdir -p ${D}/lib
> -		tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME}
> -C ${D} lib
> -		ln -sf ${MODULE_TARBALL_BASE_NAME}
> ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
> +		tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME} -C
> ${D} lib
> +		ln -sf ${MODULE_TARBALL_BASE_NAME}
> $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
>  	fi
>  
>  	for type in ${KERNEL_IMAGETYPES} ; do
>  		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>  		symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
> -		ln -sf ${base_name}.bin
> ${DEPLOYDIR}/${symlink_name}.bin
> -		ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
> +		ln -sf ${base_name}.bin
> $deployDir/${symlink_name}.bin
> +		ln -sf ${base_name}.bin $deployDir/${type}
>  	done
>  
>  	cd ${B}
> @@ -628,8 +658,8 @@ kernel_do_deploy() {
>  			echo "Copying deploy ${type} kernel-
> initramfs image and setting up links..."
>  			initramfs_base_name=${type}-
> ${INITRAMFS_BASE_NAME}
>  			initramfs_symlink_name=${type}-initramfs-
> ${MACHINE}
> -			install -m 0644
> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
> ${DEPLOYDIR}/${initramfs_base_name}.bin
> -			ln -sf ${initramfs_base_name}.bin
> ${DEPLOYDIR}/${initramfs_symlink_name}.bin
> +			install -m 0644
> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
> $deployDir/${initramfs_base_name}.bin
> +			ln -sf ${initramfs_base_name}.bin
> $deployDir/${initramfs_symlink_name}.bin
>  		fi
>  	done
>  }
> diff --git a/meta/conf/documentation.conf
> b/meta/conf/documentation.conf
> index 35b9103b4a..e061b98de3 100644
> --- a/meta/conf/documentation.conf
> +++ b/meta/conf/documentation.conf
> @@ -248,6 +248,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to
> build for a device, usually set b
>  KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a
> device, usually set by the machine configuration files and defaults
> to KERNEL_IMAGETYPE."
>  KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be
> auto-loaded during boot"
>  KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the
> build system expects to find module_conf_* values that specify
> configuration for each of the modules"
> +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
> Defaults to 'kernel'."
>  KERNEL_PATH[doc] = "The location of the kernel sources. This
> variable is set to the value of the STAGING_KERNEL_DIR within the
> module class (module.bbclass)."
>  KERNEL_SRC[doc] = "The location of the kernel sources. This variable
> is set to the value of the STAGING_KERNEL_DIR within the module class
> (module.bbclass)."
>  KFEATURE_DESCRIPTION[doc] = "Provides a short description of a
> configuration fragment. You use this variable in the .scc file that
> describes a configuration fragment file."
> diff --git a/meta/recipes-kernel/linux/linux-dtb.inc b/meta/recipes-
> kernel/linux/linux-dtb.inc
> index 0174c80d85..da6467bf9f 100644
> --- a/meta/recipes-kernel/linux/linux-dtb.inc
> +++ b/meta/recipes-kernel/linux/linux-dtb.inc
> @@ -4,7 +4,7 @@ FILES_kernel-devicetree =
> "/${KERNEL_IMAGEDEST}/devicetree*"
>  PACKAGE_WRITE_DEPS += "virtual/update-alternatives-native"
>  
>  python __anonymous () {
> -    d.appendVar("PACKAGES", " kernel-devicetree")
> +    d.appendVar("PACKAGES", " ${KERNEL_PACKAGE_NAME}-devicetree")
>  }
>  
>  normalize_dtb () {
> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
> b/meta/recipes-kernel/linux/linux-yocto.inc
> index 637506a2a8..4e0ce029da 100644
> --- a/meta/recipes-kernel/linux/linux-yocto.inc
> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
> @@ -12,7 +12,7 @@ INC_PR = "r4"
>  # PREFERRED_PROVIDER for virtual/kernel. This avoids network access
> required
>  # by the use of AUTOREV SRCREVs, which are the default for this
> recipe.
>  python () {
> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
> d.getVar("PN"):
> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
> d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN",
> True):
>          d.delVar("BB_DONT_CACHE")
>          raise bb.parse.SkipPackage("Set
> PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
> (d.getVar("PN")))
>  }

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v6] kernel: Add support for multiple kernel packages
  2017-08-16 16:00         ` Wold, Saul
@ 2017-08-17 21:13           ` Haris Okanovic
  0 siblings, 0 replies; 31+ messages in thread
From: Haris Okanovic @ 2017-08-17 21:13 UTC (permalink / raw)
  To: Wold, Saul, openembedded-core; +Cc: josh.hernstrom



On 08/16/2017 11:00 AM, Wold, Saul wrote:
> On Mon, 2017-08-14 at 16:29 -0500, Haris Okanovic wrote:
>> Some distros may want to provide alternate kernel "flavors" via feeds
>> or
>> within bootable images. For example, readily available builds which
>> provide certain diagnostic features can enable developers and testers
>> to
>> more quickly resolve issues by avoiding lengthy kernel builds.
>>
>> This change allows for building multiple flavors of the kernel and
>> module packages by templatizing kernel package names via a new
>> KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the
>> old
>> name of "kernel", but can be overridden by certain recipes providing
>> alternate kernel flavors.
>>
>> To maintain compatibility, recipes providing alternate kernel flavors
>> cannot be the "preferred provider" for virtual/kernel. This is
>> because
>> OE puts the preferred provider's build and source at
>> "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
>> "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
>> "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using
>> the
>> default KERNEL_PACKAGE_NAME="kernel" follows the old semantics --
>> build
>> in the old location and may be preferred provider -- while recipes
>> using
>> all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and
>> don't
>> provide "virtual/kernel".
>>
>> Testing:
>>   1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
>>      linux-yocto-tiny_4.9.bb so that it may build alongside
>>      the main kernel.
>>   2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel
>> flavors.
>>   3. Verified image and modules IPKs exist for both:
>>      tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>>      tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
>>   4. Verified linux-yocto is the "preferred provider", and was built
>> in
>>      shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>>   5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
>>      core-image-base.bb to include both kernel flavors.
>>   6. `bitbake core-image-base` to build an image.
>>   7. Verified image contains two bzImage's under /boot/, with
>>      "yocto-standard" selected to boot via symlink.
>>
>> Discussion threads:
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org_pipermail_openembedded-2Dcore_2015-2DDecemb&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=0QcXD-YEVpGbAgVAWiuCmMnvCng6N5j5KrqqwqXHW2E&s=88YT5OEfyAkDMCqrZzRoGH6Z8DsSjP8nfCmrq4fronk&e=
>> er/thread.html#114122
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org_pipermail_openembedded-2Dcore_2017-2DJuly_t&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=0QcXD-YEVpGbAgVAWiuCmMnvCng6N5j5KrqqwqXHW2E&s=2NjYYuy80NctfYU9vcnLPueVm9rALs-0nFjVd5cnY8w&e=
>> hread.html#139130
>>
>> Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
>> Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
>> Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
>> Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
>> Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
>> Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
>> ---
>> [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to
>> the
>> "work" directory in alternate kernel builds, instead of "work-
>> shared",
>> so
>> that the two builds don't clobber each other.
>>
>> [PATCH v3] An updated version of this change rebased onto the current
>> OE-core master. Changes:
>>   - Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
>>     kernel builds, since alternate kernels aren't the
>>     PREFERRED_PROVIDER for virtual/kernel by definition.
>>   - Remove "virtual/kernel" from PROVIDES in alternate kernel builds.
>>
>> [PATCH v4] Another rebase onto master; no functional change.
>> Improved description and testing steps.
>>
>> [PATCH v5]
>>   - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
>>   - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions
>>
>> [PATCH v6] Add KERNEL_PACKAGE_NAME to kernel-module-split.bbclass for
>> module recipes; fixes lttng-modules build.
>>
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_harisokanovic_openembedded-2Dcore_tree_dev_hokanovi_&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=0QcXD-YEVpGbAgVAWiuCmMnvCng6N5j5KrqqwqXHW2E&s=HlNgsQzUBE7Qo-WEzXqkx8xf814iqTLQbr-EqAENFKs&e=
>> multi-kernel-packages-v6
>> ---
>>   meta/classes/kernel-module-split.bbclass  |  14 +++-
>>   meta/classes/kernel.bbclass               | 114 +++++++++++++++++++-
>> ----------
>>   meta/conf/documentation.conf              |   1 +
>>   meta/recipes-kernel/linux/linux-dtb.inc   |   2 +-
>>   meta/recipes-kernel/linux/linux-yocto.inc |   2 +-
>>   5 files changed, 86 insertions(+), 47 deletions(-)
>>
>> diff --git a/meta/classes/kernel-module-split.bbclass
>> b/meta/classes/kernel-module-split.bbclass
>> index 1035525dac..59f19f3de2 100644
>> --- a/meta/classes/kernel-module-split.bbclass
>> +++ b/meta/classes/kernel-module-split.bbclass
>> @@ -30,7 +30,12 @@ do_install_append() {
>>   
>>   PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>>   
>> -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
>> +# Default KERNEL_PACKAGE_NAME should match kernel.bbclass
>> +# Redefined here since some recipes only build modules and therefore
>> +# don't consume kernel.bbclass to get this default.
>> +KERNEL_PACKAGE_NAME ??= "kernel"
>> +
>> +KERNEL_MODULES_META_PACKAGE ?= "${KERNEL_PACKAGE_NAME}-modules"
>>   
> Sorry, I missed that you sent this on Monday when I replied to your
> "thoughts?" question from V5.
> 
> I think we should really be checking if KERNEL_PACKAGE_NAME is set
> already when you use it and default to kernel if it does not exist
> rather than having 2 places where KERNEL_PACKAGE_NAME is ??= set.
> 
> Sorry about the timing.
> 

Np. I removed a second definition from kernel-module-split.bbclass and 
applied the default of "kernel" in the two places it's used. Clean 
rebuild of lttng-modules, linux-yocto-tiny, and linux-yocto still works!

I'll post a v7 shortly.

-- Haris

> Sau!
> 
>>   KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>>   KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
>> @@ -129,16 +134,19 @@ python split_kernel_module_packages () {
>>              postfix = format.split('%s')[1]
>>              d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
>>   
>> +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True)
>> +    kernel_version = d.getVar("KERNEL_VERSION", True)
>> +
>>       module_regex = '^(.*)\.k?o$'
>>   
>>       module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>>       module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
>> -    module_pattern = module_pattern_prefix + 'kernel-module-%s' +
>> module_pattern_suffix
>> +    module_pattern = module_pattern_prefix + kernel_package_name +
>> '-module-%s' + module_pattern_suffix
>>   
>>       postinst = d.getVar('pkg_postinst_modules')
>>       postrm = d.getVar('pkg_postrm_modules')
>>   
>> -    modules = do_split_packages(d,
>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>> output_pattern=module_pattern, description='%s kernel module',
>> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
>> extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
>> +    modules = do_split_packages(d,
>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>> output_pattern=module_pattern, description='%s kernel module',
>> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
>> extra_depends='%s-%s' % (kernel_package_name, kernel_version))
>>       if modules:
>>           metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>>           d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
>> diff --git a/meta/classes/kernel.bbclass
>> b/meta/classes/kernel.bbclass
>> index 7670c7107a..0760bfb2c9 100644
>> --- a/meta/classes/kernel.bbclass
>> +++ b/meta/classes/kernel.bbclass
>> @@ -1,6 +1,9 @@
>>   inherit linux-kernel-base kernel-module-split
>>   
>> -PROVIDES += "virtual/kernel"
>> +KERNEL_PACKAGE_NAME ??= "kernel"
>> +KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME",
>> True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
>> +
>> +PROVIDES += "${@ "virtual/kernel" if
>> (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
>>   DEPENDS += "virtual/${TARGET_PREFIX}binutils
>> virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
>>   PACKAGE_WRITE_DEPS += "depmodwrapper-cross virtual/update-
>> alternatives-native"
>>   
>> @@ -32,11 +35,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_
>> name(d.getVar('KERNEL_VERSION')
>>   KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
>>   
>>   python __anonymous () {
>> +    pn = d.getVar("PN", True)
>> +    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
>> +
>> +    # XXX Remove this after bug 11905 is resolved
>> +    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
>> +    if kpn == pn:
>> +        bb.warn("Some packages (E.g. *-dev) might be missing due to
>> "
>> +                "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
>> +
>> +    # The default kernel recipe builds in a shared location defined
>> by
>> +    # bitbake/distro confs: STAGING_KERNEL_DIR and
>> STAGING_KERNEL_BUILDDIR.
>> +    # Set these variables to directories under ${WORKDIR} in
>> alternate
>> +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so
>> that they
>> +    # may build in parallel with the default kernel without
>> clobbering.
>> +    if kpn != "kernel":
>> +        workdir = d.getVar("WORKDIR", True)
>> +        sourceDir = os.path.join(workdir, 'kernel-source')
>> +        artifactsDir = os.path.join(workdir, 'kernel-build-
>> artifacts')
>> +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
>> +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
>>   
>>       # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
>> KERNEL_IMAGETYPES
>>       type = d.getVar('KERNEL_IMAGETYPE') or ""
>>       alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>>       types = d.getVar('KERNEL_IMAGETYPES') or ""
>> +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
>>       if type not in types.split():
>>           types = (type + ' ' + types).strip()
>>       if alttype not in types.split():
>> @@ -53,22 +77,22 @@ python __anonymous () {
>>           typelower = type.lower()
>>           imagedest = d.getVar('KERNEL_IMAGEDEST')
>>   
>> -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
>> +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
>>   
>> -        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest
>> + '/' + type + '-${KERNEL_VERSION_NAME}')
>> +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' +
>> imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
>>   
>> -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' +
>> typelower)
>> +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' %
>> (kname, typelower))
>>   
>> -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' +
>> typelower + '-${KERNEL_VERSION_PKG_NAME}')
>> +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-
>> %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>>   
>> -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
>> +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower),
>> '1')
>>   
>>           priority = d.getVar('KERNEL_PRIORITY')
>>           postinst = '#!/bin/sh\n' + 'update-alternatives --install /'
>> + imagedest + '/' + type + ' ' + type + ' ' + type + '-
>> ${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
>> -        d.setVar('pkg_postinst_kernel-image-' + typelower, postinst)
>> +        d.setVar('pkg_postinst_' + kname + '-image-' + typelower,
>> postinst)
>>   
>>           postrm = '#!/bin/sh\n' + 'update-alternatives --remove' + '
>> ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n'
>> -        d.setVar('pkg_postrm_kernel-image-' + typelower, postrm)
>> +        d.setVar('pkg_postrm_%s-image-%s' % (kname, typelower),
>> postrm)
>>   
>>       image = d.getVar('INITRAMFS_IMAGE')
>>       if image:
>> @@ -126,9 +150,9 @@ base_do_unpack_append () {
>>   
>>   inherit kernel-arch deploy
>>   
>> -PACKAGES_DYNAMIC += "^kernel-module-.*"
>> -PACKAGES_DYNAMIC += "^kernel-image-.*"
>> -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>>   
>>   export OS = "${TARGET_OS}"
>>   export CROSS_COMPILE = "${TARGET_PREFIX}"
>> @@ -371,9 +395,9 @@ do_shared_workdir_setscene () {
>>   
>>   emit_depmod_pkgdata() {
>>   	# Stash data for depmod
>> -	install -d ${PKGDESTWORK}/kernel-depmod/
>> -	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
>> depmod/kernel-abiversion
>> -	cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-
>> ${KERNEL_VERSION}
>> +	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
>> +	echo "${KERNEL_VERSION}" >
>> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-
>> abiversion
>> +	cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
>> depmod/System.map-${KERNEL_VERSION}
>>   }
>>   
>>   PACKAGEFUNCS += "emit_depmod_pkgdata"
>> @@ -388,7 +412,7 @@ do_shared_workdir () {
>>   	# Store the kernel version in sysroots for module-
>> base.bbclass
>>   	#
>>   
>> -	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
>> +	echo "${KERNEL_VERSION}" >
>> $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>>   
>>   	# Copy files required for module builds
>>   	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
>> @@ -486,28 +510,28 @@ EXPORT_FUNCTIONS do_compile do_install
>> do_configure
>>   
>>   # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base
>> ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
>> ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>>   FILES_${PN} = ""
>> -FILES_kernel-base =
>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>> -FILES_kernel-image = ""
>> -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
>> /boot/config* ${KERNEL_SRC_PATH}
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>> -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
>> -FILES_kernel-modules = ""
>> -RDEPENDS_kernel = "kernel-base"
>> +FILES_${KERNEL_PACKAGE_NAME}-base =
>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>> +FILES_${KERNEL_PACKAGE_NAME}-image = ""
>> +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
>> /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>> +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
>> ${KERNEL_VERSION_NAME}"
>> +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
>> +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
>>   # Allow machines to override this dependency if kernel image files
>> are
>>   # not wanted in images as standard
>> -RDEPENDS_kernel-base ?= "kernel-image"
>> -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNE
>> L_VERSION}')}"
>> -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE',
>> 'vmlinux', 'kernel-vmlinux', '', d)}"
>> -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSI
>> ON}')}"
>> -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"
>> -
>> -pkg_postinst_kernel-base () {
>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-
>> image"
>> +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@
>> legitimize_package_name('${KERNEL_VERSION}')}"
>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNE
>> L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
>> +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitim
>> ize_package_name('${KERNEL_VERSION}')}"
>> +RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-
>> ${KERNEL_VERSION}"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
>> +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta
>> package"
>> +
>> +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>>   	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>>   		mkdir -p $D/lib/modules/${KERNEL_VERSION}
>>   	fi
>> @@ -521,7 +545,7 @@ pkg_postinst_kernel-base () {
>>   PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>>   
>>   python split_kernel_packages () {
>> -    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-
>> firmware-%s', description='Firmware for %s', recursive=True,
>> extra_depends='')
>> +    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>> output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
>> description='Firmware for %s', recursive=True, extra_depends='')
>>   }
>>   
>>   # Many scripts want to look in arch/$arch/boot for the bootable
>> @@ -604,21 +628,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-
>> ${MACHINE}.tgz"
>>   MODULE_TARBALL_DEPLOY ?= "1"
>>   
>>   kernel_do_deploy() {
>> +	deployDir="${DEPLOYDIR}"
>> +	if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
>> +		deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
>> +		mkdir "$deployDir"
>> +	fi
>> +
>>   	for type in ${KERNEL_IMAGETYPES} ; do
>>   		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>> -		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>> ${DEPLOYDIR}/${base_name}.bin
>> +		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>> $deployDir/${base_name}.bin
>>   	done
>>   	if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e
>> '^CONFIG_MODULES=y$' .config); then
>>   		mkdir -p ${D}/lib
>> -		tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME}
>> -C ${D} lib
>> -		ln -sf ${MODULE_TARBALL_BASE_NAME}
>> ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
>> +		tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME} -C
>> ${D} lib
>> +		ln -sf ${MODULE_TARBALL_BASE_NAME}
>> $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
>>   	fi
>>   
>>   	for type in ${KERNEL_IMAGETYPES} ; do
>>   		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>>   		symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
>> -		ln -sf ${base_name}.bin
>> ${DEPLOYDIR}/${symlink_name}.bin
>> -		ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
>> +		ln -sf ${base_name}.bin
>> $deployDir/${symlink_name}.bin
>> +		ln -sf ${base_name}.bin $deployDir/${type}
>>   	done
>>   
>>   	cd ${B}
>> @@ -628,8 +658,8 @@ kernel_do_deploy() {
>>   			echo "Copying deploy ${type} kernel-
>> initramfs image and setting up links..."
>>   			initramfs_base_name=${type}-
>> ${INITRAMFS_BASE_NAME}
>>   			initramfs_symlink_name=${type}-initramfs-
>> ${MACHINE}
>> -			install -m 0644
>> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
>> ${DEPLOYDIR}/${initramfs_base_name}.bin
>> -			ln -sf ${initramfs_base_name}.bin
>> ${DEPLOYDIR}/${initramfs_symlink_name}.bin
>> +			install -m 0644
>> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
>> $deployDir/${initramfs_base_name}.bin
>> +			ln -sf ${initramfs_base_name}.bin
>> $deployDir/${initramfs_symlink_name}.bin
>>   		fi
>>   	done
>>   }
>> diff --git a/meta/conf/documentation.conf
>> b/meta/conf/documentation.conf
>> index 35b9103b4a..e061b98de3 100644
>> --- a/meta/conf/documentation.conf
>> +++ b/meta/conf/documentation.conf
>> @@ -248,6 +248,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to
>> build for a device, usually set b
>>   KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a
>> device, usually set by the machine configuration files and defaults
>> to KERNEL_IMAGETYPE."
>>   KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be
>> auto-loaded during boot"
>>   KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the
>> build system expects to find module_conf_* values that specify
>> configuration for each of the modules"
>> +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
>> Defaults to 'kernel'."
>>   KERNEL_PATH[doc] = "The location of the kernel sources. This
>> variable is set to the value of the STAGING_KERNEL_DIR within the
>> module class (module.bbclass)."
>>   KERNEL_SRC[doc] = "The location of the kernel sources. This variable
>> is set to the value of the STAGING_KERNEL_DIR within the module class
>> (module.bbclass)."
>>   KFEATURE_DESCRIPTION[doc] = "Provides a short description of a
>> configuration fragment. You use this variable in the .scc file that
>> describes a configuration fragment file."
>> diff --git a/meta/recipes-kernel/linux/linux-dtb.inc b/meta/recipes-
>> kernel/linux/linux-dtb.inc
>> index 0174c80d85..da6467bf9f 100644
>> --- a/meta/recipes-kernel/linux/linux-dtb.inc
>> +++ b/meta/recipes-kernel/linux/linux-dtb.inc
>> @@ -4,7 +4,7 @@ FILES_kernel-devicetree =
>> "/${KERNEL_IMAGEDEST}/devicetree*"
>>   PACKAGE_WRITE_DEPS += "virtual/update-alternatives-native"
>>   
>>   python __anonymous () {
>> -    d.appendVar("PACKAGES", " kernel-devicetree")
>> +    d.appendVar("PACKAGES", " ${KERNEL_PACKAGE_NAME}-devicetree")
>>   }
>>   
>>   normalize_dtb () {
>> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
>> b/meta/recipes-kernel/linux/linux-yocto.inc
>> index 637506a2a8..4e0ce029da 100644
>> --- a/meta/recipes-kernel/linux/linux-yocto.inc
>> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
>> @@ -12,7 +12,7 @@ INC_PR = "r4"
>>   # PREFERRED_PROVIDER for virtual/kernel. This avoids network access
>> required
>>   # by the use of AUTOREV SRCREVs, which are the default for this
>> recipe.
>>   python () {
>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
>> d.getVar("PN"):
>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>> d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN",
>> True):
>>           d.delVar("BB_DONT_CACHE")
>>           raise bb.parse.SkipPackage("Set
>> PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
>> (d.getVar("PN")))
>>   }


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH v7] kernel: Add support for multiple kernel packages
  2017-07-19 15:56     ` Wold, Saul
                         ` (3 preceding siblings ...)
  2017-08-14 21:29       ` [PATCH v6] " Haris Okanovic
@ 2017-08-17 21:14       ` Haris Okanovic
  2017-09-01 18:09         ` Otavio Salvador
  2017-10-19 19:19       ` [PATCH v8] " Haris Okanovic
  2017-11-07 18:40       ` [PATCH v9] " Haris Okanovic
  6 siblings, 1 reply; 31+ messages in thread
From: Haris Okanovic @ 2017-08-17 21:14 UTC (permalink / raw)
  To: openembedded-core; +Cc: haris.okanovic, saul.wold, josh.hernstrom

Some distros may want to provide alternate kernel "flavors" via feeds or
within bootable images. For example, readily available builds which
provide certain diagnostic features can enable developers and testers to
more quickly resolve issues by avoiding lengthy kernel builds.

This change allows for building multiple flavors of the kernel and
module packages by templatizing kernel package names via a new
KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the old
name of "kernel", but can be overridden by certain recipes providing
alternate kernel flavors.

To maintain compatibility, recipes providing alternate kernel flavors
cannot be the "preferred provider" for virtual/kernel. This is because
OE puts the preferred provider's build and source at
"tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
"tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
"tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using the
default KERNEL_PACKAGE_NAME="kernel" follows the old semantics -- build
in the old location and may be preferred provider -- while recipes using
all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and don't
provide "virtual/kernel".

Testing:
 1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
    linux-yocto-tiny_4.9.bb so that it may build alongside
    the main kernel.
 2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel flavors.
 3. Verified image and modules IPKs exist for both:
    tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
    tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
 4. Verified linux-yocto is the "preferred provider", and was built in
    shared directory: tmp-glibc/work-shared/qemux86/kernel-*
 5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
    core-image-base.bb to include both kernel flavors.
 6. `bitbake core-image-base` to build an image.
 7. Verified image contains two bzImage's under /boot/, with
    "yocto-standard" selected to boot via symlink.

Discussion threads:
http://lists.openembedded.org/pipermail/openembedded-core/2015-December/thread.html#114122
http://lists.openembedded.org/pipermail/openembedded-core/2017-July/thread.html#139130

Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
---
[PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to the
"work" directory in alternate kernel builds, instead of "work-shared",
so
that the two builds don't clobber each other.

[PATCH v3] An updated version of this change rebased onto the current
OE-core master. Changes:
 - Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
   kernel builds, since alternate kernels aren't the
   PREFERRED_PROVIDER for virtual/kernel by definition.
 - Remove "virtual/kernel" from PROVIDES in alternate kernel builds.

[PATCH v4] Another rebase onto master; no functional change.
Improved description and testing steps.

[PATCH v5]
 - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
 - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions

[PATCH v6] Add KERNEL_PACKAGE_NAME to kernel-module-split.bbclass for
module recipes; fixes lttng-modules build.

[PATCH v7] Remove second definition of KERNEL_PACKAGE_NAME from
kernel-module-split.bbclass; apply a default in two places where
KERNEL_PACKAGE_NAME is referenced.

https://github.com/harisokanovic/openembedded-core/tree/dev/hokanovi/multi-kernel-packages-v7
---
 meta/classes/kernel-module-split.bbclass  |   9 ++-
 meta/classes/kernel.bbclass               | 114 +++++++++++++++++++-----------
 meta/conf/documentation.conf              |   1 +
 meta/recipes-kernel/linux/linux-dtb.inc   |   2 +-
 meta/recipes-kernel/linux/linux-yocto.inc |   2 +-
 5 files changed, 81 insertions(+), 47 deletions(-)

diff --git a/meta/classes/kernel-module-split.bbclass b/meta/classes/kernel-module-split.bbclass
index 1035525dac..73c7f18c78 100644
--- a/meta/classes/kernel-module-split.bbclass
+++ b/meta/classes/kernel-module-split.bbclass
@@ -30,7 +30,7 @@ do_install_append() {
 
 PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
 
-KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
+KERNEL_MODULES_META_PACKAGE ?= "${@ d.getVar("KERNEL_PACKAGE_NAME", True) or "kernel" }-modules"
 
 KERNEL_MODULE_PACKAGE_PREFIX ?= ""
 KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
@@ -129,16 +129,19 @@ python split_kernel_module_packages () {
            postfix = format.split('%s')[1]
            d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
 
+    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True) or "kernel"
+    kernel_version = d.getVar("KERNEL_VERSION", True)
+
     module_regex = '^(.*)\.k?o$'
 
     module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
     module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
-    module_pattern = module_pattern_prefix + 'kernel-module-%s' + module_pattern_suffix
+    module_pattern = module_pattern_prefix + kernel_package_name + '-module-%s' + module_pattern_suffix
 
     postinst = d.getVar('pkg_postinst_modules')
     postrm = d.getVar('pkg_postrm_modules')
 
-    modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
+    modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='%s-%s' % (kernel_package_name, kernel_version))
     if modules:
         metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
         d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index 7670c7107a..0760bfb2c9 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -1,6 +1,9 @@
 inherit linux-kernel-base kernel-module-split
 
-PROVIDES += "virtual/kernel"
+KERNEL_PACKAGE_NAME ??= "kernel"
+KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
+
+PROVIDES += "${@ "virtual/kernel" if (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
 DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
 PACKAGE_WRITE_DEPS += "depmodwrapper-cross virtual/update-alternatives-native"
 
@@ -32,11 +35,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION')
 KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
 
 python __anonymous () {
+    pn = d.getVar("PN", True)
+    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
+
+    # XXX Remove this after bug 11905 is resolved
+    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
+    if kpn == pn:
+        bb.warn("Some packages (E.g. *-dev) might be missing due to "
+                "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
+
+    # The default kernel recipe builds in a shared location defined by
+    # bitbake/distro confs: STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR.
+    # Set these variables to directories under ${WORKDIR} in alternate
+    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so that they
+    # may build in parallel with the default kernel without clobbering.
+    if kpn != "kernel":
+        workdir = d.getVar("WORKDIR", True)
+        sourceDir = os.path.join(workdir, 'kernel-source')
+        artifactsDir = os.path.join(workdir, 'kernel-build-artifacts')
+        d.setVar("STAGING_KERNEL_DIR", sourceDir)
+        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
 
     # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES
     type = d.getVar('KERNEL_IMAGETYPE') or ""
     alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
     types = d.getVar('KERNEL_IMAGETYPES') or ""
+    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
     if type not in types.split():
         types = (type + ' ' + types).strip()
     if alttype not in types.split():
@@ -53,22 +77,22 @@ python __anonymous () {
         typelower = type.lower()
         imagedest = d.getVar('KERNEL_IMAGEDEST')
 
-        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
+        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
 
-        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
+        d.setVar('FILES_' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
 
-        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' + typelower)
+        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' % (kname, typelower))
 
-        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' + typelower + '-${KERNEL_VERSION_PKG_NAME}')
+        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
 
-        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
+        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower), '1')
 
         priority = d.getVar('KERNEL_PRIORITY')
         postinst = '#!/bin/sh\n' + 'update-alternatives --install /' + imagedest + '/' + type + ' ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
-        d.setVar('pkg_postinst_kernel-image-' + typelower, postinst)
+        d.setVar('pkg_postinst_' + kname + '-image-' + typelower, postinst)
 
         postrm = '#!/bin/sh\n' + 'update-alternatives --remove' + ' ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n'
-        d.setVar('pkg_postrm_kernel-image-' + typelower, postrm)
+        d.setVar('pkg_postrm_%s-image-%s' % (kname, typelower), postrm)
 
     image = d.getVar('INITRAMFS_IMAGE')
     if image:
@@ -126,9 +150,9 @@ base_do_unpack_append () {
 
 inherit kernel-arch deploy
 
-PACKAGES_DYNAMIC += "^kernel-module-.*"
-PACKAGES_DYNAMIC += "^kernel-image-.*"
-PACKAGES_DYNAMIC += "^kernel-firmware-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
 
 export OS = "${TARGET_OS}"
 export CROSS_COMPILE = "${TARGET_PREFIX}"
@@ -371,9 +395,9 @@ do_shared_workdir_setscene () {
 
 emit_depmod_pkgdata() {
 	# Stash data for depmod
-	install -d ${PKGDESTWORK}/kernel-depmod/
-	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-depmod/kernel-abiversion
-	cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-${KERNEL_VERSION}
+	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
+	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-abiversion
+	cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/System.map-${KERNEL_VERSION}
 }
 
 PACKAGEFUNCS += "emit_depmod_pkgdata"
@@ -388,7 +412,7 @@ do_shared_workdir () {
 	# Store the kernel version in sysroots for module-base.bbclass
 	#
 
-	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
+	echo "${KERNEL_VERSION}" > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
 
 	# Copy files required for module builds
 	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
@@ -486,28 +510,28 @@ EXPORT_FUNCTIONS do_compile do_install do_configure
 
 # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
 FILES_${PN} = ""
-FILES_kernel-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
-FILES_kernel-image = ""
-FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
-FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
-FILES_kernel-modules = ""
-RDEPENDS_kernel = "kernel-base"
+FILES_${KERNEL_PACKAGE_NAME}-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
+FILES_${KERNEL_PACKAGE_NAME}-image = ""
+FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
+FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
+FILES_${KERNEL_PACKAGE_NAME}-modules = ""
+RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
 # Allow machines to override this dependency if kernel image files are
 # not wanted in images as standard
-RDEPENDS_kernel-base ?= "kernel-image"
-PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
-RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', 'kernel-vmlinux', '', d)}"
-PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSION}')}"
-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"
-
-pkg_postinst_kernel-base () {
+RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-image"
+PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
+RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
+PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitimize_package_name('${KERNEL_VERSION}')}"
+RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-${KERNEL_VERSION}"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
+DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta package"
+
+pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
 	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
 		mkdir -p $D/lib/modules/${KERNEL_VERSION}
 	fi
@@ -521,7 +545,7 @@ pkg_postinst_kernel-base () {
 PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
 
 python split_kernel_packages () {
-    do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
+    do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
 }
 
 # Many scripts want to look in arch/$arch/boot for the bootable
@@ -604,21 +628,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-${MACHINE}.tgz"
 MODULE_TARBALL_DEPLOY ?= "1"
 
 kernel_do_deploy() {
+	deployDir="${DEPLOYDIR}"
+	if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
+		deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
+		mkdir "$deployDir"
+	fi
+
 	for type in ${KERNEL_IMAGETYPES} ; do
 		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
-		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${DEPLOYDIR}/${base_name}.bin
+		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} $deployDir/${base_name}.bin
 	done
 	if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
 		mkdir -p ${D}/lib
-		tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
-		ln -sf ${MODULE_TARBALL_BASE_NAME} ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
+		tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
+		ln -sf ${MODULE_TARBALL_BASE_NAME} $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
 	fi
 
 	for type in ${KERNEL_IMAGETYPES} ; do
 		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
 		symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
-		ln -sf ${base_name}.bin ${DEPLOYDIR}/${symlink_name}.bin
-		ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
+		ln -sf ${base_name}.bin $deployDir/${symlink_name}.bin
+		ln -sf ${base_name}.bin $deployDir/${type}
 	done
 
 	cd ${B}
@@ -628,8 +658,8 @@ kernel_do_deploy() {
 			echo "Copying deploy ${type} kernel-initramfs image and setting up links..."
 			initramfs_base_name=${type}-${INITRAMFS_BASE_NAME}
 			initramfs_symlink_name=${type}-initramfs-${MACHINE}
-			install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs ${DEPLOYDIR}/${initramfs_base_name}.bin
-			ln -sf ${initramfs_base_name}.bin ${DEPLOYDIR}/${initramfs_symlink_name}.bin
+			install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs $deployDir/${initramfs_base_name}.bin
+			ln -sf ${initramfs_base_name}.bin $deployDir/${initramfs_symlink_name}.bin
 		fi
 	done
 }
diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
index 35b9103b4a..e061b98de3 100644
--- a/meta/conf/documentation.conf
+++ b/meta/conf/documentation.conf
@@ -248,6 +248,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to build for a device, usually set b
 KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a device, usually set by the machine configuration files and defaults to KERNEL_IMAGETYPE."
 KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be auto-loaded during boot"
 KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the build system expects to find module_conf_* values that specify configuration for each of the modules"
+KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages. Defaults to 'kernel'."
 KERNEL_PATH[doc] = "The location of the kernel sources. This variable is set to the value of the STAGING_KERNEL_DIR within the module class (module.bbclass)."
 KERNEL_SRC[doc] = "The location of the kernel sources. This variable is set to the value of the STAGING_KERNEL_DIR within the module class (module.bbclass)."
 KFEATURE_DESCRIPTION[doc] = "Provides a short description of a configuration fragment. You use this variable in the .scc file that describes a configuration fragment file."
diff --git a/meta/recipes-kernel/linux/linux-dtb.inc b/meta/recipes-kernel/linux/linux-dtb.inc
index 0174c80d85..da6467bf9f 100644
--- a/meta/recipes-kernel/linux/linux-dtb.inc
+++ b/meta/recipes-kernel/linux/linux-dtb.inc
@@ -4,7 +4,7 @@ FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/devicetree*"
 PACKAGE_WRITE_DEPS += "virtual/update-alternatives-native"
 
 python __anonymous () {
-    d.appendVar("PACKAGES", " kernel-devicetree")
+    d.appendVar("PACKAGES", " ${KERNEL_PACKAGE_NAME}-devicetree")
 }
 
 normalize_dtb () {
diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc
index 637506a2a8..4e0ce029da 100644
--- a/meta/recipes-kernel/linux/linux-yocto.inc
+++ b/meta/recipes-kernel/linux/linux-yocto.inc
@@ -12,7 +12,7 @@ INC_PR = "r4"
 # PREFERRED_PROVIDER for virtual/kernel. This avoids network access required
 # by the use of AUTOREV SRCREVs, which are the default for this recipe.
 python () {
-    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != d.getVar("PN"):
+    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN", True):
         d.delVar("BB_DONT_CACHE")
         raise bb.parse.SkipPackage("Set PREFERRED_PROVIDER_virtual/kernel to %s to enable it" % (d.getVar("PN")))
 }
-- 
2.13.2



^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH v7] kernel: Add support for multiple kernel packages
  2017-08-17 21:14       ` [PATCH v7] " Haris Okanovic
@ 2017-09-01 18:09         ` Otavio Salvador
  0 siblings, 0 replies; 31+ messages in thread
From: Otavio Salvador @ 2017-09-01 18:09 UTC (permalink / raw)
  To: Haris Okanovic
  Cc: josh.hernstrom, Saul Wold,
	Patches and discussions about the oe-core layer

On Thu, Aug 17, 2017 at 6:14 PM, Haris Okanovic <haris.okanovic@ni.com> wrote:
...
>  7. Verified image contains two bzImage's under /boot/, with
>     "yocto-standard" selected to boot via symlink.

Please take a look at
https://patchwork.openembedded.org/patch/143549/; it will impact this
change.

I think you could have a symlink with the kernel name on it. So using
your example we'd have a zImage-tiny-linux next to zImage.

...
> [PATCH v5]
>  - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
>  - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions

Instead of a subdir, why not using a suffix? it avoids sub directories
and allows for an easier find of the generated files.


-- 
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH v8] kernel: Add support for multiple kernel packages
  2017-07-19 15:56     ` Wold, Saul
                         ` (4 preceding siblings ...)
  2017-08-17 21:14       ` [PATCH v7] " Haris Okanovic
@ 2017-10-19 19:19       ` Haris Okanovic
  2017-10-23 21:38         ` Saul Wold
  2017-10-25  8:00         ` Bruce Ashfield
  2017-11-07 18:40       ` [PATCH v9] " Haris Okanovic
  6 siblings, 2 replies; 31+ messages in thread
From: Haris Okanovic @ 2017-10-19 19:19 UTC (permalink / raw)
  To: openembedded-core; +Cc: haris.okanovic, saul.wold, josh.hernstrom

Some distros may want to provide alternate kernel "flavors" via feeds or
within bootable images. For example, readily available builds which
provide certain diagnostic features can enable developers and testers to
more quickly resolve issues by avoiding lengthy kernel builds.

This change allows for building multiple flavors of the kernel and
module packages by templatizing kernel package names via a new
KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the old
name of "kernel", but can be overridden by certain recipes providing
alternate kernel flavors.

To maintain compatibility, recipes providing alternate kernel flavors
cannot be the "preferred provider" for virtual/kernel. This is because
OE puts the preferred provider's build and source at
"tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
"tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
"tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using the
default KERNEL_PACKAGE_NAME="kernel" follows the old semantics -- build
in the old location and may be preferred provider -- while recipes using
all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and don't
provide "virtual/kernel".

Testing:
 1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
    linux-yocto-tiny_4.9.bb so that it may build alongside
    the main kernel.
 2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel flavors.
 3. Verified image and modules IPKs exist for both:
    tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
    tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
 4. Verified linux-yocto is the "preferred provider", and was built in
    shared directory: tmp-glibc/work-shared/qemux86/kernel-*
 5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
    core-image-base.bb to include both kernel flavors.
 6. `bitbake core-image-base` to build an image.
 7. Verified image contains two bzImage's under /boot/, with
    "yocto-standard" selected to boot via symlink.

Discussion threads:
http://lists.openembedded.org/pipermail/openembedded-core/2015-December/thread.html#114122
http://lists.openembedded.org/pipermail/openembedded-core/2017-July/thread.html#139130

Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
---
[PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to the
"work" directory in alternate kernel builds, instead of "work-shared",
so
that the two builds don't clobber each other.

[PATCH v3] An updated version of this change rebased onto the current
OE-core master. Changes:
 - Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
   kernel builds, since alternate kernels aren't the
   PREFERRED_PROVIDER for virtual/kernel by definition.
 - Remove "virtual/kernel" from PROVIDES in alternate kernel builds.

[PATCH v4] Another rebase onto master; no functional change.
Improved description and testing steps.

[PATCH v5]
 - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
 - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions

[PATCH v6] Add KERNEL_PACKAGE_NAME to kernel-module-split.bbclass for
module recipes; fixes lttng-modules build.

[PATCH v7] Remove second definition of KERNEL_PACKAGE_NAME from
kernel-module-split.bbclass; apply a default in two places where
KERNEL_PACKAGE_NAME is referenced.

[PATCH v8] Rebase onto current master and more fixups.
 - kernel-devicetree.bbclass: Fixup package names
 - depmodwrapper-cross: don't error when called from alt kernel recipes
 - kernel.bbclass: Don't install /boot/image symlink in alt recipes

https://github.com/harisokanovic/openembedded-core/tree/dev/hokanovi/multi-kernel-packages-v8
---
 meta/classes/kernel-devicetree.bbclass             |   8 +-
 meta/classes/kernel-module-split.bbclass           |   9 +-
 meta/classes/kernel.bbclass                        | 114 +++++++++++++--------
 meta/conf/documentation.conf                       |   1 +
 .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |  14 +--
 meta/recipes-kernel/linux/linux-yocto.inc          |   2 +-
 6 files changed, 90 insertions(+), 58 deletions(-)

diff --git a/meta/classes/kernel-devicetree.bbclass b/meta/classes/kernel-devicetree.bbclass
index 6e08be4b70..4f80cc62eb 100644
--- a/meta/classes/kernel-devicetree.bbclass
+++ b/meta/classes/kernel-devicetree.bbclass
@@ -1,10 +1,10 @@
 # Support for device tree generation
 PACKAGES_append = " \
-    kernel-devicetree \
-    ${@['kernel-image-zimage-bundle', ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
+    ${KERNEL_PACKAGE_NAME}-devicetree \
+    ${@[d.getVar('KERNEL_PACKAGE_NAME') + '-image-zimage-bundle', ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
 "
-FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
-FILES_kernel-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
+FILES_${KERNEL_PACKAGE_NAME}-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
+FILES_${KERNEL_PACKAGE_NAME}-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
 
 # Generate kernel+devicetree bundle
 KERNEL_DEVICETREE_BUNDLE ?= "0"
diff --git a/meta/classes/kernel-module-split.bbclass b/meta/classes/kernel-module-split.bbclass
index 1035525dac..73c7f18c78 100644
--- a/meta/classes/kernel-module-split.bbclass
+++ b/meta/classes/kernel-module-split.bbclass
@@ -30,7 +30,7 @@ do_install_append() {
 
 PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
 
-KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
+KERNEL_MODULES_META_PACKAGE ?= "${@ d.getVar("KERNEL_PACKAGE_NAME", True) or "kernel" }-modules"
 
 KERNEL_MODULE_PACKAGE_PREFIX ?= ""
 KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
@@ -129,16 +129,19 @@ python split_kernel_module_packages () {
            postfix = format.split('%s')[1]
            d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
 
+    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True) or "kernel"
+    kernel_version = d.getVar("KERNEL_VERSION", True)
+
     module_regex = '^(.*)\.k?o$'
 
     module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
     module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
-    module_pattern = module_pattern_prefix + 'kernel-module-%s' + module_pattern_suffix
+    module_pattern = module_pattern_prefix + kernel_package_name + '-module-%s' + module_pattern_suffix
 
     postinst = d.getVar('pkg_postinst_modules')
     postrm = d.getVar('pkg_postrm_modules')
 
-    modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
+    modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='%s-%s' % (kernel_package_name, kernel_version))
     if modules:
         metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
         d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index 756707a3c2..48b718d777 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -1,6 +1,9 @@
 inherit linux-kernel-base kernel-module-split
 
-PROVIDES += "virtual/kernel"
+KERNEL_PACKAGE_NAME ??= "kernel"
+KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
+
+PROVIDES += "${@ "virtual/kernel" if (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
 DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
 PACKAGE_WRITE_DEPS += "depmodwrapper-cross"
 
@@ -34,11 +37,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION')
 KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
 
 python __anonymous () {
+    pn = d.getVar("PN", True)
+    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
+
+    # XXX Remove this after bug 11905 is resolved
+    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
+    if kpn == pn:
+        bb.warn("Some packages (E.g. *-dev) might be missing due to "
+                "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
+
+    # The default kernel recipe builds in a shared location defined by
+    # bitbake/distro confs: STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR.
+    # Set these variables to directories under ${WORKDIR} in alternate
+    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so that they
+    # may build in parallel with the default kernel without clobbering.
+    if kpn != "kernel":
+        workdir = d.getVar("WORKDIR", True)
+        sourceDir = os.path.join(workdir, 'kernel-source')
+        artifactsDir = os.path.join(workdir, 'kernel-build-artifacts')
+        d.setVar("STAGING_KERNEL_DIR", sourceDir)
+        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
 
     # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES
     type = d.getVar('KERNEL_IMAGETYPE') or ""
     alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
     types = d.getVar('KERNEL_IMAGETYPES') or ""
+    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
     if type not in types.split():
         types = (type + ' ' + types).strip()
     if alttype not in types.split():
@@ -55,15 +79,15 @@ python __anonymous () {
         typelower = type.lower()
         imagedest = d.getVar('KERNEL_IMAGEDEST')
 
-        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
+        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
 
-        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type)
+        d.setVar('FILES_' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type)
 
-        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' + typelower)
+        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' % (kname, typelower))
 
-        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' + typelower + '-${KERNEL_VERSION_PKG_NAME}')
+        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
 
-        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
+        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower), '1')
 
     image = d.getVar('INITRAMFS_IMAGE')
     if image:
@@ -121,9 +145,9 @@ base_do_unpack_append () {
 
 inherit kernel-arch deploy
 
-PACKAGES_DYNAMIC += "^kernel-module-.*"
-PACKAGES_DYNAMIC += "^kernel-image-.*"
-PACKAGES_DYNAMIC += "^kernel-firmware-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
 
 export OS = "${TARGET_OS}"
 export CROSS_COMPILE = "${TARGET_PREFIX}"
@@ -339,7 +363,9 @@ kernel_do_install() {
 	install -d ${D}/boot
 	for type in ${KERNEL_IMAGETYPES} ; do
 		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${D}/${KERNEL_IMAGEDEST}/${type}-${KERNEL_VERSION}
-		ln -sf ${type}-${KERNEL_VERSION} ${D}/${KERNEL_IMAGEDEST}/${type}
+		if [ "${KERNEL_PACKAGE_NAME}" == "kernel" ]; then
+			ln -sf ${type}-${KERNEL_VERSION} ${D}/${KERNEL_IMAGEDEST}/${type}
+		fi
 	done
 	install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION}
 	install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
@@ -393,9 +419,9 @@ do_shared_workdir_setscene () {
 
 emit_depmod_pkgdata() {
 	# Stash data for depmod
-	install -d ${PKGDESTWORK}/kernel-depmod/
-	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-depmod/kernel-abiversion
-	cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-${KERNEL_VERSION}
+	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
+	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-abiversion
+	cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/System.map-${KERNEL_VERSION}
 }
 
 PACKAGEFUNCS += "emit_depmod_pkgdata"
@@ -410,7 +436,7 @@ do_shared_workdir () {
 	# Store the kernel version in sysroots for module-base.bbclass
 	#
 
-	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
+	echo "${KERNEL_VERSION}" > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
 
 	# Copy files required for module builds
 	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
@@ -508,28 +534,28 @@ EXPORT_FUNCTIONS do_compile do_install do_configure
 
 # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
 FILES_${PN} = ""
-FILES_kernel-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
-FILES_kernel-image = ""
-FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
-FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
-FILES_kernel-modules = ""
-RDEPENDS_kernel = "kernel-base"
+FILES_${KERNEL_PACKAGE_NAME}-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
+FILES_${KERNEL_PACKAGE_NAME}-image = ""
+FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
+FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
+FILES_${KERNEL_PACKAGE_NAME}-modules = ""
+RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
 # Allow machines to override this dependency if kernel image files are
 # not wanted in images as standard
-RDEPENDS_kernel-base ?= "kernel-image"
-PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
-RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', 'kernel-vmlinux', '', d)}"
-PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSION}')}"
-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"
-
-pkg_postinst_kernel-base () {
+RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-image"
+PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
+RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
+PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitimize_package_name('${KERNEL_VERSION}')}"
+RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-${KERNEL_VERSION}"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
+DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta package"
+
+pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
 	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
 		mkdir -p $D/lib/modules/${KERNEL_VERSION}
 	fi
@@ -543,7 +569,7 @@ pkg_postinst_kernel-base () {
 PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
 
 python split_kernel_packages () {
-    do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
+    do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
 }
 
 # Many scripts want to look in arch/$arch/boot for the bootable
@@ -626,21 +652,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-${MACHINE}.tgz"
 MODULE_TARBALL_DEPLOY ?= "1"
 
 kernel_do_deploy() {
+	deployDir="${DEPLOYDIR}"
+	if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
+		deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
+		mkdir "$deployDir"
+	fi
+
 	for type in ${KERNEL_IMAGETYPES} ; do
 		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
-		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${DEPLOYDIR}/${base_name}.bin
+		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} $deployDir/${base_name}.bin
 	done
 	if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
 		mkdir -p ${D}/lib
-		tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
-		ln -sf ${MODULE_TARBALL_BASE_NAME} ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
+		tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
+		ln -sf ${MODULE_TARBALL_BASE_NAME} $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
 	fi
 
 	for type in ${KERNEL_IMAGETYPES} ; do
 		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
 		symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
-		ln -sf ${base_name}.bin ${DEPLOYDIR}/${symlink_name}.bin
-		ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
+		ln -sf ${base_name}.bin $deployDir/${symlink_name}.bin
+		ln -sf ${base_name}.bin $deployDir/${type}
 	done
 
 	cd ${B}
@@ -650,8 +682,8 @@ kernel_do_deploy() {
 			echo "Copying deploy ${type} kernel-initramfs image and setting up links..."
 			initramfs_base_name=${type}-${INITRAMFS_BASE_NAME}
 			initramfs_symlink_name=${type}-initramfs-${MACHINE}
-			install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs ${DEPLOYDIR}/${initramfs_base_name}.bin
-			ln -sf ${initramfs_base_name}.bin ${DEPLOYDIR}/${initramfs_symlink_name}.bin
+			install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs $deployDir/${initramfs_base_name}.bin
+			ln -sf ${initramfs_base_name}.bin $deployDir/${initramfs_symlink_name}.bin
 		fi
 	done
 }
diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
index a55e2836b5..2c88504fb9 100644
--- a/meta/conf/documentation.conf
+++ b/meta/conf/documentation.conf
@@ -247,6 +247,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to build for a device, usually set b
 KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a device, usually set by the machine configuration files and defaults to KERNEL_IMAGETYPE."
 KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be auto-loaded during boot"
 KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the build system expects to find module_conf_* values that specify configuration for each of the modules"
+KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages. Defaults to 'kernel'."
 KERNEL_PATH[doc] = "The location of the kernel sources. This variable is set to the value of the STAGING_KERNEL_DIR within the module class (module.bbclass)."
 KERNEL_SRC[doc] = "The location of the kernel sources. This variable is set to the value of the STAGING_KERNEL_DIR within the module class (module.bbclass)."
 KFEATURE_DESCRIPTION[doc] = "Provides a short description of a configuration fragment. You use this variable in the .scc file that describes a configuration fragment file."
diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
index 44d013f29d..2eec921728 100644
--- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
+++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
@@ -23,17 +23,13 @@ if [ "\$1" != "-a" -o "\$2" != "-b" ]; then
     echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
     exit 1
 fi
-if [ ! -r ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion ]; then
-    echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" >&2
-else
-    kernelabi=\$(cat ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion)
-    if [ "\$kernelabi" != "\$4" ]; then
-        echo "Error: Kernel version \$4 does not match kernel-abiversion (\$kernelabi)" >&2
-        exit 1
-    fi
+
+kernelabi=""
+if [ -r "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" ]; then
+    kernelabi=\$(cat "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion")
 fi
 
-if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ]; then
+if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [ "\$kernelabi" != "\$4" ]; then
     echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/System.map-\$4" >&2
     exec env depmod "\$1" "\$2" "\$3" "\$4"
 else
diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc
index 9c1f61be75..8a70eb5018 100644
--- a/meta/recipes-kernel/linux/linux-yocto.inc
+++ b/meta/recipes-kernel/linux/linux-yocto.inc
@@ -12,7 +12,7 @@ INC_PR = "r4"
 # PREFERRED_PROVIDER for virtual/kernel. This avoids network access required
 # by the use of AUTOREV SRCREVs, which are the default for this recipe.
 python () {
-    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != d.getVar("PN"):
+    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN", True):
         d.delVar("BB_DONT_CACHE")
         raise bb.parse.SkipPackage("Set PREFERRED_PROVIDER_virtual/kernel to %s to enable it" % (d.getVar("PN")))
 }
-- 
2.14.2



^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH v8] kernel: Add support for multiple kernel packages
  2017-10-19 19:19       ` [PATCH v8] " Haris Okanovic
@ 2017-10-23 21:38         ` Saul Wold
  2017-10-25 23:47           ` Haris Okanovic
  2017-10-25  8:00         ` Bruce Ashfield
  1 sibling, 1 reply; 31+ messages in thread
From: Saul Wold @ 2017-10-23 21:38 UTC (permalink / raw)
  To: Haris Okanovic, openembedded-core; +Cc: josh.hernstrom


Haris,

We are really really close, one suggestion in the commit message and
linux-yocto-rt needs a fix similar to linux-yocto.inc (or maybe code
removed).

See below

Thanks so much for this work

Sau!

On Thu, 2017-10-19 at 14:19 -0500, Haris Okanovic wrote:
> Some distros may want to provide alternate kernel "flavors" via feeds
> or
> within bootable images. For example, readily available builds which
> provide certain diagnostic features can enable developers and testers
> to
> more quickly resolve issues by avoiding lengthy kernel builds.
> 
> This change allows for building multiple flavors of the kernel and
> module packages by templatizing kernel package names via a new
> KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the
> old
> name of "kernel", but can be overridden by certain recipes providing
> alternate kernel flavors.
> 
> To maintain compatibility, recipes providing alternate kernel flavors
> cannot be the "preferred provider" for virtual/kernel. This is
> because
> OE puts the preferred provider's build and source at
> "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
> "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
> "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using
> the
> default KERNEL_PACKAGE_NAME="kernel" follows the old semantics --
> build
> in the old location and may be preferred provider -- while recipes
> using
> all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and
> don't
> provide "virtual/kernel".
> 
> Testing:
>  1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
>     linux-yocto-tiny_4.9.bb so that it may build alongside
>     the main kernel.
I would also suggest using an example of KERNEL_PACKAGE_NAME_pn-linux-
yocto-tiny = "tiny-linux", this can be added to a conf file such as
local.conf file in order to allow for a kernel recipe to easily revert
back to being a possible PREFERRED_PROVIDER_virtual/kernel if a single
kernel is needed.

One additional code related comment at the very bottom.

Sau!
>  2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel
> flavors.
>  3. Verified image and modules IPKs exist for both:
>     tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>     tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
>  4. Verified linux-yocto is the "preferred provider", and was built
> in
>     shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>  5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
>     core-image-base.bb to include both kernel flavors.
>  6. `bitbake core-image-base` to build an image.
>  7. Verified image contains two bzImage's under /boot/, with
>     "yocto-standard" selected to boot via symlink.
> 
> Discussion threads:
> http://lists.openembedded.org/pipermail/openembedded-core/2015-Decemb
> er/thread.html#114122
> http://lists.openembedded.org/pipermail/openembedded-core/2017-July/t
> hread.html#139130
> 
Also, can you add the tag for tracking bug/features: 
[YOCTO #11363] 

> Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
> Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
> Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
> Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
> Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
> Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
> ---
> [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to
> the
> "work" directory in alternate kernel builds, instead of "work-
> shared",
> so
> that the two builds don't clobber each other.
> 
> [PATCH v3] An updated version of this change rebased onto the current
> OE-core master. Changes:
>  - Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
>    kernel builds, since alternate kernels aren't the
>    PREFERRED_PROVIDER for virtual/kernel by definition.
>  - Remove "virtual/kernel" from PROVIDES in alternate kernel builds.
> 
> [PATCH v4] Another rebase onto master; no functional change.
> Improved description and testing steps.
> 
> [PATCH v5]
>  - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
>  - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions
> 
> [PATCH v6] Add KERNEL_PACKAGE_NAME to kernel-module-split.bbclass for
> module recipes; fixes lttng-modules build.
> 
> [PATCH v7] Remove second definition of KERNEL_PACKAGE_NAME from
> kernel-module-split.bbclass; apply a default in two places where
> KERNEL_PACKAGE_NAME is referenced.
> 
> [PATCH v8] Rebase onto current master and more fixups.
>  - kernel-devicetree.bbclass: Fixup package names
>  - depmodwrapper-cross: don't error when called from alt kernel
> recipes
>  - kernel.bbclass: Don't install /boot/image symlink in alt recipes
> 
> https://github.com/harisokanovic/openembedded-core/tree/dev/hokanovi/
> multi-kernel-packages-v8
> ---
>  meta/classes/kernel-devicetree.bbclass             |   8 +-
>  meta/classes/kernel-module-split.bbclass           |   9 +-
>  meta/classes/kernel.bbclass                        | 114
> +++++++++++++--------
>  meta/conf/documentation.conf                       |   1 +
>  .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |  14 +--
>  meta/recipes-kernel/linux/linux-yocto.inc          |   2 +-
>  6 files changed, 90 insertions(+), 58 deletions(-)
> 
> diff --git a/meta/classes/kernel-devicetree.bbclass
> b/meta/classes/kernel-devicetree.bbclass
> index 6e08be4b70..4f80cc62eb 100644
> --- a/meta/classes/kernel-devicetree.bbclass
> +++ b/meta/classes/kernel-devicetree.bbclass
> @@ -1,10 +1,10 @@
>  # Support for device tree generation
>  PACKAGES_append = " \
> -    kernel-devicetree \
> -    ${@['kernel-image-zimage-bundle',
> ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
> +    ${KERNEL_PACKAGE_NAME}-devicetree \
> +    ${@[d.getVar('KERNEL_PACKAGE_NAME') + '-image-zimage-bundle',
> ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
>  "
> -FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb
> /${KERNEL_IMAGEDEST}/*.dtbo"
> -FILES_kernel-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-
> *.dtb.bin"
> +FILES_${KERNEL_PACKAGE_NAME}-devicetree =
> "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
> +FILES_${KERNEL_PACKAGE_NAME}-image-zimage-bundle =
> "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
>  
>  # Generate kernel+devicetree bundle
>  KERNEL_DEVICETREE_BUNDLE ?= "0"
> diff --git a/meta/classes/kernel-module-split.bbclass
> b/meta/classes/kernel-module-split.bbclass
> index 1035525dac..73c7f18c78 100644
> --- a/meta/classes/kernel-module-split.bbclass
> +++ b/meta/classes/kernel-module-split.bbclass
> @@ -30,7 +30,7 @@ do_install_append() {
>  
>  PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>  
> -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
> +KERNEL_MODULES_META_PACKAGE ?= "${@ d.getVar("KERNEL_PACKAGE_NAME",
> True) or "kernel" }-modules"
>  
>  KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>  KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
> @@ -129,16 +129,19 @@ python split_kernel_module_packages () {
>             postfix = format.split('%s')[1]
>             d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
>  
> +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True) or
> "kernel"
> +    kernel_version = d.getVar("KERNEL_VERSION", True)
> +
>      module_regex = '^(.*)\.k?o$'
>  
>      module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>      module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
> -    module_pattern = module_pattern_prefix + 'kernel-module-%s' +
> module_pattern_suffix
> +    module_pattern = module_pattern_prefix + kernel_package_name +
> '-module-%s' + module_pattern_suffix
>  
>      postinst = d.getVar('pkg_postinst_modules')
>      postrm = d.getVar('pkg_postrm_modules')
>  
> -    modules = do_split_packages(d,
> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
> output_pattern=module_pattern, description='%s kernel module',
> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
> extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
> +    modules = do_split_packages(d,
> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
> output_pattern=module_pattern, description='%s kernel module',
> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
> extra_depends='%s-%s' % (kernel_package_name, kernel_version))
>      if modules:
>          metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>          d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
> diff --git a/meta/classes/kernel.bbclass
> b/meta/classes/kernel.bbclass
> index 756707a3c2..48b718d777 100644
> --- a/meta/classes/kernel.bbclass
> +++ b/meta/classes/kernel.bbclass
> @@ -1,6 +1,9 @@
>  inherit linux-kernel-base kernel-module-split
>  
> -PROVIDES += "virtual/kernel"
> +KERNEL_PACKAGE_NAME ??= "kernel"
> +KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME",
> True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
> +
> +PROVIDES += "${@ "virtual/kernel" if
> (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
>  DEPENDS += "virtual/${TARGET_PREFIX}binutils
> virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
>  PACKAGE_WRITE_DEPS += "depmodwrapper-cross"
>  
> @@ -34,11 +37,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_
> name(d.getVar('KERNEL_VERSION')
>  KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
>  
>  python __anonymous () {
> +    pn = d.getVar("PN", True)
> +    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
> +
> +    # XXX Remove this after bug 11905 is resolved
> +    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
> +    if kpn == pn:
> +        bb.warn("Some packages (E.g. *-dev) might be missing due to
> "
> +                "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
> +
> +    # The default kernel recipe builds in a shared location defined
> by
> +    # bitbake/distro confs: STAGING_KERNEL_DIR and
> STAGING_KERNEL_BUILDDIR.
> +    # Set these variables to directories under ${WORKDIR} in
> alternate
> +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so
> that they
> +    # may build in parallel with the default kernel without
> clobbering.
> +    if kpn != "kernel":
> +        workdir = d.getVar("WORKDIR", True)
> +        sourceDir = os.path.join(workdir, 'kernel-source')
> +        artifactsDir = os.path.join(workdir, 'kernel-build-
> artifacts')
> +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
> +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
>  
>      # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
> KERNEL_IMAGETYPES
>      type = d.getVar('KERNEL_IMAGETYPE') or ""
>      alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>      types = d.getVar('KERNEL_IMAGETYPES') or ""
> +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
>      if type not in types.split():
>          types = (type + ' ' + types).strip()
>      if alttype not in types.split():
> @@ -55,15 +79,15 @@ python __anonymous () {
>          typelower = type.lower()
>          imagedest = d.getVar('KERNEL_IMAGEDEST')
>  
> -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
> +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
>  
> -        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest
> + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' +
> type)
> +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' +
> imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest
> + '/' + type)
>  
> -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' +
> typelower)
> +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' %
> (kname, typelower))
>  
> -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' +
> typelower + '-${KERNEL_VERSION_PKG_NAME}')
> +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-
> %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>  
> -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
> +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower),
> '1')
>  
>      image = d.getVar('INITRAMFS_IMAGE')
>      if image:
> @@ -121,9 +145,9 @@ base_do_unpack_append () {
>  
>  inherit kernel-arch deploy
>  
> -PACKAGES_DYNAMIC += "^kernel-module-.*"
> -PACKAGES_DYNAMIC += "^kernel-image-.*"
> -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>  
>  export OS = "${TARGET_OS}"
>  export CROSS_COMPILE = "${TARGET_PREFIX}"
> @@ -339,7 +363,9 @@ kernel_do_install() {
>  	install -d ${D}/boot
>  	for type in ${KERNEL_IMAGETYPES} ; do
>  		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
> ${D}/${KERNEL_IMAGEDEST}/${type}-${KERNEL_VERSION}
> -		ln -sf ${type}-${KERNEL_VERSION}
> ${D}/${KERNEL_IMAGEDEST}/${type}
> +		if [ "${KERNEL_PACKAGE_NAME}" == "kernel" ]; then
> +			ln -sf ${type}-${KERNEL_VERSION}
> ${D}/${KERNEL_IMAGEDEST}/${type}
> +		fi
>  	done
>  	install -m 0644 System.map ${D}/boot/System.map-
> ${KERNEL_VERSION}
>  	install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
> @@ -393,9 +419,9 @@ do_shared_workdir_setscene () {
>  
>  emit_depmod_pkgdata() {
>  	# Stash data for depmod
> -	install -d ${PKGDESTWORK}/kernel-depmod/
> -	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
> depmod/kernel-abiversion
> -	cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-
> ${KERNEL_VERSION}
> +	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
> +	echo "${KERNEL_VERSION}" >
> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-
> abiversion
> +	cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
> depmod/System.map-${KERNEL_VERSION}
>  }
>  
>  PACKAGEFUNCS += "emit_depmod_pkgdata"
> @@ -410,7 +436,7 @@ do_shared_workdir () {
>  	# Store the kernel version in sysroots for module-
> base.bbclass
>  	#
>  
> -	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
> +	echo "${KERNEL_VERSION}" >
> $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>  
>  	# Copy files required for module builds
>  	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
> @@ -508,28 +534,28 @@ EXPORT_FUNCTIONS do_compile do_install
> do_configure
>  
>  # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base
> ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
> ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>  FILES_${PN} = ""
> -FILES_kernel-base =
> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
> -FILES_kernel-image = ""
> -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
> /boot/config* ${KERNEL_SRC_PATH}
> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
> -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
> -FILES_kernel-modules = ""
> -RDEPENDS_kernel = "kernel-base"
> +FILES_${KERNEL_PACKAGE_NAME}-base =
> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
> +FILES_${KERNEL_PACKAGE_NAME}-image = ""
> +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
> /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
> +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
> ${KERNEL_VERSION_NAME}"
> +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
> +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
>  # Allow machines to override this dependency if kernel image files
> are
>  # not wanted in images as standard
> -RDEPENDS_kernel-base ?= "kernel-image"
> -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNE
> L_VERSION}')}"
> -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE',
> 'vmlinux', 'kernel-vmlinux', '', d)}"
> -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSI
> ON}')}"
> -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"
> -
> -pkg_postinst_kernel-base () {
> +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-
> image"
> +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@
> legitimize_package_name('${KERNEL_VERSION}')}"
> +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNE
> L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
> +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitim
> ize_package_name('${KERNEL_VERSION}')}"
> +RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-
> ${KERNEL_VERSION}"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
> +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta
> package"
> +
> +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>  	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>  		mkdir -p $D/lib/modules/${KERNEL_VERSION}
>  	fi
> @@ -543,7 +569,7 @@ pkg_postinst_kernel-base () {
>  PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>  
>  python split_kernel_packages () {
> -    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-
> firmware-%s', description='Firmware for %s', recursive=True,
> extra_depends='')
> +    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
> output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
> description='Firmware for %s', recursive=True, extra_depends='')
>  }
>  
>  # Many scripts want to look in arch/$arch/boot for the bootable
> @@ -626,21 +652,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-
> ${MACHINE}.tgz"
>  MODULE_TARBALL_DEPLOY ?= "1"
>  
>  kernel_do_deploy() {
> +	deployDir="${DEPLOYDIR}"
> +	if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
> +		deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
> +		mkdir "$deployDir"
> +	fi
> +
>  	for type in ${KERNEL_IMAGETYPES} ; do
>  		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
> -		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
> ${DEPLOYDIR}/${base_name}.bin
> +		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
> $deployDir/${base_name}.bin
>  	done
>  	if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e
> '^CONFIG_MODULES=y$' .config); then
>  		mkdir -p ${D}/lib
> -		tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME}
> -C ${D} lib
> -		ln -sf ${MODULE_TARBALL_BASE_NAME}
> ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
> +		tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME} -C
> ${D} lib
> +		ln -sf ${MODULE_TARBALL_BASE_NAME}
> $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
>  	fi
>  
>  	for type in ${KERNEL_IMAGETYPES} ; do
>  		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>  		symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
> -		ln -sf ${base_name}.bin
> ${DEPLOYDIR}/${symlink_name}.bin
> -		ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
> +		ln -sf ${base_name}.bin
> $deployDir/${symlink_name}.bin
> +		ln -sf ${base_name}.bin $deployDir/${type}
>  	done
>  
>  	cd ${B}
> @@ -650,8 +682,8 @@ kernel_do_deploy() {
>  			echo "Copying deploy ${type} kernel-
> initramfs image and setting up links..."
>  			initramfs_base_name=${type}-
> ${INITRAMFS_BASE_NAME}
>  			initramfs_symlink_name=${type}-initramfs-
> ${MACHINE}
> -			install -m 0644
> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
> ${DEPLOYDIR}/${initramfs_base_name}.bin
> -			ln -sf ${initramfs_base_name}.bin
> ${DEPLOYDIR}/${initramfs_symlink_name}.bin
> +			install -m 0644
> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
> $deployDir/${initramfs_base_name}.bin
> +			ln -sf ${initramfs_base_name}.bin
> $deployDir/${initramfs_symlink_name}.bin
>  		fi
>  	done
>  }
> diff --git a/meta/conf/documentation.conf
> b/meta/conf/documentation.conf
> index a55e2836b5..2c88504fb9 100644
> --- a/meta/conf/documentation.conf
> +++ b/meta/conf/documentation.conf
> @@ -247,6 +247,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to
> build for a device, usually set b
>  KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a
> device, usually set by the machine configuration files and defaults
> to KERNEL_IMAGETYPE."
>  KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be
> auto-loaded during boot"
>  KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the
> build system expects to find module_conf_* values that specify
> configuration for each of the modules"
> +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
> Defaults to 'kernel'."
>  KERNEL_PATH[doc] = "The location of the kernel sources. This
> variable is set to the value of the STAGING_KERNEL_DIR within the
> module class (module.bbclass)."
>  KERNEL_SRC[doc] = "The location of the kernel sources. This variable
> is set to the value of the STAGING_KERNEL_DIR within the module class
> (module.bbclass)."
>  KFEATURE_DESCRIPTION[doc] = "Provides a short description of a
> configuration fragment. You use this variable in the .scc file that
> describes a configuration fragment file."
> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> index 44d013f29d..2eec921728 100644
> --- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> @@ -23,17 +23,13 @@ if [ "\$1" != "-a" -o "\$2" != "-b" ]; then
>      echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
>      exit 1
>  fi
> -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion ]; then
> -    echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/kernel-
> abiversion" >&2
> -else
> -    kernelabi=\$(cat ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion)
> -    if [ "\$kernelabi" != "\$4" ]; then
> -        echo "Error: Kernel version \$4 does not match kernel-
> abiversion (\$kernelabi)" >&2
> -        exit 1
> -    fi
> +
> +kernelabi=""
> +if [ -r "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" ]; then
> +    kernelabi=\$(cat "${PKGDATA_DIR}/kernel-depmod/kernel-
> abiversion")
>  fi
>  
> -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ]; then
> +if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [
> "\$kernelabi" != "\$4" ]; then
>      echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/System.map-
> \$4" >&2
>      exec env depmod "\$1" "\$2" "\$3" "\$4"
>  else
> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
> b/meta/recipes-kernel/linux/linux-yocto.inc
> index 9c1f61be75..8a70eb5018 100644
> --- a/meta/recipes-kernel/linux/linux-yocto.inc
> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
> @@ -12,7 +12,7 @@ INC_PR = "r4"
>  # PREFERRED_PROVIDER for virtual/kernel. This avoids network access
> required
>  # by the use of AUTOREV SRCREVs, which are the default for this
> recipe.
>  python () {
> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
> d.getVar("PN"):
> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
> d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN",
> True):

I think this change is also needed in the *-rt recipes as they have a
similar check, maybe that check just needs to be removed?

Sau!
>          d.delVar("BB_DONT_CACHE")
>          raise bb.parse.SkipPackage("Set
> PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
> (d.getVar("PN")))
>  }
> -- 
> 2.14.2
> 


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v8] kernel: Add support for multiple kernel packages
  2017-10-19 19:19       ` [PATCH v8] " Haris Okanovic
  2017-10-23 21:38         ` Saul Wold
@ 2017-10-25  8:00         ` Bruce Ashfield
  2017-10-25 23:49           ` Haris Okanovic
  1 sibling, 1 reply; 31+ messages in thread
From: Bruce Ashfield @ 2017-10-25  8:00 UTC (permalink / raw)
  To: Haris Okanovic
  Cc: Wold, Saul, Patches and discussions about the oe-core layer,
	josh.hernstrom

On Thu, Oct 19, 2017 at 3:19 PM, Haris Okanovic <haris.okanovic@ni.com> wrote:
> Some distros may want to provide alternate kernel "flavors" via feeds or
> within bootable images. For example, readily available builds which
> provide certain diagnostic features can enable developers and testers to
> more quickly resolve issues by avoiding lengthy kernel builds.
>
> This change allows for building multiple flavors of the kernel and
> module packages by templatizing kernel package names via a new
> KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the old
> name of "kernel", but can be overridden by certain recipes providing
> alternate kernel flavors.
>
> To maintain compatibility, recipes providing alternate kernel flavors
> cannot be the "preferred provider" for virtual/kernel. This is because
> OE puts the preferred provider's build and source at
> "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
> "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
> "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using the
> default KERNEL_PACKAGE_NAME="kernel" follows the old semantics -- build
> in the old location and may be preferred provider -- while recipes using
> all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and don't
> provide "virtual/kernel".
>
> Testing:
>  1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
>     linux-yocto-tiny_4.9.bb so that it may build alongside
>     the main kernel.
>  2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel flavors.
>  3. Verified image and modules IPKs exist for both:
>     tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>     tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
>  4. Verified linux-yocto is the "preferred provider", and was built in
>     shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>  5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
>     core-image-base.bb to include both kernel flavors.
>  6. `bitbake core-image-base` to build an image.
>  7. Verified image contains two bzImage's under /boot/, with
>     "yocto-standard" selected to boot via symlink.
>
> Discussion threads:
> http://lists.openembedded.org/pipermail/openembedded-core/2015-December/thread.html#114122
> http://lists.openembedded.org/pipermail/openembedded-core/2017-July/thread.html#139130
>
> Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
> Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
> Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
> Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
> Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
> Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
> ---
> [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to the
> "work" directory in alternate kernel builds, instead of "work-shared",
> so
> that the two builds don't clobber each other.
>
> [PATCH v3] An updated version of this change rebased onto the current
> OE-core master. Changes:
>  - Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
>    kernel builds, since alternate kernels aren't the
>    PREFERRED_PROVIDER for virtual/kernel by definition.
>  - Remove "virtual/kernel" from PROVIDES in alternate kernel builds.
>
> [PATCH v4] Another rebase onto master; no functional change.
> Improved description and testing steps.
>
> [PATCH v5]
>  - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
>  - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions
>
> [PATCH v6] Add KERNEL_PACKAGE_NAME to kernel-module-split.bbclass for
> module recipes; fixes lttng-modules build.
>
> [PATCH v7] Remove second definition of KERNEL_PACKAGE_NAME from
> kernel-module-split.bbclass; apply a default in two places where
> KERNEL_PACKAGE_NAME is referenced.
>
> [PATCH v8] Rebase onto current master and more fixups.
>  - kernel-devicetree.bbclass: Fixup package names
>  - depmodwrapper-cross: don't error when called from alt kernel recipes
>  - kernel.bbclass: Don't install /boot/image symlink in alt recipes
>
> https://github.com/harisokanovic/openembedded-core/tree/dev/hokanovi/multi-kernel-packages-v8
> ---
>  meta/classes/kernel-devicetree.bbclass             |   8 +-
>  meta/classes/kernel-module-split.bbclass           |   9 +-
>  meta/classes/kernel.bbclass                        | 114 +++++++++++++--------
>  meta/conf/documentation.conf                       |   1 +
>  .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |  14 +--
>  meta/recipes-kernel/linux/linux-yocto.inc          |   2 +-
>  6 files changed, 90 insertions(+), 58 deletions(-)
>
> diff --git a/meta/classes/kernel-devicetree.bbclass b/meta/classes/kernel-devicetree.bbclass
> index 6e08be4b70..4f80cc62eb 100644
> --- a/meta/classes/kernel-devicetree.bbclass
> +++ b/meta/classes/kernel-devicetree.bbclass
> @@ -1,10 +1,10 @@
>  # Support for device tree generation
>  PACKAGES_append = " \
> -    kernel-devicetree \
> -    ${@['kernel-image-zimage-bundle', ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
> +    ${KERNEL_PACKAGE_NAME}-devicetree \
> +    ${@[d.getVar('KERNEL_PACKAGE_NAME') + '-image-zimage-bundle', ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
>  "
> -FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
> -FILES_kernel-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
> +FILES_${KERNEL_PACKAGE_NAME}-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
> +FILES_${KERNEL_PACKAGE_NAME}-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
>
>  # Generate kernel+devicetree bundle
>  KERNEL_DEVICETREE_BUNDLE ?= "0"
> diff --git a/meta/classes/kernel-module-split.bbclass b/meta/classes/kernel-module-split.bbclass
> index 1035525dac..73c7f18c78 100644
> --- a/meta/classes/kernel-module-split.bbclass
> +++ b/meta/classes/kernel-module-split.bbclass
> @@ -30,7 +30,7 @@ do_install_append() {
>
>  PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>
> -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
> +KERNEL_MODULES_META_PACKAGE ?= "${@ d.getVar("KERNEL_PACKAGE_NAME", True) or "kernel" }-modules"
>
>  KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>  KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
> @@ -129,16 +129,19 @@ python split_kernel_module_packages () {
>             postfix = format.split('%s')[1]
>             d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
>
> +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True) or "kernel"
> +    kernel_version = d.getVar("KERNEL_VERSION", True)

Minor 'nit, is this just a cleanup and not part of the technical bits
of the patch ?
When making changes to a complex recipe .. it really is a better idea to do this
in a separate patch.

If I've missed how this is related to the new KERNEL_PACKAGE_NAME, then
disregard that comment. i.e. you really can't mix the new variable and
the d.getVar
call in the do_split_packages. Either way, no issue .. that use of a
variable just
jumped out to me as unrelated to the actual package name varying.

> +
>      module_regex = '^(.*)\.k?o$'
>
>      module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>      module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
> -    module_pattern = module_pattern_prefix + 'kernel-module-%s' + module_pattern_suffix
> +    module_pattern = module_pattern_prefix + kernel_package_name + '-module-%s' + module_pattern_suffix
>
>      postinst = d.getVar('pkg_postinst_modules')
>      postrm = d.getVar('pkg_postrm_modules')
>
> -    modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
> +    modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='%s-%s' % (kernel_package_name, kernel_version))
>      if modules:
>          metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>          d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
> diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
> index 756707a3c2..48b718d777 100644
> --- a/meta/classes/kernel.bbclass
> +++ b/meta/classes/kernel.bbclass
> @@ -1,6 +1,9 @@
>  inherit linux-kernel-base kernel-module-split
>
> -PROVIDES += "virtual/kernel"
> +KERNEL_PACKAGE_NAME ??= "kernel"
> +KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
> +
> +PROVIDES += "${@ "virtual/kernel" if (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
>  DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
>  PACKAGE_WRITE_DEPS += "depmodwrapper-cross"
>
> @@ -34,11 +37,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION')
>  KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
>
>  python __anonymous () {
> +    pn = d.getVar("PN", True)
> +    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
> +
> +    # XXX Remove this after bug 11905 is resolved
> +    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
> +    if kpn == pn:
> +        bb.warn("Some packages (E.g. *-dev) might be missing due to "
> +                "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
> +
> +    # The default kernel recipe builds in a shared location defined by
> +    # bitbake/distro confs: STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR.
> +    # Set these variables to directories under ${WORKDIR} in alternate
> +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so that they
> +    # may build in parallel with the default kernel without clobbering.
> +    if kpn != "kernel":
> +        workdir = d.getVar("WORKDIR", True)
> +        sourceDir = os.path.join(workdir, 'kernel-source')
> +        artifactsDir = os.path.join(workdir, 'kernel-build-artifacts')
> +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
> +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
>
>      # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES
>      type = d.getVar('KERNEL_IMAGETYPE') or ""
>      alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>      types = d.getVar('KERNEL_IMAGETYPES') or ""
> +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
>      if type not in types.split():
>          types = (type + ' ' + types).strip()
>      if alttype not in types.split():
> @@ -55,15 +79,15 @@ python __anonymous () {
>          typelower = type.lower()
>          imagedest = d.getVar('KERNEL_IMAGEDEST')
>
> -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
> +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
>
> -        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type)
> +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type)
>
> -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' + typelower)
> +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' % (kname, typelower))
>
> -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' + typelower + '-${KERNEL_VERSION_PKG_NAME}')
> +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>
> -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
> +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower), '1')
>
>      image = d.getVar('INITRAMFS_IMAGE')
>      if image:
> @@ -121,9 +145,9 @@ base_do_unpack_append () {
>
>  inherit kernel-arch deploy
>
> -PACKAGES_DYNAMIC += "^kernel-module-.*"
> -PACKAGES_DYNAMIC += "^kernel-image-.*"
> -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>
>  export OS = "${TARGET_OS}"
>  export CROSS_COMPILE = "${TARGET_PREFIX}"
> @@ -339,7 +363,9 @@ kernel_do_install() {
>         install -d ${D}/boot
>         for type in ${KERNEL_IMAGETYPES} ; do
>                 install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${D}/${KERNEL_IMAGEDEST}/${type}-${KERNEL_VERSION}
> -               ln -sf ${type}-${KERNEL_VERSION} ${D}/${KERNEL_IMAGEDEST}/${type}
> +               if [ "${KERNEL_PACKAGE_NAME}" == "kernel" ]; then
> +                       ln -sf ${type}-${KERNEL_VERSION} ${D}/${KERNEL_IMAGEDEST}/${type}
> +               fi
>         done
>         install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION}
>         install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
> @@ -393,9 +419,9 @@ do_shared_workdir_setscene () {
>
>  emit_depmod_pkgdata() {
>         # Stash data for depmod
> -       install -d ${PKGDESTWORK}/kernel-depmod/
> -       echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-depmod/kernel-abiversion
> -       cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-${KERNEL_VERSION}
> +       install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
> +       echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-abiversion
> +       cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/System.map-${KERNEL_VERSION}
>  }
>
>  PACKAGEFUNCS += "emit_depmod_pkgdata"
> @@ -410,7 +436,7 @@ do_shared_workdir () {
>         # Store the kernel version in sysroots for module-base.bbclass
>         #
>
> -       echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
> +       echo "${KERNEL_VERSION}" > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>
>         # Copy files required for module builds
>         cp System.map $kerneldir/System.map-${KERNEL_VERSION}
> @@ -508,28 +534,28 @@ EXPORT_FUNCTIONS do_compile do_install do_configure
>
>  # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>  FILES_${PN} = ""
> -FILES_kernel-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
> -FILES_kernel-image = ""
> -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
> -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
> -FILES_kernel-modules = ""
> -RDEPENDS_kernel = "kernel-base"
> +FILES_${KERNEL_PACKAGE_NAME}-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
> +FILES_${KERNEL_PACKAGE_NAME}-image = ""
> +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
> +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
> +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
> +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
>  # Allow machines to override this dependency if kernel image files are
>  # not wanted in images as standard
> -RDEPENDS_kernel-base ?= "kernel-image"
> -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
> -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', 'kernel-vmlinux', '', d)}"
> -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSION}')}"
> -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"
> -
> -pkg_postinst_kernel-base () {
> +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-image"
> +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
> +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
> +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitimize_package_name('${KERNEL_VERSION}')}"
> +RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-${KERNEL_VERSION}"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
> +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta package"
> +
> +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>         if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>                 mkdir -p $D/lib/modules/${KERNEL_VERSION}
>         fi
> @@ -543,7 +569,7 @@ pkg_postinst_kernel-base () {
>  PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>
>  python split_kernel_packages () {
> -    do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
> +    do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
>  }
>
>  # Many scripts want to look in arch/$arch/boot for the bootable
> @@ -626,21 +652,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-${MACHINE}.tgz"
>  MODULE_TARBALL_DEPLOY ?= "1"
>
>  kernel_do_deploy() {
> +       deployDir="${DEPLOYDIR}"
> +       if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
> +               deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
> +               mkdir "$deployDir"
> +       fi
> +
>         for type in ${KERNEL_IMAGETYPES} ; do
>                 base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
> -               install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${DEPLOYDIR}/${base_name}.bin
> +               install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} $deployDir/${base_name}.bin
>         done
>         if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
>                 mkdir -p ${D}/lib
> -               tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
> -               ln -sf ${MODULE_TARBALL_BASE_NAME} ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
> +               tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
> +               ln -sf ${MODULE_TARBALL_BASE_NAME} $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
>         fi
>
>         for type in ${KERNEL_IMAGETYPES} ; do
>                 base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>                 symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
> -               ln -sf ${base_name}.bin ${DEPLOYDIR}/${symlink_name}.bin
> -               ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
> +               ln -sf ${base_name}.bin $deployDir/${symlink_name}.bin
> +               ln -sf ${base_name}.bin $deployDir/${type}
>         done
>
>         cd ${B}
> @@ -650,8 +682,8 @@ kernel_do_deploy() {
>                         echo "Copying deploy ${type} kernel-initramfs image and setting up links..."
>                         initramfs_base_name=${type}-${INITRAMFS_BASE_NAME}
>                         initramfs_symlink_name=${type}-initramfs-${MACHINE}
> -                       install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs ${DEPLOYDIR}/${initramfs_base_name}.bin
> -                       ln -sf ${initramfs_base_name}.bin ${DEPLOYDIR}/${initramfs_symlink_name}.bin
> +                       install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs $deployDir/${initramfs_base_name}.bin
> +                       ln -sf ${initramfs_base_name}.bin $deployDir/${initramfs_symlink_name}.bin
>                 fi
>         done
>  }
> diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
> index a55e2836b5..2c88504fb9 100644
> --- a/meta/conf/documentation.conf
> +++ b/meta/conf/documentation.conf
> @@ -247,6 +247,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to build for a device, usually set b
>  KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a device, usually set by the machine configuration files and defaults to KERNEL_IMAGETYPE."
>  KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be auto-loaded during boot"
>  KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the build system expects to find module_conf_* values that specify configuration for each of the modules"
> +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages. Defaults to 'kernel'."
>  KERNEL_PATH[doc] = "The location of the kernel sources. This variable is set to the value of the STAGING_KERNEL_DIR within the module class (module.bbclass)."
>  KERNEL_SRC[doc] = "The location of the kernel sources. This variable is set to the value of the STAGING_KERNEL_DIR within the module class (module.bbclass)."
>  KFEATURE_DESCRIPTION[doc] = "Provides a short description of a configuration fragment. You use this variable in the .scc file that describes a configuration fragment file."
> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> index 44d013f29d..2eec921728 100644
> --- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> @@ -23,17 +23,13 @@ if [ "\$1" != "-a" -o "\$2" != "-b" ]; then
>      echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
>      exit 1
>  fi
> -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion ]; then
> -    echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" >&2
> -else
> -    kernelabi=\$(cat ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion)
> -    if [ "\$kernelabi" != "\$4" ]; then
> -        echo "Error: Kernel version \$4 does not match kernel-abiversion (\$kernelabi)" >&2
> -        exit 1

Why is the kernel abi check being dropped ? Or is is somehow relocated and the
diff is just hiding it from me ?

I see you referencing the depmod wrapper change in the v8 summary, but it
isn't clear to me that removing the check completely is a good idea.

The changes look good to me in general, just my comment and question
above.

Bruce

> -    fi
> +
> +kernelabi=""
> +if [ -r "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" ]; then
> +    kernelabi=\$(cat "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion")
>  fi
>
> -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ]; then
> +if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [ "\$kernelabi" != "\$4" ]; then
>      echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/System.map-\$4" >&2
>      exec env depmod "\$1" "\$2" "\$3" "\$4"
>  else
> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc
> index 9c1f61be75..8a70eb5018 100644
> --- a/meta/recipes-kernel/linux/linux-yocto.inc
> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
> @@ -12,7 +12,7 @@ INC_PR = "r4"
>  # PREFERRED_PROVIDER for virtual/kernel. This avoids network access required
>  # by the use of AUTOREV SRCREVs, which are the default for this recipe.
>  python () {
> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != d.getVar("PN"):
> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN", True):
>          d.delVar("BB_DONT_CACHE")
>          raise bb.parse.SkipPackage("Set PREFERRED_PROVIDER_virtual/kernel to %s to enable it" % (d.getVar("PN")))
>  }
> --
> 2.14.2
>



-- 
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end"


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v8] kernel: Add support for multiple kernel packages
  2017-10-23 21:38         ` Saul Wold
@ 2017-10-25 23:47           ` Haris Okanovic
  0 siblings, 0 replies; 31+ messages in thread
From: Haris Okanovic @ 2017-10-25 23:47 UTC (permalink / raw)
  To: Saul Wold, openembedded-core; +Cc: josh.hernstrom


On 10/23/2017 04:38 PM, Saul Wold wrote:
> 
> Haris,
> 
> We are really really close, one suggestion in the commit message and
> linux-yocto-rt needs a fix similar to linux-yocto.inc (or maybe code
> removed).
> 
> See below
> 
> Thanks so much for this work
> 
> Sau!
> 
> On Thu, 2017-10-19 at 14:19 -0500, Haris Okanovic wrote:
>> Some distros may want to provide alternate kernel "flavors" via feeds
>> or
>> within bootable images. For example, readily available builds which
>> provide certain diagnostic features can enable developers and testers
>> to
>> more quickly resolve issues by avoiding lengthy kernel builds.
>>
>> This change allows for building multiple flavors of the kernel and
>> module packages by templatizing kernel package names via a new
>> KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the
>> old
>> name of "kernel", but can be overridden by certain recipes providing
>> alternate kernel flavors.
>>
>> To maintain compatibility, recipes providing alternate kernel flavors
>> cannot be the "preferred provider" for virtual/kernel. This is
>> because
>> OE puts the preferred provider's build and source at
>> "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
>> "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
>> "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using
>> the
>> default KERNEL_PACKAGE_NAME="kernel" follows the old semantics --
>> build
>> in the old location and may be preferred provider -- while recipes
>> using
>> all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and
>> don't
>> provide "virtual/kernel".
>>
>> Testing:
>>   1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
>>      linux-yocto-tiny_4.9.bb so that it may build alongside
>>      the main kernel.
> I would also suggest using an example of KERNEL_PACKAGE_NAME_pn-linux-
> yocto-tiny = "tiny-linux", this can be added to a conf file such as
> local.conf file in order to allow for a kernel recipe to easily revert
> back to being a possible PREFERRED_PROVIDER_virtual/kernel if a single
> kernel is needed.
> 
> One additional code related comment at the very bottom.
> 

Sure. Updated testing section and successfully re-ran all steps.

> Sau!
>>   2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel
>> flavors.
>>   3. Verified image and modules IPKs exist for both:
>>      tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>>      tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
>>   4. Verified linux-yocto is the "preferred provider", and was built
>> in
>>      shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>>   5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
>>      core-image-base.bb to include both kernel flavors.
>>   6. `bitbake core-image-base` to build an image.
>>   7. Verified image contains two bzImage's under /boot/, with
>>      "yocto-standard" selected to boot via symlink.
>>
>> Discussion threads:
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org_pipermail_openembedded-2Dcore_2015-2DDecemb&d=DwICaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=CELKDprUza4SWI1u2Fypwugx9Xc02d2vjiezk0izIEM&s=PTcNwBf0unLuyw5-OdgBzLd6vCdbGwGgr1r1TkqSb8c&e=
>> er/thread.html#114122
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org_pipermail_openembedded-2Dcore_2017-2DJuly_t&d=DwICaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=CELKDprUza4SWI1u2Fypwugx9Xc02d2vjiezk0izIEM&s=sI-EDX5g0v_gF7fpvHRlgMvP6dtdT5Iw4aJAQoa8-AU&e=
>> hread.html#139130
>>
> Also, can you add the tag for tracking bug/features:
> [YOCTO #11363]
> 

Done.

>> Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
>> Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
>> Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
>> Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
>> Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
>> Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
>> ---
>> [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to
>> the
>> "work" directory in alternate kernel builds, instead of "work-
>> shared",
>> so
>> that the two builds don't clobber each other.
>>
>> [PATCH v3] An updated version of this change rebased onto the current
>> OE-core master. Changes:
>>   - Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
>>     kernel builds, since alternate kernels aren't the
>>     PREFERRED_PROVIDER for virtual/kernel by definition.
>>   - Remove "virtual/kernel" from PROVIDES in alternate kernel builds.
>>
>> [PATCH v4] Another rebase onto master; no functional change.
>> Improved description and testing steps.
>>
>> [PATCH v5]
>>   - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
>>   - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions
>>
>> [PATCH v6] Add KERNEL_PACKAGE_NAME to kernel-module-split.bbclass for
>> module recipes; fixes lttng-modules build.
>>
>> [PATCH v7] Remove second definition of KERNEL_PACKAGE_NAME from
>> kernel-module-split.bbclass; apply a default in two places where
>> KERNEL_PACKAGE_NAME is referenced.
>>
>> [PATCH v8] Rebase onto current master and more fixups.
>>   - kernel-devicetree.bbclass: Fixup package names
>>   - depmodwrapper-cross: don't error when called from alt kernel
>> recipes
>>   - kernel.bbclass: Don't install /boot/image symlink in alt recipes
>>
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_harisokanovic_openembedded-2Dcore_tree_dev_hokanovi_&d=DwICaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=CELKDprUza4SWI1u2Fypwugx9Xc02d2vjiezk0izIEM&s=guWWLvqmyFm1pkNjrzqqwhkTkd_tmRlVAXoMv-zSyyI&e=
>> multi-kernel-packages-v8
>> ---
>>   meta/classes/kernel-devicetree.bbclass             |   8 +-
>>   meta/classes/kernel-module-split.bbclass           |   9 +-
>>   meta/classes/kernel.bbclass                        | 114
>> +++++++++++++--------
>>   meta/conf/documentation.conf                       |   1 +
>>   .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |  14 +--
>>   meta/recipes-kernel/linux/linux-yocto.inc          |   2 +-
>>   6 files changed, 90 insertions(+), 58 deletions(-)
>>
>> diff --git a/meta/classes/kernel-devicetree.bbclass
>> b/meta/classes/kernel-devicetree.bbclass
>> index 6e08be4b70..4f80cc62eb 100644
>> --- a/meta/classes/kernel-devicetree.bbclass
>> +++ b/meta/classes/kernel-devicetree.bbclass
>> @@ -1,10 +1,10 @@
>>   # Support for device tree generation
>>   PACKAGES_append = " \
>> -    kernel-devicetree \
>> -    ${@['kernel-image-zimage-bundle',
>> ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
>> +    ${KERNEL_PACKAGE_NAME}-devicetree \
>> +    ${@[d.getVar('KERNEL_PACKAGE_NAME') + '-image-zimage-bundle',
>> ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
>>   "
>> -FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb
>> /${KERNEL_IMAGEDEST}/*.dtbo"
>> -FILES_kernel-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-
>> *.dtb.bin"
>> +FILES_${KERNEL_PACKAGE_NAME}-devicetree =
>> "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
>> +FILES_${KERNEL_PACKAGE_NAME}-image-zimage-bundle =
>> "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
>>   
>>   # Generate kernel+devicetree bundle
>>   KERNEL_DEVICETREE_BUNDLE ?= "0"
>> diff --git a/meta/classes/kernel-module-split.bbclass
>> b/meta/classes/kernel-module-split.bbclass
>> index 1035525dac..73c7f18c78 100644
>> --- a/meta/classes/kernel-module-split.bbclass
>> +++ b/meta/classes/kernel-module-split.bbclass
>> @@ -30,7 +30,7 @@ do_install_append() {
>>   
>>   PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>>   
>> -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
>> +KERNEL_MODULES_META_PACKAGE ?= "${@ d.getVar("KERNEL_PACKAGE_NAME",
>> True) or "kernel" }-modules"
>>   
>>   KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>>   KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
>> @@ -129,16 +129,19 @@ python split_kernel_module_packages () {
>>              postfix = format.split('%s')[1]
>>              d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
>>   
>> +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True) or
>> "kernel"
>> +    kernel_version = d.getVar("KERNEL_VERSION", True)
>> +
>>       module_regex = '^(.*)\.k?o$'
>>   
>>       module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>>       module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
>> -    module_pattern = module_pattern_prefix + 'kernel-module-%s' +
>> module_pattern_suffix
>> +    module_pattern = module_pattern_prefix + kernel_package_name +
>> '-module-%s' + module_pattern_suffix
>>   
>>       postinst = d.getVar('pkg_postinst_modules')
>>       postrm = d.getVar('pkg_postrm_modules')
>>   
>> -    modules = do_split_packages(d,
>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>> output_pattern=module_pattern, description='%s kernel module',
>> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
>> extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
>> +    modules = do_split_packages(d,
>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>> output_pattern=module_pattern, description='%s kernel module',
>> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
>> extra_depends='%s-%s' % (kernel_package_name, kernel_version))
>>       if modules:
>>           metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>>           d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
>> diff --git a/meta/classes/kernel.bbclass
>> b/meta/classes/kernel.bbclass
>> index 756707a3c2..48b718d777 100644
>> --- a/meta/classes/kernel.bbclass
>> +++ b/meta/classes/kernel.bbclass
>> @@ -1,6 +1,9 @@
>>   inherit linux-kernel-base kernel-module-split
>>   
>> -PROVIDES += "virtual/kernel"
>> +KERNEL_PACKAGE_NAME ??= "kernel"
>> +KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME",
>> True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
>> +
>> +PROVIDES += "${@ "virtual/kernel" if
>> (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
>>   DEPENDS += "virtual/${TARGET_PREFIX}binutils
>> virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
>>   PACKAGE_WRITE_DEPS += "depmodwrapper-cross"
>>   
>> @@ -34,11 +37,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_
>> name(d.getVar('KERNEL_VERSION')
>>   KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
>>   
>>   python __anonymous () {
>> +    pn = d.getVar("PN", True)
>> +    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
>> +
>> +    # XXX Remove this after bug 11905 is resolved
>> +    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
>> +    if kpn == pn:
>> +        bb.warn("Some packages (E.g. *-dev) might be missing due to
>> "
>> +                "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
>> +
>> +    # The default kernel recipe builds in a shared location defined
>> by
>> +    # bitbake/distro confs: STAGING_KERNEL_DIR and
>> STAGING_KERNEL_BUILDDIR.
>> +    # Set these variables to directories under ${WORKDIR} in
>> alternate
>> +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so
>> that they
>> +    # may build in parallel with the default kernel without
>> clobbering.
>> +    if kpn != "kernel":
>> +        workdir = d.getVar("WORKDIR", True)
>> +        sourceDir = os.path.join(workdir, 'kernel-source')
>> +        artifactsDir = os.path.join(workdir, 'kernel-build-
>> artifacts')
>> +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
>> +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
>>   
>>       # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
>> KERNEL_IMAGETYPES
>>       type = d.getVar('KERNEL_IMAGETYPE') or ""
>>       alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>>       types = d.getVar('KERNEL_IMAGETYPES') or ""
>> +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
>>       if type not in types.split():
>>           types = (type + ' ' + types).strip()
>>       if alttype not in types.split():
>> @@ -55,15 +79,15 @@ python __anonymous () {
>>           typelower = type.lower()
>>           imagedest = d.getVar('KERNEL_IMAGEDEST')
>>   
>> -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
>> +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
>>   
>> -        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest
>> + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' +
>> type)
>> +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' +
>> imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest
>> + '/' + type)
>>   
>> -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' +
>> typelower)
>> +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' %
>> (kname, typelower))
>>   
>> -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' +
>> typelower + '-${KERNEL_VERSION_PKG_NAME}')
>> +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-
>> %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>>   
>> -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
>> +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower),
>> '1')
>>   
>>       image = d.getVar('INITRAMFS_IMAGE')
>>       if image:
>> @@ -121,9 +145,9 @@ base_do_unpack_append () {
>>   
>>   inherit kernel-arch deploy
>>   
>> -PACKAGES_DYNAMIC += "^kernel-module-.*"
>> -PACKAGES_DYNAMIC += "^kernel-image-.*"
>> -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>>   
>>   export OS = "${TARGET_OS}"
>>   export CROSS_COMPILE = "${TARGET_PREFIX}"
>> @@ -339,7 +363,9 @@ kernel_do_install() {
>>   	install -d ${D}/boot
>>   	for type in ${KERNEL_IMAGETYPES} ; do
>>   		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>> ${D}/${KERNEL_IMAGEDEST}/${type}-${KERNEL_VERSION}
>> -		ln -sf ${type}-${KERNEL_VERSION}
>> ${D}/${KERNEL_IMAGEDEST}/${type}
>> +		if [ "${KERNEL_PACKAGE_NAME}" == "kernel" ]; then
>> +			ln -sf ${type}-${KERNEL_VERSION}
>> ${D}/${KERNEL_IMAGEDEST}/${type}
>> +		fi
>>   	done
>>   	install -m 0644 System.map ${D}/boot/System.map-
>> ${KERNEL_VERSION}
>>   	install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
>> @@ -393,9 +419,9 @@ do_shared_workdir_setscene () {
>>   
>>   emit_depmod_pkgdata() {
>>   	# Stash data for depmod
>> -	install -d ${PKGDESTWORK}/kernel-depmod/
>> -	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
>> depmod/kernel-abiversion
>> -	cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-
>> ${KERNEL_VERSION}
>> +	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
>> +	echo "${KERNEL_VERSION}" >
>> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-
>> abiversion
>> +	cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
>> depmod/System.map-${KERNEL_VERSION}
>>   }
>>   
>>   PACKAGEFUNCS += "emit_depmod_pkgdata"
>> @@ -410,7 +436,7 @@ do_shared_workdir () {
>>   	# Store the kernel version in sysroots for module-
>> base.bbclass
>>   	#
>>   
>> -	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
>> +	echo "${KERNEL_VERSION}" >
>> $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>>   
>>   	# Copy files required for module builds
>>   	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
>> @@ -508,28 +534,28 @@ EXPORT_FUNCTIONS do_compile do_install
>> do_configure
>>   
>>   # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base
>> ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
>> ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>>   FILES_${PN} = ""
>> -FILES_kernel-base =
>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>> -FILES_kernel-image = ""
>> -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
>> /boot/config* ${KERNEL_SRC_PATH}
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>> -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
>> -FILES_kernel-modules = ""
>> -RDEPENDS_kernel = "kernel-base"
>> +FILES_${KERNEL_PACKAGE_NAME}-base =
>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>> +FILES_${KERNEL_PACKAGE_NAME}-image = ""
>> +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
>> /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>> +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
>> ${KERNEL_VERSION_NAME}"
>> +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
>> +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
>>   # Allow machines to override this dependency if kernel image files
>> are
>>   # not wanted in images as standard
>> -RDEPENDS_kernel-base ?= "kernel-image"
>> -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNE
>> L_VERSION}')}"
>> -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE',
>> 'vmlinux', 'kernel-vmlinux', '', d)}"
>> -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSI
>> ON}')}"
>> -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"
>> -
>> -pkg_postinst_kernel-base () {
>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-
>> image"
>> +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@
>> legitimize_package_name('${KERNEL_VERSION}')}"
>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNE
>> L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
>> +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitim
>> ize_package_name('${KERNEL_VERSION}')}"
>> +RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-
>> ${KERNEL_VERSION}"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
>> +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta
>> package"
>> +
>> +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>>   	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>>   		mkdir -p $D/lib/modules/${KERNEL_VERSION}
>>   	fi
>> @@ -543,7 +569,7 @@ pkg_postinst_kernel-base () {
>>   PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>>   
>>   python split_kernel_packages () {
>> -    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-
>> firmware-%s', description='Firmware for %s', recursive=True,
>> extra_depends='')
>> +    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>> output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
>> description='Firmware for %s', recursive=True, extra_depends='')
>>   }
>>   
>>   # Many scripts want to look in arch/$arch/boot for the bootable
>> @@ -626,21 +652,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-
>> ${MACHINE}.tgz"
>>   MODULE_TARBALL_DEPLOY ?= "1"
>>   
>>   kernel_do_deploy() {
>> +	deployDir="${DEPLOYDIR}"
>> +	if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
>> +		deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
>> +		mkdir "$deployDir"
>> +	fi
>> +
>>   	for type in ${KERNEL_IMAGETYPES} ; do
>>   		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>> -		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>> ${DEPLOYDIR}/${base_name}.bin
>> +		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>> $deployDir/${base_name}.bin
>>   	done
>>   	if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e
>> '^CONFIG_MODULES=y$' .config); then
>>   		mkdir -p ${D}/lib
>> -		tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME}
>> -C ${D} lib
>> -		ln -sf ${MODULE_TARBALL_BASE_NAME}
>> ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
>> +		tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME} -C
>> ${D} lib
>> +		ln -sf ${MODULE_TARBALL_BASE_NAME}
>> $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
>>   	fi
>>   
>>   	for type in ${KERNEL_IMAGETYPES} ; do
>>   		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>>   		symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
>> -		ln -sf ${base_name}.bin
>> ${DEPLOYDIR}/${symlink_name}.bin
>> -		ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
>> +		ln -sf ${base_name}.bin
>> $deployDir/${symlink_name}.bin
>> +		ln -sf ${base_name}.bin $deployDir/${type}
>>   	done
>>   
>>   	cd ${B}
>> @@ -650,8 +682,8 @@ kernel_do_deploy() {
>>   			echo "Copying deploy ${type} kernel-
>> initramfs image and setting up links..."
>>   			initramfs_base_name=${type}-
>> ${INITRAMFS_BASE_NAME}
>>   			initramfs_symlink_name=${type}-initramfs-
>> ${MACHINE}
>> -			install -m 0644
>> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
>> ${DEPLOYDIR}/${initramfs_base_name}.bin
>> -			ln -sf ${initramfs_base_name}.bin
>> ${DEPLOYDIR}/${initramfs_symlink_name}.bin
>> +			install -m 0644
>> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
>> $deployDir/${initramfs_base_name}.bin
>> +			ln -sf ${initramfs_base_name}.bin
>> $deployDir/${initramfs_symlink_name}.bin
>>   		fi
>>   	done
>>   }
>> diff --git a/meta/conf/documentation.conf
>> b/meta/conf/documentation.conf
>> index a55e2836b5..2c88504fb9 100644
>> --- a/meta/conf/documentation.conf
>> +++ b/meta/conf/documentation.conf
>> @@ -247,6 +247,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to
>> build for a device, usually set b
>>   KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a
>> device, usually set by the machine configuration files and defaults
>> to KERNEL_IMAGETYPE."
>>   KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be
>> auto-loaded during boot"
>>   KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the
>> build system expects to find module_conf_* values that specify
>> configuration for each of the modules"
>> +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
>> Defaults to 'kernel'."
>>   KERNEL_PATH[doc] = "The location of the kernel sources. This
>> variable is set to the value of the STAGING_KERNEL_DIR within the
>> module class (module.bbclass)."
>>   KERNEL_SRC[doc] = "The location of the kernel sources. This variable
>> is set to the value of the STAGING_KERNEL_DIR within the module class
>> (module.bbclass)."
>>   KFEATURE_DESCRIPTION[doc] = "Provides a short description of a
>> configuration fragment. You use this variable in the .scc file that
>> describes a configuration fragment file."
>> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> index 44d013f29d..2eec921728 100644
>> --- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> @@ -23,17 +23,13 @@ if [ "\$1" != "-a" -o "\$2" != "-b" ]; then
>>       echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
>>       exit 1
>>   fi
>> -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion ]; then
>> -    echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/kernel-
>> abiversion" >&2
>> -else
>> -    kernelabi=\$(cat ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion)
>> -    if [ "\$kernelabi" != "\$4" ]; then
>> -        echo "Error: Kernel version \$4 does not match kernel-
>> abiversion (\$kernelabi)" >&2
>> -        exit 1
>> -    fi
>> +
>> +kernelabi=""
>> +if [ -r "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" ]; then
>> +    kernelabi=\$(cat "${PKGDATA_DIR}/kernel-depmod/kernel-
>> abiversion")
>>   fi
>>   
>> -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ]; then
>> +if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [
>> "\$kernelabi" != "\$4" ]; then
>>       echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/System.map-
>> \$4" >&2
>>       exec env depmod "\$1" "\$2" "\$3" "\$4"
>>   else
>> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
>> b/meta/recipes-kernel/linux/linux-yocto.inc
>> index 9c1f61be75..8a70eb5018 100644
>> --- a/meta/recipes-kernel/linux/linux-yocto.inc
>> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
>> @@ -12,7 +12,7 @@ INC_PR = "r4"
>>   # PREFERRED_PROVIDER for virtual/kernel. This avoids network access
>> required
>>   # by the use of AUTOREV SRCREVs, which are the default for this
>> recipe.
>>   python () {
>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
>> d.getVar("PN"):
>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>> d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN",
>> True):
> 
> I think this change is also needed in the *-rt recipes as they have a
> similar check, maybe that check just needs to be removed?
> 

I don't _think_ the check is strictly necessary, since building an image 
should always select PREFERRED_PROVIDER_virtual/kernel recipe. However, 
I don't know all use cases of kernel.bbclass and associated recipes, so 
I opted to preserve existing behavior to be on the safe side. I.e. 
Alternate kernel recipes are not be buildable unless KERNEL_PACKAGE_NAME 
is also changed.

I'll defer to someone else on entirely removing this sanity check. For 
now, I made the aforementioned change to other *-rt recipes as you 
suggested. Also verified linux-yocto-rt is not buildable unless 
`KERNEL_PACKAGE_NAME_pn-linux-yocto-rt = "rt-linux"` is added to local.conf.

> Sau!
>>           d.delVar("BB_DONT_CACHE")
>>           raise bb.parse.SkipPackage("Set
>> PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
>> (d.getVar("PN")))
>>   }
>> -- 
>> 2.14.2
>>

I'll post a V9 shortly.

-- Haris


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v8] kernel: Add support for multiple kernel packages
  2017-10-25  8:00         ` Bruce Ashfield
@ 2017-10-25 23:49           ` Haris Okanovic
  0 siblings, 0 replies; 31+ messages in thread
From: Haris Okanovic @ 2017-10-25 23:49 UTC (permalink / raw)
  To: Bruce Ashfield
  Cc: Wold, Saul, Patches and discussions about the oe-core layer,
	josh.hernstrom



On 10/25/2017 03:00 AM, Bruce Ashfield wrote:
> On Thu, Oct 19, 2017 at 3:19 PM, Haris Okanovic <haris.okanovic@ni.com> wrote:
>> Some distros may want to provide alternate kernel "flavors" via feeds or
>> within bootable images. For example, readily available builds which
>> provide certain diagnostic features can enable developers and testers to
>> more quickly resolve issues by avoiding lengthy kernel builds.
>>
>> This change allows for building multiple flavors of the kernel and
>> module packages by templatizing kernel package names via a new
>> KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the old
>> name of "kernel", but can be overridden by certain recipes providing
>> alternate kernel flavors.
>>
>> To maintain compatibility, recipes providing alternate kernel flavors
>> cannot be the "preferred provider" for virtual/kernel. This is because
>> OE puts the preferred provider's build and source at
>> "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
>> "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
>> "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using the
>> default KERNEL_PACKAGE_NAME="kernel" follows the old semantics -- build
>> in the old location and may be preferred provider -- while recipes using
>> all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and don't
>> provide "virtual/kernel".
>>
>> Testing:
>>   1. Prepended `KERNEL_PACKAGE_NAME = "tiny-linux"` to
>>      linux-yocto-tiny_4.9.bb so that it may build alongside
>>      the main kernel.
>>   2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel flavors.
>>   3. Verified image and modules IPKs exist for both:
>>      tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>>      tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
>>   4. Verified linux-yocto is the "preferred provider", and was built in
>>      shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>>   5. Appended `CORE_IMAGE_BASE_INSTALL += "tiny-linux"` to
>>      core-image-base.bb to include both kernel flavors.
>>   6. `bitbake core-image-base` to build an image.
>>   7. Verified image contains two bzImage's under /boot/, with
>>      "yocto-standard" selected to boot via symlink.
>>
>> Discussion threads:
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org_pipermail_openembedded-2Dcore_2015-2DDecember_thread.html-23114122&d=DwIFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=IQK-3FiOavEFVw7leFD0d4BvVhNPMEK_t-k_zxTTplY&s=Mi4q3g-xO_2-FIVwIT0ndJOC_NzE0e4Z_VZm4iIkI14&e=
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org_pipermail_openembedded-2Dcore_2017-2DJuly_thread.html-23139130&d=DwIFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=IQK-3FiOavEFVw7leFD0d4BvVhNPMEK_t-k_zxTTplY&s=-PHnINRO8z8mw3j15b6oAimJJFkMcyk_kr2c9mReYx0&e=
>>
>> Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
>> Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
>> Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
>> Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
>> Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
>> Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
>> ---
>> [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to the
>> "work" directory in alternate kernel builds, instead of "work-shared",
>> so
>> that the two builds don't clobber each other.
>>
>> [PATCH v3] An updated version of this change rebased onto the current
>> OE-core master. Changes:
>>   - Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
>>     kernel builds, since alternate kernels aren't the
>>     PREFERRED_PROVIDER for virtual/kernel by definition.
>>   - Remove "virtual/kernel" from PROVIDES in alternate kernel builds.
>>
>> [PATCH v4] Another rebase onto master; no functional change.
>> Improved description and testing steps.
>>
>> [PATCH v5]
>>   - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
>>   - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions
>>
>> [PATCH v6] Add KERNEL_PACKAGE_NAME to kernel-module-split.bbclass for
>> module recipes; fixes lttng-modules build.
>>
>> [PATCH v7] Remove second definition of KERNEL_PACKAGE_NAME from
>> kernel-module-split.bbclass; apply a default in two places where
>> KERNEL_PACKAGE_NAME is referenced.
>>
>> [PATCH v8] Rebase onto current master and more fixups.
>>   - kernel-devicetree.bbclass: Fixup package names
>>   - depmodwrapper-cross: don't error when called from alt kernel recipes
>>   - kernel.bbclass: Don't install /boot/image symlink in alt recipes
>>
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_harisokanovic_openembedded-2Dcore_tree_dev_hokanovi_multi-2Dkernel-2Dpackages-2Dv8&d=DwIFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=IQK-3FiOavEFVw7leFD0d4BvVhNPMEK_t-k_zxTTplY&s=WcRCf1pg_c3VTEyiF11sSomaRy_dFiFJE74X4QEFi80&e=
>> ---
>>   meta/classes/kernel-devicetree.bbclass             |   8 +-
>>   meta/classes/kernel-module-split.bbclass           |   9 +-
>>   meta/classes/kernel.bbclass                        | 114 +++++++++++++--------
>>   meta/conf/documentation.conf                       |   1 +
>>   .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |  14 +--
>>   meta/recipes-kernel/linux/linux-yocto.inc          |   2 +-
>>   6 files changed, 90 insertions(+), 58 deletions(-)
>>
>> diff --git a/meta/classes/kernel-devicetree.bbclass b/meta/classes/kernel-devicetree.bbclass
>> index 6e08be4b70..4f80cc62eb 100644
>> --- a/meta/classes/kernel-devicetree.bbclass
>> +++ b/meta/classes/kernel-devicetree.bbclass
>> @@ -1,10 +1,10 @@
>>   # Support for device tree generation
>>   PACKAGES_append = " \
>> -    kernel-devicetree \
>> -    ${@['kernel-image-zimage-bundle', ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
>> +    ${KERNEL_PACKAGE_NAME}-devicetree \
>> +    ${@[d.getVar('KERNEL_PACKAGE_NAME') + '-image-zimage-bundle', ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
>>   "
>> -FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
>> -FILES_kernel-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
>> +FILES_${KERNEL_PACKAGE_NAME}-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
>> +FILES_${KERNEL_PACKAGE_NAME}-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
>>
>>   # Generate kernel+devicetree bundle
>>   KERNEL_DEVICETREE_BUNDLE ?= "0"
>> diff --git a/meta/classes/kernel-module-split.bbclass b/meta/classes/kernel-module-split.bbclass
>> index 1035525dac..73c7f18c78 100644
>> --- a/meta/classes/kernel-module-split.bbclass
>> +++ b/meta/classes/kernel-module-split.bbclass
>> @@ -30,7 +30,7 @@ do_install_append() {
>>
>>   PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>>
>> -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
>> +KERNEL_MODULES_META_PACKAGE ?= "${@ d.getVar("KERNEL_PACKAGE_NAME", True) or "kernel" }-modules"
>>
>>   KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>>   KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
>> @@ -129,16 +129,19 @@ python split_kernel_module_packages () {
>>              postfix = format.split('%s')[1]
>>              d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
>>
>> +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True) or "kernel"
>> +    kernel_version = d.getVar("KERNEL_VERSION", True)
> 
> Minor 'nit, is this just a cleanup and not part of the technical bits
> of the patch ?
> When making changes to a complex recipe .. it really is a better idea to do this
> in a separate patch.
> 
> If I've missed how this is related to the new KERNEL_PACKAGE_NAME, then
> disregard that comment. i.e. you really can't mix the new variable and
> the d.getVar
> call in the do_split_packages. Either way, no issue .. that use of a
> variable just
> jumped out to me as unrelated to the actual package name varying.
> 

Kernel images and their modules are tightly coupled. To the best of my 
knowledge, there's no guarantee two different versions (or even two 
different configurations of the same version) of /boot/*Image can 
successfully load the other's modules. It's therefore necessary to 
package an alternate kernel's modules separately so that it can be 
installed along side alternate kernel images. Otherwise, those alternate 
images are not very useful unless they're configured without module 
support. I argue that module support is common enough to include these 
changes in the same patch, but I suppose that reasoning is somewhat 
subjective and debatable!

>> +
>>       module_regex = '^(.*)\.k?o$'
>>
>>       module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>>       module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
>> -    module_pattern = module_pattern_prefix + 'kernel-module-%s' + module_pattern_suffix
>> +    module_pattern = module_pattern_prefix + kernel_package_name + '-module-%s' + module_pattern_suffix
>>
>>       postinst = d.getVar('pkg_postinst_modules')
>>       postrm = d.getVar('pkg_postrm_modules')
>>
>> -    modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
>> +    modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='%s-%s' % (kernel_package_name, kernel_version))
>>       if modules:
>>           metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>>           d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
>> diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
>> index 756707a3c2..48b718d777 100644
>> --- a/meta/classes/kernel.bbclass
>> +++ b/meta/classes/kernel.bbclass
>> @@ -1,6 +1,9 @@
>>   inherit linux-kernel-base kernel-module-split
>>
>> -PROVIDES += "virtual/kernel"
>> +KERNEL_PACKAGE_NAME ??= "kernel"
>> +KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
>> +
>> +PROVIDES += "${@ "virtual/kernel" if (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
>>   DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
>>   PACKAGE_WRITE_DEPS += "depmodwrapper-cross"
>>
>> @@ -34,11 +37,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION')
>>   KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
>>
>>   python __anonymous () {
>> +    pn = d.getVar("PN", True)
>> +    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
>> +
>> +    # XXX Remove this after bug 11905 is resolved
>> +    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
>> +    if kpn == pn:
>> +        bb.warn("Some packages (E.g. *-dev) might be missing due to "
>> +                "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
>> +
>> +    # The default kernel recipe builds in a shared location defined by
>> +    # bitbake/distro confs: STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR.
>> +    # Set these variables to directories under ${WORKDIR} in alternate
>> +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so that they
>> +    # may build in parallel with the default kernel without clobbering.
>> +    if kpn != "kernel":
>> +        workdir = d.getVar("WORKDIR", True)
>> +        sourceDir = os.path.join(workdir, 'kernel-source')
>> +        artifactsDir = os.path.join(workdir, 'kernel-build-artifacts')
>> +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
>> +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
>>
>>       # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES
>>       type = d.getVar('KERNEL_IMAGETYPE') or ""
>>       alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>>       types = d.getVar('KERNEL_IMAGETYPES') or ""
>> +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
>>       if type not in types.split():
>>           types = (type + ' ' + types).strip()
>>       if alttype not in types.split():
>> @@ -55,15 +79,15 @@ python __anonymous () {
>>           typelower = type.lower()
>>           imagedest = d.getVar('KERNEL_IMAGEDEST')
>>
>> -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
>> +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
>>
>> -        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type)
>> +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type)
>>
>> -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' + typelower)
>> +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' % (kname, typelower))
>>
>> -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' + typelower + '-${KERNEL_VERSION_PKG_NAME}')
>> +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>>
>> -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
>> +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower), '1')
>>
>>       image = d.getVar('INITRAMFS_IMAGE')
>>       if image:
>> @@ -121,9 +145,9 @@ base_do_unpack_append () {
>>
>>   inherit kernel-arch deploy
>>
>> -PACKAGES_DYNAMIC += "^kernel-module-.*"
>> -PACKAGES_DYNAMIC += "^kernel-image-.*"
>> -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>>
>>   export OS = "${TARGET_OS}"
>>   export CROSS_COMPILE = "${TARGET_PREFIX}"
>> @@ -339,7 +363,9 @@ kernel_do_install() {
>>          install -d ${D}/boot
>>          for type in ${KERNEL_IMAGETYPES} ; do
>>                  install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${D}/${KERNEL_IMAGEDEST}/${type}-${KERNEL_VERSION}
>> -               ln -sf ${type}-${KERNEL_VERSION} ${D}/${KERNEL_IMAGEDEST}/${type}
>> +               if [ "${KERNEL_PACKAGE_NAME}" == "kernel" ]; then
>> +                       ln -sf ${type}-${KERNEL_VERSION} ${D}/${KERNEL_IMAGEDEST}/${type}
>> +               fi
>>          done
>>          install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION}
>>          install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
>> @@ -393,9 +419,9 @@ do_shared_workdir_setscene () {
>>
>>   emit_depmod_pkgdata() {
>>          # Stash data for depmod
>> -       install -d ${PKGDESTWORK}/kernel-depmod/
>> -       echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-depmod/kernel-abiversion
>> -       cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-${KERNEL_VERSION}
>> +       install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
>> +       echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-abiversion
>> +       cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/System.map-${KERNEL_VERSION}
>>   }
>>
>>   PACKAGEFUNCS += "emit_depmod_pkgdata"
>> @@ -410,7 +436,7 @@ do_shared_workdir () {
>>          # Store the kernel version in sysroots for module-base.bbclass
>>          #
>>
>> -       echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
>> +       echo "${KERNEL_VERSION}" > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>>
>>          # Copy files required for module builds
>>          cp System.map $kerneldir/System.map-${KERNEL_VERSION}
>> @@ -508,28 +534,28 @@ EXPORT_FUNCTIONS do_compile do_install do_configure
>>
>>   # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>>   FILES_${PN} = ""
>> -FILES_kernel-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>> -FILES_kernel-image = ""
>> -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>> -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
>> -FILES_kernel-modules = ""
>> -RDEPENDS_kernel = "kernel-base"
>> +FILES_${KERNEL_PACKAGE_NAME}-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>> +FILES_${KERNEL_PACKAGE_NAME}-image = ""
>> +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>> +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
>> +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
>> +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
>>   # Allow machines to override this dependency if kernel image files are
>>   # not wanted in images as standard
>> -RDEPENDS_kernel-base ?= "kernel-image"
>> -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
>> -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', 'kernel-vmlinux', '', d)}"
>> -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSION}')}"
>> -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"
>> -
>> -pkg_postinst_kernel-base () {
>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-image"
>> +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
>> +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitimize_package_name('${KERNEL_VERSION}')}"
>> +RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-${KERNEL_VERSION}"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
>> +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta package"
>> +
>> +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>>          if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>>                  mkdir -p $D/lib/modules/${KERNEL_VERSION}
>>          fi
>> @@ -543,7 +569,7 @@ pkg_postinst_kernel-base () {
>>   PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>>
>>   python split_kernel_packages () {
>> -    do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
>> +    do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
>>   }
>>
>>   # Many scripts want to look in arch/$arch/boot for the bootable
>> @@ -626,21 +652,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-${MACHINE}.tgz"
>>   MODULE_TARBALL_DEPLOY ?= "1"
>>
>>   kernel_do_deploy() {
>> +       deployDir="${DEPLOYDIR}"
>> +       if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
>> +               deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
>> +               mkdir "$deployDir"
>> +       fi
>> +
>>          for type in ${KERNEL_IMAGETYPES} ; do
>>                  base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>> -               install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${DEPLOYDIR}/${base_name}.bin
>> +               install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} $deployDir/${base_name}.bin
>>          done
>>          if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
>>                  mkdir -p ${D}/lib
>> -               tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
>> -               ln -sf ${MODULE_TARBALL_BASE_NAME} ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
>> +               tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
>> +               ln -sf ${MODULE_TARBALL_BASE_NAME} $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
>>          fi
>>
>>          for type in ${KERNEL_IMAGETYPES} ; do
>>                  base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>>                  symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
>> -               ln -sf ${base_name}.bin ${DEPLOYDIR}/${symlink_name}.bin
>> -               ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
>> +               ln -sf ${base_name}.bin $deployDir/${symlink_name}.bin
>> +               ln -sf ${base_name}.bin $deployDir/${type}
>>          done
>>
>>          cd ${B}
>> @@ -650,8 +682,8 @@ kernel_do_deploy() {
>>                          echo "Copying deploy ${type} kernel-initramfs image and setting up links..."
>>                          initramfs_base_name=${type}-${INITRAMFS_BASE_NAME}
>>                          initramfs_symlink_name=${type}-initramfs-${MACHINE}
>> -                       install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs ${DEPLOYDIR}/${initramfs_base_name}.bin
>> -                       ln -sf ${initramfs_base_name}.bin ${DEPLOYDIR}/${initramfs_symlink_name}.bin
>> +                       install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs $deployDir/${initramfs_base_name}.bin
>> +                       ln -sf ${initramfs_base_name}.bin $deployDir/${initramfs_symlink_name}.bin
>>                  fi
>>          done
>>   }
>> diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
>> index a55e2836b5..2c88504fb9 100644
>> --- a/meta/conf/documentation.conf
>> +++ b/meta/conf/documentation.conf
>> @@ -247,6 +247,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to build for a device, usually set b
>>   KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a device, usually set by the machine configuration files and defaults to KERNEL_IMAGETYPE."
>>   KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be auto-loaded during boot"
>>   KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the build system expects to find module_conf_* values that specify configuration for each of the modules"
>> +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages. Defaults to 'kernel'."
>>   KERNEL_PATH[doc] = "The location of the kernel sources. This variable is set to the value of the STAGING_KERNEL_DIR within the module class (module.bbclass)."
>>   KERNEL_SRC[doc] = "The location of the kernel sources. This variable is set to the value of the STAGING_KERNEL_DIR within the module class (module.bbclass)."
>>   KFEATURE_DESCRIPTION[doc] = "Provides a short description of a configuration fragment. You use this variable in the .scc file that describes a configuration fragment file."
>> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> index 44d013f29d..2eec921728 100644
>> --- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> @@ -23,17 +23,13 @@ if [ "\$1" != "-a" -o "\$2" != "-b" ]; then
>>       echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
>>       exit 1
>>   fi
>> -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion ]; then
>> -    echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" >&2
>> -else
>> -    kernelabi=\$(cat ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion)
>> -    if [ "\$kernelabi" != "\$4" ]; then
>> -        echo "Error: Kernel version \$4 does not match kernel-abiversion (\$kernelabi)" >&2
>> -        exit 1
> 
> Why is the kernel abi check being dropped ? Or is is somehow relocated and the
> diff is just hiding it from me ?
> 
> I see you referencing the depmod wrapper change in the v8 summary, but it
> isn't clear to me that removing the check completely is a good idea.
> 
> The changes look good to me in general, just my comment and question
> above.
>
The abi check moved down a few lines...

> Bruce
> 
>> -    fi
>> +
>> +kernelabi=""
>> +if [ -r "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" ]; then
>> +    kernelabi=\$(cat "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion")
>>   fi
>>
>> -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ]; then
>> +if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [ "\$kernelabi" != "\$4" ]; then

...to here.

Depmodwrapper conditionally passes a `-F .../System.map` parameter to 
depmod when installing the main kernel, dropping it otherwise (now with 
a warning instead of an error). This shouldn't alter depmod's behavior 
since -F is only significant when paired with -e, which not presently 
being used. It's necessary since an erroring depmodwrapper prevents 
installing alternate kernels into offline images.

>>       echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/System.map-\$4" >&2
>>       exec env depmod "\$1" "\$2" "\$3" "\$4"
>>   else
>> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc
>> index 9c1f61be75..8a70eb5018 100644
>> --- a/meta/recipes-kernel/linux/linux-yocto.inc
>> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
>> @@ -12,7 +12,7 @@ INC_PR = "r4"
>>   # PREFERRED_PROVIDER for virtual/kernel. This avoids network access required
>>   # by the use of AUTOREV SRCREVs, which are the default for this recipe.
>>   python () {
>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != d.getVar("PN"):
>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN", True):
>>           d.delVar("BB_DONT_CACHE")
>>           raise bb.parse.SkipPackage("Set PREFERRED_PROVIDER_virtual/kernel to %s to enable it" % (d.getVar("PN")))
>>   }
>> --
>> 2.14.2
>>
> 
> 
> 

-- Haris


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH v9] kernel: Add support for multiple kernel packages
  2017-07-19 15:56     ` Wold, Saul
                         ` (5 preceding siblings ...)
  2017-10-19 19:19       ` [PATCH v8] " Haris Okanovic
@ 2017-11-07 18:40       ` Haris Okanovic
  2017-11-08 22:20         ` Wold, Saul
  6 siblings, 1 reply; 31+ messages in thread
From: Haris Okanovic @ 2017-11-07 18:40 UTC (permalink / raw)
  To: openembedded-core; +Cc: haris.okanovic, saul.wold, josh.hernstrom

Some distros may want to provide alternate kernel "flavors" via feeds or
within bootable images. For example, readily available builds which
provide certain diagnostic features can enable developers and testers to
more quickly resolve issues by avoiding lengthy kernel builds.

This change allows for building multiple flavors of the kernel and
module packages by templatizing kernel package names via a new
KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the old
name of "kernel", but can be overridden by certain recipes providing
alternate kernel flavors.

To maintain compatibility, recipes providing alternate kernel flavors
cannot be the "preferred provider" for virtual/kernel. This is because
OE puts the preferred provider's build and source at
"tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
"tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
"tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using the
default KERNEL_PACKAGE_NAME="kernel" follows the old semantics -- build
in the old location and may be preferred provider -- while recipes using
all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and don't
provide "virtual/kernel".

Testing:
 1. Add `KERNEL_PACKAGE_NAME_pn-linux-yocto-tiny = "tiny-linux"`
    to local.conf so that linux-yocto-tiny may build alongside
    the main kernel (linux-yocto).
 2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel flavors.
 3. Verified image and modules IPKs exist for both:
    tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
    tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
 4. Verified linux-yocto is the "preferred provider", and was built in
    shared directory: tmp-glibc/work-shared/qemux86/kernel-*
 5. Add `CORE_IMAGE_BASE_INSTALL_append_pn-core-image-base = "tiny-linux"`
    to local.conf to install both kernel flavors in core-image-base.
 6. `bitbake core-image-base` to build an image.
 7. Verified image contains two bzImage's under /boot/, with
    "yocto-standard" (linux-yocto recipe) selected to boot via symlink.

Discussion threads:
http://lists.openembedded.org/pipermail/openembedded-core/2015-December/thread.html#114122
http://lists.openembedded.org/pipermail/openembedded-core/2017-July/thread.html#139130

[YOCTO #11363]

Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
---
[PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to the
"work" directory in alternate kernel builds, instead of "work-shared",
so
that the two builds don't clobber each other.

[PATCH v3] An updated version of this change rebased onto the current
OE-core master. Changes:
 - Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
   kernel builds, since alternate kernels aren't the
   PREFERRED_PROVIDER for virtual/kernel by definition.
 - Remove "virtual/kernel" from PROVIDES in alternate kernel builds.

[PATCH v4] Another rebase onto master; no functional change.
Improved description and testing steps.

[PATCH v5]
 - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
 - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions

[PATCH v6] Add KERNEL_PACKAGE_NAME to kernel-module-split.bbclass for
module recipes; fixes lttng-modules build.

[PATCH v7] Remove second definition of KERNEL_PACKAGE_NAME from
kernel-module-split.bbclass; apply a default in two places where
KERNEL_PACKAGE_NAME is referenced.

[PATCH v8] Rebase onto current master and more fixups.
 - kernel-devicetree.bbclass: Fixup package names
 - depmodwrapper-cross: don't error when called from alt kernel recipes
 - kernel.bbclass: Don't install /boot/image symlink in alt recipes

[PATCH v9]
 - Add feature tracking tag
 - Update testing section to define vars in local.conf
 - Add KERNEL_PACKAGE_NAME check to *-rt recipes

https://github.com/harisokanovic/openembedded-core/tree/dev/hokanovi/multi-kernel-packages-v9
---
 meta/classes/kernel-devicetree.bbclass             |   8 +-
 meta/classes/kernel-module-split.bbclass           |   9 +-
 meta/classes/kernel.bbclass                        | 114 +++++++++++++--------
 meta/conf/documentation.conf                       |   1 +
 .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |  14 +--
 meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb   |   2 +-
 meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb   |   2 +-
 meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb    |   2 +-
 meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb    |   2 +-
 meta/recipes-kernel/linux/linux-yocto.inc          |   2 +-
 10 files changed, 94 insertions(+), 62 deletions(-)

diff --git a/meta/classes/kernel-devicetree.bbclass b/meta/classes/kernel-devicetree.bbclass
index 6e08be4b70..4f80cc62eb 100644
--- a/meta/classes/kernel-devicetree.bbclass
+++ b/meta/classes/kernel-devicetree.bbclass
@@ -1,10 +1,10 @@
 # Support for device tree generation
 PACKAGES_append = " \
-    kernel-devicetree \
-    ${@['kernel-image-zimage-bundle', ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
+    ${KERNEL_PACKAGE_NAME}-devicetree \
+    ${@[d.getVar('KERNEL_PACKAGE_NAME') + '-image-zimage-bundle', ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
 "
-FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
-FILES_kernel-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
+FILES_${KERNEL_PACKAGE_NAME}-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
+FILES_${KERNEL_PACKAGE_NAME}-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
 
 # Generate kernel+devicetree bundle
 KERNEL_DEVICETREE_BUNDLE ?= "0"
diff --git a/meta/classes/kernel-module-split.bbclass b/meta/classes/kernel-module-split.bbclass
index 1035525dac..73c7f18c78 100644
--- a/meta/classes/kernel-module-split.bbclass
+++ b/meta/classes/kernel-module-split.bbclass
@@ -30,7 +30,7 @@ do_install_append() {
 
 PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
 
-KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
+KERNEL_MODULES_META_PACKAGE ?= "${@ d.getVar("KERNEL_PACKAGE_NAME", True) or "kernel" }-modules"
 
 KERNEL_MODULE_PACKAGE_PREFIX ?= ""
 KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
@@ -129,16 +129,19 @@ python split_kernel_module_packages () {
            postfix = format.split('%s')[1]
            d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
 
+    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True) or "kernel"
+    kernel_version = d.getVar("KERNEL_VERSION", True)
+
     module_regex = '^(.*)\.k?o$'
 
     module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
     module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
-    module_pattern = module_pattern_prefix + 'kernel-module-%s' + module_pattern_suffix
+    module_pattern = module_pattern_prefix + kernel_package_name + '-module-%s' + module_pattern_suffix
 
     postinst = d.getVar('pkg_postinst_modules')
     postrm = d.getVar('pkg_postrm_modules')
 
-    modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
+    modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='%s-%s' % (kernel_package_name, kernel_version))
     if modules:
         metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
         d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index 756707a3c2..48b718d777 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -1,6 +1,9 @@
 inherit linux-kernel-base kernel-module-split
 
-PROVIDES += "virtual/kernel"
+KERNEL_PACKAGE_NAME ??= "kernel"
+KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
+
+PROVIDES += "${@ "virtual/kernel" if (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
 DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
 PACKAGE_WRITE_DEPS += "depmodwrapper-cross"
 
@@ -34,11 +37,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION')
 KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
 
 python __anonymous () {
+    pn = d.getVar("PN", True)
+    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
+
+    # XXX Remove this after bug 11905 is resolved
+    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
+    if kpn == pn:
+        bb.warn("Some packages (E.g. *-dev) might be missing due to "
+                "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
+
+    # The default kernel recipe builds in a shared location defined by
+    # bitbake/distro confs: STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR.
+    # Set these variables to directories under ${WORKDIR} in alternate
+    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so that they
+    # may build in parallel with the default kernel without clobbering.
+    if kpn != "kernel":
+        workdir = d.getVar("WORKDIR", True)
+        sourceDir = os.path.join(workdir, 'kernel-source')
+        artifactsDir = os.path.join(workdir, 'kernel-build-artifacts')
+        d.setVar("STAGING_KERNEL_DIR", sourceDir)
+        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
 
     # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES
     type = d.getVar('KERNEL_IMAGETYPE') or ""
     alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
     types = d.getVar('KERNEL_IMAGETYPES') or ""
+    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
     if type not in types.split():
         types = (type + ' ' + types).strip()
     if alttype not in types.split():
@@ -55,15 +79,15 @@ python __anonymous () {
         typelower = type.lower()
         imagedest = d.getVar('KERNEL_IMAGEDEST')
 
-        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
+        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
 
-        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type)
+        d.setVar('FILES_' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type)
 
-        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' + typelower)
+        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' % (kname, typelower))
 
-        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' + typelower + '-${KERNEL_VERSION_PKG_NAME}')
+        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
 
-        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
+        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower), '1')
 
     image = d.getVar('INITRAMFS_IMAGE')
     if image:
@@ -121,9 +145,9 @@ base_do_unpack_append () {
 
 inherit kernel-arch deploy
 
-PACKAGES_DYNAMIC += "^kernel-module-.*"
-PACKAGES_DYNAMIC += "^kernel-image-.*"
-PACKAGES_DYNAMIC += "^kernel-firmware-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
+PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
 
 export OS = "${TARGET_OS}"
 export CROSS_COMPILE = "${TARGET_PREFIX}"
@@ -339,7 +363,9 @@ kernel_do_install() {
 	install -d ${D}/boot
 	for type in ${KERNEL_IMAGETYPES} ; do
 		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${D}/${KERNEL_IMAGEDEST}/${type}-${KERNEL_VERSION}
-		ln -sf ${type}-${KERNEL_VERSION} ${D}/${KERNEL_IMAGEDEST}/${type}
+		if [ "${KERNEL_PACKAGE_NAME}" == "kernel" ]; then
+			ln -sf ${type}-${KERNEL_VERSION} ${D}/${KERNEL_IMAGEDEST}/${type}
+		fi
 	done
 	install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION}
 	install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
@@ -393,9 +419,9 @@ do_shared_workdir_setscene () {
 
 emit_depmod_pkgdata() {
 	# Stash data for depmod
-	install -d ${PKGDESTWORK}/kernel-depmod/
-	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-depmod/kernel-abiversion
-	cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-${KERNEL_VERSION}
+	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
+	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-abiversion
+	cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/System.map-${KERNEL_VERSION}
 }
 
 PACKAGEFUNCS += "emit_depmod_pkgdata"
@@ -410,7 +436,7 @@ do_shared_workdir () {
 	# Store the kernel version in sysroots for module-base.bbclass
 	#
 
-	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
+	echo "${KERNEL_VERSION}" > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
 
 	# Copy files required for module builds
 	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
@@ -508,28 +534,28 @@ EXPORT_FUNCTIONS do_compile do_install do_configure
 
 # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
 FILES_${PN} = ""
-FILES_kernel-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
-FILES_kernel-image = ""
-FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
-FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
-FILES_kernel-modules = ""
-RDEPENDS_kernel = "kernel-base"
+FILES_${KERNEL_PACKAGE_NAME}-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
+FILES_${KERNEL_PACKAGE_NAME}-image = ""
+FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
+FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
+FILES_${KERNEL_PACKAGE_NAME}-modules = ""
+RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
 # Allow machines to override this dependency if kernel image files are
 # not wanted in images as standard
-RDEPENDS_kernel-base ?= "kernel-image"
-PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
-RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', 'kernel-vmlinux', '', d)}"
-PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSION}')}"
-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"
-
-pkg_postinst_kernel-base () {
+RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-image"
+PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
+RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
+PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitimize_package_name('${KERNEL_VERSION}')}"
+RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-${KERNEL_VERSION}"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
+ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
+DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta package"
+
+pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
 	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
 		mkdir -p $D/lib/modules/${KERNEL_VERSION}
 	fi
@@ -543,7 +569,7 @@ pkg_postinst_kernel-base () {
 PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
 
 python split_kernel_packages () {
-    do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
+    do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
 }
 
 # Many scripts want to look in arch/$arch/boot for the bootable
@@ -626,21 +652,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-${MACHINE}.tgz"
 MODULE_TARBALL_DEPLOY ?= "1"
 
 kernel_do_deploy() {
+	deployDir="${DEPLOYDIR}"
+	if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
+		deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
+		mkdir "$deployDir"
+	fi
+
 	for type in ${KERNEL_IMAGETYPES} ; do
 		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
-		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${DEPLOYDIR}/${base_name}.bin
+		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} $deployDir/${base_name}.bin
 	done
 	if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
 		mkdir -p ${D}/lib
-		tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
-		ln -sf ${MODULE_TARBALL_BASE_NAME} ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
+		tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
+		ln -sf ${MODULE_TARBALL_BASE_NAME} $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
 	fi
 
 	for type in ${KERNEL_IMAGETYPES} ; do
 		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
 		symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
-		ln -sf ${base_name}.bin ${DEPLOYDIR}/${symlink_name}.bin
-		ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
+		ln -sf ${base_name}.bin $deployDir/${symlink_name}.bin
+		ln -sf ${base_name}.bin $deployDir/${type}
 	done
 
 	cd ${B}
@@ -650,8 +682,8 @@ kernel_do_deploy() {
 			echo "Copying deploy ${type} kernel-initramfs image and setting up links..."
 			initramfs_base_name=${type}-${INITRAMFS_BASE_NAME}
 			initramfs_symlink_name=${type}-initramfs-${MACHINE}
-			install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs ${DEPLOYDIR}/${initramfs_base_name}.bin
-			ln -sf ${initramfs_base_name}.bin ${DEPLOYDIR}/${initramfs_symlink_name}.bin
+			install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs $deployDir/${initramfs_base_name}.bin
+			ln -sf ${initramfs_base_name}.bin $deployDir/${initramfs_symlink_name}.bin
 		fi
 	done
 }
diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
index a55e2836b5..2c88504fb9 100644
--- a/meta/conf/documentation.conf
+++ b/meta/conf/documentation.conf
@@ -247,6 +247,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to build for a device, usually set b
 KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a device, usually set by the machine configuration files and defaults to KERNEL_IMAGETYPE."
 KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be auto-loaded during boot"
 KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the build system expects to find module_conf_* values that specify configuration for each of the modules"
+KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages. Defaults to 'kernel'."
 KERNEL_PATH[doc] = "The location of the kernel sources. This variable is set to the value of the STAGING_KERNEL_DIR within the module class (module.bbclass)."
 KERNEL_SRC[doc] = "The location of the kernel sources. This variable is set to the value of the STAGING_KERNEL_DIR within the module class (module.bbclass)."
 KFEATURE_DESCRIPTION[doc] = "Provides a short description of a configuration fragment. You use this variable in the .scc file that describes a configuration fragment file."
diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
index 44d013f29d..2eec921728 100644
--- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
+++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
@@ -23,17 +23,13 @@ if [ "\$1" != "-a" -o "\$2" != "-b" ]; then
     echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
     exit 1
 fi
-if [ ! -r ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion ]; then
-    echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" >&2
-else
-    kernelabi=\$(cat ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion)
-    if [ "\$kernelabi" != "\$4" ]; then
-        echo "Error: Kernel version \$4 does not match kernel-abiversion (\$kernelabi)" >&2
-        exit 1
-    fi
+
+kernelabi=""
+if [ -r "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" ]; then
+    kernelabi=\$(cat "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion")
 fi
 
-if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ]; then
+if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [ "\$kernelabi" != "\$4" ]; then
     echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/System.map-\$4" >&2
     exec env depmod "\$1" "\$2" "\$3" "\$4"
 else
diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb b/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
index f93d9530eb..894e2ffbf6 100644
--- a/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
+++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
@@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
 # to build multiple virtual/kernel providers, e.g. as dependency of
 # core-image-rt-sdk, core-image-rt.
 python () {
-    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
+    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
         raise bb.parse.SkipPackage("Set PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
 }
 
diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb b/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
index c49a9340f8..be4d163ff1 100644
--- a/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
+++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
@@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
 # to build multiple virtual/kernel providers, e.g. as dependency of
 # core-image-rt-sdk, core-image-rt.
 python () {
-    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
+    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
         raise bb.parse.SkipPackage("Set PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
 }
 
diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb b/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
index 25d88833a9..e489bbb9f2 100644
--- a/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
+++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
@@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
 # to build multiple virtual/kernel providers, e.g. as dependency of
 # core-image-rt-sdk, core-image-rt.
 python () {
-    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
+    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
         raise bb.parse.SkipPackage("Set PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
 }
 
diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb b/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
index 6734dc0d05..8212b1445c 100644
--- a/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
+++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
@@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
 # to build multiple virtual/kernel providers, e.g. as dependency of
 # core-image-rt-sdk, core-image-rt.
 python () {
-    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
+    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
         raise bb.parse.SkipPackage("Set PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
 }
 
diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc
index 9c1f61be75..8a70eb5018 100644
--- a/meta/recipes-kernel/linux/linux-yocto.inc
+++ b/meta/recipes-kernel/linux/linux-yocto.inc
@@ -12,7 +12,7 @@ INC_PR = "r4"
 # PREFERRED_PROVIDER for virtual/kernel. This avoids network access required
 # by the use of AUTOREV SRCREVs, which are the default for this recipe.
 python () {
-    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != d.getVar("PN"):
+    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN", True):
         d.delVar("BB_DONT_CACHE")
         raise bb.parse.SkipPackage("Set PREFERRED_PROVIDER_virtual/kernel to %s to enable it" % (d.getVar("PN")))
 }
-- 
2.14.2



^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH v9] kernel: Add support for multiple kernel packages
  2017-11-07 18:40       ` [PATCH v9] " Haris Okanovic
@ 2017-11-08 22:20         ` Wold, Saul
  2017-11-10 16:16           ` Bruce Ashfield
  2017-11-10 21:51           ` Haris Okanovic
  0 siblings, 2 replies; 31+ messages in thread
From: Wold, Saul @ 2017-11-08 22:20 UTC (permalink / raw)
  To: openembedded-core, haris.okanovic
  Cc: Ashfield, Bruce (Wind River), josh.hernstrom


Haris,

Thanks for your patience on this process.  This version works well, now
I have the extra work of getting these kernel known to systemd-boot!

Acked-by below!

Sau!

On Tue, 2017-11-07 at 12:40 -0600, Haris Okanovic wrote:
> Some distros may want to provide alternate kernel "flavors" via feeds
> or
> within bootable images. For example, readily available builds which
> provide certain diagnostic features can enable developers and testers
> to
> more quickly resolve issues by avoiding lengthy kernel builds.
> 
> This change allows for building multiple flavors of the kernel and
> module packages by templatizing kernel package names via a new
> KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the
> old
> name of "kernel", but can be overridden by certain recipes providing
> alternate kernel flavors.
> 
> To maintain compatibility, recipes providing alternate kernel flavors
> cannot be the "preferred provider" for virtual/kernel. This is
> because
> OE puts the preferred provider's build and source at
> "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
> "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
> "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using
> the
> default KERNEL_PACKAGE_NAME="kernel" follows the old semantics --
> build
> in the old location and may be preferred provider -- while recipes
> using
> all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and
> don't
> provide "virtual/kernel".
> 
> Testing:
>  1. Add `KERNEL_PACKAGE_NAME_pn-linux-yocto-tiny = "tiny-linux"`
>     to local.conf so that linux-yocto-tiny may build alongside
>     the main kernel (linux-yocto).
>  2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel
> flavors.
>  3. Verified image and modules IPKs exist for both:
>     tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>     tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
>  4. Verified linux-yocto is the "preferred provider", and was built
> in
>     shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>  5. Add `CORE_IMAGE_BASE_INSTALL_append_pn-core-image-base = "tiny-
> linux"`
>     to local.conf to install both kernel flavors in core-image-base.
>  6. `bitbake core-image-base` to build an image.
>  7. Verified image contains two bzImage's under /boot/, with
>     "yocto-standard" (linux-yocto recipe) selected to boot via
> symlink.
> 
> Discussion threads:
> http://lists.openembedded.org/pipermail/openembedded-core/2015-Decemb
> er/thread.html#114122
> http://lists.openembedded.org/pipermail/openembedded-core/2017-July/t
> hread.html#139130
> 
> [YOCTO #11363]
> 
> Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
> Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
> Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
> Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
> Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
> Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>

Acked-by: Saul Wold <sgw@linux.intel.com>

Sau!

> ---
> [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to
> the
> "work" directory in alternate kernel builds, instead of "work-
> shared",
> so
> that the two builds don't clobber each other.
> 
> [PATCH v3] An updated version of this change rebased onto the current
> OE-core master. Changes:
>  - Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
>    kernel builds, since alternate kernels aren't the
>    PREFERRED_PROVIDER for virtual/kernel by definition.
>  - Remove "virtual/kernel" from PROVIDES in alternate kernel builds.
> 
> [PATCH v4] Another rebase onto master; no functional change.
> Improved description and testing steps.
> 
> [PATCH v5]
>  - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
>  - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions
> 
> [PATCH v6] Add KERNEL_PACKAGE_NAME to kernel-module-split.bbclass for
> module recipes; fixes lttng-modules build.
> 
> [PATCH v7] Remove second definition of KERNEL_PACKAGE_NAME from
> kernel-module-split.bbclass; apply a default in two places where
> KERNEL_PACKAGE_NAME is referenced.
> 
> [PATCH v8] Rebase onto current master and more fixups.
>  - kernel-devicetree.bbclass: Fixup package names
>  - depmodwrapper-cross: don't error when called from alt kernel
> recipes
>  - kernel.bbclass: Don't install /boot/image symlink in alt recipes
> 
> [PATCH v9]
>  - Add feature tracking tag
>  - Update testing section to define vars in local.conf
>  - Add KERNEL_PACKAGE_NAME check to *-rt recipes
> 
> https://github.com/harisokanovic/openembedded-core/tree/dev/hokanovi/
> multi-kernel-packages-v9
> ---
>  meta/classes/kernel-devicetree.bbclass             |   8 +-
>  meta/classes/kernel-module-split.bbclass           |   9 +-
>  meta/classes/kernel.bbclass                        | 114
> +++++++++++++--------
>  meta/conf/documentation.conf                       |   1 +
>  .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |  14 +--
>  meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb   |   2 +-
>  meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb   |   2 +-
>  meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb    |   2 +-
>  meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb    |   2 +-
>  meta/recipes-kernel/linux/linux-yocto.inc          |   2 +-
>  10 files changed, 94 insertions(+), 62 deletions(-)
> 
> diff --git a/meta/classes/kernel-devicetree.bbclass
> b/meta/classes/kernel-devicetree.bbclass
> index 6e08be4b70..4f80cc62eb 100644
> --- a/meta/classes/kernel-devicetree.bbclass
> +++ b/meta/classes/kernel-devicetree.bbclass
> @@ -1,10 +1,10 @@
>  # Support for device tree generation
>  PACKAGES_append = " \
> -    kernel-devicetree \
> -    ${@['kernel-image-zimage-bundle',
> ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
> +    ${KERNEL_PACKAGE_NAME}-devicetree \
> +    ${@[d.getVar('KERNEL_PACKAGE_NAME') + '-image-zimage-bundle',
> ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
>  "
> -FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb
> /${KERNEL_IMAGEDEST}/*.dtbo"
> -FILES_kernel-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-
> *.dtb.bin"
> +FILES_${KERNEL_PACKAGE_NAME}-devicetree =
> "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
> +FILES_${KERNEL_PACKAGE_NAME}-image-zimage-bundle =
> "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
>  
>  # Generate kernel+devicetree bundle
>  KERNEL_DEVICETREE_BUNDLE ?= "0"
> diff --git a/meta/classes/kernel-module-split.bbclass
> b/meta/classes/kernel-module-split.bbclass
> index 1035525dac..73c7f18c78 100644
> --- a/meta/classes/kernel-module-split.bbclass
> +++ b/meta/classes/kernel-module-split.bbclass
> @@ -30,7 +30,7 @@ do_install_append() {
>  
>  PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>  
> -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
> +KERNEL_MODULES_META_PACKAGE ?= "${@ d.getVar("KERNEL_PACKAGE_NAME",
> True) or "kernel" }-modules"
>  
>  KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>  KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
> @@ -129,16 +129,19 @@ python split_kernel_module_packages () {
>             postfix = format.split('%s')[1]
>             d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
>  
> +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True) or
> "kernel"
> +    kernel_version = d.getVar("KERNEL_VERSION", True)
> +
>      module_regex = '^(.*)\.k?o$'
>  
>      module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>      module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
> -    module_pattern = module_pattern_prefix + 'kernel-module-%s' +
> module_pattern_suffix
> +    module_pattern = module_pattern_prefix + kernel_package_name +
> '-module-%s' + module_pattern_suffix
>  
>      postinst = d.getVar('pkg_postinst_modules')
>      postrm = d.getVar('pkg_postrm_modules')
>  
> -    modules = do_split_packages(d,
> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
> output_pattern=module_pattern, description='%s kernel module',
> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
> extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
> +    modules = do_split_packages(d,
> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
> output_pattern=module_pattern, description='%s kernel module',
> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
> extra_depends='%s-%s' % (kernel_package_name, kernel_version))
>      if modules:
>          metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>          d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
> diff --git a/meta/classes/kernel.bbclass
> b/meta/classes/kernel.bbclass
> index 756707a3c2..48b718d777 100644
> --- a/meta/classes/kernel.bbclass
> +++ b/meta/classes/kernel.bbclass
> @@ -1,6 +1,9 @@
>  inherit linux-kernel-base kernel-module-split
>  
> -PROVIDES += "virtual/kernel"
> +KERNEL_PACKAGE_NAME ??= "kernel"
> +KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME",
> True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
> +
> +PROVIDES += "${@ "virtual/kernel" if
> (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
>  DEPENDS += "virtual/${TARGET_PREFIX}binutils
> virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
>  PACKAGE_WRITE_DEPS += "depmodwrapper-cross"
>  
> @@ -34,11 +37,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_
> name(d.getVar('KERNEL_VERSION')
>  KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
>  
>  python __anonymous () {
> +    pn = d.getVar("PN", True)
> +    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
> +
> +    # XXX Remove this after bug 11905 is resolved
> +    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
> +    if kpn == pn:
> +        bb.warn("Some packages (E.g. *-dev) might be missing due to
> "
> +                "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
> +
> +    # The default kernel recipe builds in a shared location defined
> by
> +    # bitbake/distro confs: STAGING_KERNEL_DIR and
> STAGING_KERNEL_BUILDDIR.
> +    # Set these variables to directories under ${WORKDIR} in
> alternate
> +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so
> that they
> +    # may build in parallel with the default kernel without
> clobbering.
> +    if kpn != "kernel":
> +        workdir = d.getVar("WORKDIR", True)
> +        sourceDir = os.path.join(workdir, 'kernel-source')
> +        artifactsDir = os.path.join(workdir, 'kernel-build-
> artifacts')
> +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
> +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
>  
>      # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
> KERNEL_IMAGETYPES
>      type = d.getVar('KERNEL_IMAGETYPE') or ""
>      alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>      types = d.getVar('KERNEL_IMAGETYPES') or ""
> +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
>      if type not in types.split():
>          types = (type + ' ' + types).strip()
>      if alttype not in types.split():
> @@ -55,15 +79,15 @@ python __anonymous () {
>          typelower = type.lower()
>          imagedest = d.getVar('KERNEL_IMAGEDEST')
>  
> -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
> +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
>  
> -        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest
> + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' +
> type)
> +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' +
> imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest
> + '/' + type)
>  
> -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' +
> typelower)
> +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' %
> (kname, typelower))
>  
> -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' +
> typelower + '-${KERNEL_VERSION_PKG_NAME}')
> +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-
> %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>  
> -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
> +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower),
> '1')
>  
>      image = d.getVar('INITRAMFS_IMAGE')
>      if image:
> @@ -121,9 +145,9 @@ base_do_unpack_append () {
>  
>  inherit kernel-arch deploy
>  
> -PACKAGES_DYNAMIC += "^kernel-module-.*"
> -PACKAGES_DYNAMIC += "^kernel-image-.*"
> -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>  
>  export OS = "${TARGET_OS}"
>  export CROSS_COMPILE = "${TARGET_PREFIX}"
> @@ -339,7 +363,9 @@ kernel_do_install() {
>  	install -d ${D}/boot
>  	for type in ${KERNEL_IMAGETYPES} ; do
>  		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
> ${D}/${KERNEL_IMAGEDEST}/${type}-${KERNEL_VERSION}
> -		ln -sf ${type}-${KERNEL_VERSION}
> ${D}/${KERNEL_IMAGEDEST}/${type}
> +		if [ "${KERNEL_PACKAGE_NAME}" == "kernel" ]; then
> +			ln -sf ${type}-${KERNEL_VERSION}
> ${D}/${KERNEL_IMAGEDEST}/${type}
> +		fi
>  	done
>  	install -m 0644 System.map ${D}/boot/System.map-
> ${KERNEL_VERSION}
>  	install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
> @@ -393,9 +419,9 @@ do_shared_workdir_setscene () {
>  
>  emit_depmod_pkgdata() {
>  	# Stash data for depmod
> -	install -d ${PKGDESTWORK}/kernel-depmod/
> -	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
> depmod/kernel-abiversion
> -	cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-
> ${KERNEL_VERSION}
> +	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
> +	echo "${KERNEL_VERSION}" >
> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-
> abiversion
> +	cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
> depmod/System.map-${KERNEL_VERSION}
>  }
>  
>  PACKAGEFUNCS += "emit_depmod_pkgdata"
> @@ -410,7 +436,7 @@ do_shared_workdir () {
>  	# Store the kernel version in sysroots for module-
> base.bbclass
>  	#
>  
> -	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
> +	echo "${KERNEL_VERSION}" >
> $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>  
>  	# Copy files required for module builds
>  	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
> @@ -508,28 +534,28 @@ EXPORT_FUNCTIONS do_compile do_install
> do_configure
>  
>  # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base
> ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
> ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>  FILES_${PN} = ""
> -FILES_kernel-base =
> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
> -FILES_kernel-image = ""
> -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
> /boot/config* ${KERNEL_SRC_PATH}
> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
> -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
> -FILES_kernel-modules = ""
> -RDEPENDS_kernel = "kernel-base"
> +FILES_${KERNEL_PACKAGE_NAME}-base =
> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
> +FILES_${KERNEL_PACKAGE_NAME}-image = ""
> +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
> /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
> +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
> ${KERNEL_VERSION_NAME}"
> +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
> +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
>  # Allow machines to override this dependency if kernel image files
> are
>  # not wanted in images as standard
> -RDEPENDS_kernel-base ?= "kernel-image"
> -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNE
> L_VERSION}')}"
> -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE',
> 'vmlinux', 'kernel-vmlinux', '', d)}"
> -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSI
> ON}')}"
> -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"
> -
> -pkg_postinst_kernel-base () {
> +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-
> image"
> +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@
> legitimize_package_name('${KERNEL_VERSION}')}"
> +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNE
> L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
> +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitim
> ize_package_name('${KERNEL_VERSION}')}"
> +RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-
> ${KERNEL_VERSION}"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
> +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta
> package"
> +
> +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>  	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>  		mkdir -p $D/lib/modules/${KERNEL_VERSION}
>  	fi
> @@ -543,7 +569,7 @@ pkg_postinst_kernel-base () {
>  PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>  
>  python split_kernel_packages () {
> -    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-
> firmware-%s', description='Firmware for %s', recursive=True,
> extra_depends='')
> +    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
> output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
> description='Firmware for %s', recursive=True, extra_depends='')
>  }
>  
>  # Many scripts want to look in arch/$arch/boot for the bootable
> @@ -626,21 +652,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-
> ${MACHINE}.tgz"
>  MODULE_TARBALL_DEPLOY ?= "1"
>  
>  kernel_do_deploy() {
> +	deployDir="${DEPLOYDIR}"
> +	if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
> +		deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
> +		mkdir "$deployDir"
> +	fi
> +
>  	for type in ${KERNEL_IMAGETYPES} ; do
>  		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
> -		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
> ${DEPLOYDIR}/${base_name}.bin
> +		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
> $deployDir/${base_name}.bin
>  	done
>  	if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e
> '^CONFIG_MODULES=y$' .config); then
>  		mkdir -p ${D}/lib
> -		tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME}
> -C ${D} lib
> -		ln -sf ${MODULE_TARBALL_BASE_NAME}
> ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
> +		tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME} -C
> ${D} lib
> +		ln -sf ${MODULE_TARBALL_BASE_NAME}
> $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
>  	fi
>  
>  	for type in ${KERNEL_IMAGETYPES} ; do
>  		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>  		symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
> -		ln -sf ${base_name}.bin
> ${DEPLOYDIR}/${symlink_name}.bin
> -		ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
> +		ln -sf ${base_name}.bin
> $deployDir/${symlink_name}.bin
> +		ln -sf ${base_name}.bin $deployDir/${type}
>  	done
>  
>  	cd ${B}
> @@ -650,8 +682,8 @@ kernel_do_deploy() {
>  			echo "Copying deploy ${type} kernel-
> initramfs image and setting up links..."
>  			initramfs_base_name=${type}-
> ${INITRAMFS_BASE_NAME}
>  			initramfs_symlink_name=${type}-initramfs-
> ${MACHINE}
> -			install -m 0644
> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
> ${DEPLOYDIR}/${initramfs_base_name}.bin
> -			ln -sf ${initramfs_base_name}.bin
> ${DEPLOYDIR}/${initramfs_symlink_name}.bin
> +			install -m 0644
> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
> $deployDir/${initramfs_base_name}.bin
> +			ln -sf ${initramfs_base_name}.bin
> $deployDir/${initramfs_symlink_name}.bin
>  		fi
>  	done
>  }
> diff --git a/meta/conf/documentation.conf
> b/meta/conf/documentation.conf
> index a55e2836b5..2c88504fb9 100644
> --- a/meta/conf/documentation.conf
> +++ b/meta/conf/documentation.conf
> @@ -247,6 +247,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to
> build for a device, usually set b
>  KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a
> device, usually set by the machine configuration files and defaults
> to KERNEL_IMAGETYPE."
>  KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be
> auto-loaded during boot"
>  KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the
> build system expects to find module_conf_* values that specify
> configuration for each of the modules"
> +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
> Defaults to 'kernel'."
>  KERNEL_PATH[doc] = "The location of the kernel sources. This
> variable is set to the value of the STAGING_KERNEL_DIR within the
> module class (module.bbclass)."
>  KERNEL_SRC[doc] = "The location of the kernel sources. This variable
> is set to the value of the STAGING_KERNEL_DIR within the module class
> (module.bbclass)."
>  KFEATURE_DESCRIPTION[doc] = "Provides a short description of a
> configuration fragment. You use this variable in the .scc file that
> describes a configuration fragment file."
> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> index 44d013f29d..2eec921728 100644
> --- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> @@ -23,17 +23,13 @@ if [ "\$1" != "-a" -o "\$2" != "-b" ]; then
>      echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
>      exit 1
>  fi
> -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion ]; then
> -    echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/kernel-
> abiversion" >&2
> -else
> -    kernelabi=\$(cat ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion)
> -    if [ "\$kernelabi" != "\$4" ]; then
> -        echo "Error: Kernel version \$4 does not match kernel-
> abiversion (\$kernelabi)" >&2
> -        exit 1
> -    fi
> +
> +kernelabi=""
> +if [ -r "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" ]; then
> +    kernelabi=\$(cat "${PKGDATA_DIR}/kernel-depmod/kernel-
> abiversion")
>  fi
>  
> -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ]; then
> +if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [
> "\$kernelabi" != "\$4" ]; then
>      echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/System.map-
> \$4" >&2
>      exec env depmod "\$1" "\$2" "\$3" "\$4"
>  else
> diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
> b/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
> index f93d9530eb..894e2ffbf6 100644
> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>  # to build multiple virtual/kernel providers, e.g. as dependency of
>  # core-image-rt-sdk, core-image-rt.
>  python () {
> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
> yocto-rt":
> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
>          raise bb.parse.SkipPackage("Set
> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
>  }
>  
> diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
> b/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
> index c49a9340f8..be4d163ff1 100644
> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>  # to build multiple virtual/kernel providers, e.g. as dependency of
>  # core-image-rt-sdk, core-image-rt.
>  python () {
> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
> yocto-rt":
> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
>          raise bb.parse.SkipPackage("Set
> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
>  }
>  
> diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
> b/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
> index 25d88833a9..e489bbb9f2 100644
> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>  # to build multiple virtual/kernel providers, e.g. as dependency of
>  # core-image-rt-sdk, core-image-rt.
>  python () {
> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
> yocto-rt":
> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
>          raise bb.parse.SkipPackage("Set
> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
>  }
>  
> diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
> b/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
> index 6734dc0d05..8212b1445c 100644
> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>  # to build multiple virtual/kernel providers, e.g. as dependency of
>  # core-image-rt-sdk, core-image-rt.
>  python () {
> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
> yocto-rt":
> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
>          raise bb.parse.SkipPackage("Set
> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
>  }
>  
> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
> b/meta/recipes-kernel/linux/linux-yocto.inc
> index 9c1f61be75..8a70eb5018 100644
> --- a/meta/recipes-kernel/linux/linux-yocto.inc
> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
> @@ -12,7 +12,7 @@ INC_PR = "r4"
>  # PREFERRED_PROVIDER for virtual/kernel. This avoids network access
> required
>  # by the use of AUTOREV SRCREVs, which are the default for this
> recipe.
>  python () {
> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
> d.getVar("PN"):
> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
> d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN",
> True):
>          d.delVar("BB_DONT_CACHE")
>          raise bb.parse.SkipPackage("Set
> PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
> (d.getVar("PN")))
>  }
> -- 
> 2.14.2
> 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v9] kernel: Add support for multiple kernel packages
  2017-11-08 22:20         ` Wold, Saul
@ 2017-11-10 16:16           ` Bruce Ashfield
  2017-11-10 21:51           ` Haris Okanovic
  1 sibling, 0 replies; 31+ messages in thread
From: Bruce Ashfield @ 2017-11-10 16:16 UTC (permalink / raw)
  To: Wold, Saul; +Cc: haris.okanovic, josh.hernstrom, openembedded-core

On Wed, Nov 8, 2017 at 5:20 PM, Wold, Saul <saul.wold@intel.com> wrote:
>
> Haris,
>
> Thanks for your patience on this process.  This version works well, now
> I have the extra work of getting these kernel known to systemd-boot!
>
> Acked-by below!
>
> Sau!
>
> On Tue, 2017-11-07 at 12:40 -0600, Haris Okanovic wrote:
>> Some distros may want to provide alternate kernel "flavors" via feeds
>> or
>> within bootable images. For example, readily available builds which
>> provide certain diagnostic features can enable developers and testers
>> to
>> more quickly resolve issues by avoiding lengthy kernel builds.
>>
>> This change allows for building multiple flavors of the kernel and
>> module packages by templatizing kernel package names via a new
>> KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the
>> old
>> name of "kernel", but can be overridden by certain recipes providing
>> alternate kernel flavors.
>>
>> To maintain compatibility, recipes providing alternate kernel flavors
>> cannot be the "preferred provider" for virtual/kernel. This is
>> because
>> OE puts the preferred provider's build and source at
>> "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
>> "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
>> "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using
>> the
>> default KERNEL_PACKAGE_NAME="kernel" follows the old semantics --
>> build
>> in the old location and may be preferred provider -- while recipes
>> using
>> all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and
>> don't
>> provide "virtual/kernel".
>>
>> Testing:
>>  1. Add `KERNEL_PACKAGE_NAME_pn-linux-yocto-tiny = "tiny-linux"`
>>     to local.conf so that linux-yocto-tiny may build alongside
>>     the main kernel (linux-yocto).
>>  2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel
>> flavors.
>>  3. Verified image and modules IPKs exist for both:
>>     tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>>     tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
>>  4. Verified linux-yocto is the "preferred provider", and was built
>> in
>>     shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>>  5. Add `CORE_IMAGE_BASE_INSTALL_append_pn-core-image-base = "tiny-
>> linux"`
>>     to local.conf to install both kernel flavors in core-image-base.
>>  6. `bitbake core-image-base` to build an image.
>>  7. Verified image contains two bzImage's under /boot/, with
>>     "yocto-standard" (linux-yocto recipe) selected to boot via
>> symlink.
>>
>> Discussion threads:
>> http://lists.openembedded.org/pipermail/openembedded-core/2015-Decemb
>> er/thread.html#114122
>> http://lists.openembedded.org/pipermail/openembedded-core/2017-July/t
>> hread.html#139130
>>
>> [YOCTO #11363]
>>
>> Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
>> Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
>> Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
>> Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
>> Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
>> Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
>
> Acked-by: Saul Wold <sgw@linux.intel.com>


.. and this version looks fine to me as well.

Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com>

>
> Sau!
>
>> ---
>> [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to
>> the
>> "work" directory in alternate kernel builds, instead of "work-
>> shared",
>> so
>> that the two builds don't clobber each other.
>>
>> [PATCH v3] An updated version of this change rebased onto the current
>> OE-core master. Changes:
>>  - Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
>>    kernel builds, since alternate kernels aren't the
>>    PREFERRED_PROVIDER for virtual/kernel by definition.
>>  - Remove "virtual/kernel" from PROVIDES in alternate kernel builds.
>>
>> [PATCH v4] Another rebase onto master; no functional change.
>> Improved description and testing steps.
>>
>> [PATCH v5]
>>  - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
>>  - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions
>>
>> [PATCH v6] Add KERNEL_PACKAGE_NAME to kernel-module-split.bbclass for
>> module recipes; fixes lttng-modules build.
>>
>> [PATCH v7] Remove second definition of KERNEL_PACKAGE_NAME from
>> kernel-module-split.bbclass; apply a default in two places where
>> KERNEL_PACKAGE_NAME is referenced.
>>
>> [PATCH v8] Rebase onto current master and more fixups.
>>  - kernel-devicetree.bbclass: Fixup package names
>>  - depmodwrapper-cross: don't error when called from alt kernel
>> recipes
>>  - kernel.bbclass: Don't install /boot/image symlink in alt recipes
>>
>> [PATCH v9]
>>  - Add feature tracking tag
>>  - Update testing section to define vars in local.conf
>>  - Add KERNEL_PACKAGE_NAME check to *-rt recipes
>>
>> https://github.com/harisokanovic/openembedded-core/tree/dev/hokanovi/
>> multi-kernel-packages-v9
>> ---
>>  meta/classes/kernel-devicetree.bbclass             |   8 +-
>>  meta/classes/kernel-module-split.bbclass           |   9 +-
>>  meta/classes/kernel.bbclass                        | 114
>> +++++++++++++--------
>>  meta/conf/documentation.conf                       |   1 +
>>  .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |  14 +--
>>  meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb   |   2 +-
>>  meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb   |   2 +-
>>  meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb    |   2 +-
>>  meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb    |   2 +-
>>  meta/recipes-kernel/linux/linux-yocto.inc          |   2 +-
>>  10 files changed, 94 insertions(+), 62 deletions(-)
>>
>> diff --git a/meta/classes/kernel-devicetree.bbclass
>> b/meta/classes/kernel-devicetree.bbclass
>> index 6e08be4b70..4f80cc62eb 100644
>> --- a/meta/classes/kernel-devicetree.bbclass
>> +++ b/meta/classes/kernel-devicetree.bbclass
>> @@ -1,10 +1,10 @@
>>  # Support for device tree generation
>>  PACKAGES_append = " \
>> -    kernel-devicetree \
>> -    ${@['kernel-image-zimage-bundle',
>> ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
>> +    ${KERNEL_PACKAGE_NAME}-devicetree \
>> +    ${@[d.getVar('KERNEL_PACKAGE_NAME') + '-image-zimage-bundle',
>> ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
>>  "
>> -FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb
>> /${KERNEL_IMAGEDEST}/*.dtbo"
>> -FILES_kernel-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-
>> *.dtb.bin"
>> +FILES_${KERNEL_PACKAGE_NAME}-devicetree =
>> "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
>> +FILES_${KERNEL_PACKAGE_NAME}-image-zimage-bundle =
>> "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
>>
>>  # Generate kernel+devicetree bundle
>>  KERNEL_DEVICETREE_BUNDLE ?= "0"
>> diff --git a/meta/classes/kernel-module-split.bbclass
>> b/meta/classes/kernel-module-split.bbclass
>> index 1035525dac..73c7f18c78 100644
>> --- a/meta/classes/kernel-module-split.bbclass
>> +++ b/meta/classes/kernel-module-split.bbclass
>> @@ -30,7 +30,7 @@ do_install_append() {
>>
>>  PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>>
>> -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
>> +KERNEL_MODULES_META_PACKAGE ?= "${@ d.getVar("KERNEL_PACKAGE_NAME",
>> True) or "kernel" }-modules"
>>
>>  KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>>  KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
>> @@ -129,16 +129,19 @@ python split_kernel_module_packages () {
>>             postfix = format.split('%s')[1]
>>             d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
>>
>> +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True) or
>> "kernel"
>> +    kernel_version = d.getVar("KERNEL_VERSION", True)
>> +
>>      module_regex = '^(.*)\.k?o$'
>>
>>      module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>>      module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
>> -    module_pattern = module_pattern_prefix + 'kernel-module-%s' +
>> module_pattern_suffix
>> +    module_pattern = module_pattern_prefix + kernel_package_name +
>> '-module-%s' + module_pattern_suffix
>>
>>      postinst = d.getVar('pkg_postinst_modules')
>>      postrm = d.getVar('pkg_postrm_modules')
>>
>> -    modules = do_split_packages(d,
>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>> output_pattern=module_pattern, description='%s kernel module',
>> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
>> extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
>> +    modules = do_split_packages(d,
>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>> output_pattern=module_pattern, description='%s kernel module',
>> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
>> extra_depends='%s-%s' % (kernel_package_name, kernel_version))
>>      if modules:
>>          metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>>          d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
>> diff --git a/meta/classes/kernel.bbclass
>> b/meta/classes/kernel.bbclass
>> index 756707a3c2..48b718d777 100644
>> --- a/meta/classes/kernel.bbclass
>> +++ b/meta/classes/kernel.bbclass
>> @@ -1,6 +1,9 @@
>>  inherit linux-kernel-base kernel-module-split
>>
>> -PROVIDES += "virtual/kernel"
>> +KERNEL_PACKAGE_NAME ??= "kernel"
>> +KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME",
>> True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
>> +
>> +PROVIDES += "${@ "virtual/kernel" if
>> (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
>>  DEPENDS += "virtual/${TARGET_PREFIX}binutils
>> virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
>>  PACKAGE_WRITE_DEPS += "depmodwrapper-cross"
>>
>> @@ -34,11 +37,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_
>> name(d.getVar('KERNEL_VERSION')
>>  KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
>>
>>  python __anonymous () {
>> +    pn = d.getVar("PN", True)
>> +    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
>> +
>> +    # XXX Remove this after bug 11905 is resolved
>> +    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
>> +    if kpn == pn:
>> +        bb.warn("Some packages (E.g. *-dev) might be missing due to
>> "
>> +                "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
>> +
>> +    # The default kernel recipe builds in a shared location defined
>> by
>> +    # bitbake/distro confs: STAGING_KERNEL_DIR and
>> STAGING_KERNEL_BUILDDIR.
>> +    # Set these variables to directories under ${WORKDIR} in
>> alternate
>> +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so
>> that they
>> +    # may build in parallel with the default kernel without
>> clobbering.
>> +    if kpn != "kernel":
>> +        workdir = d.getVar("WORKDIR", True)
>> +        sourceDir = os.path.join(workdir, 'kernel-source')
>> +        artifactsDir = os.path.join(workdir, 'kernel-build-
>> artifacts')
>> +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
>> +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
>>
>>      # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
>> KERNEL_IMAGETYPES
>>      type = d.getVar('KERNEL_IMAGETYPE') or ""
>>      alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>>      types = d.getVar('KERNEL_IMAGETYPES') or ""
>> +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
>>      if type not in types.split():
>>          types = (type + ' ' + types).strip()
>>      if alttype not in types.split():
>> @@ -55,15 +79,15 @@ python __anonymous () {
>>          typelower = type.lower()
>>          imagedest = d.getVar('KERNEL_IMAGEDEST')
>>
>> -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
>> +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
>>
>> -        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest
>> + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' +
>> type)
>> +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' +
>> imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest
>> + '/' + type)
>>
>> -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' +
>> typelower)
>> +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' %
>> (kname, typelower))
>>
>> -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' +
>> typelower + '-${KERNEL_VERSION_PKG_NAME}')
>> +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-
>> %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>>
>> -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
>> +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower),
>> '1')
>>
>>      image = d.getVar('INITRAMFS_IMAGE')
>>      if image:
>> @@ -121,9 +145,9 @@ base_do_unpack_append () {
>>
>>  inherit kernel-arch deploy
>>
>> -PACKAGES_DYNAMIC += "^kernel-module-.*"
>> -PACKAGES_DYNAMIC += "^kernel-image-.*"
>> -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>>
>>  export OS = "${TARGET_OS}"
>>  export CROSS_COMPILE = "${TARGET_PREFIX}"
>> @@ -339,7 +363,9 @@ kernel_do_install() {
>>       install -d ${D}/boot
>>       for type in ${KERNEL_IMAGETYPES} ; do
>>               install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>> ${D}/${KERNEL_IMAGEDEST}/${type}-${KERNEL_VERSION}
>> -             ln -sf ${type}-${KERNEL_VERSION}
>> ${D}/${KERNEL_IMAGEDEST}/${type}
>> +             if [ "${KERNEL_PACKAGE_NAME}" == "kernel" ]; then
>> +                     ln -sf ${type}-${KERNEL_VERSION}
>> ${D}/${KERNEL_IMAGEDEST}/${type}
>> +             fi
>>       done
>>       install -m 0644 System.map ${D}/boot/System.map-
>> ${KERNEL_VERSION}
>>       install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
>> @@ -393,9 +419,9 @@ do_shared_workdir_setscene () {
>>
>>  emit_depmod_pkgdata() {
>>       # Stash data for depmod
>> -     install -d ${PKGDESTWORK}/kernel-depmod/
>> -     echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
>> depmod/kernel-abiversion
>> -     cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-
>> ${KERNEL_VERSION}
>> +     install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
>> +     echo "${KERNEL_VERSION}" >
>> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-
>> abiversion
>> +     cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
>> depmod/System.map-${KERNEL_VERSION}
>>  }
>>
>>  PACKAGEFUNCS += "emit_depmod_pkgdata"
>> @@ -410,7 +436,7 @@ do_shared_workdir () {
>>       # Store the kernel version in sysroots for module-
>> base.bbclass
>>       #
>>
>> -     echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
>> +     echo "${KERNEL_VERSION}" >
>> $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>>
>>       # Copy files required for module builds
>>       cp System.map $kerneldir/System.map-${KERNEL_VERSION}
>> @@ -508,28 +534,28 @@ EXPORT_FUNCTIONS do_compile do_install
>> do_configure
>>
>>  # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base
>> ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
>> ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>>  FILES_${PN} = ""
>> -FILES_kernel-base =
>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>> -FILES_kernel-image = ""
>> -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
>> /boot/config* ${KERNEL_SRC_PATH}
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>> -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
>> -FILES_kernel-modules = ""
>> -RDEPENDS_kernel = "kernel-base"
>> +FILES_${KERNEL_PACKAGE_NAME}-base =
>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>> +FILES_${KERNEL_PACKAGE_NAME}-image = ""
>> +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
>> /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>> +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
>> ${KERNEL_VERSION_NAME}"
>> +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
>> +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
>>  # Allow machines to override this dependency if kernel image files
>> are
>>  # not wanted in images as standard
>> -RDEPENDS_kernel-base ?= "kernel-image"
>> -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNE
>> L_VERSION}')}"
>> -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE',
>> 'vmlinux', 'kernel-vmlinux', '', d)}"
>> -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSI
>> ON}')}"
>> -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"
>> -
>> -pkg_postinst_kernel-base () {
>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-
>> image"
>> +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@
>> legitimize_package_name('${KERNEL_VERSION}')}"
>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNE
>> L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
>> +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitim
>> ize_package_name('${KERNEL_VERSION}')}"
>> +RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-
>> ${KERNEL_VERSION}"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
>> +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta
>> package"
>> +
>> +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>>       if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>>               mkdir -p $D/lib/modules/${KERNEL_VERSION}
>>       fi
>> @@ -543,7 +569,7 @@ pkg_postinst_kernel-base () {
>>  PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>>
>>  python split_kernel_packages () {
>> -    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-
>> firmware-%s', description='Firmware for %s', recursive=True,
>> extra_depends='')
>> +    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>> output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
>> description='Firmware for %s', recursive=True, extra_depends='')
>>  }
>>
>>  # Many scripts want to look in arch/$arch/boot for the bootable
>> @@ -626,21 +652,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-
>> ${MACHINE}.tgz"
>>  MODULE_TARBALL_DEPLOY ?= "1"
>>
>>  kernel_do_deploy() {
>> +     deployDir="${DEPLOYDIR}"
>> +     if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
>> +             deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
>> +             mkdir "$deployDir"
>> +     fi
>> +
>>       for type in ${KERNEL_IMAGETYPES} ; do
>>               base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>> -             install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>> ${DEPLOYDIR}/${base_name}.bin
>> +             install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>> $deployDir/${base_name}.bin
>>       done
>>       if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e
>> '^CONFIG_MODULES=y$' .config); then
>>               mkdir -p ${D}/lib
>> -             tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME}
>> -C ${D} lib
>> -             ln -sf ${MODULE_TARBALL_BASE_NAME}
>> ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
>> +             tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME} -C
>> ${D} lib
>> +             ln -sf ${MODULE_TARBALL_BASE_NAME}
>> $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
>>       fi
>>
>>       for type in ${KERNEL_IMAGETYPES} ; do
>>               base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>>               symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
>> -             ln -sf ${base_name}.bin
>> ${DEPLOYDIR}/${symlink_name}.bin
>> -             ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
>> +             ln -sf ${base_name}.bin
>> $deployDir/${symlink_name}.bin
>> +             ln -sf ${base_name}.bin $deployDir/${type}
>>       done
>>
>>       cd ${B}
>> @@ -650,8 +682,8 @@ kernel_do_deploy() {
>>                       echo "Copying deploy ${type} kernel-
>> initramfs image and setting up links..."
>>                       initramfs_base_name=${type}-
>> ${INITRAMFS_BASE_NAME}
>>                       initramfs_symlink_name=${type}-initramfs-
>> ${MACHINE}
>> -                     install -m 0644
>> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
>> ${DEPLOYDIR}/${initramfs_base_name}.bin
>> -                     ln -sf ${initramfs_base_name}.bin
>> ${DEPLOYDIR}/${initramfs_symlink_name}.bin
>> +                     install -m 0644
>> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
>> $deployDir/${initramfs_base_name}.bin
>> +                     ln -sf ${initramfs_base_name}.bin
>> $deployDir/${initramfs_symlink_name}.bin
>>               fi
>>       done
>>  }
>> diff --git a/meta/conf/documentation.conf
>> b/meta/conf/documentation.conf
>> index a55e2836b5..2c88504fb9 100644
>> --- a/meta/conf/documentation.conf
>> +++ b/meta/conf/documentation.conf
>> @@ -247,6 +247,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to
>> build for a device, usually set b
>>  KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a
>> device, usually set by the machine configuration files and defaults
>> to KERNEL_IMAGETYPE."
>>  KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be
>> auto-loaded during boot"
>>  KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the
>> build system expects to find module_conf_* values that specify
>> configuration for each of the modules"
>> +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
>> Defaults to 'kernel'."
>>  KERNEL_PATH[doc] = "The location of the kernel sources. This
>> variable is set to the value of the STAGING_KERNEL_DIR within the
>> module class (module.bbclass)."
>>  KERNEL_SRC[doc] = "The location of the kernel sources. This variable
>> is set to the value of the STAGING_KERNEL_DIR within the module class
>> (module.bbclass)."
>>  KFEATURE_DESCRIPTION[doc] = "Provides a short description of a
>> configuration fragment. You use this variable in the .scc file that
>> describes a configuration fragment file."
>> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> index 44d013f29d..2eec921728 100644
>> --- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> @@ -23,17 +23,13 @@ if [ "\$1" != "-a" -o "\$2" != "-b" ]; then
>>      echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
>>      exit 1
>>  fi
>> -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion ]; then
>> -    echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/kernel-
>> abiversion" >&2
>> -else
>> -    kernelabi=\$(cat ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion)
>> -    if [ "\$kernelabi" != "\$4" ]; then
>> -        echo "Error: Kernel version \$4 does not match kernel-
>> abiversion (\$kernelabi)" >&2
>> -        exit 1
>> -    fi
>> +
>> +kernelabi=""
>> +if [ -r "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" ]; then
>> +    kernelabi=\$(cat "${PKGDATA_DIR}/kernel-depmod/kernel-
>> abiversion")
>>  fi
>>
>> -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ]; then
>> +if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [
>> "\$kernelabi" != "\$4" ]; then
>>      echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/System.map-
>> \$4" >&2
>>      exec env depmod "\$1" "\$2" "\$3" "\$4"
>>  else
>> diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>> b/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>> index f93d9530eb..894e2ffbf6 100644
>> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>>  # to build multiple virtual/kernel providers, e.g. as dependency of
>>  # core-image-rt-sdk, core-image-rt.
>>  python () {
>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>> yocto-rt":
>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
>>          raise bb.parse.SkipPackage("Set
>> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
>>  }
>>
>> diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>> b/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>> index c49a9340f8..be4d163ff1 100644
>> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>>  # to build multiple virtual/kernel providers, e.g. as dependency of
>>  # core-image-rt-sdk, core-image-rt.
>>  python () {
>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>> yocto-rt":
>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
>>          raise bb.parse.SkipPackage("Set
>> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
>>  }
>>
>> diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>> b/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>> index 25d88833a9..e489bbb9f2 100644
>> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>>  # to build multiple virtual/kernel providers, e.g. as dependency of
>>  # core-image-rt-sdk, core-image-rt.
>>  python () {
>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>> yocto-rt":
>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
>>          raise bb.parse.SkipPackage("Set
>> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
>>  }
>>
>> diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>> b/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>> index 6734dc0d05..8212b1445c 100644
>> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>>  # to build multiple virtual/kernel providers, e.g. as dependency of
>>  # core-image-rt-sdk, core-image-rt.
>>  python () {
>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>> yocto-rt":
>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
>>          raise bb.parse.SkipPackage("Set
>> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
>>  }
>>
>> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
>> b/meta/recipes-kernel/linux/linux-yocto.inc
>> index 9c1f61be75..8a70eb5018 100644
>> --- a/meta/recipes-kernel/linux/linux-yocto.inc
>> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
>> @@ -12,7 +12,7 @@ INC_PR = "r4"
>>  # PREFERRED_PROVIDER for virtual/kernel. This avoids network access
>> required
>>  # by the use of AUTOREV SRCREVs, which are the default for this
>> recipe.
>>  python () {
>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
>> d.getVar("PN"):
>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>> d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN",
>> True):
>>          d.delVar("BB_DONT_CACHE")
>>          raise bb.parse.SkipPackage("Set
>> PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
>> (d.getVar("PN")))
>>  }
>> --
>> 2.14.2
>>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core



-- 
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end"


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v9] kernel: Add support for multiple kernel packages
  2017-11-08 22:20         ` Wold, Saul
  2017-11-10 16:16           ` Bruce Ashfield
@ 2017-11-10 21:51           ` Haris Okanovic
  2017-11-10 22:00             ` Wold, Saul
  2017-12-04 16:13             ` Burton, Ross
  1 sibling, 2 replies; 31+ messages in thread
From: Haris Okanovic @ 2017-11-10 21:51 UTC (permalink / raw)
  To: Wold, Saul, openembedded-core
  Cc: Ashfield, Bruce (Wind River), josh.hernstrom

No problem! Thanks for all the good feedback. I think we shook out most 
of the gremlins in the last few months.

Let me know if you need help with boot loader integration.

-- Haris


On 11/08/2017 04:20 PM, Wold, Saul wrote:
> 
> Haris,
> 
> Thanks for your patience on this process.  This version works well, now
> I have the extra work of getting these kernel known to systemd-boot!
> 
> Acked-by below!
> 
> Sau!
> 
> On Tue, 2017-11-07 at 12:40 -0600, Haris Okanovic wrote:
>> Some distros may want to provide alternate kernel "flavors" via feeds
>> or
>> within bootable images. For example, readily available builds which
>> provide certain diagnostic features can enable developers and testers
>> to
>> more quickly resolve issues by avoiding lengthy kernel builds.
>>
>> This change allows for building multiple flavors of the kernel and
>> module packages by templatizing kernel package names via a new
>> KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the
>> old
>> name of "kernel", but can be overridden by certain recipes providing
>> alternate kernel flavors.
>>
>> To maintain compatibility, recipes providing alternate kernel flavors
>> cannot be the "preferred provider" for virtual/kernel. This is
>> because
>> OE puts the preferred provider's build and source at
>> "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
>> "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
>> "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using
>> the
>> default KERNEL_PACKAGE_NAME="kernel" follows the old semantics --
>> build
>> in the old location and may be preferred provider -- while recipes
>> using
>> all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and
>> don't
>> provide "virtual/kernel".
>>
>> Testing:
>>   1. Add `KERNEL_PACKAGE_NAME_pn-linux-yocto-tiny = "tiny-linux"`
>>      to local.conf so that linux-yocto-tiny may build alongside
>>      the main kernel (linux-yocto).
>>   2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel
>> flavors.
>>   3. Verified image and modules IPKs exist for both:
>>      tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>>      tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
>>   4. Verified linux-yocto is the "preferred provider", and was built
>> in
>>      shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>>   5. Add `CORE_IMAGE_BASE_INSTALL_append_pn-core-image-base = "tiny-
>> linux"`
>>      to local.conf to install both kernel flavors in core-image-base.
>>   6. `bitbake core-image-base` to build an image.
>>   7. Verified image contains two bzImage's under /boot/, with
>>      "yocto-standard" (linux-yocto recipe) selected to boot via
>> symlink.
>>
>> Discussion threads:
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org_pipermail_openembedded-2Dcore_2015-2DDecemb&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=Po_g6d_nUSqHTshbn-ZaBXenlH_4CQklz7Csmi7u70A&s=cJkppECRP9FwMwrmn-tbJfRpffqbPbeRXS1uCu5JsB0&e=
>> er/thread.html#114122
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org_pipermail_openembedded-2Dcore_2017-2DJuly_t&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=Po_g6d_nUSqHTshbn-ZaBXenlH_4CQklz7Csmi7u70A&s=B73w8-RIOKqgiEjZMC2ra49Q1594cWVJp9c6Yx6u34w&e=
>> hread.html#139130
>>
>> [YOCTO #11363]
>>
>> Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
>> Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
>> Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
>> Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
>> Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
>> Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
> 
> Acked-by: Saul Wold <sgw@linux.intel.com>
> 
> Sau!
> 
>> ---
>> [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to
>> the
>> "work" directory in alternate kernel builds, instead of "work-
>> shared",
>> so
>> that the two builds don't clobber each other.
>>
>> [PATCH v3] An updated version of this change rebased onto the current
>> OE-core master. Changes:
>>   - Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
>>     kernel builds, since alternate kernels aren't the
>>     PREFERRED_PROVIDER for virtual/kernel by definition.
>>   - Remove "virtual/kernel" from PROVIDES in alternate kernel builds.
>>
>> [PATCH v4] Another rebase onto master; no functional change.
>> Improved description and testing steps.
>>
>> [PATCH v5]
>>   - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
>>   - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions
>>
>> [PATCH v6] Add KERNEL_PACKAGE_NAME to kernel-module-split.bbclass for
>> module recipes; fixes lttng-modules build.
>>
>> [PATCH v7] Remove second definition of KERNEL_PACKAGE_NAME from
>> kernel-module-split.bbclass; apply a default in two places where
>> KERNEL_PACKAGE_NAME is referenced.
>>
>> [PATCH v8] Rebase onto current master and more fixups.
>>   - kernel-devicetree.bbclass: Fixup package names
>>   - depmodwrapper-cross: don't error when called from alt kernel
>> recipes
>>   - kernel.bbclass: Don't install /boot/image symlink in alt recipes
>>
>> [PATCH v9]
>>   - Add feature tracking tag
>>   - Update testing section to define vars in local.conf
>>   - Add KERNEL_PACKAGE_NAME check to *-rt recipes
>>
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_harisokanovic_openembedded-2Dcore_tree_dev_hokanovi_&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=Po_g6d_nUSqHTshbn-ZaBXenlH_4CQklz7Csmi7u70A&s=g1DTbKMM_NmbTwVK6ABKrg7v5Qst-DAX8wovpBEZiQQ&e=
>> multi-kernel-packages-v9
>> ---
>>   meta/classes/kernel-devicetree.bbclass             |   8 +-
>>   meta/classes/kernel-module-split.bbclass           |   9 +-
>>   meta/classes/kernel.bbclass                        | 114
>> +++++++++++++--------
>>   meta/conf/documentation.conf                       |   1 +
>>   .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |  14 +--
>>   meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb   |   2 +-
>>   meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb   |   2 +-
>>   meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb    |   2 +-
>>   meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb    |   2 +-
>>   meta/recipes-kernel/linux/linux-yocto.inc          |   2 +-
>>   10 files changed, 94 insertions(+), 62 deletions(-)
>>
>> diff --git a/meta/classes/kernel-devicetree.bbclass
>> b/meta/classes/kernel-devicetree.bbclass
>> index 6e08be4b70..4f80cc62eb 100644
>> --- a/meta/classes/kernel-devicetree.bbclass
>> +++ b/meta/classes/kernel-devicetree.bbclass
>> @@ -1,10 +1,10 @@
>>   # Support for device tree generation
>>   PACKAGES_append = " \
>> -    kernel-devicetree \
>> -    ${@['kernel-image-zimage-bundle',
>> ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
>> +    ${KERNEL_PACKAGE_NAME}-devicetree \
>> +    ${@[d.getVar('KERNEL_PACKAGE_NAME') + '-image-zimage-bundle',
>> ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
>>   "
>> -FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb
>> /${KERNEL_IMAGEDEST}/*.dtbo"
>> -FILES_kernel-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-
>> *.dtb.bin"
>> +FILES_${KERNEL_PACKAGE_NAME}-devicetree =
>> "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
>> +FILES_${KERNEL_PACKAGE_NAME}-image-zimage-bundle =
>> "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
>>   
>>   # Generate kernel+devicetree bundle
>>   KERNEL_DEVICETREE_BUNDLE ?= "0"
>> diff --git a/meta/classes/kernel-module-split.bbclass
>> b/meta/classes/kernel-module-split.bbclass
>> index 1035525dac..73c7f18c78 100644
>> --- a/meta/classes/kernel-module-split.bbclass
>> +++ b/meta/classes/kernel-module-split.bbclass
>> @@ -30,7 +30,7 @@ do_install_append() {
>>   
>>   PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>>   
>> -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
>> +KERNEL_MODULES_META_PACKAGE ?= "${@ d.getVar("KERNEL_PACKAGE_NAME",
>> True) or "kernel" }-modules"
>>   
>>   KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>>   KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
>> @@ -129,16 +129,19 @@ python split_kernel_module_packages () {
>>              postfix = format.split('%s')[1]
>>              d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
>>   
>> +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True) or
>> "kernel"
>> +    kernel_version = d.getVar("KERNEL_VERSION", True)
>> +
>>       module_regex = '^(.*)\.k?o$'
>>   
>>       module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>>       module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
>> -    module_pattern = module_pattern_prefix + 'kernel-module-%s' +
>> module_pattern_suffix
>> +    module_pattern = module_pattern_prefix + kernel_package_name +
>> '-module-%s' + module_pattern_suffix
>>   
>>       postinst = d.getVar('pkg_postinst_modules')
>>       postrm = d.getVar('pkg_postrm_modules')
>>   
>> -    modules = do_split_packages(d,
>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>> output_pattern=module_pattern, description='%s kernel module',
>> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
>> extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
>> +    modules = do_split_packages(d,
>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>> output_pattern=module_pattern, description='%s kernel module',
>> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
>> extra_depends='%s-%s' % (kernel_package_name, kernel_version))
>>       if modules:
>>           metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>>           d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
>> diff --git a/meta/classes/kernel.bbclass
>> b/meta/classes/kernel.bbclass
>> index 756707a3c2..48b718d777 100644
>> --- a/meta/classes/kernel.bbclass
>> +++ b/meta/classes/kernel.bbclass
>> @@ -1,6 +1,9 @@
>>   inherit linux-kernel-base kernel-module-split
>>   
>> -PROVIDES += "virtual/kernel"
>> +KERNEL_PACKAGE_NAME ??= "kernel"
>> +KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME",
>> True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
>> +
>> +PROVIDES += "${@ "virtual/kernel" if
>> (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
>>   DEPENDS += "virtual/${TARGET_PREFIX}binutils
>> virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
>>   PACKAGE_WRITE_DEPS += "depmodwrapper-cross"
>>   
>> @@ -34,11 +37,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_
>> name(d.getVar('KERNEL_VERSION')
>>   KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
>>   
>>   python __anonymous () {
>> +    pn = d.getVar("PN", True)
>> +    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
>> +
>> +    # XXX Remove this after bug 11905 is resolved
>> +    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
>> +    if kpn == pn:
>> +        bb.warn("Some packages (E.g. *-dev) might be missing due to
>> "
>> +                "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
>> +
>> +    # The default kernel recipe builds in a shared location defined
>> by
>> +    # bitbake/distro confs: STAGING_KERNEL_DIR and
>> STAGING_KERNEL_BUILDDIR.
>> +    # Set these variables to directories under ${WORKDIR} in
>> alternate
>> +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so
>> that they
>> +    # may build in parallel with the default kernel without
>> clobbering.
>> +    if kpn != "kernel":
>> +        workdir = d.getVar("WORKDIR", True)
>> +        sourceDir = os.path.join(workdir, 'kernel-source')
>> +        artifactsDir = os.path.join(workdir, 'kernel-build-
>> artifacts')
>> +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
>> +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
>>   
>>       # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
>> KERNEL_IMAGETYPES
>>       type = d.getVar('KERNEL_IMAGETYPE') or ""
>>       alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>>       types = d.getVar('KERNEL_IMAGETYPES') or ""
>> +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
>>       if type not in types.split():
>>           types = (type + ' ' + types).strip()
>>       if alttype not in types.split():
>> @@ -55,15 +79,15 @@ python __anonymous () {
>>           typelower = type.lower()
>>           imagedest = d.getVar('KERNEL_IMAGEDEST')
>>   
>> -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
>> +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
>>   
>> -        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest
>> + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' +
>> type)
>> +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' +
>> imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest
>> + '/' + type)
>>   
>> -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' +
>> typelower)
>> +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' %
>> (kname, typelower))
>>   
>> -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' +
>> typelower + '-${KERNEL_VERSION_PKG_NAME}')
>> +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-
>> %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>>   
>> -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
>> +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower),
>> '1')
>>   
>>       image = d.getVar('INITRAMFS_IMAGE')
>>       if image:
>> @@ -121,9 +145,9 @@ base_do_unpack_append () {
>>   
>>   inherit kernel-arch deploy
>>   
>> -PACKAGES_DYNAMIC += "^kernel-module-.*"
>> -PACKAGES_DYNAMIC += "^kernel-image-.*"
>> -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>>   
>>   export OS = "${TARGET_OS}"
>>   export CROSS_COMPILE = "${TARGET_PREFIX}"
>> @@ -339,7 +363,9 @@ kernel_do_install() {
>>   	install -d ${D}/boot
>>   	for type in ${KERNEL_IMAGETYPES} ; do
>>   		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>> ${D}/${KERNEL_IMAGEDEST}/${type}-${KERNEL_VERSION}
>> -		ln -sf ${type}-${KERNEL_VERSION}
>> ${D}/${KERNEL_IMAGEDEST}/${type}
>> +		if [ "${KERNEL_PACKAGE_NAME}" == "kernel" ]; then
>> +			ln -sf ${type}-${KERNEL_VERSION}
>> ${D}/${KERNEL_IMAGEDEST}/${type}
>> +		fi
>>   	done
>>   	install -m 0644 System.map ${D}/boot/System.map-
>> ${KERNEL_VERSION}
>>   	install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
>> @@ -393,9 +419,9 @@ do_shared_workdir_setscene () {
>>   
>>   emit_depmod_pkgdata() {
>>   	# Stash data for depmod
>> -	install -d ${PKGDESTWORK}/kernel-depmod/
>> -	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
>> depmod/kernel-abiversion
>> -	cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-
>> ${KERNEL_VERSION}
>> +	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
>> +	echo "${KERNEL_VERSION}" >
>> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-
>> abiversion
>> +	cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
>> depmod/System.map-${KERNEL_VERSION}
>>   }
>>   
>>   PACKAGEFUNCS += "emit_depmod_pkgdata"
>> @@ -410,7 +436,7 @@ do_shared_workdir () {
>>   	# Store the kernel version in sysroots for module-
>> base.bbclass
>>   	#
>>   
>> -	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
>> +	echo "${KERNEL_VERSION}" >
>> $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>>   
>>   	# Copy files required for module builds
>>   	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
>> @@ -508,28 +534,28 @@ EXPORT_FUNCTIONS do_compile do_install
>> do_configure
>>   
>>   # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base
>> ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
>> ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>>   FILES_${PN} = ""
>> -FILES_kernel-base =
>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>> -FILES_kernel-image = ""
>> -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
>> /boot/config* ${KERNEL_SRC_PATH}
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>> -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
>> -FILES_kernel-modules = ""
>> -RDEPENDS_kernel = "kernel-base"
>> +FILES_${KERNEL_PACKAGE_NAME}-base =
>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>> +FILES_${KERNEL_PACKAGE_NAME}-image = ""
>> +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
>> /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>> +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
>> ${KERNEL_VERSION_NAME}"
>> +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
>> +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
>>   # Allow machines to override this dependency if kernel image files
>> are
>>   # not wanted in images as standard
>> -RDEPENDS_kernel-base ?= "kernel-image"
>> -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNE
>> L_VERSION}')}"
>> -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE',
>> 'vmlinux', 'kernel-vmlinux', '', d)}"
>> -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSI
>> ON}')}"
>> -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"
>> -
>> -pkg_postinst_kernel-base () {
>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-
>> image"
>> +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@
>> legitimize_package_name('${KERNEL_VERSION}')}"
>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNE
>> L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
>> +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitim
>> ize_package_name('${KERNEL_VERSION}')}"
>> +RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-
>> ${KERNEL_VERSION}"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
>> +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta
>> package"
>> +
>> +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>>   	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>>   		mkdir -p $D/lib/modules/${KERNEL_VERSION}
>>   	fi
>> @@ -543,7 +569,7 @@ pkg_postinst_kernel-base () {
>>   PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>>   
>>   python split_kernel_packages () {
>> -    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-
>> firmware-%s', description='Firmware for %s', recursive=True,
>> extra_depends='')
>> +    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>> output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
>> description='Firmware for %s', recursive=True, extra_depends='')
>>   }
>>   
>>   # Many scripts want to look in arch/$arch/boot for the bootable
>> @@ -626,21 +652,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-
>> ${MACHINE}.tgz"
>>   MODULE_TARBALL_DEPLOY ?= "1"
>>   
>>   kernel_do_deploy() {
>> +	deployDir="${DEPLOYDIR}"
>> +	if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
>> +		deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
>> +		mkdir "$deployDir"
>> +	fi
>> +
>>   	for type in ${KERNEL_IMAGETYPES} ; do
>>   		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>> -		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>> ${DEPLOYDIR}/${base_name}.bin
>> +		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>> $deployDir/${base_name}.bin
>>   	done
>>   	if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e
>> '^CONFIG_MODULES=y$' .config); then
>>   		mkdir -p ${D}/lib
>> -		tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME}
>> -C ${D} lib
>> -		ln -sf ${MODULE_TARBALL_BASE_NAME}
>> ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
>> +		tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME} -C
>> ${D} lib
>> +		ln -sf ${MODULE_TARBALL_BASE_NAME}
>> $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
>>   	fi
>>   
>>   	for type in ${KERNEL_IMAGETYPES} ; do
>>   		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>>   		symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
>> -		ln -sf ${base_name}.bin
>> ${DEPLOYDIR}/${symlink_name}.bin
>> -		ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
>> +		ln -sf ${base_name}.bin
>> $deployDir/${symlink_name}.bin
>> +		ln -sf ${base_name}.bin $deployDir/${type}
>>   	done
>>   
>>   	cd ${B}
>> @@ -650,8 +682,8 @@ kernel_do_deploy() {
>>   			echo "Copying deploy ${type} kernel-
>> initramfs image and setting up links..."
>>   			initramfs_base_name=${type}-
>> ${INITRAMFS_BASE_NAME}
>>   			initramfs_symlink_name=${type}-initramfs-
>> ${MACHINE}
>> -			install -m 0644
>> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
>> ${DEPLOYDIR}/${initramfs_base_name}.bin
>> -			ln -sf ${initramfs_base_name}.bin
>> ${DEPLOYDIR}/${initramfs_symlink_name}.bin
>> +			install -m 0644
>> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
>> $deployDir/${initramfs_base_name}.bin
>> +			ln -sf ${initramfs_base_name}.bin
>> $deployDir/${initramfs_symlink_name}.bin
>>   		fi
>>   	done
>>   }
>> diff --git a/meta/conf/documentation.conf
>> b/meta/conf/documentation.conf
>> index a55e2836b5..2c88504fb9 100644
>> --- a/meta/conf/documentation.conf
>> +++ b/meta/conf/documentation.conf
>> @@ -247,6 +247,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to
>> build for a device, usually set b
>>   KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a
>> device, usually set by the machine configuration files and defaults
>> to KERNEL_IMAGETYPE."
>>   KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be
>> auto-loaded during boot"
>>   KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the
>> build system expects to find module_conf_* values that specify
>> configuration for each of the modules"
>> +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
>> Defaults to 'kernel'."
>>   KERNEL_PATH[doc] = "The location of the kernel sources. This
>> variable is set to the value of the STAGING_KERNEL_DIR within the
>> module class (module.bbclass)."
>>   KERNEL_SRC[doc] = "The location of the kernel sources. This variable
>> is set to the value of the STAGING_KERNEL_DIR within the module class
>> (module.bbclass)."
>>   KFEATURE_DESCRIPTION[doc] = "Provides a short description of a
>> configuration fragment. You use this variable in the .scc file that
>> describes a configuration fragment file."
>> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> index 44d013f29d..2eec921728 100644
>> --- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> @@ -23,17 +23,13 @@ if [ "\$1" != "-a" -o "\$2" != "-b" ]; then
>>       echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
>>       exit 1
>>   fi
>> -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion ]; then
>> -    echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/kernel-
>> abiversion" >&2
>> -else
>> -    kernelabi=\$(cat ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion)
>> -    if [ "\$kernelabi" != "\$4" ]; then
>> -        echo "Error: Kernel version \$4 does not match kernel-
>> abiversion (\$kernelabi)" >&2
>> -        exit 1
>> -    fi
>> +
>> +kernelabi=""
>> +if [ -r "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" ]; then
>> +    kernelabi=\$(cat "${PKGDATA_DIR}/kernel-depmod/kernel-
>> abiversion")
>>   fi
>>   
>> -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ]; then
>> +if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [
>> "\$kernelabi" != "\$4" ]; then
>>       echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/System.map-
>> \$4" >&2
>>       exec env depmod "\$1" "\$2" "\$3" "\$4"
>>   else
>> diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>> b/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>> index f93d9530eb..894e2ffbf6 100644
>> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>>   # to build multiple virtual/kernel providers, e.g. as dependency of
>>   # core-image-rt-sdk, core-image-rt.
>>   python () {
>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>> yocto-rt":
>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
>>           raise bb.parse.SkipPackage("Set
>> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
>>   }
>>   
>> diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>> b/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>> index c49a9340f8..be4d163ff1 100644
>> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>>   # to build multiple virtual/kernel providers, e.g. as dependency of
>>   # core-image-rt-sdk, core-image-rt.
>>   python () {
>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>> yocto-rt":
>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
>>           raise bb.parse.SkipPackage("Set
>> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
>>   }
>>   
>> diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>> b/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>> index 25d88833a9..e489bbb9f2 100644
>> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>>   # to build multiple virtual/kernel providers, e.g. as dependency of
>>   # core-image-rt-sdk, core-image-rt.
>>   python () {
>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>> yocto-rt":
>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
>>           raise bb.parse.SkipPackage("Set
>> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
>>   }
>>   
>> diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>> b/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>> index 6734dc0d05..8212b1445c 100644
>> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>>   # to build multiple virtual/kernel providers, e.g. as dependency of
>>   # core-image-rt-sdk, core-image-rt.
>>   python () {
>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>> yocto-rt":
>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
>>           raise bb.parse.SkipPackage("Set
>> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
>>   }
>>   
>> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
>> b/meta/recipes-kernel/linux/linux-yocto.inc
>> index 9c1f61be75..8a70eb5018 100644
>> --- a/meta/recipes-kernel/linux/linux-yocto.inc
>> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
>> @@ -12,7 +12,7 @@ INC_PR = "r4"
>>   # PREFERRED_PROVIDER for virtual/kernel. This avoids network access
>> required
>>   # by the use of AUTOREV SRCREVs, which are the default for this
>> recipe.
>>   python () {
>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
>> d.getVar("PN"):
>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>> d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN",
>> True):
>>           d.delVar("BB_DONT_CACHE")
>>           raise bb.parse.SkipPackage("Set
>> PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
>> (d.getVar("PN")))
>>   }
>> -- 
>> 2.14.2


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v9] kernel: Add support for multiple kernel packages
  2017-11-10 21:51           ` Haris Okanovic
@ 2017-11-10 22:00             ` Wold, Saul
  2017-11-13 19:16               ` Haris Okanovic
  2017-12-04 16:13             ` Burton, Ross
  1 sibling, 1 reply; 31+ messages in thread
From: Wold, Saul @ 2017-11-10 22:00 UTC (permalink / raw)
  To: openembedded-core, haris.okanovic
  Cc: Ashfield, Bruce (Wind River), Orling, Timothy T, josh.hernstrom

On Fri, 2017-11-10 at 15:51 -0600, Haris Okanovic wrote:
> No problem! Thanks for all the good feedback. I think we shook out
> most 
> of the gremlins in the last few months.
> 
Thanks again for your patience !

> Let me know if you need help with boot loader integration.
> 
Funny you should mention that, there is another bug recently opened
about supporting multiple kernels for at least grub* and systemd-boot.

I have some ideas about using the existing bbclasses and extending the
LABELS variable automagically.  We also have some plans for make the
bootfs be created in a more generic install fashion, rather then the
additional do_deploy() function, this is an early WIP.

If you have any ideas or work already, we would be happy to use it.

Sau!


> -- Haris
> 
> 
> On 11/08/2017 04:20 PM, Wold, Saul wrote:
> > 
> > Haris,
> > 
> > Thanks for your patience on this process.  This version works well,
> > now
> > I have the extra work of getting these kernel known to systemd-
> > boot!
> > 
> > Acked-by below!
> > 
> > Sau!
> > 
> > On Tue, 2017-11-07 at 12:40 -0600, Haris Okanovic wrote:
> > > Some distros may want to provide alternate kernel "flavors" via
> > > feeds
> > > or
> > > within bootable images. For example, readily available builds
> > > which
> > > provide certain diagnostic features can enable developers and
> > > testers
> > > to
> > > more quickly resolve issues by avoiding lengthy kernel builds.
> > > 
> > > This change allows for building multiple flavors of the kernel
> > > and
> > > module packages by templatizing kernel package names via a new
> > > KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to
> > > the
> > > old
> > > name of "kernel", but can be overridden by certain recipes
> > > providing
> > > alternate kernel flavors.
> > > 
> > > To maintain compatibility, recipes providing alternate kernel
> > > flavors
> > > cannot be the "preferred provider" for virtual/kernel. This is
> > > because
> > > OE puts the preferred provider's build and source at
> > > "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
> > > "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
> > > "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes
> > > using
> > > the
> > > default KERNEL_PACKAGE_NAME="kernel" follows the old semantics --
> > > build
> > > in the old location and may be preferred provider -- while
> > > recipes
> > > using
> > > all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and
> > > don't
> > > provide "virtual/kernel".
> > > 
> > > Testing:
> > >   1. Add `KERNEL_PACKAGE_NAME_pn-linux-yocto-tiny = "tiny-linux"`
> > >      to local.conf so that linux-yocto-tiny may build alongside
> > >      the main kernel (linux-yocto).
> > >   2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel
> > > flavors.
> > >   3. Verified image and modules IPKs exist for both:
> > >      tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
> > >      tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-
> > > tiny
> > >   4. Verified linux-yocto is the "preferred provider", and was
> > > built
> > > in
> > >      shared directory: tmp-glibc/work-shared/qemux86/kernel-*
> > >   5. Add `CORE_IMAGE_BASE_INSTALL_append_pn-core-image-base =
> > > "tiny-
> > > linux"`
> > >      to local.conf to install both kernel flavors in core-image-
> > > base.
> > >   6. `bitbake core-image-base` to build an image.
> > >   7. Verified image contains two bzImage's under /boot/, with
> > >      "yocto-standard" (linux-yocto recipe) selected to boot via
> > > symlink.
> > > 
> > > Discussion threads:
> > > https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openemb
> > > edded.org_pipermail_openembedded-2Dcore_2015-
> > > 2DDecemb&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r
> > > =8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=Po_g6d_nUSqHTshbn-
> > > ZaBXenlH_4CQklz7Csmi7u70A&s=cJkppECRP9FwMwrmn-
> > > tbJfRpffqbPbeRXS1uCu5JsB0&e=
> > > er/thread.html#114122
> > > https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openemb
> > > edded.org_pipermail_openembedded-2Dcore_2017-
> > > 2DJuly_t&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r
> > > =8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=Po_g6d_nUSqHTshbn-
> > > ZaBXenlH_4CQklz7Csmi7u70A&s=B73w8-
> > > RIOKqgiEjZMC2ra49Q1594cWVJp9c6Yx6u34w&e=
> > > hread.html#139130
> > > 
> > > [YOCTO #11363]
> > > 
> > > Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
> > > Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
> > > Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
> > > Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
> > > Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
> > > Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
> > 
> > Acked-by: Saul Wold <sgw@linux.intel.com>
> > 
> > Sau!
> > 
> > > ---
> > > [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR
> > > to
> > > the
> > > "work" directory in alternate kernel builds, instead of "work-
> > > shared",
> > > so
> > > that the two builds don't clobber each other.
> > > 
> > > [PATCH v3] An updated version of this change rebased onto the
> > > current
> > > OE-core master. Changes:
> > >   - Remove PREFERRED_PROVIDER check in linux-yocto.inc in
> > > alternate
> > >     kernel builds, since alternate kernels aren't the
> > >     PREFERRED_PROVIDER for virtual/kernel by definition.
> > >   - Remove "virtual/kernel" from PROVIDES in alternate kernel
> > > builds.
> > > 
> > > [PATCH v4] Another rebase onto master; no functional change.
> > > Improved description and testing steps.
> > > 
> > > [PATCH v5]
> > >   - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
> > >   - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions
> > > 
> > > [PATCH v6] Add KERNEL_PACKAGE_NAME to kernel-module-split.bbclass 
> > > for
> > > module recipes; fixes lttng-modules build.
> > > 
> > > [PATCH v7] Remove second definition of KERNEL_PACKAGE_NAME from
> > > kernel-module-split.bbclass; apply a default in two places where
> > > KERNEL_PACKAGE_NAME is referenced.
> > > 
> > > [PATCH v8] Rebase onto current master and more fixups.
> > >   - kernel-devicetree.bbclass: Fixup package names
> > >   - depmodwrapper-cross: don't error when called from alt kernel
> > > recipes
> > >   - kernel.bbclass: Don't install /boot/image symlink in alt
> > > recipes
> > > 
> > > [PATCH v9]
> > >   - Add feature tracking tag
> > >   - Update testing section to define vars in local.conf
> > >   - Add KERNEL_PACKAGE_NAME check to *-rt recipes
> > > 
> > > https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_h
> > > arisokanovic_openembedded-
> > > 2Dcore_tree_dev_hokanovi_&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1
> > > jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-
> > > srUYwL9U_Ms&m=Po_g6d_nUSqHTshbn-
> > > ZaBXenlH_4CQklz7Csmi7u70A&s=g1DTbKMM_NmbTwVK6ABKrg7v5Qst-
> > > DAX8wovpBEZiQQ&e=
> > > multi-kernel-packages-v9
> > > ---
> > >   meta/classes/kernel-devicetree.bbclass             |   8 +-
> > >   meta/classes/kernel-module-split.bbclass           |   9 +-
> > >   meta/classes/kernel.bbclass                        | 114
> > > +++++++++++++--------
> > >   meta/conf/documentation.conf                       |   1 +
> > >   .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |  14 +--
> > >   meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb   |   2 +-
> > >   meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb   |   2 +-
> > >   meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb    |   2 +-
> > >   meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb    |   2 +-
> > >   meta/recipes-kernel/linux/linux-yocto.inc          |   2 +-
> > >   10 files changed, 94 insertions(+), 62 deletions(-)
> > > 
> > > diff --git a/meta/classes/kernel-devicetree.bbclass
> > > b/meta/classes/kernel-devicetree.bbclass
> > > index 6e08be4b70..4f80cc62eb 100644
> > > --- a/meta/classes/kernel-devicetree.bbclass
> > > +++ b/meta/classes/kernel-devicetree.bbclass
> > > @@ -1,10 +1,10 @@
> > >   # Support for device tree generation
> > >   PACKAGES_append = " \
> > > -    kernel-devicetree \
> > > -    ${@['kernel-image-zimage-bundle',
> > > ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
> > > +    ${KERNEL_PACKAGE_NAME}-devicetree \
> > > +    ${@[d.getVar('KERNEL_PACKAGE_NAME') + '-image-zimage-
> > > bundle',
> > > ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
> > >   "
> > > -FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb
> > > /${KERNEL_IMAGEDEST}/*.dtbo"
> > > -FILES_kernel-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-
> > > *.dtb.bin"
> > > +FILES_${KERNEL_PACKAGE_NAME}-devicetree =
> > > "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
> > > +FILES_${KERNEL_PACKAGE_NAME}-image-zimage-bundle =
> > > "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
> > >   
> > >   # Generate kernel+devicetree bundle
> > >   KERNEL_DEVICETREE_BUNDLE ?= "0"
> > > diff --git a/meta/classes/kernel-module-split.bbclass
> > > b/meta/classes/kernel-module-split.bbclass
> > > index 1035525dac..73c7f18c78 100644
> > > --- a/meta/classes/kernel-module-split.bbclass
> > > +++ b/meta/classes/kernel-module-split.bbclass
> > > @@ -30,7 +30,7 @@ do_install_append() {
> > >   
> > >   PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
> > >   
> > > -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
> > > +KERNEL_MODULES_META_PACKAGE ?= "${@
> > > d.getVar("KERNEL_PACKAGE_NAME",
> > > True) or "kernel" }-modules"
> > >   
> > >   KERNEL_MODULE_PACKAGE_PREFIX ?= ""
> > >   KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
> > > @@ -129,16 +129,19 @@ python split_kernel_module_packages () {
> > >              postfix = format.split('%s')[1]
> > >              d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix,
> > > ''))
> > >   
> > > +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True)
> > > or
> > > "kernel"
> > > +    kernel_version = d.getVar("KERNEL_VERSION", True)
> > > +
> > >       module_regex = '^(.*)\.k?o$'
> > >   
> > >       module_pattern_prefix =
> > > d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
> > >       module_pattern_suffix =
> > > d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
> > > -    module_pattern = module_pattern_prefix + 'kernel-module-%s'
> > > +
> > > module_pattern_suffix
> > > +    module_pattern = module_pattern_prefix + kernel_package_name
> > > +
> > > '-module-%s' + module_pattern_suffix
> > >   
> > >       postinst = d.getVar('pkg_postinst_modules')
> > >       postrm = d.getVar('pkg_postrm_modules')
> > >   
> > > -    modules = do_split_packages(d,
> > > root='${nonarch_base_libdir}/modules', file_regex=module_regex,
> > > output_pattern=module_pattern, description='%s kernel module',
> > > postinst=postinst, postrm=postrm, recursive=True,
> > > hook=frob_metadata,
> > > extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
> > > +    modules = do_split_packages(d,
> > > root='${nonarch_base_libdir}/modules', file_regex=module_regex,
> > > output_pattern=module_pattern, description='%s kernel module',
> > > postinst=postinst, postrm=postrm, recursive=True,
> > > hook=frob_metadata,
> > > extra_depends='%s-%s' % (kernel_package_name, kernel_version))
> > >       if modules:
> > >           metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
> > >           d.appendVar('RDEPENDS_' + metapkg, ' '+'
> > > '.join(modules))
> > > diff --git a/meta/classes/kernel.bbclass
> > > b/meta/classes/kernel.bbclass
> > > index 756707a3c2..48b718d777 100644
> > > --- a/meta/classes/kernel.bbclass
> > > +++ b/meta/classes/kernel.bbclass
> > > @@ -1,6 +1,9 @@
> > >   inherit linux-kernel-base kernel-module-split
> > >   
> > > -PROVIDES += "virtual/kernel"
> > > +KERNEL_PACKAGE_NAME ??= "kernel"
> > > +KERNEL_DEPLOYSUBDIR ??= "${@ "" if
> > > (d.getVar("KERNEL_PACKAGE_NAME",
> > > True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
> > > +
> > > +PROVIDES += "${@ "virtual/kernel" if
> > > (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
> > >   DEPENDS += "virtual/${TARGET_PREFIX}binutils
> > > virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
> > >   PACKAGE_WRITE_DEPS += "depmodwrapper-cross"
> > >   
> > > @@ -34,11 +37,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_pack
> > > age_
> > > name(d.getVar('KERNEL_VERSION')
> > >   KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
> > >   
> > >   python __anonymous () {
> > > +    pn = d.getVar("PN", True)
> > > +    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
> > > +
> > > +    # XXX Remove this after bug 11905 is resolved
> > > +    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
> > > +    if kpn == pn:
> > > +        bb.warn("Some packages (E.g. *-dev) might be missing due
> > > to
> > > "
> > > +                "bug 11905 (variable KERNEL_PACKAGE_NAME ==
> > > PN)")
> > > +
> > > +    # The default kernel recipe builds in a shared location
> > > defined
> > > by
> > > +    # bitbake/distro confs: STAGING_KERNEL_DIR and
> > > STAGING_KERNEL_BUILDDIR.
> > > +    # Set these variables to directories under ${WORKDIR} in
> > > alternate
> > > +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel)
> > > so
> > > that they
> > > +    # may build in parallel with the default kernel without
> > > clobbering.
> > > +    if kpn != "kernel":
> > > +        workdir = d.getVar("WORKDIR", True)
> > > +        sourceDir = os.path.join(workdir, 'kernel-source')
> > > +        artifactsDir = os.path.join(workdir, 'kernel-build-
> > > artifacts')
> > > +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
> > > +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
> > >   
> > >       # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
> > > KERNEL_IMAGETYPES
> > >       type = d.getVar('KERNEL_IMAGETYPE') or ""
> > >       alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
> > >       types = d.getVar('KERNEL_IMAGETYPES') or ""
> > > +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
> > >       if type not in types.split():
> > >           types = (type + ' ' + types).strip()
> > >       if alttype not in types.split():
> > > @@ -55,15 +79,15 @@ python __anonymous () {
> > >           typelower = type.lower()
> > >           imagedest = d.getVar('KERNEL_IMAGEDEST')
> > >   
> > > -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' +
> > > typelower)
> > > +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname,
> > > typelower))
> > >   
> > > -        d.setVar('FILES_kernel-image-' + typelower, '/' +
> > > imagedest
> > > + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/'
> > > +
> > > type)
> > > +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' +
> > > imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' +
> > > imagedest
> > > + '/' + type)
> > >   
> > > -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-
> > > image-' +
> > > typelower)
> > > +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s'
> > > %
> > > (kname, typelower))
> > >   
> > > -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-
> > > ' +
> > > typelower + '-${KERNEL_VERSION_PKG_NAME}')
> > > +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-
> > > image-
> > > %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
> > >   
> > > -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
> > > +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower),
> > > '1')
> > >   
> > >       image = d.getVar('INITRAMFS_IMAGE')
> > >       if image:
> > > @@ -121,9 +145,9 @@ base_do_unpack_append () {
> > >   
> > >   inherit kernel-arch deploy
> > >   
> > > -PACKAGES_DYNAMIC += "^kernel-module-.*"
> > > -PACKAGES_DYNAMIC += "^kernel-image-.*"
> > > -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
> > > +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
> > > +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
> > > +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
> > >   
> > >   export OS = "${TARGET_OS}"
> > >   export CROSS_COMPILE = "${TARGET_PREFIX}"
> > > @@ -339,7 +363,9 @@ kernel_do_install() {
> > >   	install -d ${D}/boot
> > >   	for type in ${KERNEL_IMAGETYPES} ; do
> > >   		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
> > > ${D}/${KERNEL_IMAGEDEST}/${type}-${KERNEL_VERSION}
> > > -		ln -sf ${type}-${KERNEL_VERSION}
> > > ${D}/${KERNEL_IMAGEDEST}/${type}
> > > +		if [ "${KERNEL_PACKAGE_NAME}" == "kernel" ];
> > > then
> > > +			ln -sf ${type}-${KERNEL_VERSION}
> > > ${D}/${KERNEL_IMAGEDEST}/${type}
> > > +		fi
> > >   	done
> > >   	install -m 0644 System.map ${D}/boot/System.map-
> > > ${KERNEL_VERSION}
> > >   	install -m 0644 .config ${D}/boot/config-
> > > ${KERNEL_VERSION}
> > > @@ -393,9 +419,9 @@ do_shared_workdir_setscene () {
> > >   
> > >   emit_depmod_pkgdata() {
> > >   	# Stash data for depmod
> > > -	install -d ${PKGDESTWORK}/kernel-depmod/
> > > -	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
> > > depmod/kernel-abiversion
> > > -	cp ${B}/System.map ${PKGDESTWORK}/kernel-
> > > depmod/System.map-
> > > ${KERNEL_VERSION}
> > > +	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
> > > +	echo "${KERNEL_VERSION}" >
> > > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
> > > depmod/${KERNEL_PACKAGE_NAME}-
> > > abiversion
> > > +	cp ${B}/System.map
> > > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
> > > depmod/System.map-${KERNEL_VERSION}
> > >   }
> > >   
> > >   PACKAGEFUNCS += "emit_depmod_pkgdata"
> > > @@ -410,7 +436,7 @@ do_shared_workdir () {
> > >   	# Store the kernel version in sysroots for module-
> > > base.bbclass
> > >   	#
> > >   
> > > -	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
> > > +	echo "${KERNEL_VERSION}" >
> > > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
> > >   
> > >   	# Copy files required for module builds
> > >   	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
> > > @@ -508,28 +534,28 @@ EXPORT_FUNCTIONS do_compile do_install
> > > do_configure
> > >   
> > >   # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base
> > > ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
> > > ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
> > >   FILES_${PN} = ""
> > > -FILES_kernel-base =
> > > "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
> > > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
> > > -FILES_kernel-image = ""
> > > -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
> > > /boot/config* ${KERNEL_SRC_PATH}
> > > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
> > > -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
> > > -FILES_kernel-modules = ""
> > > -RDEPENDS_kernel = "kernel-base"
> > > +FILES_${KERNEL_PACKAGE_NAME}-base =
> > > "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
> > > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
> > > +FILES_${KERNEL_PACKAGE_NAME}-image = ""
> > > +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
> > > /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
> > > ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
> > > +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
> > > ${KERNEL_VERSION_NAME}"
> > > +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
> > > +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
> > >   # Allow machines to override this dependency if kernel image
> > > files
> > > are
> > >   # not wanted in images as standard
> > > -RDEPENDS_kernel-base ?= "kernel-image"
> > > -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${K
> > > ERNE
> > > L_VERSION}')}"
> > > -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE'
> > > ,
> > > 'vmlinux', 'kernel-vmlinux', '', d)}"
> > > -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_V
> > > ERSI
> > > ON}')}"
> > > -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"
> > > -
> > > -pkg_postinst_kernel-base () {
> > > +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-
> > > image"
> > > +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-
> > > image-${@
> > > legitimize_package_name('${KERNEL_VERSION}')}"
> > > +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('K
> > > ERNE
> > > L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '',
> > > d)}"
> > > +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@leg
> > > itim
> > > ize_package_name('${KERNEL_VERSION}')}"
> > > +RPROVIDES_${KERNEL_PACKAGE_NAME}-base +=
> > > "${KERNEL_PACKAGE_NAME}-
> > > ${KERNEL_VERSION}"
> > > +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
> > > +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
> > > +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
> > > +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
> > > +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules
> > > meta
> > > package"
> > > +
> > > +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
> > >   	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
> > >   		mkdir -p $D/lib/modules/${KERNEL_VERSION}
> > >   	fi
> > > @@ -543,7 +569,7 @@ pkg_postinst_kernel-base () {
> > >   PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
> > >   
> > >   python split_kernel_packages () {
> > > -    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
> > > file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
> > > output_pattern='kernel-
> > > firmware-%s', description='Firmware for %s', recursive=True,
> > > extra_depends='')
> > > +    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
> > > file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
> > > output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
> > > description='Firmware for %s', recursive=True, extra_depends='')
> > >   }
> > >   
> > >   # Many scripts want to look in arch/$arch/boot for the bootable
> > > @@ -626,21 +652,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-
> > > ${MACHINE}.tgz"
> > >   MODULE_TARBALL_DEPLOY ?= "1"
> > >   
> > >   kernel_do_deploy() {
> > > +	deployDir="${DEPLOYDIR}"
> > > +	if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
> > > +		deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
> > > +		mkdir "$deployDir"
> > > +	fi
> > > +
> > >   	for type in ${KERNEL_IMAGETYPES} ; do
> > >   		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
> > > -		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
> > > ${DEPLOYDIR}/${base_name}.bin
> > > +		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
> > > $deployDir/${base_name}.bin
> > >   	done
> > >   	if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e
> > > '^CONFIG_MODULES=y$' .config); then
> > >   		mkdir -p ${D}/lib
> > > -		tar -cvzf
> > > ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME}
> > > -C ${D} lib
> > > -		ln -sf ${MODULE_TARBALL_BASE_NAME}
> > > ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
> > > +		tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME}
> > > -C
> > > ${D} lib
> > > +		ln -sf ${MODULE_TARBALL_BASE_NAME}
> > > $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
> > >   	fi
> > >   
> > >   	for type in ${KERNEL_IMAGETYPES} ; do
> > >   		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
> > >   		symlink_name=${type}-
> > > ${KERNEL_IMAGE_SYMLINK_NAME}
> > > -		ln -sf ${base_name}.bin
> > > ${DEPLOYDIR}/${symlink_name}.bin
> > > -		ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
> > > +		ln -sf ${base_name}.bin
> > > $deployDir/${symlink_name}.bin
> > > +		ln -sf ${base_name}.bin $deployDir/${type}
> > >   	done
> > >   
> > >   	cd ${B}
> > > @@ -650,8 +682,8 @@ kernel_do_deploy() {
> > >   			echo "Copying deploy ${type} kernel-
> > > initramfs image and setting up links..."
> > >   			initramfs_base_name=${type}-
> > > ${INITRAMFS_BASE_NAME}
> > >   			initramfs_symlink_name=${type}-
> > > initramfs-
> > > ${MACHINE}
> > > -			install -m 0644
> > > ${KERNEL_OUTPUT_DIR}/${type}.initramfs
> > > ${DEPLOYDIR}/${initramfs_base_name}.bin
> > > -			ln -sf ${initramfs_base_name}.bin
> > > ${DEPLOYDIR}/${initramfs_symlink_name}.bin
> > > +			install -m 0644
> > > ${KERNEL_OUTPUT_DIR}/${type}.initramfs
> > > $deployDir/${initramfs_base_name}.bin
> > > +			ln -sf ${initramfs_base_name}.bin
> > > $deployDir/${initramfs_symlink_name}.bin
> > >   		fi
> > >   	done
> > >   }
> > > diff --git a/meta/conf/documentation.conf
> > > b/meta/conf/documentation.conf
> > > index a55e2836b5..2c88504fb9 100644
> > > --- a/meta/conf/documentation.conf
> > > +++ b/meta/conf/documentation.conf
> > > @@ -247,6 +247,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel
> > > to
> > > build for a device, usually set b
> > >   KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build
> > > for a
> > > device, usually set by the machine configuration files and
> > > defaults
> > > to KERNEL_IMAGETYPE."
> > >   KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need
> > > to be
> > > auto-loaded during boot"
> > >   KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which
> > > the
> > > build system expects to find module_conf_* values that specify
> > > configuration for each of the modules"
> > > +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
> > > Defaults to 'kernel'."
> > >   KERNEL_PATH[doc] = "The location of the kernel sources. This
> > > variable is set to the value of the STAGING_KERNEL_DIR within the
> > > module class (module.bbclass)."
> > >   KERNEL_SRC[doc] = "The location of the kernel sources. This
> > > variable
> > > is set to the value of the STAGING_KERNEL_DIR within the module
> > > class
> > > (module.bbclass)."
> > >   KFEATURE_DESCRIPTION[doc] = "Provides a short description of a
> > > configuration fragment. You use this variable in the .scc file
> > > that
> > > describes a configuration fragment file."
> > > diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> > > b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> > > index 44d013f29d..2eec921728 100644
> > > --- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> > > +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> > > @@ -23,17 +23,13 @@ if [ "\$1" != "-a" -o "\$2" != "-b" ]; then
> > >       echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
> > >       exit 1
> > >   fi
> > > -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion ]; then
> > > -    echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/kernel-
> > > abiversion" >&2
> > > -else
> > > -    kernelabi=\$(cat ${PKGDATA_DIR}/kernel-depmod/kernel-
> > > abiversion)
> > > -    if [ "\$kernelabi" != "\$4" ]; then
> > > -        echo "Error: Kernel version \$4 does not match kernel-
> > > abiversion (\$kernelabi)" >&2
> > > -        exit 1
> > > -    fi
> > > +
> > > +kernelabi=""
> > > +if [ -r "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" ]; then
> > > +    kernelabi=\$(cat "${PKGDATA_DIR}/kernel-depmod/kernel-
> > > abiversion")
> > >   fi
> > >   
> > > -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ]; then
> > > +if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [
> > > "\$kernelabi" != "\$4" ]; then
> > >       echo "Unable to read: ${PKGDATA_DIR}/kernel-
> > > depmod/System.map-
> > > \$4" >&2
> > >       exec env depmod "\$1" "\$2" "\$3" "\$4"
> > >   else
> > > diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
> > > b/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
> > > index f93d9530eb..894e2ffbf6 100644
> > > --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
> > > +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
> > > @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
> > >   # to build multiple virtual/kernel providers, e.g. as
> > > dependency of
> > >   # core-image-rt-sdk, core-image-rt.
> > >   python () {
> > > -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
> > > yocto-rt":
> > > +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
> > > d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-
> > > rt":
> > >           raise bb.parse.SkipPackage("Set
> > > PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable
> > > it")
> > >   }
> > >   
> > > diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
> > > b/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
> > > index c49a9340f8..be4d163ff1 100644
> > > --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
> > > +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
> > > @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
> > >   # to build multiple virtual/kernel providers, e.g. as
> > > dependency of
> > >   # core-image-rt-sdk, core-image-rt.
> > >   python () {
> > > -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
> > > yocto-rt":
> > > +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
> > > d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-
> > > rt":
> > >           raise bb.parse.SkipPackage("Set
> > > PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable
> > > it")
> > >   }
> > >   
> > > diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
> > > b/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
> > > index 25d88833a9..e489bbb9f2 100644
> > > --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
> > > +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
> > > @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
> > >   # to build multiple virtual/kernel providers, e.g. as
> > > dependency of
> > >   # core-image-rt-sdk, core-image-rt.
> > >   python () {
> > > -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
> > > yocto-rt":
> > > +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
> > > d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-
> > > rt":
> > >           raise bb.parse.SkipPackage("Set
> > > PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable
> > > it")
> > >   }
> > >   
> > > diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
> > > b/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
> > > index 6734dc0d05..8212b1445c 100644
> > > --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
> > > +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
> > > @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
> > >   # to build multiple virtual/kernel providers, e.g. as
> > > dependency of
> > >   # core-image-rt-sdk, core-image-rt.
> > >   python () {
> > > -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
> > > yocto-rt":
> > > +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
> > > d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-
> > > rt":
> > >           raise bb.parse.SkipPackage("Set
> > > PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable
> > > it")
> > >   }
> > >   
> > > diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
> > > b/meta/recipes-kernel/linux/linux-yocto.inc
> > > index 9c1f61be75..8a70eb5018 100644
> > > --- a/meta/recipes-kernel/linux/linux-yocto.inc
> > > +++ b/meta/recipes-kernel/linux/linux-yocto.inc
> > > @@ -12,7 +12,7 @@ INC_PR = "r4"
> > >   # PREFERRED_PROVIDER for virtual/kernel. This avoids network
> > > access
> > > required
> > >   # by the use of AUTOREV SRCREVs, which are the default for this
> > > recipe.
> > >   python () {
> > > -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
> > > d.getVar("PN"):
> > > +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
> > > d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) !=
> > > d.getVar("PN",
> > > True):
> > >           d.delVar("BB_DONT_CACHE")
> > >           raise bb.parse.SkipPackage("Set
> > > PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
> > > (d.getVar("PN")))
> > >   }
> > > -- 
> > > 2.14.2

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v9] kernel: Add support for multiple kernel packages
  2017-11-10 22:00             ` Wold, Saul
@ 2017-11-13 19:16               ` Haris Okanovic
  2017-11-13 19:23                 ` Otavio Salvador
  0 siblings, 1 reply; 31+ messages in thread
From: Haris Okanovic @ 2017-11-13 19:16 UTC (permalink / raw)
  To: Wold, Saul, openembedded-core
  Cc: Ashfield, Bruce (Wind River), Orling, Timothy T, josh.hernstrom

On 11/10/2017 04:00 PM, Wold, Saul wrote:
> On Fri, 2017-11-10 at 15:51 -0600, Haris Okanovic wrote:
>> No problem! Thanks for all the good feedback. I think we shook out
>> most
>> of the gremlins in the last few months.
>>
> Thanks again for your patience !
> 
>> Let me know if you need help with boot loader integration.
>>
> Funny you should mention that, there is another bug recently opened
> about supporting multiple kernels for at least grub* and systemd-boot.
> 
> I have some ideas about using the existing bbclasses and extending the
> LABELS variable automagically.  We also have some plans for make the
> bootfs be created in a more generic install fashion, rather then the
> additional do_deploy() function, this is an early WIP.
> 
> If you have any ideas or work already, we would be happy to use it.
> 

Unfortunately, we don't have any good selection mechanism just yet. Our 
main use case is to aid in debugging driver issues, mostly aimed at 
kernel developers. We provide an image + modules in our feed that's 
compiled with debug options, and require the user to select a preferred 
boot kernel via symlink on the file system.

I envisioned using update-alternatives in the future to facilitate 
selection. The call from postinst would give preference to OE's 
preferred provider while a call from users could override that, if desired.

I'm not familiar with the <bootloader>.bbclass-es and the LABELS 
variable. We use a static boot loader config on our systems. How would 
this work if a kernel is installed from feed -- I.e. after image build? 
Is there a mechanism to rebuild the boot loader config dynamically?

-- Haris


> Sau!
> 
> 
>> -- Haris
>>
>>
>> On 11/08/2017 04:20 PM, Wold, Saul wrote:
>>>
>>> Haris,
>>>
>>> Thanks for your patience on this process.  This version works well,
>>> now
>>> I have the extra work of getting these kernel known to systemd-
>>> boot!
>>>
>>> Acked-by below!
>>>
>>> Sau!
>>>
>>> On Tue, 2017-11-07 at 12:40 -0600, Haris Okanovic wrote:
>>>> Some distros may want to provide alternate kernel "flavors" via
>>>> feeds
>>>> or
>>>> within bootable images. For example, readily available builds
>>>> which
>>>> provide certain diagnostic features can enable developers and
>>>> testers
>>>> to
>>>> more quickly resolve issues by avoiding lengthy kernel builds.
>>>>
>>>> This change allows for building multiple flavors of the kernel
>>>> and
>>>> module packages by templatizing kernel package names via a new
>>>> KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to
>>>> the
>>>> old
>>>> name of "kernel", but can be overridden by certain recipes
>>>> providing
>>>> alternate kernel flavors.
>>>>
>>>> To maintain compatibility, recipes providing alternate kernel
>>>> flavors
>>>> cannot be the "preferred provider" for virtual/kernel. This is
>>>> because
>>>> OE puts the preferred provider's build and source at
>>>> "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
>>>> "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
>>>> "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes
>>>> using
>>>> the
>>>> default KERNEL_PACKAGE_NAME="kernel" follows the old semantics --
>>>> build
>>>> in the old location and may be preferred provider -- while
>>>> recipes
>>>> using
>>>> all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and
>>>> don't
>>>> provide "virtual/kernel".
>>>>
>>>> Testing:
>>>>    1. Add `KERNEL_PACKAGE_NAME_pn-linux-yocto-tiny = "tiny-linux"`
>>>>       to local.conf so that linux-yocto-tiny may build alongside
>>>>       the main kernel (linux-yocto).
>>>>    2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel
>>>> flavors.
>>>>    3. Verified image and modules IPKs exist for both:
>>>>       tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>>>>       tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-
>>>> tiny
>>>>    4. Verified linux-yocto is the "preferred provider", and was
>>>> built
>>>> in
>>>>       shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>>>>    5. Add `CORE_IMAGE_BASE_INSTALL_append_pn-core-image-base =
>>>> "tiny-
>>>> linux"`
>>>>       to local.conf to install both kernel flavors in core-image-
>>>> base.
>>>>    6. `bitbake core-image-base` to build an image.
>>>>    7. Verified image contains two bzImage's under /boot/, with
>>>>       "yocto-standard" (linux-yocto recipe) selected to boot via
>>>> symlink.
>>>>
>>>> Discussion threads:
>>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openemb
>>>> edded.org_pipermail_openembedded-2Dcore_2015-
>>>> 2DDecemb&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r
>>>> =8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=Po_g6d_nUSqHTshbn-
>>>> ZaBXenlH_4CQklz7Csmi7u70A&s=cJkppECRP9FwMwrmn-
>>>> tbJfRpffqbPbeRXS1uCu5JsB0&e=
>>>> er/thread.html#114122
>>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openemb
>>>> edded.org_pipermail_openembedded-2Dcore_2017-
>>>> 2DJuly_t&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r
>>>> =8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=Po_g6d_nUSqHTshbn-
>>>> ZaBXenlH_4CQklz7Csmi7u70A&s=B73w8-
>>>> RIOKqgiEjZMC2ra49Q1594cWVJp9c6Yx6u34w&e=
>>>> hread.html#139130
>>>>
>>>> [YOCTO #11363]
>>>>
>>>> Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
>>>> Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
>>>> Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
>>>> Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
>>>> Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
>>>> Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
>>>
>>> Acked-by: Saul Wold <sgw@linux.intel.com>
>>>
>>> Sau!
>>>
>>>> ---
>>>> [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR
>>>> to
>>>> the
>>>> "work" directory in alternate kernel builds, instead of "work-
>>>> shared",
>>>> so
>>>> that the two builds don't clobber each other.
>>>>
>>>> [PATCH v3] An updated version of this change rebased onto the
>>>> current
>>>> OE-core master. Changes:
>>>>    - Remove PREFERRED_PROVIDER check in linux-yocto.inc in
>>>> alternate
>>>>      kernel builds, since alternate kernels aren't the
>>>>      PREFERRED_PROVIDER for virtual/kernel by definition.
>>>>    - Remove "virtual/kernel" from PROVIDES in alternate kernel
>>>> builds.
>>>>
>>>> [PATCH v4] Another rebase onto master; no functional change.
>>>> Improved description and testing steps.
>>>>
>>>> [PATCH v5]
>>>>    - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
>>>>    - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions
>>>>
>>>> [PATCH v6] Add KERNEL_PACKAGE_NAME to kernel-module-split.bbclass
>>>> for
>>>> module recipes; fixes lttng-modules build.
>>>>
>>>> [PATCH v7] Remove second definition of KERNEL_PACKAGE_NAME from
>>>> kernel-module-split.bbclass; apply a default in two places where
>>>> KERNEL_PACKAGE_NAME is referenced.
>>>>
>>>> [PATCH v8] Rebase onto current master and more fixups.
>>>>    - kernel-devicetree.bbclass: Fixup package names
>>>>    - depmodwrapper-cross: don't error when called from alt kernel
>>>> recipes
>>>>    - kernel.bbclass: Don't install /boot/image symlink in alt
>>>> recipes
>>>>
>>>> [PATCH v9]
>>>>    - Add feature tracking tag
>>>>    - Update testing section to define vars in local.conf
>>>>    - Add KERNEL_PACKAGE_NAME check to *-rt recipes
>>>>
>>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_h
>>>> arisokanovic_openembedded-
>>>> 2Dcore_tree_dev_hokanovi_&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1
>>>> jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-
>>>> srUYwL9U_Ms&m=Po_g6d_nUSqHTshbn-
>>>> ZaBXenlH_4CQklz7Csmi7u70A&s=g1DTbKMM_NmbTwVK6ABKrg7v5Qst-
>>>> DAX8wovpBEZiQQ&e=
>>>> multi-kernel-packages-v9
>>>> ---
>>>>    meta/classes/kernel-devicetree.bbclass             |   8 +-
>>>>    meta/classes/kernel-module-split.bbclass           |   9 +-
>>>>    meta/classes/kernel.bbclass                        | 114
>>>> +++++++++++++--------
>>>>    meta/conf/documentation.conf                       |   1 +
>>>>    .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |  14 +--
>>>>    meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb   |   2 +-
>>>>    meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb   |   2 +-
>>>>    meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb    |   2 +-
>>>>    meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb    |   2 +-
>>>>    meta/recipes-kernel/linux/linux-yocto.inc          |   2 +-
>>>>    10 files changed, 94 insertions(+), 62 deletions(-)
>>>>
>>>> diff --git a/meta/classes/kernel-devicetree.bbclass
>>>> b/meta/classes/kernel-devicetree.bbclass
>>>> index 6e08be4b70..4f80cc62eb 100644
>>>> --- a/meta/classes/kernel-devicetree.bbclass
>>>> +++ b/meta/classes/kernel-devicetree.bbclass
>>>> @@ -1,10 +1,10 @@
>>>>    # Support for device tree generation
>>>>    PACKAGES_append = " \
>>>> -    kernel-devicetree \
>>>> -    ${@['kernel-image-zimage-bundle',
>>>> ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
>>>> +    ${KERNEL_PACKAGE_NAME}-devicetree \
>>>> +    ${@[d.getVar('KERNEL_PACKAGE_NAME') + '-image-zimage-
>>>> bundle',
>>>> ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
>>>>    "
>>>> -FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb
>>>> /${KERNEL_IMAGEDEST}/*.dtbo"
>>>> -FILES_kernel-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-
>>>> *.dtb.bin"
>>>> +FILES_${KERNEL_PACKAGE_NAME}-devicetree =
>>>> "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
>>>> +FILES_${KERNEL_PACKAGE_NAME}-image-zimage-bundle =
>>>> "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
>>>>    
>>>>    # Generate kernel+devicetree bundle
>>>>    KERNEL_DEVICETREE_BUNDLE ?= "0"
>>>> diff --git a/meta/classes/kernel-module-split.bbclass
>>>> b/meta/classes/kernel-module-split.bbclass
>>>> index 1035525dac..73c7f18c78 100644
>>>> --- a/meta/classes/kernel-module-split.bbclass
>>>> +++ b/meta/classes/kernel-module-split.bbclass
>>>> @@ -30,7 +30,7 @@ do_install_append() {
>>>>    
>>>>    PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>>>>    
>>>> -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
>>>> +KERNEL_MODULES_META_PACKAGE ?= "${@
>>>> d.getVar("KERNEL_PACKAGE_NAME",
>>>> True) or "kernel" }-modules"
>>>>    
>>>>    KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>>>>    KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
>>>> @@ -129,16 +129,19 @@ python split_kernel_module_packages () {
>>>>               postfix = format.split('%s')[1]
>>>>               d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix,
>>>> ''))
>>>>    
>>>> +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True)
>>>> or
>>>> "kernel"
>>>> +    kernel_version = d.getVar("KERNEL_VERSION", True)
>>>> +
>>>>        module_regex = '^(.*)\.k?o$'
>>>>    
>>>>        module_pattern_prefix =
>>>> d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>>>>        module_pattern_suffix =
>>>> d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
>>>> -    module_pattern = module_pattern_prefix + 'kernel-module-%s'
>>>> +
>>>> module_pattern_suffix
>>>> +    module_pattern = module_pattern_prefix + kernel_package_name
>>>> +
>>>> '-module-%s' + module_pattern_suffix
>>>>    
>>>>        postinst = d.getVar('pkg_postinst_modules')
>>>>        postrm = d.getVar('pkg_postrm_modules')
>>>>    
>>>> -    modules = do_split_packages(d,
>>>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>>>> output_pattern=module_pattern, description='%s kernel module',
>>>> postinst=postinst, postrm=postrm, recursive=True,
>>>> hook=frob_metadata,
>>>> extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
>>>> +    modules = do_split_packages(d,
>>>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>>>> output_pattern=module_pattern, description='%s kernel module',
>>>> postinst=postinst, postrm=postrm, recursive=True,
>>>> hook=frob_metadata,
>>>> extra_depends='%s-%s' % (kernel_package_name, kernel_version))
>>>>        if modules:
>>>>            metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>>>>            d.appendVar('RDEPENDS_' + metapkg, ' '+'
>>>> '.join(modules))
>>>> diff --git a/meta/classes/kernel.bbclass
>>>> b/meta/classes/kernel.bbclass
>>>> index 756707a3c2..48b718d777 100644
>>>> --- a/meta/classes/kernel.bbclass
>>>> +++ b/meta/classes/kernel.bbclass
>>>> @@ -1,6 +1,9 @@
>>>>    inherit linux-kernel-base kernel-module-split
>>>>    
>>>> -PROVIDES += "virtual/kernel"
>>>> +KERNEL_PACKAGE_NAME ??= "kernel"
>>>> +KERNEL_DEPLOYSUBDIR ??= "${@ "" if
>>>> (d.getVar("KERNEL_PACKAGE_NAME",
>>>> True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
>>>> +
>>>> +PROVIDES += "${@ "virtual/kernel" if
>>>> (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
>>>>    DEPENDS += "virtual/${TARGET_PREFIX}binutils
>>>> virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
>>>>    PACKAGE_WRITE_DEPS += "depmodwrapper-cross"
>>>>    
>>>> @@ -34,11 +37,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_pack
>>>> age_
>>>> name(d.getVar('KERNEL_VERSION')
>>>>    KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
>>>>    
>>>>    python __anonymous () {
>>>> +    pn = d.getVar("PN", True)
>>>> +    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
>>>> +
>>>> +    # XXX Remove this after bug 11905 is resolved
>>>> +    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
>>>> +    if kpn == pn:
>>>> +        bb.warn("Some packages (E.g. *-dev) might be missing due
>>>> to
>>>> "
>>>> +                "bug 11905 (variable KERNEL_PACKAGE_NAME ==
>>>> PN)")
>>>> +
>>>> +    # The default kernel recipe builds in a shared location
>>>> defined
>>>> by
>>>> +    # bitbake/distro confs: STAGING_KERNEL_DIR and
>>>> STAGING_KERNEL_BUILDDIR.
>>>> +    # Set these variables to directories under ${WORKDIR} in
>>>> alternate
>>>> +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel)
>>>> so
>>>> that they
>>>> +    # may build in parallel with the default kernel without
>>>> clobbering.
>>>> +    if kpn != "kernel":
>>>> +        workdir = d.getVar("WORKDIR", True)
>>>> +        sourceDir = os.path.join(workdir, 'kernel-source')
>>>> +        artifactsDir = os.path.join(workdir, 'kernel-build-
>>>> artifacts')
>>>> +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
>>>> +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
>>>>    
>>>>        # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
>>>> KERNEL_IMAGETYPES
>>>>        type = d.getVar('KERNEL_IMAGETYPE') or ""
>>>>        alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>>>>        types = d.getVar('KERNEL_IMAGETYPES') or ""
>>>> +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
>>>>        if type not in types.split():
>>>>            types = (type + ' ' + types).strip()
>>>>        if alttype not in types.split():
>>>> @@ -55,15 +79,15 @@ python __anonymous () {
>>>>            typelower = type.lower()
>>>>            imagedest = d.getVar('KERNEL_IMAGEDEST')
>>>>    
>>>> -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' +
>>>> typelower)
>>>> +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname,
>>>> typelower))
>>>>    
>>>> -        d.setVar('FILES_kernel-image-' + typelower, '/' +
>>>> imagedest
>>>> + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/'
>>>> +
>>>> type)
>>>> +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' +
>>>> imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' +
>>>> imagedest
>>>> + '/' + type)
>>>>    
>>>> -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-
>>>> image-' +
>>>> typelower)
>>>> +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s'
>>>> %
>>>> (kname, typelower))
>>>>    
>>>> -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-
>>>> ' +
>>>> typelower + '-${KERNEL_VERSION_PKG_NAME}')
>>>> +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-
>>>> image-
>>>> %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>>>>    
>>>> -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
>>>> +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower),
>>>> '1')
>>>>    
>>>>        image = d.getVar('INITRAMFS_IMAGE')
>>>>        if image:
>>>> @@ -121,9 +145,9 @@ base_do_unpack_append () {
>>>>    
>>>>    inherit kernel-arch deploy
>>>>    
>>>> -PACKAGES_DYNAMIC += "^kernel-module-.*"
>>>> -PACKAGES_DYNAMIC += "^kernel-image-.*"
>>>> -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
>>>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
>>>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
>>>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>>>>    
>>>>    export OS = "${TARGET_OS}"
>>>>    export CROSS_COMPILE = "${TARGET_PREFIX}"
>>>> @@ -339,7 +363,9 @@ kernel_do_install() {
>>>>    	install -d ${D}/boot
>>>>    	for type in ${KERNEL_IMAGETYPES} ; do
>>>>    		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>>>> ${D}/${KERNEL_IMAGEDEST}/${type}-${KERNEL_VERSION}
>>>> -		ln -sf ${type}-${KERNEL_VERSION}
>>>> ${D}/${KERNEL_IMAGEDEST}/${type}
>>>> +		if [ "${KERNEL_PACKAGE_NAME}" == "kernel" ];
>>>> then
>>>> +			ln -sf ${type}-${KERNEL_VERSION}
>>>> ${D}/${KERNEL_IMAGEDEST}/${type}
>>>> +		fi
>>>>    	done
>>>>    	install -m 0644 System.map ${D}/boot/System.map-
>>>> ${KERNEL_VERSION}
>>>>    	install -m 0644 .config ${D}/boot/config-
>>>> ${KERNEL_VERSION}
>>>> @@ -393,9 +419,9 @@ do_shared_workdir_setscene () {
>>>>    
>>>>    emit_depmod_pkgdata() {
>>>>    	# Stash data for depmod
>>>> -	install -d ${PKGDESTWORK}/kernel-depmod/
>>>> -	echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
>>>> depmod/kernel-abiversion
>>>> -	cp ${B}/System.map ${PKGDESTWORK}/kernel-
>>>> depmod/System.map-
>>>> ${KERNEL_VERSION}
>>>> +	install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
>>>> +	echo "${KERNEL_VERSION}" >
>>>> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
>>>> depmod/${KERNEL_PACKAGE_NAME}-
>>>> abiversion
>>>> +	cp ${B}/System.map
>>>> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
>>>> depmod/System.map-${KERNEL_VERSION}
>>>>    }
>>>>    
>>>>    PACKAGEFUNCS += "emit_depmod_pkgdata"
>>>> @@ -410,7 +436,7 @@ do_shared_workdir () {
>>>>    	# Store the kernel version in sysroots for module-
>>>> base.bbclass
>>>>    	#
>>>>    
>>>> -	echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
>>>> +	echo "${KERNEL_VERSION}" >
>>>> $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>>>>    
>>>>    	# Copy files required for module builds
>>>>    	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
>>>> @@ -508,28 +534,28 @@ EXPORT_FUNCTIONS do_compile do_install
>>>> do_configure
>>>>    
>>>>    # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base
>>>> ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
>>>> ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>>>>    FILES_${PN} = ""
>>>> -FILES_kernel-base =
>>>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>>>> -FILES_kernel-image = ""
>>>> -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
>>>> /boot/config* ${KERNEL_SRC_PATH}
>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>>>> -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
>>>> -FILES_kernel-modules = ""
>>>> -RDEPENDS_kernel = "kernel-base"
>>>> +FILES_${KERNEL_PACKAGE_NAME}-base =
>>>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>>>> +FILES_${KERNEL_PACKAGE_NAME}-image = ""
>>>> +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
>>>> /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
>>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>>>> +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
>>>> ${KERNEL_VERSION_NAME}"
>>>> +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
>>>> +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
>>>>    # Allow machines to override this dependency if kernel image
>>>> files
>>>> are
>>>>    # not wanted in images as standard
>>>> -RDEPENDS_kernel-base ?= "kernel-image"
>>>> -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${K
>>>> ERNE
>>>> L_VERSION}')}"
>>>> -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE'
>>>> ,
>>>> 'vmlinux', 'kernel-vmlinux', '', d)}"
>>>> -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_V
>>>> ERSI
>>>> ON}')}"
>>>> -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"
>>>> -
>>>> -pkg_postinst_kernel-base () {
>>>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-
>>>> image"
>>>> +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-
>>>> image-${@
>>>> legitimize_package_name('${KERNEL_VERSION}')}"
>>>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('K
>>>> ERNE
>>>> L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '',
>>>> d)}"
>>>> +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@leg
>>>> itim
>>>> ize_package_name('${KERNEL_VERSION}')}"
>>>> +RPROVIDES_${KERNEL_PACKAGE_NAME}-base +=
>>>> "${KERNEL_PACKAGE_NAME}-
>>>> ${KERNEL_VERSION}"
>>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
>>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
>>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
>>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
>>>> +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules
>>>> meta
>>>> package"
>>>> +
>>>> +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>>>>    	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>>>>    		mkdir -p $D/lib/modules/${KERNEL_VERSION}
>>>>    	fi
>>>> @@ -543,7 +569,7 @@ pkg_postinst_kernel-base () {
>>>>    PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>>>>    
>>>>    python split_kernel_packages () {
>>>> -    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>>>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>>>> output_pattern='kernel-
>>>> firmware-%s', description='Firmware for %s', recursive=True,
>>>> extra_depends='')
>>>> +    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>>>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>>>> output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
>>>> description='Firmware for %s', recursive=True, extra_depends='')
>>>>    }
>>>>    
>>>>    # Many scripts want to look in arch/$arch/boot for the bootable
>>>> @@ -626,21 +652,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-
>>>> ${MACHINE}.tgz"
>>>>    MODULE_TARBALL_DEPLOY ?= "1"
>>>>    
>>>>    kernel_do_deploy() {
>>>> +	deployDir="${DEPLOYDIR}"
>>>> +	if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
>>>> +		deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
>>>> +		mkdir "$deployDir"
>>>> +	fi
>>>> +
>>>>    	for type in ${KERNEL_IMAGETYPES} ; do
>>>>    		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>>>> -		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>>>> ${DEPLOYDIR}/${base_name}.bin
>>>> +		install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>>>> $deployDir/${base_name}.bin
>>>>    	done
>>>>    	if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e
>>>> '^CONFIG_MODULES=y$' .config); then
>>>>    		mkdir -p ${D}/lib
>>>> -		tar -cvzf
>>>> ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME}
>>>> -C ${D} lib
>>>> -		ln -sf ${MODULE_TARBALL_BASE_NAME}
>>>> ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
>>>> +		tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME}
>>>> -C
>>>> ${D} lib
>>>> +		ln -sf ${MODULE_TARBALL_BASE_NAME}
>>>> $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
>>>>    	fi
>>>>    
>>>>    	for type in ${KERNEL_IMAGETYPES} ; do
>>>>    		base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>>>>    		symlink_name=${type}-
>>>> ${KERNEL_IMAGE_SYMLINK_NAME}
>>>> -		ln -sf ${base_name}.bin
>>>> ${DEPLOYDIR}/${symlink_name}.bin
>>>> -		ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
>>>> +		ln -sf ${base_name}.bin
>>>> $deployDir/${symlink_name}.bin
>>>> +		ln -sf ${base_name}.bin $deployDir/${type}
>>>>    	done
>>>>    
>>>>    	cd ${B}
>>>> @@ -650,8 +682,8 @@ kernel_do_deploy() {
>>>>    			echo "Copying deploy ${type} kernel-
>>>> initramfs image and setting up links..."
>>>>    			initramfs_base_name=${type}-
>>>> ${INITRAMFS_BASE_NAME}
>>>>    			initramfs_symlink_name=${type}-
>>>> initramfs-
>>>> ${MACHINE}
>>>> -			install -m 0644
>>>> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
>>>> ${DEPLOYDIR}/${initramfs_base_name}.bin
>>>> -			ln -sf ${initramfs_base_name}.bin
>>>> ${DEPLOYDIR}/${initramfs_symlink_name}.bin
>>>> +			install -m 0644
>>>> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
>>>> $deployDir/${initramfs_base_name}.bin
>>>> +			ln -sf ${initramfs_base_name}.bin
>>>> $deployDir/${initramfs_symlink_name}.bin
>>>>    		fi
>>>>    	done
>>>>    }
>>>> diff --git a/meta/conf/documentation.conf
>>>> b/meta/conf/documentation.conf
>>>> index a55e2836b5..2c88504fb9 100644
>>>> --- a/meta/conf/documentation.conf
>>>> +++ b/meta/conf/documentation.conf
>>>> @@ -247,6 +247,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel
>>>> to
>>>> build for a device, usually set b
>>>>    KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build
>>>> for a
>>>> device, usually set by the machine configuration files and
>>>> defaults
>>>> to KERNEL_IMAGETYPE."
>>>>    KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need
>>>> to be
>>>> auto-loaded during boot"
>>>>    KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which
>>>> the
>>>> build system expects to find module_conf_* values that specify
>>>> configuration for each of the modules"
>>>> +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
>>>> Defaults to 'kernel'."
>>>>    KERNEL_PATH[doc] = "The location of the kernel sources. This
>>>> variable is set to the value of the STAGING_KERNEL_DIR within the
>>>> module class (module.bbclass)."
>>>>    KERNEL_SRC[doc] = "The location of the kernel sources. This
>>>> variable
>>>> is set to the value of the STAGING_KERNEL_DIR within the module
>>>> class
>>>> (module.bbclass)."
>>>>    KFEATURE_DESCRIPTION[doc] = "Provides a short description of a
>>>> configuration fragment. You use this variable in the .scc file
>>>> that
>>>> describes a configuration fragment file."
>>>> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>>>> b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>>>> index 44d013f29d..2eec921728 100644
>>>> --- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>>>> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>>>> @@ -23,17 +23,13 @@ if [ "\$1" != "-a" -o "\$2" != "-b" ]; then
>>>>        echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
>>>>        exit 1
>>>>    fi
>>>> -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion ]; then
>>>> -    echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/kernel-
>>>> abiversion" >&2
>>>> -else
>>>> -    kernelabi=\$(cat ${PKGDATA_DIR}/kernel-depmod/kernel-
>>>> abiversion)
>>>> -    if [ "\$kernelabi" != "\$4" ]; then
>>>> -        echo "Error: Kernel version \$4 does not match kernel-
>>>> abiversion (\$kernelabi)" >&2
>>>> -        exit 1
>>>> -    fi
>>>> +
>>>> +kernelabi=""
>>>> +if [ -r "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" ]; then
>>>> +    kernelabi=\$(cat "${PKGDATA_DIR}/kernel-depmod/kernel-
>>>> abiversion")
>>>>    fi
>>>>    
>>>> -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ]; then
>>>> +if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [
>>>> "\$kernelabi" != "\$4" ]; then
>>>>        echo "Unable to read: ${PKGDATA_DIR}/kernel-
>>>> depmod/System.map-
>>>> \$4" >&2
>>>>        exec env depmod "\$1" "\$2" "\$3" "\$4"
>>>>    else
>>>> diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>>>> b/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>>>> index f93d9530eb..894e2ffbf6 100644
>>>> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>>>> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>>>> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>>>>    # to build multiple virtual/kernel providers, e.g. as
>>>> dependency of
>>>>    # core-image-rt-sdk, core-image-rt.
>>>>    python () {
>>>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>>>> yocto-rt":
>>>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>>>> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-
>>>> rt":
>>>>            raise bb.parse.SkipPackage("Set
>>>> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable
>>>> it")
>>>>    }
>>>>    
>>>> diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>>>> b/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>>>> index c49a9340f8..be4d163ff1 100644
>>>> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>>>> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>>>> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>>>>    # to build multiple virtual/kernel providers, e.g. as
>>>> dependency of
>>>>    # core-image-rt-sdk, core-image-rt.
>>>>    python () {
>>>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>>>> yocto-rt":
>>>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>>>> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-
>>>> rt":
>>>>            raise bb.parse.SkipPackage("Set
>>>> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable
>>>> it")
>>>>    }
>>>>    
>>>> diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>>>> b/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>>>> index 25d88833a9..e489bbb9f2 100644
>>>> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>>>> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>>>> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>>>>    # to build multiple virtual/kernel providers, e.g. as
>>>> dependency of
>>>>    # core-image-rt-sdk, core-image-rt.
>>>>    python () {
>>>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>>>> yocto-rt":
>>>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>>>> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-
>>>> rt":
>>>>            raise bb.parse.SkipPackage("Set
>>>> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable
>>>> it")
>>>>    }
>>>>    
>>>> diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>>>> b/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>>>> index 6734dc0d05..8212b1445c 100644
>>>> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>>>> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>>>> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>>>>    # to build multiple virtual/kernel providers, e.g. as
>>>> dependency of
>>>>    # core-image-rt-sdk, core-image-rt.
>>>>    python () {
>>>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>>>> yocto-rt":
>>>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>>>> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-
>>>> rt":
>>>>            raise bb.parse.SkipPackage("Set
>>>> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable
>>>> it")
>>>>    }
>>>>    
>>>> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
>>>> b/meta/recipes-kernel/linux/linux-yocto.inc
>>>> index 9c1f61be75..8a70eb5018 100644
>>>> --- a/meta/recipes-kernel/linux/linux-yocto.inc
>>>> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
>>>> @@ -12,7 +12,7 @@ INC_PR = "r4"
>>>>    # PREFERRED_PROVIDER for virtual/kernel. This avoids network
>>>> access
>>>> required
>>>>    # by the use of AUTOREV SRCREVs, which are the default for this
>>>> recipe.
>>>>    python () {
>>>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
>>>> d.getVar("PN"):
>>>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>>>> d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) !=
>>>> d.getVar("PN",
>>>> True):
>>>>            d.delVar("BB_DONT_CACHE")
>>>>            raise bb.parse.SkipPackage("Set
>>>> PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
>>>> (d.getVar("PN")))
>>>>    }
>>>> -- 
>>>> 2.14.2


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v9] kernel: Add support for multiple kernel packages
  2017-11-13 19:16               ` Haris Okanovic
@ 2017-11-13 19:23                 ` Otavio Salvador
  0 siblings, 0 replies; 31+ messages in thread
From: Otavio Salvador @ 2017-11-13 19:23 UTC (permalink / raw)
  To: Haris Okanovic
  Cc: Ashfield, Bruce (Wind River),
	Orling, Timothy T, openembedded-core, josh.hernstrom, Wold, Saul

On Mon, Nov 13, 2017 at 5:16 PM, Haris Okanovic <haris.okanovic@ni.com> wrote:
> On 11/10/2017 04:00 PM, Wold, Saul wrote:
>>
>> On Fri, 2017-11-10 at 15:51 -0600, Haris Okanovic wrote:
>>>
>>> No problem! Thanks for all the good feedback. I think we shook out
>>> most
>>> of the gremlins in the last few months.
>>>
>> Thanks again for your patience !
>>
>>> Let me know if you need help with boot loader integration.
>>>
>> Funny you should mention that, there is another bug recently opened
>> about supporting multiple kernels for at least grub* and systemd-boot.
>>
>> I have some ideas about using the existing bbclasses and extending the
>> LABELS variable automagically.  We also have some plans for make the
>> bootfs be created in a more generic install fashion, rather then the
>> additional do_deploy() function, this is an early WIP.
>>
>> If you have any ideas or work already, we would be happy to use it.
>>
>
> Unfortunately, we don't have any good selection mechanism just yet. Our main
> use case is to aid in debugging driver issues, mostly aimed at kernel
> developers. We provide an image + modules in our feed that's compiled with
> debug options, and require the user to select a preferred boot kernel via
> symlink on the file system.
>
> I envisioned using update-alternatives in the future to facilitate
> selection. The call from postinst would give preference to OE's preferred
> provider while a call from users could override that, if desired.
>
> I'm not familiar with the <bootloader>.bbclass-es and the LABELS variable.
> We use a static boot loader config on our systems. How would this work if a
> kernel is installed from feed -- I.e. after image build? Is there a
> mechanism to rebuild the boot loader config dynamically?

I belive this needs to be done on target, as a post-installation hook.

Debian and other generic distributions handle this using this
strategy. Also it is tied to the bootloader. So we'll need two
versions (grub and u-boot/syslinux).

-- 
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v9] kernel: Add support for multiple kernel packages
  2017-11-10 21:51           ` Haris Okanovic
  2017-11-10 22:00             ` Wold, Saul
@ 2017-12-04 16:13             ` Burton, Ross
  2017-12-12 22:19               ` Haris Okanovic
  1 sibling, 1 reply; 31+ messages in thread
From: Burton, Ross @ 2017-12-04 16:13 UTC (permalink / raw)
  To: Haris Okanovic
  Cc: Ashfield, Bruce (Wind River),
	josh.hernstrom, openembedded-core, Wold, Saul

[-- Attachment #1: Type: text/plain, Size: 31332 bytes --]

I know I'm late and this has gone through so many revisions, but I'm seeing
unexplained changes in buildhistory:

$ buildhistory-diff
packages/corei7-64-intel-common-poky-linux/linux-intel/kernel-image-bzimage:
FILELIST: removed "/boot/bzImage"

Doing builds of virtual/kernel with and without this patch and comparing
pkgdata directly confirms that the /boot/bzImage symlink doesn't exist with
this patch but does without it.

Ross

On 10 November 2017 at 21:51, Haris Okanovic <haris.okanovic@ni.com> wrote:

> No problem! Thanks for all the good feedback. I think we shook out most of
> the gremlins in the last few months.
>
> Let me know if you need help with boot loader integration.
>
> -- Haris
>
>
>
> On 11/08/2017 04:20 PM, Wold, Saul wrote:
>
>>
>> Haris,
>>
>> Thanks for your patience on this process.  This version works well, now
>> I have the extra work of getting these kernel known to systemd-boot!
>>
>> Acked-by below!
>>
>> Sau!
>>
>> On Tue, 2017-11-07 at 12:40 -0600, Haris Okanovic wrote:
>>
>>> Some distros may want to provide alternate kernel "flavors" via feeds
>>> or
>>> within bootable images. For example, readily available builds which
>>> provide certain diagnostic features can enable developers and testers
>>> to
>>> more quickly resolve issues by avoiding lengthy kernel builds.
>>>
>>> This change allows for building multiple flavors of the kernel and
>>> module packages by templatizing kernel package names via a new
>>> KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults to the
>>> old
>>> name of "kernel", but can be overridden by certain recipes providing
>>> alternate kernel flavors.
>>>
>>> To maintain compatibility, recipes providing alternate kernel flavors
>>> cannot be the "preferred provider" for virtual/kernel. This is
>>> because
>>> OE puts the preferred provider's build and source at
>>> "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
>>> "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
>>> "tmp-glibc/work/*/$PN/" like other recipes. Therefore, recipes using
>>> the
>>> default KERNEL_PACKAGE_NAME="kernel" follows the old semantics --
>>> build
>>> in the old location and may be preferred provider -- while recipes
>>> using
>>> all other KERNEL_PACKAGE_NAME's build from the normal WORKDIR and
>>> don't
>>> provide "virtual/kernel".
>>>
>>> Testing:
>>>   1. Add `KERNEL_PACKAGE_NAME_pn-linux-yocto-tiny = "tiny-linux"`
>>>      to local.conf so that linux-yocto-tiny may build alongside
>>>      the main kernel (linux-yocto).
>>>   2. `bitbake linux-yocto linux-yocto-tiny` to build both kernel
>>> flavors.
>>>   3. Verified image and modules IPKs exist for both:
>>>      tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>>>      tmp-glibc/deploy/ipk/qemux86/tiny-linux* for linux-yocto-tiny
>>>   4. Verified linux-yocto is the "preferred provider", and was built
>>> in
>>>      shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>>>   5. Add `CORE_IMAGE_BASE_INSTALL_append_pn-core-image-base = "tiny-
>>> linux"`
>>>      to local.conf to install both kernel flavors in core-image-base.
>>>   6. `bitbake core-image-base` to build an image.
>>>   7. Verified image contains two bzImage's under /boot/, with
>>>      "yocto-standard" (linux-yocto recipe) selected to boot via
>>> symlink.
>>>
>>> Discussion threads:
>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.op
>>> enembedded.org_pipermail_openembedded-2Dcore_2015-2DDecemb&
>>> d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bz
>>> iuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=Po_g6d_nUSqHTshb
>>> n-ZaBXenlH_4CQklz7Csmi7u70A&s=cJkppECRP9FwMwrmn-tbJfRpffqbPb
>>> eRXS1uCu5JsB0&e=
>>> er/thread.html#114122
>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.op
>>> enembedded.org_pipermail_openembedded-2Dcore_2017-2DJuly_t&
>>> d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bz
>>> iuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=Po_g6d_nUSqHTshb
>>> n-ZaBXenlH_4CQklz7Csmi7u70A&s=B73w8-RIOKqgiEjZMC2ra49Q1594cW
>>> VJp9c6Yx6u34w&e=
>>>
>>> hread.html#139130
>>>
>>> [YOCTO #11363]
>>>
>>> Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
>>> Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
>>> Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
>>> Coauthored-by: Gratian Crisan <gratian.crisan@ni.com>
>>> Coauthored-by: Haris Okanovic <haris.okanovic@ni.com>
>>> Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com>
>>>
>>
>> Acked-by: Saul Wold <sgw@linux.intel.com>
>>
>> Sau!
>>
>> ---
>>> [PATCH v2] Change STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR to
>>> the
>>> "work" directory in alternate kernel builds, instead of "work-
>>> shared",
>>> so
>>> that the two builds don't clobber each other.
>>>
>>> [PATCH v3] An updated version of this change rebased onto the current
>>> OE-core master. Changes:
>>>   - Remove PREFERRED_PROVIDER check in linux-yocto.inc in alternate
>>>     kernel builds, since alternate kernels aren't the
>>>     PREFERRED_PROVIDER for virtual/kernel by definition.
>>>   - Remove "virtual/kernel" from PROVIDES in alternate kernel builds.
>>>
>>> [PATCH v4] Another rebase onto master; no functional change.
>>> Improved description and testing steps.
>>>
>>> [PATCH v5]
>>>   - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
>>>   - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions
>>>
>>> [PATCH v6] Add KERNEL_PACKAGE_NAME to kernel-module-split.bbclass for
>>> module recipes; fixes lttng-modules build.
>>>
>>> [PATCH v7] Remove second definition of KERNEL_PACKAGE_NAME from
>>> kernel-module-split.bbclass; apply a default in two places where
>>> KERNEL_PACKAGE_NAME is referenced.
>>>
>>> [PATCH v8] Rebase onto current master and more fixups.
>>>   - kernel-devicetree.bbclass: Fixup package names
>>>   - depmodwrapper-cross: don't error when called from alt kernel
>>> recipes
>>>   - kernel.bbclass: Don't install /boot/image symlink in alt recipes
>>>
>>> [PATCH v9]
>>>   - Add feature tracking tag
>>>   - Update testing section to define vars in local.conf
>>>   - Add KERNEL_PACKAGE_NAME check to *-rt recipes
>>>
>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__github.
>>> com_harisokanovic_openembedded-2Dcore_tree_dev_hokanovi_&d=
>>> DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziu
>>> w3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=Po_g6d_nUSqHTshb
>>> n-ZaBXenlH_4CQklz7Csmi7u70A&s=g1DTbKMM_NmbTwVK6ABKrg7v5Qst-D
>>> AX8wovpBEZiQQ&e=
>>>
>>> multi-kernel-packages-v9
>>> ---
>>>   meta/classes/kernel-devicetree.bbclass             |   8 +-
>>>   meta/classes/kernel-module-split.bbclass           |   9 +-
>>>   meta/classes/kernel.bbclass                        | 114
>>> +++++++++++++--------
>>>   meta/conf/documentation.conf                       |   1 +
>>>   .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |  14 +--
>>>   meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb   |   2 +-
>>>   meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb   |   2 +-
>>>   meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb    |   2 +-
>>>   meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb    |   2 +-
>>>   meta/recipes-kernel/linux/linux-yocto.inc          |   2 +-
>>>   10 files changed, 94 insertions(+), 62 deletions(-)
>>>
>>> diff --git a/meta/classes/kernel-devicetree.bbclass
>>> b/meta/classes/kernel-devicetree.bbclass
>>> index 6e08be4b70..4f80cc62eb 100644
>>> --- a/meta/classes/kernel-devicetree.bbclass
>>> +++ b/meta/classes/kernel-devicetree.bbclass
>>> @@ -1,10 +1,10 @@
>>>   # Support for device tree generation
>>>   PACKAGES_append = " \
>>> -    kernel-devicetree \
>>> -    ${@['kernel-image-zimage-bundle',
>>> ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
>>> +    ${KERNEL_PACKAGE_NAME}-devicetree \
>>> +    ${@[d.getVar('KERNEL_PACKAGE_NAME') + '-image-zimage-bundle',
>>> ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
>>>   "
>>> -FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb
>>> /${KERNEL_IMAGEDEST}/*.dtbo"
>>> -FILES_kernel-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-
>>> *.dtb.bin"
>>> +FILES_${KERNEL_PACKAGE_NAME}-devicetree =
>>> "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
>>> +FILES_${KERNEL_PACKAGE_NAME}-image-zimage-bundle =
>>> "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
>>>     # Generate kernel+devicetree bundle
>>>   KERNEL_DEVICETREE_BUNDLE ?= "0"
>>> diff --git a/meta/classes/kernel-module-split.bbclass
>>> b/meta/classes/kernel-module-split.bbclass
>>> index 1035525dac..73c7f18c78 100644
>>> --- a/meta/classes/kernel-module-split.bbclass
>>> +++ b/meta/classes/kernel-module-split.bbclass
>>> @@ -30,7 +30,7 @@ do_install_append() {
>>>     PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>>>   -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
>>> +KERNEL_MODULES_META_PACKAGE ?= "${@ d.getVar("KERNEL_PACKAGE_NAME",
>>> True) or "kernel" }-modules"
>>>     KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>>>   KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
>>> @@ -129,16 +129,19 @@ python split_kernel_module_packages () {
>>>              postfix = format.split('%s')[1]
>>>              d.setVar('RPROVIDES_' + pkg, pkg.replace(postfix, ''))
>>>   +    kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME", True) or
>>> "kernel"
>>> +    kernel_version = d.getVar("KERNEL_VERSION", True)
>>> +
>>>       module_regex = '^(.*)\.k?o$'
>>>         module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>>>       module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
>>> -    module_pattern = module_pattern_prefix + 'kernel-module-%s' +
>>> module_pattern_suffix
>>> +    module_pattern = module_pattern_prefix + kernel_package_name +
>>> '-module-%s' + module_pattern_suffix
>>>         postinst = d.getVar('pkg_postinst_modules')
>>>       postrm = d.getVar('pkg_postrm_modules')
>>>   -    modules = do_split_packages(d,
>>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>>> output_pattern=module_pattern, description='%s kernel module',
>>> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
>>> extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
>>> +    modules = do_split_packages(d,
>>> root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>>> output_pattern=module_pattern, description='%s kernel module',
>>> postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata,
>>> extra_depends='%s-%s' % (kernel_package_name, kernel_version))
>>>       if modules:
>>>           metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>>>           d.appendVar('RDEPENDS_' + metapkg, ' '+' '.join(modules))
>>> diff --git a/meta/classes/kernel.bbclass
>>> b/meta/classes/kernel.bbclass
>>> index 756707a3c2..48b718d777 100644
>>> --- a/meta/classes/kernel.bbclass
>>> +++ b/meta/classes/kernel.bbclass
>>> @@ -1,6 +1,9 @@
>>>   inherit linux-kernel-base kernel-module-split
>>>   -PROVIDES += "virtual/kernel"
>>> +KERNEL_PACKAGE_NAME ??= "kernel"
>>> +KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME",
>>> True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
>>> +
>>> +PROVIDES += "${@ "virtual/kernel" if
>>> (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
>>>   DEPENDS += "virtual/${TARGET_PREFIX}binutils
>>> virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
>>>   PACKAGE_WRITE_DEPS += "depmodwrapper-cross"
>>>   @@ -34,11 +37,32 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_
>>> name(d.getVar('KERNEL_VERSION')
>>>   KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
>>>     python __anonymous () {
>>> +    pn = d.getVar("PN", True)
>>> +    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
>>> +
>>> +    # XXX Remove this after bug 11905 is resolved
>>> +    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
>>> +    if kpn == pn:
>>> +        bb.warn("Some packages (E.g. *-dev) might be missing due to
>>> "
>>> +                "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
>>> +
>>> +    # The default kernel recipe builds in a shared location defined
>>> by
>>> +    # bitbake/distro confs: STAGING_KERNEL_DIR and
>>> STAGING_KERNEL_BUILDDIR.
>>> +    # Set these variables to directories under ${WORKDIR} in
>>> alternate
>>> +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so
>>> that they
>>> +    # may build in parallel with the default kernel without
>>> clobbering.
>>> +    if kpn != "kernel":
>>> +        workdir = d.getVar("WORKDIR", True)
>>> +        sourceDir = os.path.join(workdir, 'kernel-source')
>>> +        artifactsDir = os.path.join(workdir, 'kernel-build-
>>> artifacts')
>>> +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
>>> +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
>>>         # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
>>> KERNEL_IMAGETYPES
>>>       type = d.getVar('KERNEL_IMAGETYPE') or ""
>>>       alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>>>       types = d.getVar('KERNEL_IMAGETYPES') or ""
>>> +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
>>>       if type not in types.split():
>>>           types = (type + ' ' + types).strip()
>>>       if alttype not in types.split():
>>> @@ -55,15 +79,15 @@ python __anonymous () {
>>>           typelower = type.lower()
>>>           imagedest = d.getVar('KERNEL_IMAGEDEST')
>>>   -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
>>> +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
>>>   -        d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest
>>> + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' +
>>> type)
>>> +        d.setVar('FILES_' + kname + '-image-' + typelower, '/' +
>>> imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest
>>> + '/' + type)
>>>   -        d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' +
>>> typelower)
>>> +        d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' %
>>> (kname, typelower))
>>>   -        d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' +
>>> typelower + '-${KERNEL_VERSION_PKG_NAME}')
>>> +        d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-
>>> %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>>>   -        d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
>>> +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower),
>>> '1')
>>>         image = d.getVar('INITRAMFS_IMAGE')
>>>       if image:
>>> @@ -121,9 +145,9 @@ base_do_unpack_append () {
>>>     inherit kernel-arch deploy
>>>   -PACKAGES_DYNAMIC += "^kernel-module-.*"
>>> -PACKAGES_DYNAMIC += "^kernel-image-.*"
>>> -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
>>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
>>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
>>> +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>>>     export OS = "${TARGET_OS}"
>>>   export CROSS_COMPILE = "${TARGET_PREFIX}"
>>> @@ -339,7 +363,9 @@ kernel_do_install() {
>>>         install -d ${D}/boot
>>>         for type in ${KERNEL_IMAGETYPES} ; do
>>>                 install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>>> ${D}/${KERNEL_IMAGEDEST}/${type}-${KERNEL_VERSION}
>>> -               ln -sf ${type}-${KERNEL_VERSION}
>>> ${D}/${KERNEL_IMAGEDEST}/${type}
>>> +               if [ "${KERNEL_PACKAGE_NAME}" == "kernel" ]; then
>>> +                       ln -sf ${type}-${KERNEL_VERSION}
>>> ${D}/${KERNEL_IMAGEDEST}/${type}
>>> +               fi
>>>         done
>>>         install -m 0644 System.map ${D}/boot/System.map-
>>> ${KERNEL_VERSION}
>>>         install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
>>> @@ -393,9 +419,9 @@ do_shared_workdir_setscene () {
>>>     emit_depmod_pkgdata() {
>>>         # Stash data for depmod
>>> -       install -d ${PKGDESTWORK}/kernel-depmod/
>>> -       echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
>>> depmod/kernel-abiversion
>>> -       cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-
>>> ${KERNEL_VERSION}
>>> +       install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
>>> +       echo "${KERNEL_VERSION}" >
>>> ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-
>>> abiversion
>>> +       cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
>>> depmod/System.map-${KERNEL_VERSION}
>>>   }
>>>     PACKAGEFUNCS += "emit_depmod_pkgdata"
>>> @@ -410,7 +436,7 @@ do_shared_workdir () {
>>>         # Store the kernel version in sysroots for module-
>>> base.bbclass
>>>         #
>>>   -     echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
>>> +       echo "${KERNEL_VERSION}" >
>>> $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>>>         # Copy files required for module builds
>>>         cp System.map $kerneldir/System.map-${KERNEL_VERSION}
>>> @@ -508,28 +534,28 @@ EXPORT_FUNCTIONS do_compile do_install
>>> do_configure
>>>     # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base
>>> ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
>>> ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>>>   FILES_${PN} = ""
>>> -FILES_kernel-base =
>>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>>> -FILES_kernel-image = ""
>>> -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
>>> /boot/config* ${KERNEL_SRC_PATH}
>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>>> -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
>>> -FILES_kernel-modules = ""
>>> -RDEPENDS_kernel = "kernel-base"
>>> +FILES_${KERNEL_PACKAGE_NAME}-base =
>>> "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>>> +FILES_${KERNEL_PACKAGE_NAME}-image = ""
>>> +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
>>> /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
>>> ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>>> +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
>>> ${KERNEL_VERSION_NAME}"
>>> +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
>>> +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
>>>   # Allow machines to override this dependency if kernel image files
>>> are
>>>   # not wanted in images as standard
>>> -RDEPENDS_kernel-base ?= "kernel-image"
>>> -PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNE
>>> L_VERSION}')}"
>>> -RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE',
>>> 'vmlinux', 'kernel-vmlinux', '', d)}"
>>> -PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSI
>>> ON}')}"
>>> -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"
>>> -
>>> -pkg_postinst_kernel-base () {
>>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-
>>> image"
>>> +PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@
>>> legitimize_package_name('${KERNEL_VERSION}')}"
>>> +RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@base_conditional('KERNE
>>> L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
>>> +PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitim
>>> ize_package_name('${KERNEL_VERSION}')}"
>>> +RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-
>>> ${KERNEL_VERSION}"
>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
>>> +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
>>> +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta
>>> package"
>>> +
>>> +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>>>         if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>>>                 mkdir -p $D/lib/modules/${KERNEL_VERSION}
>>>         fi
>>> @@ -543,7 +569,7 @@ pkg_postinst_kernel-base () {
>>>   PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>>>     python split_kernel_packages () {
>>> -    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-
>>> firmware-%s', description='Firmware for %s', recursive=True,
>>> extra_depends='')
>>> +    do_split_packages(d, root='${nonarch_base_libdir}/firmware',
>>> file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>>> output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
>>> description='Firmware for %s', recursive=True, extra_depends='')
>>>   }
>>>     # Many scripts want to look in arch/$arch/boot for the bootable
>>> @@ -626,21 +652,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-
>>> ${MACHINE}.tgz"
>>>   MODULE_TARBALL_DEPLOY ?= "1"
>>>     kernel_do_deploy() {
>>> +       deployDir="${DEPLOYDIR}"
>>> +       if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
>>> +               deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
>>> +               mkdir "$deployDir"
>>> +       fi
>>> +
>>>         for type in ${KERNEL_IMAGETYPES} ; do
>>>                 base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>>> -               install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>>> ${DEPLOYDIR}/${base_name}.bin
>>> +               install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>>> $deployDir/${base_name}.bin
>>>         done
>>>         if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e
>>> '^CONFIG_MODULES=y$' .config); then
>>>                 mkdir -p ${D}/lib
>>> -               tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME}
>>> -C ${D} lib
>>> -               ln -sf ${MODULE_TARBALL_BASE_NAME}
>>> ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
>>> +               tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME} -C
>>> ${D} lib
>>> +               ln -sf ${MODULE_TARBALL_BASE_NAME}
>>> $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
>>>         fi
>>>         for type in ${KERNEL_IMAGETYPES} ; do
>>>                 base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>>>                 symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
>>> -               ln -sf ${base_name}.bin
>>> ${DEPLOYDIR}/${symlink_name}.bin
>>> -               ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
>>> +               ln -sf ${base_name}.bin
>>> $deployDir/${symlink_name}.bin
>>> +               ln -sf ${base_name}.bin $deployDir/${type}
>>>         done
>>>         cd ${B}
>>> @@ -650,8 +682,8 @@ kernel_do_deploy() {
>>>                         echo "Copying deploy ${type} kernel-
>>> initramfs image and setting up links..."
>>>                         initramfs_base_name=${type}-
>>> ${INITRAMFS_BASE_NAME}
>>>                         initramfs_symlink_name=${type}-initramfs-
>>> ${MACHINE}
>>> -                       install -m 0644
>>> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
>>> ${DEPLOYDIR}/${initramfs_base_name}.bin
>>> -                       ln -sf ${initramfs_base_name}.bin
>>> ${DEPLOYDIR}/${initramfs_symlink_name}.bin
>>> +                       install -m 0644
>>> ${KERNEL_OUTPUT_DIR}/${type}.initramfs
>>> $deployDir/${initramfs_base_name}.bin
>>> +                       ln -sf ${initramfs_base_name}.bin
>>> $deployDir/${initramfs_symlink_name}.bin
>>>                 fi
>>>         done
>>>   }
>>> diff --git a/meta/conf/documentation.conf
>>> b/meta/conf/documentation.conf
>>> index a55e2836b5..2c88504fb9 100644
>>> --- a/meta/conf/documentation.conf
>>> +++ b/meta/conf/documentation.conf
>>> @@ -247,6 +247,7 @@ KERNEL_IMAGETYPE[doc] = "The type of kernel to
>>> build for a device, usually set b
>>>   KERNEL_IMAGETYPES[doc] = "The list of types of kernel to build for a
>>> device, usually set by the machine configuration files and defaults
>>> to KERNEL_IMAGETYPE."
>>>   KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that need to be
>>> auto-loaded during boot"
>>>   KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for which the
>>> build system expects to find module_conf_* values that specify
>>> configuration for each of the modules"
>>> +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
>>> Defaults to 'kernel'."
>>>   KERNEL_PATH[doc] = "The location of the kernel sources. This
>>> variable is set to the value of the STAGING_KERNEL_DIR within the
>>> module class (module.bbclass)."
>>>   KERNEL_SRC[doc] = "The location of the kernel sources. This variable
>>> is set to the value of the STAGING_KERNEL_DIR within the module class
>>> (module.bbclass)."
>>>   KFEATURE_DESCRIPTION[doc] = "Provides a short description of a
>>> configuration fragment. You use this variable in the .scc file that
>>> describes a configuration fragment file."
>>> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>>> b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>>> index 44d013f29d..2eec921728 100644
>>> --- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>>> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>>> @@ -23,17 +23,13 @@ if [ "\$1" != "-a" -o "\$2" != "-b" ]; then
>>>       echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
>>>       exit 1
>>>   fi
>>> -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion ]; then
>>> -    echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/kernel-
>>> abiversion" >&2
>>> -else
>>> -    kernelabi=\$(cat ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion)
>>> -    if [ "\$kernelabi" != "\$4" ]; then
>>> -        echo "Error: Kernel version \$4 does not match kernel-
>>> abiversion (\$kernelabi)" >&2
>>> -        exit 1
>>> -    fi
>>> +
>>> +kernelabi=""
>>> +if [ -r "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" ]; then
>>> +    kernelabi=\$(cat "${PKGDATA_DIR}/kernel-depmod/kernel-
>>> abiversion")
>>>   fi
>>>   -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ]; then
>>> +if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [
>>> "\$kernelabi" != "\$4" ]; then
>>>       echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/System.map-
>>> \$4" >&2
>>>       exec env depmod "\$1" "\$2" "\$3" "\$4"
>>>   else
>>> diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>>> b/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>>> index f93d9530eb..894e2ffbf6 100644
>>> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>>> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>>> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>>>   # to build multiple virtual/kernel providers, e.g. as dependency of
>>>   # core-image-rt-sdk, core-image-rt.
>>>   python () {
>>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>>> yocto-rt":
>>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>>> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
>>>           raise bb.parse.SkipPackage("Set
>>> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
>>>   }
>>>   diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>>> b/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>>> index c49a9340f8..be4d163ff1 100644
>>> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>>> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>>> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>>>   # to build multiple virtual/kernel providers, e.g. as dependency of
>>>   # core-image-rt-sdk, core-image-rt.
>>>   python () {
>>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>>> yocto-rt":
>>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>>> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
>>>           raise bb.parse.SkipPackage("Set
>>> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
>>>   }
>>>   diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>>> b/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>>> index 25d88833a9..e489bbb9f2 100644
>>> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>>> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>>> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>>>   # to build multiple virtual/kernel providers, e.g. as dependency of
>>>   # core-image-rt-sdk, core-image-rt.
>>>   python () {
>>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>>> yocto-rt":
>>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>>> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
>>>           raise bb.parse.SkipPackage("Set
>>> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
>>>   }
>>>   diff --git a/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>>> b/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>>> index 6734dc0d05..8212b1445c 100644
>>> --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>>> +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>>> @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>>>   # to build multiple virtual/kernel providers, e.g. as dependency of
>>>   # core-image-rt-sdk, core-image-rt.
>>>   python () {
>>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>>> yocto-rt":
>>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>>> d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-yocto-rt":
>>>           raise bb.parse.SkipPackage("Set
>>> PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to enable it")
>>>   }
>>>   diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
>>> b/meta/recipes-kernel/linux/linux-yocto.inc
>>> index 9c1f61be75..8a70eb5018 100644
>>> --- a/meta/recipes-kernel/linux/linux-yocto.inc
>>> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
>>> @@ -12,7 +12,7 @@ INC_PR = "r4"
>>>   # PREFERRED_PROVIDER for virtual/kernel. This avoids network access
>>> required
>>>   # by the use of AUTOREV SRCREVs, which are the default for this
>>> recipe.
>>>   python () {
>>> -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
>>> d.getVar("PN"):
>>> +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>>> d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) != d.getVar("PN",
>>> True):
>>>           d.delVar("BB_DONT_CACHE")
>>>           raise bb.parse.SkipPackage("Set
>>> PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
>>> (d.getVar("PN")))
>>>   }
>>> --
>>> 2.14.2
>>>
>> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>

[-- Attachment #2: Type: text/html, Size: 40790 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v9] kernel: Add support for multiple kernel packages
  2017-12-04 16:13             ` Burton, Ross
@ 2017-12-12 22:19               ` Haris Okanovic
  2017-12-13 12:31                 ` Burton, Ross
  0 siblings, 1 reply; 31+ messages in thread
From: Haris Okanovic @ 2017-12-12 22:19 UTC (permalink / raw)
  To: Burton, Ross
  Cc: Ashfield, Bruce (Wind River),
	josh.hernstrom, openembedded-core, Wold, Saul

Hi Ross,

On 12/04/2017 10:13 AM, Burton, Ross wrote:
> I know I'm late and this has gone through so many revisions, but I'm 
> seeing unexplained changes in buildhistory:
> 
> $ buildhistory-diff
> packages/corei7-64-intel-common-poky-linux/linux-intel/kernel-image-bzimage: 
> FILELIST: removed "/boot/bzImage"
> 
> Doing builds of virtual/kernel with and without this patch and comparing 
> pkgdata directly confirms that the /boot/bzImage symlink doesn't exist 
> with this patch but does without it.
> 

I can see a reference to "/boot/bzImage" in both buildhistory and 
tmp-glibc/work/.../pkgdata [1] after running a clean rebuild of 
virtual/kernel [2].

[1] file paths:
 
"buildhistory/packages/qemux86-oe-linux/linux-yocto/kernel-image-bzimage/files-in-package.txt"
 
"tmp-glibc/work/qemux86-oe-linux/linux-yocto/4.12.12+gitAUTOINC+eda4d18ce4_16de014967-r0/pkgdata/runtime/kernel-image-bzimage"

[2] clean rebuild command:
  bitbake -c cleanall virtual/kernel
  bitbake virtual/kernel

Which file are you diffing? Could you share the full path?

-- Haris

> Ross
> 
> On 10 November 2017 at 21:51, Haris Okanovic <haris.okanovic@ni.com 
> <mailto:haris.okanovic@ni.com>> wrote:
> 
>     No problem! Thanks for all the good feedback. I think we shook out
>     most of the gremlins in the last few months.
> 
>     Let me know if you need help with boot loader integration.
> 
>     -- Haris
> 
> 
> 
>     On 11/08/2017 04:20 PM, Wold, Saul wrote:
> 
> 
>         Haris,
> 
>         Thanks for your patience on this process.  This version works
>         well, now
>         I have the extra work of getting these kernel known to systemd-boot!
> 
>         Acked-by below!
> 
>         Sau!
> 
>         On Tue, 2017-11-07 at 12:40 -0600, Haris Okanovic wrote:
> 
>             Some distros may want to provide alternate kernel "flavors"
>             via feeds
>             or
>             within bootable images. For example, readily available
>             builds which
>             provide certain diagnostic features can enable developers
>             and testers
>             to
>             more quickly resolve issues by avoiding lengthy kernel builds.
> 
>             This change allows for building multiple flavors of the
>             kernel and
>             module packages by templatizing kernel package names via a new
>             KERNEL_PACKAGE_NAME variable in kernel.bbclass. It defaults
>             to the
>             old
>             name of "kernel", but can be overridden by certain recipes
>             providing
>             alternate kernel flavors.
> 
>             To maintain compatibility, recipes providing alternate
>             kernel flavors
>             cannot be the "preferred provider" for virtual/kernel. This is
>             because
>             OE puts the preferred provider's build and source at
>             "tmp-glibc/work-shared/$MACHINE/kernel-build-artifacts/" and
>             "tmp-glibc/work-shared/$MACHINE/kernel-source/" instead of
>             "tmp-glibc/work/*/$PN/" like other recipes. Therefore,
>             recipes using
>             the
>             default KERNEL_PACKAGE_NAME="kernel" follows the old
>             semantics --
>             build
>             in the old location and may be preferred provider -- while
>             recipes
>             using
>             all other KERNEL_PACKAGE_NAME's build from the normal
>             WORKDIR and
>             don't
>             provide "virtual/kernel".
> 
>             Testing:
>                1. Add `KERNEL_PACKAGE_NAME_pn-linux-yocto-tiny =
>             "tiny-linux"`
>                   to local.conf so that linux-yocto-tiny may build alongside
>                   the main kernel (linux-yocto).
>                2. `bitbake linux-yocto linux-yocto-tiny` to build both
>             kernel
>             flavors.
>                3. Verified image and modules IPKs exist for both:
>                   tmp-glibc/deploy/ipk/qemux86/kernel-* for linux-yocto
>                   tmp-glibc/deploy/ipk/qemux86/tiny-linux* for
>             linux-yocto-tiny
>                4. Verified linux-yocto is the "preferred provider", and
>             was built
>             in
>                   shared directory: tmp-glibc/work-shared/qemux86/kernel-*
>                5. Add `CORE_IMAGE_BASE_INSTALL_append_pn-core-image-base
>             = "tiny-
>             linux"`
>                   to local.conf to install both kernel flavors in
>             core-image-base.
>                6. `bitbake core-image-base` to build an image.
>                7. Verified image contains two bzImage's under /boot/, with
>                   "yocto-standard" (linux-yocto recipe) selected to boot via
>             symlink.
> 
>             Discussion threads:
>             https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org_pipermail_openembedded-2Dcore_2015-2DDecemb&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=Po_g6d_nUSqHTshbn-ZaBXenlH_4CQklz7Csmi7u70A&s=cJkppECRP9FwMwrmn-tbJfRpffqbPbeRXS1uCu5JsB0&e=
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org_pipermail_openembedded-2Dcore_2015-2DDecemb&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=Po_g6d_nUSqHTshbn-ZaBXenlH_4CQklz7Csmi7u70A&s=cJkppECRP9FwMwrmn-tbJfRpffqbPbeRXS1uCu5JsB0&e=>
>             er/thread.html#114122
>             https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org_pipermail_openembedded-2Dcore_2017-2DJuly_t&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=Po_g6d_nUSqHTshbn-ZaBXenlH_4CQklz7Csmi7u70A&s=B73w8-RIOKqgiEjZMC2ra49Q1594cWVJp9c6Yx6u34w&e=
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org_pipermail_openembedded-2Dcore_2017-2DJuly_t&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=Po_g6d_nUSqHTshbn-ZaBXenlH_4CQklz7Csmi7u70A&s=B73w8-RIOKqgiEjZMC2ra49Q1594cWVJp9c6Yx6u34w&e=>
> 
>             hread.html#139130
> 
>             [YOCTO #11363]
> 
>             Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com
>             <mailto:adrian.ratiu@ni.com>>
>             Signed-off-by: Gratian Crisan <gratian.crisan@ni.com
>             <mailto:gratian.crisan@ni.com>>
>             Signed-off-by: Haris Okanovic <haris.okanovic@ni.com
>             <mailto:haris.okanovic@ni.com>>
>             Coauthored-by: Gratian Crisan <gratian.crisan@ni.com
>             <mailto:gratian.crisan@ni.com>>
>             Coauthored-by: Haris Okanovic <haris.okanovic@ni.com
>             <mailto:haris.okanovic@ni.com>>
>             Coauthored-by: Josh Hernstrom <josh.hernstrom@ni.com
>             <mailto:josh.hernstrom@ni.com>>
> 
> 
>         Acked-by: Saul Wold <sgw@linux.intel.com
>         <mailto:sgw@linux.intel.com>>
> 
>         Sau!
> 
>             ---
>             [PATCH v2] Change STAGING_KERNEL_DIR and
>             STAGING_KERNEL_BUILDDIR to
>             the
>             "work" directory in alternate kernel builds, instead of "work-
>             shared",
>             so
>             that the two builds don't clobber each other.
> 
>             [PATCH v3] An updated version of this change rebased onto
>             the current
>             OE-core master. Changes:
>                - Remove PREFERRED_PROVIDER check in linux-yocto.inc in
>             alternate
>                  kernel builds, since alternate kernels aren't the
>                  PREFERRED_PROVIDER for virtual/kernel by definition.
>                - Remove "virtual/kernel" from PROVIDES in alternate
>             kernel builds.
> 
>             [PATCH v4] Another rebase onto master; no functional change.
>             Improved description and testing steps.
> 
>             [PATCH v5]
>                - Warn when PN == KERNEL_PACKAGE_NAME (bug # 11905)
>                - Add KERNEL_DEPLOYSUBDIR to avoid DEPLOYDIR collisions
> 
>             [PATCH v6] Add KERNEL_PACKAGE_NAME to
>             kernel-module-split.bbclass for
>             module recipes; fixes lttng-modules build.
> 
>             [PATCH v7] Remove second definition of KERNEL_PACKAGE_NAME from
>             kernel-module-split.bbclass; apply a default in two places where
>             KERNEL_PACKAGE_NAME is referenced.
> 
>             [PATCH v8] Rebase onto current master and more fixups.
>                - kernel-devicetree.bbclass: Fixup package names
>                - depmodwrapper-cross: don't error when called from alt
>             kernel
>             recipes
>                - kernel.bbclass: Don't install /boot/image symlink in
>             alt recipes
> 
>             [PATCH v9]
>                - Add feature tracking tag
>                - Update testing section to define vars in local.conf
>                - Add KERNEL_PACKAGE_NAME check to *-rt recipes
> 
>             https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_harisokanovic_openembedded-2Dcore_tree_dev_hokanovi_&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=Po_g6d_nUSqHTshbn-ZaBXenlH_4CQklz7Csmi7u70A&s=g1DTbKMM_NmbTwVK6ABKrg7v5Qst-DAX8wovpBEZiQQ&e=
>             <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_harisokanovic_openembedded-2Dcore_tree_dev_hokanovi_&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=Po_g6d_nUSqHTshbn-ZaBXenlH_4CQklz7Csmi7u70A&s=g1DTbKMM_NmbTwVK6ABKrg7v5Qst-DAX8wovpBEZiQQ&e=>
> 
>             multi-kernel-packages-v9
>             ---
>                meta/classes/kernel-devicetree.bbclass             |   8 +-
>                meta/classes/kernel-module-split.bbclass           |   9 +-
>                meta/classes/kernel.bbclass                        | 114
>             +++++++++++++--------
>                meta/conf/documentation.conf                       |   1 +
>                .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__depmodwrapper-2Dcross-5F1.0.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=qlgY-8Y1g9Cq89Pn9M5yTk4r8YvbySKJLXNiZXT9HbQ&e=>
>             |  14 +--
>                meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.10.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=uYMHx1CaQM9mvkTAOhJ1-8y0C3YmbfKIQbs9BLe7J5E&e=> 
>               |   2 +-
>                meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.12.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=_oN3Rf0BYilWc5XSBIjUTHmA1U91aV_nw8qmd2XCOOc&e=> 
>               |   2 +-
>                meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.4.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=5gPtrJeah56v8FQaPyMAlG97S5Po4b9odaMPEULAc4c&e=> 
>                |   2 +-
>                meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.9.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=dsIUW4hBrziD1cM8dWZANTqlqlUz3p6T9ZsLbn4iy6c&e=> 
>                |   2 +-
>                meta/recipes-kernel/linux/linux-yocto.inc          |   2 +-
>                10 files changed, 94 insertions(+), 62 deletions(-)
> 
>             diff --git a/meta/classes/kernel-devicetree.bbclass
>             b/meta/classes/kernel-devicetree.bbclass
>             index 6e08be4b70..4f80cc62eb 100644
>             --- a/meta/classes/kernel-devicetree.bbclass
>             +++ b/meta/classes/kernel-devicetree.bbclass
>             @@ -1,10 +1,10 @@
>                # Support for device tree generation
>                PACKAGES_append = " \
>             -    kernel-devicetree \
>             -    ${@['kernel-image-zimage-bundle',
>             ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
>             +    ${KERNEL_PACKAGE_NAME}-devicetree \
>             +    ${@[d.getVar('KERNEL_PACKAGE_NAME') +
>             '-image-zimage-bundle',
>             ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
>                "
>             -FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb
>             /${KERNEL_IMAGEDEST}/*.dtbo"
>             -FILES_kernel-image-zimage-bundle =
>             "/${KERNEL_IMAGEDEST}/zImage-
>             *.dtb.bin"
>             +FILES_${KERNEL_PACKAGE_NAME}-devicetree =
>             "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
>             +FILES_${KERNEL_PACKAGE_NAME}-image-zimage-bundle =
>             "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
>                  # Generate kernel+devicetree bundle
>                KERNEL_DEVICETREE_BUNDLE ?= "0"
>             diff --git a/meta/classes/kernel-module-split.bbclass
>             b/meta/classes/kernel-module-split.bbclass
>             index 1035525dac..73c7f18c78 100644
>             --- a/meta/classes/kernel-module-split.bbclass
>             +++ b/meta/classes/kernel-module-split.bbclass
>             @@ -30,7 +30,7 @@ do_install_append() {
>                  PACKAGESPLITFUNCS_prepend = "split_kernel_module_packages "
>                -KERNEL_MODULES_META_PACKAGE ?= "kernel-modules"
>             +KERNEL_MODULES_META_PACKAGE ?= "${@
>             d.getVar("KERNEL_PACKAGE_NAME",
>             True) or "kernel" }-modules"
>                  KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>                KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
>             @@ -129,16 +129,19 @@ python split_kernel_module_packages () {
>                           postfix = format.split('%s')[1]
>                           d.setVar('RPROVIDES_' + pkg,
>             pkg.replace(postfix, ''))
>                +    kernel_package_name =
>             d.getVar("KERNEL_PACKAGE_NAME", True) or
>             "kernel"
>             +    kernel_version = d.getVar("KERNEL_VERSION", True)
>             +
>                    module_regex = '^(.*)\.k?o$'
>                      module_pattern_prefix =
>             d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
>                    module_pattern_suffix =
>             d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
>             -    module_pattern = module_pattern_prefix +
>             'kernel-module-%s' +
>             module_pattern_suffix
>             +    module_pattern = module_pattern_prefix +
>             kernel_package_name +
>             '-module-%s' + module_pattern_suffix
>                      postinst = d.getVar('pkg_postinst_modules')
>                    postrm = d.getVar('pkg_postrm_modules')
>                -    modules = do_split_packages(d,
>             root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>             output_pattern=module_pattern, description='%s kernel module',
>             postinst=postinst, postrm=postrm, recursive=True,
>             hook=frob_metadata,
>             extra_depends='kernel-%s' % (d.getVar("KERNEL_VERSION")))
>             +    modules = do_split_packages(d,
>             root='${nonarch_base_libdir}/modules', file_regex=module_regex,
>             output_pattern=module_pattern, description='%s kernel module',
>             postinst=postinst, postrm=postrm, recursive=True,
>             hook=frob_metadata,
>             extra_depends='%s-%s' % (kernel_package_name, kernel_version))
>                    if modules:
>                        metapkg = d.getVar('KERNEL_MODULES_META_PACKAGE')
>                        d.appendVar('RDEPENDS_' + metapkg, ' '+'
>             '.join(modules))
>             diff --git a/meta/classes/kernel.bbclass
>             b/meta/classes/kernel.bbclass
>             index 756707a3c2..48b718d777 100644
>             --- a/meta/classes/kernel.bbclass
>             +++ b/meta/classes/kernel.bbclass
>             @@ -1,6 +1,9 @@
>                inherit linux-kernel-base kernel-module-split
>                -PROVIDES += "virtual/kernel"
>             +KERNEL_PACKAGE_NAME ??= "kernel"
>             +KERNEL_DEPLOYSUBDIR ??= "${@ "" if
>             (d.getVar("KERNEL_PACKAGE_NAME",
>             True) == "kernel") else d.getVar("KERNEL_PACKAGE_NAME", True) }"
>             +
>             +PROVIDES += "${@ "virtual/kernel" if
>             (d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel") else "" }"
>                DEPENDS += "virtual/${TARGET_PREFIX}binutils
>             virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
>                PACKAGE_WRITE_DEPS += "depmodwrapper-cross"
>                @@ -34,11 +37,32 @@ KERNEL_VERSION_PKG_NAME =
>             "${@legitimize_package_
>             name(d.getVar('KERNEL_VERSION')
>                KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
>                  python __anonymous () {
>             +    pn = d.getVar("PN", True)
>             +    kpn = d.getVar("KERNEL_PACKAGE_NAME", True)
>             +
>             +    # XXX Remove this after bug 11905 is resolved
>             +    #  FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand
>             correctly
>             +    if kpn == pn:
>             +        bb.warn("Some packages (E.g. *-dev) might be
>             missing due to
>             "
>             +                "bug 11905 (variable KERNEL_PACKAGE_NAME ==
>             PN)")
>             +
>             +    # The default kernel recipe builds in a shared location
>             defined
>             by
>             +    # bitbake/distro confs: STAGING_KERNEL_DIR and
>             STAGING_KERNEL_BUILDDIR.
>             +    # Set these variables to directories under ${WORKDIR} in
>             alternate
>             +    # kernel recipes (I.e. where KERNEL_PACKAGE_NAME !=
>             kernel) so
>             that they
>             +    # may build in parallel with the default kernel without
>             clobbering.
>             +    if kpn != "kernel":
>             +        workdir = d.getVar("WORKDIR", True)
>             +        sourceDir = os.path.join(workdir, 'kernel-source')
>             +        artifactsDir = os.path.join(workdir, 'kernel-build-
>             artifacts')
>             +        d.setVar("STAGING_KERNEL_DIR", sourceDir)
>             +        d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
>                      # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into
>             KERNEL_IMAGETYPES
>                    type = d.getVar('KERNEL_IMAGETYPE') or ""
>                    alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
>                    types = d.getVar('KERNEL_IMAGETYPES') or ""
>             +    kname = d.getVar('KERNEL_PACKAGE_NAME', True) or "kernel"
>                    if type not in types.split():
>                        types = (type + ' ' + types).strip()
>                    if alttype not in types.split():
>             @@ -55,15 +79,15 @@ python __anonymous () {
>                        typelower = type.lower()
>                        imagedest = d.getVar('KERNEL_IMAGEDEST')
>                -        d.appendVar('PACKAGES', ' ' + 'kernel-image-' +
>             typelower)
>             +        d.appendVar('PACKAGES', ' %s-image-%s' % (kname,
>             typelower))
>                -        d.setVar('FILES_kernel-image-' + typelower, '/'
>             + imagedest
>             + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest
>             + '/' +
>             type)
>             +        d.setVar('FILES_' + kname + '-image-' + typelower,
>             '/' +
>             imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' +
>             imagedest
>             + '/' + type)
>                -        d.appendVar('RDEPENDS_kernel-image', ' ' +
>             'kernel-image-' +
>             typelower)
>             +        d.appendVar('RDEPENDS_%s-image' % kname, '
>             %s-image-%s' %
>             (kname, typelower))
>                -        d.setVar('PKG_kernel-image-' + typelower,
>             'kernel-image-' +
>             typelower + '-${KERNEL_VERSION_PKG_NAME}')
>             +        d.setVar('PKG_%s-image-%s' % (kname,typelower),
>             '%s-image-
>             %s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
>                -        d.setVar('ALLOW_EMPTY_kernel-image-' +
>             typelower, '1')
>             +        d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname,
>             typelower),
>             '1')
>                      image = d.getVar('INITRAMFS_IMAGE')
>                    if image:
>             @@ -121,9 +145,9 @@ base_do_unpack_append () {
>                  inherit kernel-arch deploy
>                -PACKAGES_DYNAMIC += "^kernel-module-.*"
>             -PACKAGES_DYNAMIC += "^kernel-image-.*"
>             -PACKAGES_DYNAMIC += "^kernel-firmware-.*"
>             +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
>             +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
>             +PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
>                  export OS = "${TARGET_OS}"
>                export CROSS_COMPILE = "${TARGET_PREFIX}"
>             @@ -339,7 +363,9 @@ kernel_do_install() {
>                      install -d ${D}/boot
>                      for type in ${KERNEL_IMAGETYPES} ; do
>                              install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>             ${D}/${KERNEL_IMAGEDEST}/${type}-${KERNEL_VERSION}
>             -               ln -sf ${type}-${KERNEL_VERSION}
>             ${D}/${KERNEL_IMAGEDEST}/${type}
>             +               if [ "${KERNEL_PACKAGE_NAME}" == "kernel" ];
>             then
>             +                       ln -sf ${type}-${KERNEL_VERSION}
>             ${D}/${KERNEL_IMAGEDEST}/${type}
>             +               fi
>                      done
>                      install -m 0644 System.map ${D}/boot/System.map-
>             ${KERNEL_VERSION}
>                      install -m 0644 .config
>             ${D}/boot/config-${KERNEL_VERSION}
>             @@ -393,9 +419,9 @@ do_shared_workdir_setscene () {
>                  emit_depmod_pkgdata() {
>                      # Stash data for depmod
>             -       install -d ${PKGDESTWORK}/kernel-depmod/
>             -       echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-
>             depmod/kernel-abiversion
>             -       cp ${B}/System.map
>             ${PKGDESTWORK}/kernel-depmod/System.map-
>             ${KERNEL_VERSION}
>             +       install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
>             +       echo "${KERNEL_VERSION}" >
>             ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-
>             abiversion
>             +       cp ${B}/System.map
>             ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-
>             depmod/System.map-${KERNEL_VERSION}
>                }
>                  PACKAGEFUNCS += "emit_depmod_pkgdata"
>             @@ -410,7 +436,7 @@ do_shared_workdir () {
>                      # Store the kernel version in sysroots for module-
>             base.bbclass
>                      #
>                -     echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
>             +       echo "${KERNEL_VERSION}" >
>             $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
>                      # Copy files required for module builds
>                      cp System.map $kerneldir/System.map-${KERNEL_VERSION}
>             @@ -508,28 +534,28 @@ EXPORT_FUNCTIONS do_compile do_install
>             do_configure
>                  # 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_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base
>             ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image
>             ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
>                FILES_${PN} = ""
>             -FILES_kernel-base =
>             "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>             ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>             -FILES_kernel-image = ""
>             -FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers*
>             /boot/config* ${KERNEL_SRC_PATH}
>             ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>             -FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
>             -FILES_kernel-modules = ""
>             -RDEPENDS_kernel = "kernel-base"
>             +FILES_${KERNEL_PACKAGE_NAME}-base =
>             "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order
>             ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
>             +FILES_${KERNEL_PACKAGE_NAME}-image = ""
>             +FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map*
>             /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH}
>             ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
>             +FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-
>             ${KERNEL_VERSION_NAME}"
>             +FILES_${KERNEL_PACKAGE_NAME}-modules = ""
>             +RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
>                # Allow machines to override this dependency if kernel
>             image files
>             are
>                # not wanted in images as standard
>             -RDEPENDS_kernel-base ?= "kernel-image"
>             -PKG_kernel-image =
>             "kernel-image-${@legitimize_package_name('${KERNE
>             L_VERSION}')}"
>             -RDEPENDS_kernel-image +=
>             "${@base_conditional('KERNEL_IMAGETYPE',
>             'vmlinux', 'kernel-vmlinux', '', d)}"
>             -PKG_kernel-base =
>             "kernel-${@legitimize_package_name('${KERNEL_VERSI
>             ON}')}"
>             -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"
>             -
>             -pkg_postinst_kernel-base () {
>             +RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?=
>             "${KERNEL_PACKAGE_NAME}-
>             image"
>             +PKG_${KERNEL_PACKAGE_NAME}-image =
>             "${KERNEL_PACKAGE_NAME}-image-${@
>             legitimize_package_name('${KERNEL_VERSION}')}"
>             +RDEPENDS_${KERNEL_PACKAGE_NAME}-image +=
>             "${@base_conditional('KERNE
>             L_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux',
>             '', d)}"
>             +PKG_${KERNEL_PACKAGE_NAME}-base =
>             "${KERNEL_PACKAGE_NAME}-${@legitim
>             ize_package_name('${KERNEL_VERSION}')}"
>             +RPROVIDES_${KERNEL_PACKAGE_NAME}-base +=
>             "${KERNEL_PACKAGE_NAME}-
>             ${KERNEL_VERSION}"
>             +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
>             +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
>             +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
>             +ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
>             +DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel
>             modules meta
>             package"
>             +
>             +pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
>                      if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>                              mkdir -p $D/lib/modules/${KERNEL_VERSION}
>                      fi
>             @@ -543,7 +569,7 @@ pkg_postinst_kernel-base () {
>                PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
>                  python split_kernel_packages () {
>             -    do_split_packages(d,
>             root='${nonarch_base_libdir}/firmware',
>             file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>             output_pattern='kernel-
>             firmware-%s', description='Firmware for %s', recursive=True,
>             extra_depends='')
>             +    do_split_packages(d,
>             root='${nonarch_base_libdir}/firmware',
>             file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$',
>             output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s',
>             description='Firmware for %s', recursive=True, extra_depends='')
>                }
>                  # Many scripts want to look in arch/$arch/boot for the
>             bootable
>             @@ -626,21 +652,27 @@ MODULE_TARBALL_SYMLINK_NAME ?= "modules-
>             ${MACHINE}.tgz"
>                MODULE_TARBALL_DEPLOY ?= "1"
>                  kernel_do_deploy() {
>             +       deployDir="${DEPLOYDIR}"
>             +       if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
>             +               deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
>             +               mkdir "$deployDir"
>             +       fi
>             +
>                      for type in ${KERNEL_IMAGETYPES} ; do
>                              base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>             -               install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>             ${DEPLOYDIR}/${base_name}.bin
>             +               install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}
>             $deployDir/${base_name}.bin
>                      done
>                      if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e
>             '^CONFIG_MODULES=y$' .config); then
>                              mkdir -p ${D}/lib
>             -               tar -cvzf
>             ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME}
>             -C ${D} lib
>             -               ln -sf ${MODULE_TARBALL_BASE_NAME}
>             ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
>             +               tar -cvzf
>             $deployDir/${MODULE_TARBALL_BASE_NAME} -C
>             ${D} lib
>             +               ln -sf ${MODULE_TARBALL_BASE_NAME}
>             $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
>                      fi
>                      for type in ${KERNEL_IMAGETYPES} ; do
>                              base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
>                             
>             symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
>             -               ln -sf ${base_name}.bin
>             ${DEPLOYDIR}/${symlink_name}.bin
>             -               ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
>             +               ln -sf ${base_name}.bin
>             $deployDir/${symlink_name}.bin
>             +               ln -sf ${base_name}.bin $deployDir/${type}
>                      done
>                      cd ${B}
>             @@ -650,8 +682,8 @@ kernel_do_deploy() {
>                                      echo "Copying deploy ${type} kernel-
>             initramfs image and setting up links..."
>                                      initramfs_base_name=${type}-
>             ${INITRAMFS_BASE_NAME}
>                                     
>             initramfs_symlink_name=${type}-initramfs-
>             ${MACHINE}
>             -                       install -m 0644
>             ${KERNEL_OUTPUT_DIR}/${type}.initramfs
>             ${DEPLOYDIR}/${initramfs_base_name}.bin
>             -                       ln -sf ${initramfs_base_name}.bin
>             ${DEPLOYDIR}/${initramfs_symlink_name}.bin
>             +                       install -m 0644
>             ${KERNEL_OUTPUT_DIR}/${type}.initramfs
>             $deployDir/${initramfs_base_name}.bin
>             +                       ln -sf ${initramfs_base_name}.bin
>             $deployDir/${initramfs_symlink_name}.bin
>                              fi
>                      done
>                }
>             diff --git a/meta/conf/documentation.conf
>             b/meta/conf/documentation.conf
>             index a55e2836b5..2c88504fb9 100644
>             --- a/meta/conf/documentation.conf
>             +++ b/meta/conf/documentation.conf
>             @@ -247,6 +247,7 @@ KERNEL_IMAGETYPE[doc] = "The type of
>             kernel to
>             build for a device, usually set b
>                KERNEL_IMAGETYPES[doc] = "The list of types of kernel to
>             build for a
>             device, usually set by the machine configuration files and
>             defaults
>             to KERNEL_IMAGETYPE."
>                KERNEL_MODULE_AUTOLOAD[doc] = "Lists kernel modules that
>             need to be
>             auto-loaded during boot"
>                KERNEL_MODULE_PROBECONF[doc] = "Lists kernel modules for
>             which the
>             build system expects to find module_conf_* values that specify
>             configuration for each of the modules"
>             +KERNEL_PACKAGE_NAME[doc] = "Name prefix for kernel packages.
>             Defaults to 'kernel'."
>                KERNEL_PATH[doc] = "The location of the kernel sources. This
>             variable is set to the value of the STAGING_KERNEL_DIR
>             within the
>             module class (module.bbclass)."
>                KERNEL_SRC[doc] = "The location of the kernel sources.
>             This variable
>             is set to the value of the STAGING_KERNEL_DIR within the
>             module class
>             (module.bbclass)."
>                KFEATURE_DESCRIPTION[doc] = "Provides a short description
>             of a
>             configuration fragment. You use this variable in the .scc
>             file that
>             describes a configuration fragment file."
>             diff --git
>             a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__depmodwrapper-2Dcross-5F1.0.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=qlgY-8Y1g9Cq89Pn9M5yTk4r8YvbySKJLXNiZXT9HbQ&e=>
>             b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__depmodwrapper-2Dcross-5F1.0.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=qlgY-8Y1g9Cq89Pn9M5yTk4r8YvbySKJLXNiZXT9HbQ&e=>
>             index 44d013f29d..2eec921728 100644
>             --- a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__depmodwrapper-2Dcross-5F1.0.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=qlgY-8Y1g9Cq89Pn9M5yTk4r8YvbySKJLXNiZXT9HbQ&e=>
>             +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__depmodwrapper-2Dcross-5F1.0.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=qlgY-8Y1g9Cq89Pn9M5yTk4r8YvbySKJLXNiZXT9HbQ&e=>
>             @@ -23,17 +23,13 @@ if [ "\$1" != "-a" -o "\$2" != "-b" ]; then
>                    echo "Usage: depmodwrapper -a -b rootfs
>             KERNEL_VERSION" >&2
>                    exit 1
>                fi
>             -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion ];
>             then
>             -    echo "Unable to read: ${PKGDATA_DIR}/kernel-depmod/kernel-
>             abiversion" >&2
>             -else
>             -    kernelabi=\$(cat
>             ${PKGDATA_DIR}/kernel-depmod/kernel-abiversion)
>             -    if [ "\$kernelabi" != "\$4" ]; then
>             -        echo "Error: Kernel version \$4 does not match kernel-
>             abiversion (\$kernelabi)" >&2
>             -        exit 1
>             -    fi
>             +
>             +kernelabi=""
>             +if [ -r "${PKGDATA_DIR}/kernel-depmod/kernel-abiversion" ];
>             then
>             +    kernelabi=\$(cat "${PKGDATA_DIR}/kernel-depmod/kernel-
>             abiversion")
>                fi
>                -if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ];
>             then
>             +if [ ! -r ${PKGDATA_DIR}/kernel-depmod/System.map-\$4 ] || [
>             "\$kernelabi" != "\$4" ]; then
>                    echo "Unable to read:
>             ${PKGDATA_DIR}/kernel-depmod/System.map-
>             \$4" >&2
>                    exec env depmod "\$1" "\$2" "\$3" "\$4"
>                else
>             diff --git
>             a/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.10.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=uYMHx1CaQM9mvkTAOhJ1-8y0C3YmbfKIQbs9BLe7J5E&e=>
>             b/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.10.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=uYMHx1CaQM9mvkTAOhJ1-8y0C3YmbfKIQbs9BLe7J5E&e=>
>             index f93d9530eb..894e2ffbf6 100644
>             --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.10.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=uYMHx1CaQM9mvkTAOhJ1-8y0C3YmbfKIQbs9BLe7J5E&e=>
>             +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.10.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.10.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=uYMHx1CaQM9mvkTAOhJ1-8y0C3YmbfKIQbs9BLe7J5E&e=>
>             @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>                # to build multiple virtual/kernel providers, e.g. as
>             dependency of
>                # core-image-rt-sdk, core-image-rt.
>                python () {
>             -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>             yocto-rt":
>             +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>             d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
>             "linux-yocto-rt":
>                        raise bb.parse.SkipPackage("Set
>             PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to
>             enable it")
>                }
>                diff --git
>             a/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.12.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=_oN3Rf0BYilWc5XSBIjUTHmA1U91aV_nw8qmd2XCOOc&e=>
>             b/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.12.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=_oN3Rf0BYilWc5XSBIjUTHmA1U91aV_nw8qmd2XCOOc&e=>
>             index c49a9340f8..be4d163ff1 100644
>             --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.12.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=_oN3Rf0BYilWc5XSBIjUTHmA1U91aV_nw8qmd2XCOOc&e=>
>             +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.12.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.12.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=_oN3Rf0BYilWc5XSBIjUTHmA1U91aV_nw8qmd2XCOOc&e=>
>             @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>                # to build multiple virtual/kernel providers, e.g. as
>             dependency of
>                # core-image-rt-sdk, core-image-rt.
>                python () {
>             -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>             yocto-rt":
>             +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>             d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
>             "linux-yocto-rt":
>                        raise bb.parse.SkipPackage("Set
>             PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to
>             enable it")
>                }
>                diff --git
>             a/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.4.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=5gPtrJeah56v8FQaPyMAlG97S5Po4b9odaMPEULAc4c&e=>
>             b/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.4.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=5gPtrJeah56v8FQaPyMAlG97S5Po4b9odaMPEULAc4c&e=>
>             index 25d88833a9..e489bbb9f2 100644
>             --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.4.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=5gPtrJeah56v8FQaPyMAlG97S5Po4b9odaMPEULAc4c&e=>
>             +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.4.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.4.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=5gPtrJeah56v8FQaPyMAlG97S5Po4b9odaMPEULAc4c&e=>
>             @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>                # to build multiple virtual/kernel providers, e.g. as
>             dependency of
>                # core-image-rt-sdk, core-image-rt.
>                python () {
>             -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>             yocto-rt":
>             +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>             d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
>             "linux-yocto-rt":
>                        raise bb.parse.SkipPackage("Set
>             PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to
>             enable it")
>                }
>                diff --git
>             a/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.9.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=dsIUW4hBrziD1cM8dWZANTqlqlUz3p6T9ZsLbn4iy6c&e=>
>             b/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.9.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=dsIUW4hBrziD1cM8dWZANTqlqlUz3p6T9ZsLbn4iy6c&e=>
>             index 6734dc0d05..8212b1445c 100644
>             --- a/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.9.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=dsIUW4hBrziD1cM8dWZANTqlqlUz3p6T9ZsLbn4iy6c&e=>
>             +++ b/meta/recipes-kernel/linux/linux-yocto-rt_4.9.bb
>             <https://urldefense.proofpoint.com/v2/url?u=http-3A__linux-2Dyocto-2Drt-5F4.9.bb&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=dsIUW4hBrziD1cM8dWZANTqlqlUz3p6T9ZsLbn4iy6c&e=>
>             @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-yocto.inc
>                # to build multiple virtual/kernel providers, e.g. as
>             dependency of
>                # core-image-rt-sdk, core-image-rt.
>                python () {
>             -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") != "linux-
>             yocto-rt":
>             +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>             d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
>             "linux-yocto-rt":
>                        raise bb.parse.SkipPackage("Set
>             PREFERRED_PROVIDER_virtual/kernel to linux-yocto-rt to
>             enable it")
>                }
>                diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
>             b/meta/recipes-kernel/linux/linux-yocto.inc
>             index 9c1f61be75..8a70eb5018 100644
>             --- a/meta/recipes-kernel/linux/linux-yocto.inc
>             +++ b/meta/recipes-kernel/linux/linux-yocto.inc
>             @@ -12,7 +12,7 @@ INC_PR = "r4"
>                # PREFERRED_PROVIDER for virtual/kernel. This avoids
>             network access
>             required
>                # by the use of AUTOREV SRCREVs, which are the default
>             for this
>             recipe.
>                python () {
>             -    if d.getVar("PREFERRED_PROVIDER_virtual/kernel") !=
>             d.getVar("PN"):
>             +    if d.getVar("KERNEL_PACKAGE_NAME", True) == "kernel" and
>             d.getVar("PREFERRED_PROVIDER_virtual/kernel", True) !=
>             d.getVar("PN",
>             True):
>                        d.delVar("BB_DONT_CACHE")
>                        raise bb.parse.SkipPackage("Set
>             PREFERRED_PROVIDER_virtual/kernel to %s to enable it" %
>             (d.getVar("PN")))
>                }
>             -- 
>             2.14.2
> 
>     -- 
>     _______________________________________________
>     Openembedded-core mailing list
>     Openembedded-core@lists.openembedded.org
>     <mailto:Openembedded-core@lists.openembedded.org>
>     http://lists.openembedded.org/mailman/listinfo/openembedded-core
>     <https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org_mailman_listinfo_openembedded-2Dcore&d=DwMFaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=8Bziuw3IaCGjyrSAphuGwHmVdHcVwza-srUYwL9U_Ms&m=EP5lwXBRFEqw5QJPdVYpiQb5eB78E4pv78trR5xxbos&s=MFcC28RFVfuPEIG4-wKAWkyoD2OBChADq7nxN9-4kMM&e=>
> 
> 


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v9] kernel: Add support for multiple kernel packages
  2017-12-12 22:19               ` Haris Okanovic
@ 2017-12-13 12:31                 ` Burton, Ross
  2017-12-13 19:39                   ` Haris Okanovic
  0 siblings, 1 reply; 31+ messages in thread
From: Burton, Ross @ 2017-12-13 12:31 UTC (permalink / raw)
  To: Haris Okanovic
  Cc: Ashfield, Bruce (Wind River),
	josh.hernstrom, openembedded-core, Wold, Saul

[-- Attachment #1: Type: text/plain, Size: 1333 bytes --]

On 12 December 2017 at 22:19, Haris Okanovic <haris.okanovic@ni.com> wrote:

> I can see a reference to "/boot/bzImage" in both buildhistory and
> tmp-glibc/work/.../pkgdata [1] after running a clean rebuild of
> virtual/kernel [2].
>
> [1] file paths:
>
> "buildhistory/packages/qemux86-oe-linux/linux-yocto/kernel-
> image-bzimage/files-in-package.txt"
>
> "tmp-glibc/work/qemux86-oe-linux/linux-yocto/4.12.12+gitAUTO
> INC+eda4d18ce4_16de014967-r0/pkgdata/runtime/kernel-image-bzimage"
>
> [2] clean rebuild command:
>  bitbake -c cleanall virtual/kernel
>  bitbake virtual/kernel
>
> Which file are you diffing? Could you share the full path?
>

If I build a qemux86 virtual/kernel without and with this patch and then
run buildhistory-diff:

packages/qemux86-poky-linux/linux-yocto/kernel-image-bzimage: FILELIST:
removed "/boot/bzImage"
packages/qemux86-poky-linux/linux-yocto/kernel-image-bzimage: PKGSIZE
changed from 7020062 to 7020032 (0%)

kernel-image-bzimage contains /boot/bzImage-4.12.16-yocto-standard but not
the /boot/bzImage symlink:

$ cat
buildhistory/packages/qemux86-poky-linux/linux-yocto/kernel-image-bzimage/files-in-package.txt
drwxr-xr-x root       root               60 ./boot
-rw-r--r-- root       root          7020032
./boot/bzImage-4.12.16-yocto-standard

Ross

[-- Attachment #2: Type: text/html, Size: 1936 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v9] kernel: Add support for multiple kernel packages
  2017-12-13 12:31                 ` Burton, Ross
@ 2017-12-13 19:39                   ` Haris Okanovic
  0 siblings, 0 replies; 31+ messages in thread
From: Haris Okanovic @ 2017-12-13 19:39 UTC (permalink / raw)
  To: Burton, Ross
  Cc: Ashfield, Bruce (Wind River),
	josh.hernstrom, openembedded-core, Wold, Saul

I rebased the patch to latest master (openembedded-core commit cf5c44ac) 
and still can't reproduce what you're seeing. I can see a /boot/bzImage 
symlink in both buildHistory [1] and the IPK [2].

Are you using the same source? It seems like your kernel version is 
4.12.16 but linux-yocto is at 4.12.14 in master.

Could you send me the output of `bitbake -e virtual/kernel`? The only 
case where /boot/bzImage should be missing is when 
"${KERNEL_PACKAGE_NAME}" != "kernel". Search for an `ln -sf ...` call in 
kernel_do_install() to see the logic.

[1]
> $ cat buildhistory/packages/qemux86-oe-linux/linux-yocto/kernel-image-bzimage/files-in-package.txt 
> drwxr-xr-x root       root             4096 ./boot
> -rw-r--r-- root       root          7016320 ./boot/bzImage-4.12.14-yocto-standard
> lrwxrwxrwx root       root               30 ./boot/bzImage -> bzImage-4.12.14-yocto-standard

[2]
> $ tar -tvf data.tar.gz 
> drwxrwxrwx root/root         0 2017-12-13 13:34 ./
> drwxr-xr-x root/root         0 2017-12-13 13:34 ./boot/
> lrwxrwxrwx root/root         0 2017-12-13 13:34 ./boot/bzImage -> bzImage-4.12.14-yocto-standard
> -rw-r--r-- root/root   7016320 2017-12-13 13:33 ./boot/bzImage-4.12.14-yocto-standard

-- Haris


On 12/13/2017 06:31 AM, Burton, Ross wrote:
> On 12 December 2017 at 22:19, Haris Okanovic <haris.okanovic@ni.com 
> <mailto:haris.okanovic@ni.com>> wrote:
> 
>     I can see a reference to "/boot/bzImage" in both buildhistory and
>     tmp-glibc/work/.../pkgdata [1] after running a clean rebuild of
>     virtual/kernel [2].
> 
>     [1] file paths:
> 
>     "buildhistory/packages/qemux86-oe-linux/linux-yocto/kernel-image-bzimage/files-in-package.txt"
> 
>     "tmp-glibc/work/qemux86-oe-linux/linux-yocto/4.12.12+gitAUTOINC+eda4d18ce4_16de014967-r0/pkgdata/runtime/kernel-image-bzimage"
> 
>     [2] clean rebuild command:
>       bitbake -c cleanall virtual/kernel
>       bitbake virtual/kernel
> 
>     Which file are you diffing? Could you share the full path?
> 
> 
> If I build a qemux86 virtual/kernel without and with this patch and then 
> run buildhistory-diff:
> 
> packages/qemux86-poky-linux/linux-yocto/kernel-image-bzimage: FILELIST: 
> removed "/boot/bzImage"
> packages/qemux86-poky-linux/linux-yocto/kernel-image-bzimage: PKGSIZE 
> changed from 7020062 to 7020032 (0%)
> 
> kernel-image-bzimage contains /boot/bzImage-4.12.16-yocto-standard but 
> not the /boot/bzImage symlink:
> 
> $ cat 
> buildhistory/packages/qemux86-poky-linux/linux-yocto/kernel-image-bzimage/files-in-package.txt
> drwxr-xr-x root       root               60 ./boot
> -rw-r--r-- root       root          7020032 
> ./boot/bzImage-4.12.16-yocto-standard
> 
> Ross


^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2017-12-13 19:40 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-05 17:33 [PATCH v4] kernel: Add support for multiple kernel packages Haris Okanovic
2017-07-17 20:31 ` Wold, Saul
2017-07-18 13:34   ` Haris Okanovic
2017-07-19 15:56     ` Wold, Saul
2017-07-27 18:01       ` Rees, Kevron
2017-08-03 16:18         ` Ovidiu-Adrian Vancea
2017-08-08 15:27           ` Haris Okanovic
2017-08-08 15:27         ` Haris Okanovic
2017-08-08 15:26       ` Haris Okanovic
2017-08-08 15:34       ` [PATCH v5] " Haris Okanovic
2017-08-14 21:29       ` [PATCH v6] " Haris Okanovic
2017-08-16 16:00         ` Wold, Saul
2017-08-17 21:13           ` Haris Okanovic
2017-08-17 21:14       ` [PATCH v7] " Haris Okanovic
2017-09-01 18:09         ` Otavio Salvador
2017-10-19 19:19       ` [PATCH v8] " Haris Okanovic
2017-10-23 21:38         ` Saul Wold
2017-10-25 23:47           ` Haris Okanovic
2017-10-25  8:00         ` Bruce Ashfield
2017-10-25 23:49           ` Haris Okanovic
2017-11-07 18:40       ` [PATCH v9] " Haris Okanovic
2017-11-08 22:20         ` Wold, Saul
2017-11-10 16:16           ` Bruce Ashfield
2017-11-10 21:51           ` Haris Okanovic
2017-11-10 22:00             ` Wold, Saul
2017-11-13 19:16               ` Haris Okanovic
2017-11-13 19:23                 ` Otavio Salvador
2017-12-04 16:13             ` Burton, Ross
2017-12-12 22:19               ` Haris Okanovic
2017-12-13 12:31                 ` Burton, Ross
2017-12-13 19:39                   ` Haris Okanovic

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.