Hi Adrian, This is a very nice improvement for those who build initramfs.
Thanks. Jose Adrian Freihofer via lists.openembedded.org <adrian.freihofer= [email protected]> escreveu (domingo, 22/02/2026 à(s) 12:09): > From: Adrian Freihofer <[email protected]> > > Previously, the kernel recipe depended on the initramfs image even when > INITRAMFS_IMAGE_BUNDLE was not enabled. This caused the kernel to be > rebuilt whenever the initramfs image changed, regardless of whether the > kernel actually included the initramfs. > > The problematic chain was: > linux:do_deploy -> > linux:do_bundle_initramfs -> > image-initramfs:do_image_complete > > The original intent (acc. to the comment) was to ensure the initramfs > image was available for tools like wic. However, apart from bundling the > initramfs in the kernel, there is probably no reason why the kernel > should depend on the initramfs. And it is therefore simply wrong if it > does so anyway. Thus, use cases that may be broken by these change are > based on a bug, not a feature. This needs to be fixed by adding a > dependency on the initramfs in the right place, not in the kernel where > this destroys the kernel's sstate-caching. > > Signed-off-by: Adrian Freihofer <[email protected]> > --- > meta/classes-recipe/kernel.bbclass | 77 ++++++++++++++---------------- > 1 file changed, 35 insertions(+), 42 deletions(-) > > diff --git a/meta/classes-recipe/kernel.bbclass > b/meta/classes-recipe/kernel.bbclass > index f989b31c47..7a5ccb585a 100644 > --- a/meta/classes-recipe/kernel.bbclass > +++ b/meta/classes-recipe/kernel.bbclass > @@ -149,16 +149,13 @@ set -e > """ % (type, type, type)) > > > - image = d.getVar('INITRAMFS_IMAGE') > - # If the INTIRAMFS_IMAGE is set but the INITRAMFS_IMAGE_BUNDLE is set > to 0, > - # the do_bundle_initramfs does nothing, but the INITRAMFS_IMAGE is > built > - # standalone for use by wic and other tools. > - if image: > + if d.getVar('INITRAMFS_IMAGE') and > bb.utils.to_boolean(d.getVar('INITRAMFS_IMAGE_BUNDLE')): > if d.getVar('INITRAMFS_MULTICONFIG'): > d.appendVarFlag('do_bundle_initramfs', 'mcdepends', ' > mc:${BB_CURRENT_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_bundle_initramfs', 'do_deploy', > 'do_install', d) > bb.build.addtask('do_transform_bundled_initramfs', 'do_deploy', > 'do_bundle_initramfs', d) > > # NOTE: setting INITRAMFS_TASK is for backward compatibility > @@ -305,39 +302,37 @@ copy_initramfs() { > } > > do_bundle_initramfs () { > - if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = > x1 ]; then > - echo "Creating a kernel image with a bundled initramfs..." > - copy_initramfs > - # Backing up kernel image relies on its type(regular file > or symbolic link) > - tmp_path="" > - for imageType in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do > - if [ -h ${KERNEL_OUTPUT_DIR}/$imageType ] ; then > - linkpath=`readlink -n > ${KERNEL_OUTPUT_DIR}/$imageType` > - realpath=`readlink -fn > ${KERNEL_OUTPUT_DIR}/$imageType` > - mv -f $realpath $realpath.bak > - tmp_path=$tmp_path" > "$imageType"#"$linkpath"#"$realpath > - elif [ -f ${KERNEL_OUTPUT_DIR}/$imageType ]; then > - mv -f ${KERNEL_OUTPUT_DIR}/$imageType > ${KERNEL_OUTPUT_DIR}/$imageType.bak > - tmp_path=$tmp_path" "$imageType"##" > - fi > - done > - > > use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio > - kernel_do_compile > - # Restoring kernel image > - for tp in $tmp_path ; do > - imageType=`echo $tp|cut -d "#" -f 1` > - linkpath=`echo $tp|cut -d "#" -f 2` > - realpath=`echo $tp|cut -d "#" -f 3` > - if [ -n "$realpath" ]; then > - mv -f $realpath $realpath.initramfs > - mv -f $realpath.bak $realpath > - ln -sf $linkpath.initramfs > ${B}/${KERNEL_OUTPUT_DIR}/$imageType.initramfs > - else > - mv -f ${KERNEL_OUTPUT_DIR}/$imageType > ${KERNEL_OUTPUT_DIR}/$imageType.initramfs > - mv -f ${KERNEL_OUTPUT_DIR}/$imageType.bak > ${KERNEL_OUTPUT_DIR}/$imageType > - fi > - done > - fi > + echo "Creating a kernel image with a bundled initramfs..." > + copy_initramfs > + # Backing up kernel image relies on its type(regular file or > symbolic link) > + tmp_path="" > + for imageType in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do > + if [ -h ${KERNEL_OUTPUT_DIR}/$imageType ] ; then > + linkpath=`readlink -n > ${KERNEL_OUTPUT_DIR}/$imageType` > + realpath=`readlink -fn > ${KERNEL_OUTPUT_DIR}/$imageType` > + mv -f $realpath $realpath.bak > + tmp_path=$tmp_path" > "$imageType"#"$linkpath"#"$realpath > + elif [ -f ${KERNEL_OUTPUT_DIR}/$imageType ]; then > + mv -f ${KERNEL_OUTPUT_DIR}/$imageType > ${KERNEL_OUTPUT_DIR}/$imageType.bak > + tmp_path=$tmp_path" "$imageType"##" > + fi > + done > + > > use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio > + kernel_do_compile > + # Restoring kernel image > + for tp in $tmp_path ; do > + imageType=`echo $tp|cut -d "#" -f 1` > + linkpath=`echo $tp|cut -d "#" -f 2` > + realpath=`echo $tp|cut -d "#" -f 3` > + if [ -n "$realpath" ]; then > + mv -f $realpath $realpath.initramfs > + mv -f $realpath.bak $realpath > + ln -sf $linkpath.initramfs > ${B}/${KERNEL_OUTPUT_DIR}/$imageType.initramfs > + else > + mv -f ${KERNEL_OUTPUT_DIR}/$imageType > ${KERNEL_OUTPUT_DIR}/$imageType.initramfs > + mv -f ${KERNEL_OUTPUT_DIR}/$imageType.bak > ${KERNEL_OUTPUT_DIR}/$imageType > + fi > + done > } > do_bundle_initramfs[dirs] = "${B}" > > @@ -357,8 +352,6 @@ python do_devshell:prepend () { > os.environ["LDFLAGS"] = '' > } > > -addtask bundle_initramfs after do_install before do_deploy > - > KERNEL_DEBUG_TIMESTAMPS ??= "0" > > kernel_do_compile() { > @@ -860,7 +853,7 @@ kernel_do_deploy() { > # ensure we get the right values for both > do_deploy[prefuncs] += "read_subpackage_metadata" > > -addtask deploy after do_populate_sysroot do_packagedata > +addtask deploy after do_install do_populate_sysroot do_packagedata > > EXPORT_FUNCTIONS do_deploy > > -- > 2.52.0 > > > > > -- Best regards, José Quaresma
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#231893): https://lists.openembedded.org/g/openembedded-core/message/231893 Mute This Topic: https://lists.openembedded.org/mt/117939109/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
