public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: "'Quirin Gylstorff' via isar-users" <isar-users@googlegroups.com>
To: isar-users@googlegroups.com, jan.kiszka@siemens.com,
	felix.moessbauer@siemens.com, cedric.hombourger@siemens.com
Subject: [RFC PATCH v3 08/10] Add dracut module helper
Date: Mon,  6 Oct 2025 20:31:10 +0200	[thread overview]
Message-ID: <20251006183214.1593195-9-Quirin.Gylstorff@siemens.com> (raw)
In-Reply-To: <20251006183214.1593195-1-Quirin.Gylstorff@siemens.com>

From: Quirin Gylstorff <quirin.gylstorff@siemens.com>

This adds a helper similar to initramfs-hook to generate a dracut
module.

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
 .../dracut-module/dracut-module.inc           | 41 +++++++++++++++++++
 .../dracut-module/files/module-setup.sh.tmpl  | 20 +++++++++
 2 files changed, 61 insertions(+)
 create mode 100644 meta/recipes-initramfs/dracut-module/dracut-module.inc
 create mode 100644 meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl

diff --git a/meta/recipes-initramfs/dracut-module/dracut-module.inc b/meta/recipes-initramfs/dracut-module/dracut-module.inc
new file mode 100644
index 00000000..54071105
--- /dev/null
+++ b/meta/recipes-initramfs/dracut-module/dracut-module.inc
@@ -0,0 +1,41 @@
+#
+# Copyright (c) Siemens AG, 2025
+#
+# Authors:
+#  Quirin Gylstorff <quirin.gylstorff@siemens.com>
+#
+# SPDX-License-Identifier: MIT
+#
+
+inherit dpkg-raw
+
+FILESPATH:append := ":${FILE_DIRNAME}/files"
+
+DPKG_ARCH = "all"
+
+DRACUT_MODULE_SETUP = "module-setup.sh"
+SRC_URI += "file://${DRACUT_MODULE_SETUP}.tmpl"
+
+DRACUT_REQUIRED_BINARIES = ""
+DRACUT_MODULE_DEPENDENCIES = ""
+DRACUT_MODULE_NO ??= "50"
+DRACUT_MODULE_NAME ?= "${@ d.getVar('PN')[7:] if d.getVar('PN').startswith('dracut-') else d.getVAR('PN')}"
+
+TEMPLATE_FILES:append = " \
+    ${DRACUT_MODULE_SETUP}.tmpl \
+    "
+
+TEMPLATE_VARS:append = " \
+    DRACUT_REQUIRED_BINARIES \
+    DRACUT_MODULE_DEPENDENCIES \
+    "
+DEBIAN_DEPENDS = "dracut-core"
+DRACUT_MODULE_PATH = "${D}/usr/lib/dracut/modules.d/${DRACUT_MODULE_NO}${DRACUT_MODULE_NAME}/"
+do_install[cleandirs] += "${DRACUT_MODULE_PATH}"
+do_install:append() {
+    install -m 770 ${WORKDIR}/${DRACUT_MODULE_SETUP} ${DRACUT_MODULE_PATH}
+    if [ -f ${WORKDIR}/install.sh ]; then
+        cat ${WORKDIR}/install.sh >> ${DRACUT_MODULE_PATH}/${DRACUT_MODULE_SETUP}
+    fi
+}
+
diff --git a/meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl b/meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl
new file mode 100644
index 00000000..46477cf4
--- /dev/null
+++ b/meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# called by dracut
+check() {
+
+    # If the binary(s) requirements are not fulfilled the module can't be installed.
+    require_binaries \
+        ${DRACUT_REQUIRED_BINARIES} \
+        || return 1
+
+    return 0
+
+}
+# Module dependency requirements.
+depends() {
+    echo "${DRACUT_MODULE_DEPENDENCIES}"
+    return 0
+
+}
+
-- 
2.51.0

-- 
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/20251006183214.1593195-9-Quirin.Gylstorff%40siemens.com.

  parent reply	other threads:[~2025-10-06 18:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-06 18:31 [RFC PATCH v3 00/10] Add support for dracut 'Quirin Gylstorff' via isar-users
2025-10-06 18:31 ` [RFC PATCH v3 01/10] add dracut to custom kernel builds 'Quirin Gylstorff' via isar-users
2025-10-06 18:31 ` [RFC PATCH v3 02/10] rootfs: Allow to overwrite the initramfs generation cmds 'Quirin Gylstorff' via isar-users
2025-10-06 18:31 ` [RFC PATCH v3 03/10] rootfs Add dracut to initramfs generator 'Quirin Gylstorff' via isar-users
2025-10-06 18:31 ` [RFC PATCH v3 04/10] initramfs: allow to set the generator command 'Quirin Gylstorff' via isar-users
2025-10-06 18:31 ` [RFC PATCH v3 05/10] Add class to generate custom dracut initramfs 'Quirin Gylstorff' via isar-users
2025-10-09  5:22   ` 'cedric.hombourger@siemens.com' via isar-users
2025-10-09  6:52     ` 'Quirin Gylstorff' via isar-users
2025-10-09  6:21   ` 'cedric.hombourger@siemens.com' via isar-users
2025-10-09  6:53     ` 'Quirin Gylstorff' via isar-users
2025-10-06 18:31 ` [RFC PATCH v3 06/10] rootfs: add flag to use dracut if it is not part of the package list 'Quirin Gylstorff' via isar-users
2025-10-06 18:31 ` [RFC PATCH v3 07/10] Add example dracut initramfs 'Quirin Gylstorff' via isar-users
2025-10-06 18:31 ` 'Quirin Gylstorff' via isar-users [this message]
2025-10-06 18:31 ` [RFC PATCH v3 09/10] Use lighttpd as a example how to add a dracut module 'Quirin Gylstorff' via isar-users
2025-10-06 18:31 ` [RFC PATCH v3 10/10] 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=20251006183214.1593195-9-Quirin.Gylstorff@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