public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: "'Jan Kiszka' via isar-users" <isar-users@googlegroups.com>
To: Quirin Gylstorff <Quirin.Gylstorff@siemens.com>,
	isar-users@googlegroups.com, felix.moessbauer@siemens.com,
	cedric.hombourger@siemens.com
Subject: Re: [PATCH v6 08/13] Add class to generate custom dracut initramfs
Date: Wed, 5 Nov 2025 11:16:59 +0100	[thread overview]
Message-ID: <3dfdcce8-b841-4b0f-b50b-431ecf7694af@siemens.com> (raw)
In-Reply-To: <20251105093710.19582-9-Quirin.Gylstorff@siemens.com>

On 05.11.25 10:29, Quirin Gylstorff wrote:
> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> 
> This class allows to customize a dracut initramfs by using
> configuration files add addition modules and drivers.
> 
> It is recommended to use the addition of modules and drivers
> sparely and prefer dracut configuration files.
> 
> This class has the option to add custom modules automatically to
> the initramfs if:
>  - The modules are provided by the ISAR build system
>  - The module name is part of the package name, valid names are
>    - dracut-<module-name>
>    - <module-name>-dracut
>    - <something>-dracut-<module-name>
> 
> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> ---
>  meta/classes/initrd-dracut.bbclass | 58 ++++++++++++++++++++++++++++++

Same here: classes-recipe/

Jan

>  1 file changed, 58 insertions(+)
>  create mode 100644 meta/classes/initrd-dracut.bbclass
> 
> diff --git a/meta/classes/initrd-dracut.bbclass b/meta/classes/initrd-dracut.bbclass
> new file mode 100644
> index 00000000..0602c364
> --- /dev/null
> +++ b/meta/classes/initrd-dracut.bbclass
> @@ -0,0 +1,58 @@
> +# This software is a part of ISAR.
> +# This class provides the necessary options to
> +# customize a dracut based initramfs.
> +#
> +# This class should not provide every dracut cmdline
> +# option possible. Use the dracut configuration files.
> +
> +INITRAMFS_GENERATOR_PKG = "dracut"
> +
> +# The preferred way to configure dracut is to
> +# provide dracut-config-<your-config> package which
> +# contains all necessary config options
> +DRACUT_CONFIG_PATH ??= ""
> +
> +# Variable to add additional kernel driver to the initrd
> +DRACUT_EXTRA_DRIVERS ??= ""
> +
> +# Variable to add additional dracut modules to the initrd
> +DRACUT_EXTRA_MODULES ??= ""
> +
> +# This option does not work with some of the dracut modules in Debian
> +# as there is no standardized mapping between module name and package name
> +DRACUT_EXTRACT_MODULES_FROM_PACKAGE_NAMES ??= "False"
> +
> +def extend_dracut_cmdline(d):
> +    config_path = d.getVar('DRACUT_CONFIG_PATH') or ''
> +    extra_drivers = d.getVar('DRACUT_EXTRA_DRIVERS') or ''
> +    extra_modules = d.getVar('DRACUT_EXTRA_MODULES') or ''
> +    enable_module_extraction = bb.utils.to_boolean(d.getVar('DRACUT_EXTRACT_MODULES_FROM_PACKAGE_NAMES'))
> +    pkg_list = d.getVar('INITRAMFS_INSTALL') or ''
> +
> +    cmdline = []
> +    modules_from_pkg_names = []
> +    if enable_module_extraction:
> +        for pkg in pkg_list.split():
> +            # Skip dracut-config-* packages
> +            if pkg.startswith('dracut-config-'):
> +                continue
> +            elif pkg.startswith('dracut-'):
> +                modules_from_pkg_names.append(pkg[7:])
> +            elif pkg.endswith('-dracut'):
> +                modules_from_pkg_names.append(pkg[:-7])
> +            elif '-dracut-' in pkg:
> +                _, module_name = pkg.split('-dracut-', 1)
> +                modules_from_pkg_names.append(module_name)
> +        extra_modules = extra_modules + ' ' +' '.join(modules_from_pkg_names)
> +
> +    if config_path:
> +        cmdline.append(f"--conf {config_path}")
> +    if extra_drivers:
> +        cmdline.append(f"--add-drivers {extra_drivers}")
> +    if extra_modules:
> +        cmdline.append(f"--add {extra_modules}")
> +    return ' '.join(cmdline)
> +
> +ROOTFS_INITRAMFS_GENERATOR_CMDLINE:append = " ${@ extend_dracut_cmdline(d)}"
> +
> +inherit initramfs


-- 
Siemens AG, Foundational Technologies
Linux Expert Center

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/3dfdcce8-b841-4b0f-b50b-431ecf7694af%40siemens.com.

  reply	other threads:[~2025-11-05 10:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-05  9:29 [PATCH v6 00/13] Add support for dracut 'Quirin Gylstorff' via isar-users
2025-11-05  9:29 ` [PATCH v6 01/13] Add dracut to custom kernel builds 'Quirin Gylstorff' via isar-users
2025-11-05  9:29 ` [PATCH v6 02/13] rootfs: Allow to overwrite the initramfs generation cmds 'Quirin Gylstorff' via isar-users
2025-11-05  9:29 ` [PATCH v6 03/13] rootfs: Add isar-work directory to rootfs mounts 'Quirin Gylstorff' via isar-users
2025-11-05  9:29 ` [PATCH v6 04/13] rootfs: Copy the newly created initrd.img to the work directory 'Quirin Gylstorff' via isar-users
2025-11-05  9:29 ` [PATCH v6 05/13] rootfs: Add dracut to initramfs generator 'Quirin Gylstorff' via isar-users
2025-11-05  9:29 ` [PATCH v6 06/13] rootfs: exit immediately if INITRAMFS_GENERATOR_CMD fails 'Quirin Gylstorff' via isar-users
2025-11-05  9:29 ` [PATCH v6 07/13] initramfs: allow to set the generator command 'Quirin Gylstorff' via isar-users
2025-11-05  9:29 ` [PATCH v6 08/13] Add class to generate custom dracut initramfs 'Quirin Gylstorff' via isar-users
2025-11-05 10:16   ` 'Jan Kiszka' via isar-users [this message]
2025-11-05  9:29 ` [PATCH v6 09/13] rootfs: add flag to use dracut if it is not part of the package list 'Quirin Gylstorff' via isar-users
2025-11-05  9:29 ` [PATCH v6 10/13] Add example dracut initramfs 'Quirin Gylstorff' via isar-users
2025-11-05  9:29 ` [PATCH v6 11/13] Add dracut module helper 'Quirin Gylstorff' via isar-users
2025-11-05 10:15   ` 'Jan Kiszka' via isar-users
2025-11-05  9:29 ` [PATCH v6 12/13] Use lighttpd as a example how to add a dracut module 'Quirin Gylstorff' via isar-users
2025-11-05  9:29 ` [PATCH v6 13/13] user_manual: Add dracut for initramfs generation 'Quirin Gylstorff' via isar-users

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3dfdcce8-b841-4b0f-b50b-431ecf7694af@siemens.com \
    --to=isar-users@googlegroups.com \
    --cc=Quirin.Gylstorff@siemens.com \
    --cc=cedric.hombourger@siemens.com \
    --cc=felix.moessbauer@siemens.com \
    --cc=jan.kiszka@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox