| Message ID | 20251105072630.37142-1-christoph.steiger@siemens.com |
|---|---|
| State | Accepted, archived |
| Headers | show |
| Series | [v3,1/1] rootfs: rework no-generate-initrd rootfs feature | expand |
Am 05.11.25 um 08:26 schrieb 'Christoph Steiger' via isar-users: > Instead of using a negative feature replace it with a positive one: > generate-initrd. It can be confusing for the user why a initrd is > generated even though no additional rootfs features are enabled. > > To keep default behavior the same add generate-initrd to the default > rootfs features, unless INITRD_IMAGE is provided. > > Signed-off-by: Christoph Steiger <christoph.steiger@siemens.com> > --- > > Changes in v3: > - enable generate-initrd also when there are already other rootfs > features > > Changes in v2: > - move initialisation of INITRD_IMAGE to rootfs > > RECIPE-API-CHANGELOG.md | 14 ++++++++++++++ > meta/classes/image.bbclass | 3 --- > meta/classes/rootfs.bbclass | 10 ++++++---- > .../sbuild-chroot/sbuild-chroot.inc | 2 +- > 4 files changed, 21 insertions(+), 8 deletions(-) > > diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md > index 1826667a..1a5eba31 100644 > --- a/RECIPE-API-CHANGELOG.md > +++ b/RECIPE-API-CHANGELOG.md > @@ -797,3 +797,17 @@ root file modifications) are required. > A new class called `opensbi` has been introduced that shall help writing > shorter recipes for custom OpenSBI builds. Usage examples can be found in > `meta-isar/recipes/bsp/opensbi`. > + > +### Rework `no-generate-initrd` rootfs feature > + > +This negative feature is being replaced with a positive one: > +`generate-initrd`. The default behavior remains unchanged, as `generate-initrd` > +is now a default rootfs feature. Disabling initrd creation can be done in the I stumbled over this a while ago and was suprised because I didnt see a the change to "is now a default rootfs feature" announced anywhere. Maybe it could be included in this Changelog entry. > +following way: > +``` > +ROOTFS_FEATURE:remove = "generate-initrd" This is definitely easier to understand. Thx. regards, Andreas > +``` > +instead of > +``` > +ROOTFS_FEATURE += "no-generate-initrd" > +``` > diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass > index 441ea936..b58711d0 100644 > --- a/meta/classes/image.bbclass > +++ b/meta/classes/image.bbclass > @@ -23,7 +23,6 @@ IMAGE_FULLNAME = "${PN}-${DISTRO}-${MACHINE}" > > # These variables are used by wic and start_vm > KERNEL_IMAGE ?= "${IMAGE_FULLNAME}-${KERNEL_FILE}" > -INITRD_IMAGE ?= "" > INITRD_DEPLOY_FILE = "${@ d.getVar('INITRD_IMAGE') or '${IMAGE_FULLNAME}-initrd.img'}" > > # This defines the deployed dtbs for reuse by imagers > @@ -67,8 +66,6 @@ inherit essential > > ROOTFSDIR = "${IMAGE_ROOTFS}" > ROOTFS_FEATURES += "clean-package-cache clean-pycache generate-manifest export-dpkg-status clean-log-files clean-debconf-cache" > -# when using a custom initrd, do not generate one as part of the image rootfs > -ROOTFS_FEATURES += "${@ '' if d.getVar('INITRD_IMAGE') == '' else 'no-generate-initrd'}" > ROOTFS_PACKAGES += "${IMAGE_PREINSTALL} ${@isar_multiarch_packages('IMAGE_INSTALL', d)}" > ROOTFS_MANIFEST_DEPLOY_DIR ?= "${DEPLOY_DIR_IMAGE}" > ROOTFS_DPKGSTATUS_DEPLOY_DIR ?= "${DEPLOY_DIR_IMAGE}" > diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass > index 2fef3120..32d49146 100644 > --- a/meta/classes/rootfs.bbclass > +++ b/meta/classes/rootfs.bbclass > @@ -8,14 +8,16 @@ ROOTFS_DISTRO ?= "${DISTRO}" > ROOTFS_PACKAGES ?= "" > ROOTFS_BASE_DISTRO ?= "${BASE_DISTRO}" > > +INITRD_IMAGE ?= "" > + > # Features of the rootfs creation: > # available features are: > # 'clean-package-cache' - delete package cache from rootfs > # 'generate-manifest' - generate a package manifest of the rootfs into ${ROOTFS_MANIFEST_DEPLOY_DIR} > # 'export-dpkg-status' - exports /var/lib/dpkg/status file to ${ROOTFS_DPKGSTATUS_DEPLOY_DIR} > # 'clean-log-files' - delete log files that are not owned by packages > -# 'no-generate-initrd' - do not generate debian default initrd > -ROOTFS_FEATURES ?= "" > +# 'generate-initrd' - generate debian default initrd > +ROOTFS_FEATURES += "${@ 'generate-initrd' if d.getVar('INITRD_IMAGE') == '' else ''}" > > ROOTFS_APT_ARGS="install --yes -o Debug::pkgProblemResolver=yes" > > @@ -349,7 +351,7 @@ rootfs_restore_initrd_tooling() { > EOSUDO > } > > -ROOTFS_INSTALL_COMMAND += "${@bb.utils.contains('ROOTFS_FEATURES', 'no-generate-initrd', 'rootfs_clear_initrd_symlinks', '', d)}" > +ROOTFS_INSTALL_COMMAND += "${@bb.utils.contains('ROOTFS_FEATURES', 'generate-initrd', '', 'rootfs_clear_initrd_symlinks', d)}" > rootfs_clear_initrd_symlinks() { > sudo rm -f ${ROOTFSDIR}/initrd.img > sudo rm -f ${ROOTFSDIR}/initrd.img.old > @@ -594,7 +596,7 @@ rootfs_generate_initramfs() { > } > > python() { > - if 'no-generate-initrd' not in d.getVar('ROOTFS_FEATURES', True).split(): > + if 'generate-initrd' in d.getVar('ROOTFS_FEATURES', True).split(): > bb.build.addtask('do_generate_initramfs', 'do_rootfs', 'do_rootfs_postprocess', d) > bb.build.addtask('do_generate_initramfs_setscene', None, None, d) > } > diff --git a/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc b/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc > index 479aa91d..61d37760 100644 > --- a/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc > +++ b/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc > @@ -55,7 +55,7 @@ SBUILD_CHROOT_PREINSTALL_COMMON = " \ > SBUILD_CHROOT_DIR = "${WORKDIR}/rootfs" > ROOTFSDIR = "${SBUILD_CHROOT_DIR}" > ROOTFS_PACKAGES = "${SBUILD_CHROOT_PREINSTALL}" > -ROOTFS_FEATURES += "no-generate-initrd" > +ROOTFS_FEATURES:remove = "generate-initrd" > > ROOTFS_INSTALL_COMMAND:remove = "rootfs_restore_initrd_tooling" >
Hi Andreas, > I stumbled over this a while ago and was suprised because I didnt see a > the change to "is now a default rootfs feature" announced anywhere. > Maybe it could be included in this Changelog entry. The default behavior remains completely unchanged (or at least that is the intention). The initrd was generated per default before, and the no-generate-intird feature was missing. Now the generate-initrd feature is enabled by default, and we generate the initrd as before. Regards, Christoph
Am 06.11.25 um 09:59 schrieb Christoph Steiger: > Hi Andreas, > >> I stumbled over this a while ago and was suprised because I didnt see a >> the change to "is now a default rootfs feature" announced anywhere. >> Maybe it could be included in this Changelog entry. > The default behavior remains completely unchanged (or at least that is > the intention). The initrd was generated per default before, and the > no-generate-intird feature was missing. Now the generate-initrd > feature is enabled by default, and we generate the initrd as before. I havn't looked into why, but since b0913306 (Delay creation of initrd until end of rootfs install), we had to actively disable the initrd creation for our images. Actually now I have had a look: We reused the initramfs class in another class, which diverted the initrd creation to another implementation. Moving the do_generate_initramfs() to the rootfs class then had the effect that we no longer overwrite it. If this is not an API relevant thing, never mind. regards, Andreas > > Regards, > Christoph >
Applied to next, thanks. Best regards, Zhihang On 11/5/25 08:26, 'Christoph Steiger' via isar-users wrote: > Instead of using a negative feature replace it with a positive one: > generate-initrd. It can be confusing for the user why a initrd is > generated even though no additional rootfs features are enabled. > > To keep default behavior the same add generate-initrd to the default > rootfs features, unless INITRD_IMAGE is provided. > > Signed-off-by: Christoph Steiger <christoph.steiger@siemens.com> > --- > > Changes in v3: > - enable generate-initrd also when there are already other rootfs > features > > Changes in v2: > - move initialisation of INITRD_IMAGE to rootfs > > RECIPE-API-CHANGELOG.md | 14 ++++++++++++++ > meta/classes/image.bbclass | 3 --- > meta/classes/rootfs.bbclass | 10 ++++++---- > .../sbuild-chroot/sbuild-chroot.inc | 2 +- > 4 files changed, 21 insertions(+), 8 deletions(-) > > diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md > index 1826667a..1a5eba31 100644 > --- a/RECIPE-API-CHANGELOG.md > +++ b/RECIPE-API-CHANGELOG.md > @@ -797,3 +797,17 @@ root file modifications) are required. > A new class called `opensbi` has been introduced that shall help writing > shorter recipes for custom OpenSBI builds. Usage examples can be found in > `meta-isar/recipes/bsp/opensbi`. > + > +### Rework `no-generate-initrd` rootfs feature > + > +This negative feature is being replaced with a positive one: > +`generate-initrd`. The default behavior remains unchanged, as `generate-initrd` > +is now a default rootfs feature. Disabling initrd creation can be done in the > +following way: > +``` > +ROOTFS_FEATURE:remove = "generate-initrd" > +``` > +instead of > +``` > +ROOTFS_FEATURE += "no-generate-initrd" > +``` > diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass > index 441ea936..b58711d0 100644 > --- a/meta/classes/image.bbclass > +++ b/meta/classes/image.bbclass > @@ -23,7 +23,6 @@ IMAGE_FULLNAME = "${PN}-${DISTRO}-${MACHINE}" > > # These variables are used by wic and start_vm > KERNEL_IMAGE ?= "${IMAGE_FULLNAME}-${KERNEL_FILE}" > -INITRD_IMAGE ?= "" > INITRD_DEPLOY_FILE = "${@ d.getVar('INITRD_IMAGE') or '${IMAGE_FULLNAME}-initrd.img'}" > > # This defines the deployed dtbs for reuse by imagers > @@ -67,8 +66,6 @@ inherit essential > > ROOTFSDIR = "${IMAGE_ROOTFS}" > ROOTFS_FEATURES += "clean-package-cache clean-pycache generate-manifest export-dpkg-status clean-log-files clean-debconf-cache" > -# when using a custom initrd, do not generate one as part of the image rootfs > -ROOTFS_FEATURES += "${@ '' if d.getVar('INITRD_IMAGE') == '' else 'no-generate-initrd'}" > ROOTFS_PACKAGES += "${IMAGE_PREINSTALL} ${@isar_multiarch_packages('IMAGE_INSTALL', d)}" > ROOTFS_MANIFEST_DEPLOY_DIR ?= "${DEPLOY_DIR_IMAGE}" > ROOTFS_DPKGSTATUS_DEPLOY_DIR ?= "${DEPLOY_DIR_IMAGE}" > diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass > index 2fef3120..32d49146 100644 > --- a/meta/classes/rootfs.bbclass > +++ b/meta/classes/rootfs.bbclass > @@ -8,14 +8,16 @@ ROOTFS_DISTRO ?= "${DISTRO}" > ROOTFS_PACKAGES ?= "" > ROOTFS_BASE_DISTRO ?= "${BASE_DISTRO}" > > +INITRD_IMAGE ?= "" > + > # Features of the rootfs creation: > # available features are: > # 'clean-package-cache' - delete package cache from rootfs > # 'generate-manifest' - generate a package manifest of the rootfs into ${ROOTFS_MANIFEST_DEPLOY_DIR} > # 'export-dpkg-status' - exports /var/lib/dpkg/status file to ${ROOTFS_DPKGSTATUS_DEPLOY_DIR} > # 'clean-log-files' - delete log files that are not owned by packages > -# 'no-generate-initrd' - do not generate debian default initrd > -ROOTFS_FEATURES ?= "" > +# 'generate-initrd' - generate debian default initrd > +ROOTFS_FEATURES += "${@ 'generate-initrd' if d.getVar('INITRD_IMAGE') == '' else ''}" > > ROOTFS_APT_ARGS="install --yes -o Debug::pkgProblemResolver=yes" > > @@ -349,7 +351,7 @@ rootfs_restore_initrd_tooling() { > EOSUDO > } > > -ROOTFS_INSTALL_COMMAND += "${@bb.utils.contains('ROOTFS_FEATURES', 'no-generate-initrd', 'rootfs_clear_initrd_symlinks', '', d)}" > +ROOTFS_INSTALL_COMMAND += "${@bb.utils.contains('ROOTFS_FEATURES', 'generate-initrd', '', 'rootfs_clear_initrd_symlinks', d)}" > rootfs_clear_initrd_symlinks() { > sudo rm -f ${ROOTFSDIR}/initrd.img > sudo rm -f ${ROOTFSDIR}/initrd.img.old > @@ -594,7 +596,7 @@ rootfs_generate_initramfs() { > } > > python() { > - if 'no-generate-initrd' not in d.getVar('ROOTFS_FEATURES', True).split(): > + if 'generate-initrd' in d.getVar('ROOTFS_FEATURES', True).split(): > bb.build.addtask('do_generate_initramfs', 'do_rootfs', 'do_rootfs_postprocess', d) > bb.build.addtask('do_generate_initramfs_setscene', None, None, d) > } > diff --git a/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc b/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc > index 479aa91d..61d37760 100644 > --- a/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc > +++ b/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc > @@ -55,7 +55,7 @@ SBUILD_CHROOT_PREINSTALL_COMMON = " \ > SBUILD_CHROOT_DIR = "${WORKDIR}/rootfs" > ROOTFSDIR = "${SBUILD_CHROOT_DIR}" > ROOTFS_PACKAGES = "${SBUILD_CHROOT_PREINSTALL}" > -ROOTFS_FEATURES += "no-generate-initrd" > +ROOTFS_FEATURES:remove = "generate-initrd" > > ROOTFS_INSTALL_COMMAND:remove = "rootfs_restore_initrd_tooling" >
diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md index 1826667a..1a5eba31 100644 --- a/RECIPE-API-CHANGELOG.md +++ b/RECIPE-API-CHANGELOG.md @@ -797,3 +797,17 @@ root file modifications) are required. A new class called `opensbi` has been introduced that shall help writing shorter recipes for custom OpenSBI builds. Usage examples can be found in `meta-isar/recipes/bsp/opensbi`. + +### Rework `no-generate-initrd` rootfs feature + +This negative feature is being replaced with a positive one: +`generate-initrd`. The default behavior remains unchanged, as `generate-initrd` +is now a default rootfs feature. Disabling initrd creation can be done in the +following way: +``` +ROOTFS_FEATURE:remove = "generate-initrd" +``` +instead of +``` +ROOTFS_FEATURE += "no-generate-initrd" +``` diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index 441ea936..b58711d0 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass @@ -23,7 +23,6 @@ IMAGE_FULLNAME = "${PN}-${DISTRO}-${MACHINE}" # These variables are used by wic and start_vm KERNEL_IMAGE ?= "${IMAGE_FULLNAME}-${KERNEL_FILE}" -INITRD_IMAGE ?= "" INITRD_DEPLOY_FILE = "${@ d.getVar('INITRD_IMAGE') or '${IMAGE_FULLNAME}-initrd.img'}" # This defines the deployed dtbs for reuse by imagers @@ -67,8 +66,6 @@ inherit essential ROOTFSDIR = "${IMAGE_ROOTFS}" ROOTFS_FEATURES += "clean-package-cache clean-pycache generate-manifest export-dpkg-status clean-log-files clean-debconf-cache" -# when using a custom initrd, do not generate one as part of the image rootfs -ROOTFS_FEATURES += "${@ '' if d.getVar('INITRD_IMAGE') == '' else 'no-generate-initrd'}" ROOTFS_PACKAGES += "${IMAGE_PREINSTALL} ${@isar_multiarch_packages('IMAGE_INSTALL', d)}" ROOTFS_MANIFEST_DEPLOY_DIR ?= "${DEPLOY_DIR_IMAGE}" ROOTFS_DPKGSTATUS_DEPLOY_DIR ?= "${DEPLOY_DIR_IMAGE}" diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass index 2fef3120..32d49146 100644 --- a/meta/classes/rootfs.bbclass +++ b/meta/classes/rootfs.bbclass @@ -8,14 +8,16 @@ ROOTFS_DISTRO ?= "${DISTRO}" ROOTFS_PACKAGES ?= "" ROOTFS_BASE_DISTRO ?= "${BASE_DISTRO}" +INITRD_IMAGE ?= "" + # Features of the rootfs creation: # available features are: # 'clean-package-cache' - delete package cache from rootfs # 'generate-manifest' - generate a package manifest of the rootfs into ${ROOTFS_MANIFEST_DEPLOY_DIR} # 'export-dpkg-status' - exports /var/lib/dpkg/status file to ${ROOTFS_DPKGSTATUS_DEPLOY_DIR} # 'clean-log-files' - delete log files that are not owned by packages -# 'no-generate-initrd' - do not generate debian default initrd -ROOTFS_FEATURES ?= "" +# 'generate-initrd' - generate debian default initrd +ROOTFS_FEATURES += "${@ 'generate-initrd' if d.getVar('INITRD_IMAGE') == '' else ''}" ROOTFS_APT_ARGS="install --yes -o Debug::pkgProblemResolver=yes" @@ -349,7 +351,7 @@ rootfs_restore_initrd_tooling() { EOSUDO } -ROOTFS_INSTALL_COMMAND += "${@bb.utils.contains('ROOTFS_FEATURES', 'no-generate-initrd', 'rootfs_clear_initrd_symlinks', '', d)}" +ROOTFS_INSTALL_COMMAND += "${@bb.utils.contains('ROOTFS_FEATURES', 'generate-initrd', '', 'rootfs_clear_initrd_symlinks', d)}" rootfs_clear_initrd_symlinks() { sudo rm -f ${ROOTFSDIR}/initrd.img sudo rm -f ${ROOTFSDIR}/initrd.img.old @@ -594,7 +596,7 @@ rootfs_generate_initramfs() { } python() { - if 'no-generate-initrd' not in d.getVar('ROOTFS_FEATURES', True).split(): + if 'generate-initrd' in d.getVar('ROOTFS_FEATURES', True).split(): bb.build.addtask('do_generate_initramfs', 'do_rootfs', 'do_rootfs_postprocess', d) bb.build.addtask('do_generate_initramfs_setscene', None, None, d) } diff --git a/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc b/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc index 479aa91d..61d37760 100644 --- a/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc +++ b/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc @@ -55,7 +55,7 @@ SBUILD_CHROOT_PREINSTALL_COMMON = " \ SBUILD_CHROOT_DIR = "${WORKDIR}/rootfs" ROOTFSDIR = "${SBUILD_CHROOT_DIR}" ROOTFS_PACKAGES = "${SBUILD_CHROOT_PREINSTALL}" -ROOTFS_FEATURES += "no-generate-initrd" +ROOTFS_FEATURES:remove = "generate-initrd" ROOTFS_INSTALL_COMMAND:remove = "rootfs_restore_initrd_tooling"
Instead of using a negative feature replace it with a positive one: generate-initrd. It can be confusing for the user why a initrd is generated even though no additional rootfs features are enabled. To keep default behavior the same add generate-initrd to the default rootfs features, unless INITRD_IMAGE is provided. Signed-off-by: Christoph Steiger <christoph.steiger@siemens.com> --- Changes in v3: - enable generate-initrd also when there are already other rootfs features Changes in v2: - move initialisation of INITRD_IMAGE to rootfs RECIPE-API-CHANGELOG.md | 14 ++++++++++++++ meta/classes/image.bbclass | 3 --- meta/classes/rootfs.bbclass | 10 ++++++---- .../sbuild-chroot/sbuild-chroot.inc | 2 +- 4 files changed, 21 insertions(+), 8 deletions(-)