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:27:00 +0000
commitbedb3444e14693902f9f5eb089810a762f083460 (patch)
treec1d845c0bf2122c3b54a33de5d0f31373b81fece /meta/classes/kernel.bbclass
parentd2abfff682dce174c19fe2cce64ab9461790889e (diff)
downloadpoky-bedb3444e14693902f9f5eb089810a762f083460.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. (From OE-Core rev: 2d317b2685211f1b0d102705a63c0000df96f45f) 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 ?= ""
30INITRAMFS_IMAGE_NAME ?= "${@['${INITRAMFS_IMAGE}-${MACHINE}', ''][d.getVar('INITRAMFS_IMAGE') == '']}" 30INITRAMFS_IMAGE_NAME ?= "${@['${INITRAMFS_IMAGE}-${MACHINE}', ''][d.getVar('INITRAMFS_IMAGE') == '']}"
31INITRAMFS_TASK ?= "" 31INITRAMFS_TASK ?= ""
32INITRAMFS_IMAGE_BUNDLE ?= "" 32INITRAMFS_IMAGE_BUNDLE ?= ""
33INITRAMFS_DEPLOY_DIR_IMAGE ?= "${DEPLOY_DIR_IMAGE}"
34INITRAMFS_MULTICONFIG ?= ""
33 35
34# KERNEL_VERSION is extracted from source code. It is evaluated as 36# KERNEL_VERSION is extracted from source code. It is evaluated as
35# None for the first parsing, since the code has not been fetched. 37# None for the first parsing, since the code has not been fetched.
@@ -133,7 +135,10 @@ set -e
133 # the do_bundle_initramfs does nothing, but the INITRAMFS_IMAGE is built 135 # the do_bundle_initramfs does nothing, but the INITRAMFS_IMAGE is built
134 # standalone for use by wic and other tools. 136 # standalone for use by wic and other tools.
135 if image: 137 if image:
136 d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete') 138 if d.getVar('INITRAMFS_MULTICONFIG'):
139 d.appendVarFlag('do_bundle_initramfs', 'mcdepends', ' mc::${INITRAMFS_MULTICONFIG}:${INITRAMFS_IMAGE}:do_image_complete')
140 else:
141 d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete')
137 if image and bb.utils.to_boolean(d.getVar('INITRAMFS_IMAGE_BUNDLE')): 142 if image and bb.utils.to_boolean(d.getVar('INITRAMFS_IMAGE_BUNDLE')):
138 bb.build.addtask('do_transform_bundled_initramfs', 'do_deploy', 'do_bundle_initramfs', d) 143 bb.build.addtask('do_transform_bundled_initramfs', 'do_deploy', 'do_bundle_initramfs', d)
139 144
@@ -240,8 +245,8 @@ copy_initramfs() {
240 # Find and use the first initramfs image archive type we find 245 # Find and use the first initramfs image archive type we find
241 rm -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio 246 rm -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio
242 for img in cpio cpio.gz cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst; do 247 for img in cpio cpio.gz cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst; do
243 if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img" ]; then 248 if [ -e "${INITRAMFS_DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img" ]; then
244 cp ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img ${B}/usr/. 249 cp ${INITRAMFS_DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img ${B}/usr/.
245 case $img in 250 case $img in
246 *gz) 251 *gz)
247 echo "gzip decompressing image" 252 echo "gzip decompressing image"
@@ -278,7 +283,7 @@ copy_initramfs() {
278 fi 283 fi
279 done 284 done
280 # Verify that the above loop found a initramfs, fail otherwise 285 # Verify that the above loop found a initramfs, fail otherwise
281 [ -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." 286 [ -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."
282} 287}
283 288
284do_bundle_initramfs () { 289do_bundle_initramfs () {