summaryrefslogtreecommitdiffstats
path: root/meta/classes/kernel.bbclass
diff options
context:
space:
mode:
authorAlejandro Hernandez Samaniego <alhe@linux.microsoft.com>2022-01-23 00:55:25 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-01-26 06:25:33 +0000
commit2d317b2685211f1b0d102705a63c0000df96f45f (patch)
treeeb55636f9555d5a2f3767220fec08799515bcf9b /meta/classes/kernel.bbclass
parent68bf897e54d81ea7264f48f960b8435fc6bf7815 (diff)
downloadopenembedded-core-2d317b2685211f1b0d102705a63c0000df96f45f.tar.gz
kernel.bbclass: Allow initramfs to be built from a separate multiconfig
There may be a case where we want to build an initramfs image that doesnt inherit the same DISTRO_FEATURES (or others) from the main image being built. For example we may want our initramfs not to inherit a certain conf or feature, say we want to use musl for a smaller footprint, but if we are using TCLIBC=glibc for our DISTRO (and inherently our main image), the initramfs image would inherit that conf and be forced to use glibc, growing in size as a side effect, currently avoiding this is not supported. Allow the kernel class to create a multiconfig dependency (mcdepends) vs depends for do_bundle_initramfs and define our INITRAMFS_IMAGE from a separate multiconfig via two new variables: INITRAMFS_MULTICONFIG and INITRAMFS_DEPLOY_DIR_IMAGE which define the multiconfig where the initramfs image should be coming from and its deploy directory respectively, these two keep a default definition which preserves current behavior (do_bundle_initramfs uses depends). Example usage: - Create and use multiconfig initramfscfg.conf and set TCLIBC=musl there, along with its TMPDIR. - Add the following to our DISTRO.conf: INITRAMFS_MULTICONFIG = "initramfscfg" and set INITRAMFS_DEPLOY_DIR_IMAGE to the DEPLOY_DIR_IMAGE of the initramfscfg multiconfig (hence our main kernel will be able to grab it from there and bundle it). This will result in our musl based initramfs bundled in our main kernel and our main image to be glibc based. Signed-off-by: Alejandro Enedino Hernandez Samaniego <alhe@linux.microsoft.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/kernel.bbclass')
-rw-r--r--meta/classes/kernel.bbclass13
1 files changed, 9 insertions, 4 deletions
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index 473e28be47..880ee61406 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -30,6 +30,8 @@ INITRAMFS_IMAGE ?= ""
INITRAMFS_IMAGE_NAME ?= "${@['${INITRAMFS_IMAGE}-${MACHINE}', ''][d.getVar('INITRAMFS_IMAGE') == '']}"
INITRAMFS_TASK ?= ""
INITRAMFS_IMAGE_BUNDLE ?= ""
+INITRAMFS_DEPLOY_DIR_IMAGE ?= "${DEPLOY_DIR_IMAGE}"
+INITRAMFS_MULTICONFIG ?= ""
# KERNEL_VERSION is extracted from source code. It is evaluated as
# None for the first parsing, since the code has not been fetched.
@@ -133,7 +135,10 @@ set -e
# the do_bundle_initramfs does nothing, but the INITRAMFS_IMAGE is built
# standalone for use by wic and other tools.
if image:
- d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete')
+ if d.getVar('INITRAMFS_MULTICONFIG'):
+ d.appendVarFlag('do_bundle_initramfs', 'mcdepends', ' mc::${INITRAMFS_MULTICONFIG}:${INITRAMFS_IMAGE}:do_image_complete')
+ else:
+ d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete')
if image and bb.utils.to_boolean(d.getVar('INITRAMFS_IMAGE_BUNDLE')):
bb.build.addtask('do_transform_bundled_initramfs', 'do_deploy', 'do_bundle_initramfs', d)
@@ -240,8 +245,8 @@ copy_initramfs() {
# Find and use the first initramfs image archive type we find
rm -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio
for img in cpio cpio.gz cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst; do
- if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img" ]; then
- cp ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img ${B}/usr/.
+ if [ -e "${INITRAMFS_DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img" ]; then
+ cp ${INITRAMFS_DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img ${B}/usr/.
case $img in
*gz)
echo "gzip decompressing image"
@@ -278,7 +283,7 @@ copy_initramfs() {
fi
done
# Verify that the above loop found a initramfs, fail otherwise
- [ -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio ] && echo "Finished copy of initramfs into ./usr" || die "Could not find any ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.cpio{.gz|.lz4|.lzo|.lzma|.xz|.zst) for bundling; INITRAMFS_IMAGE_NAME might be wrong."
+ [ -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio ] && echo "Finished copy of initramfs into ./usr" || die "Could not find any ${INITRAMFS_DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.cpio{.gz|.lz4|.lzo|.lzma|.xz|.zst) for bundling; INITRAMFS_IMAGE_NAME might be wrong."
}
do_bundle_initramfs () {