From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Tue, 16 Dec 2025 11:20:15 +0100 X-Sieve: CMU Sieve 2.4 Received: from mail-wm1-f62.google.com (mail-wm1-f62.google.com [209.85.128.62]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 5BGAKDTG026608 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 16 Dec 2025 11:20:13 +0100 Received: by mail-wm1-f62.google.com with SMTP id 5b1f17b1804b1-477cf25ceccsf46459385e9.0 for ; Tue, 16 Dec 2025 02:20:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1765880408; cv=pass; d=google.com; s=arc-20240605; b=dAcMdpeAIPJsgqBIa0XBRv9EkXQkQ/nUkPsylyAhRSS93LTNj9XqXq87Q0E+2pB2Rh TS5YrySaYWlZZs/4tqyBH5EFz1AclvPO9mG1EufaxR5bIFCSJbzRTZdjFYFBUC5ldxS3 IfG2/U7qEt2wq9v7mfoDS7uw3qO8QRvN9T651ttEr2XzVxo8IhGCnF/9rNkkTjBbAGJ1 Grhd6PXtrCPkW+mbuOIgBhfnmt8O73A1mhKgBhcXaxqp3ZARy5QeTTwhMwlceZgZ2Gs5 g5086IRG75RawqyaauMkQf6Y0bEF6ibKBoO4HRtQ7FEhvMhRniouTDGjA6ZUDGkL7W4n xooA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=ODNwW7rWAkEDqJpiXtguKvVuc5d17phX2M0Djq03IbI=; fh=sUKQjti6auUXxf1DjVt0Miguvq5sRsHQTgHjSutEgSo=; b=eoWAPwXHAZ8qzXUXI0xoRO/Y1eLAfl+ZbJk3m/TR7JmQeGyB0MWvy6LW32TcSGpAju IytFtCWr0S6Xd3f1SG5zEvKU6VgCmSkDI6gS5WicRObvlmZ25HcEFXDx0wh3uAfWu4HD Oqp8FMb0HayLZ6ROzNUTordst/yMjglYqqJZ9b5F/jGreDmsGe+Qm12P1QAu8imgmcTP rTbzKdaS6wsmC56tIsEvJ1YWr2JRNeQ2l9UrbwTqJ1iK+uYAj9bWlaQxmksEr12RXLQT svUmlYSegHuO7cughmYxg1AIRqabCHLHJOBbvUSEq1Bez0SjOEeH4jKN/B+x7J7Y5f+L x9lw==; darn=ilbers.de ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=b7dKyC58; spf=pass (google.com: domain of fm-1333420-20251216102004fe25b9a080000207d5-ba7tbo@rts-flowmailer.siemens.com designates 185.136.65.225 as permitted sender) smtp.mailfrom=fm-1333420-20251216102004fe25b9a080000207d5-Ba7TBO@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1765880408; x=1766485208; darn=ilbers.de; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ODNwW7rWAkEDqJpiXtguKvVuc5d17phX2M0Djq03IbI=; b=AAPpzrXk4xbqOSXBuUV5zmk+VaTIDQKm8lH5eVrB+Fz+4//tr7VZYjGsW/OFwRUQMR tc0O4SQI+tK3RDh2PQdZGkbyklcNEizDXzSMWysCoIcAgJLWmVhSLIb/OLdFnd7QKrR4 rUWBhItydXU2rnck9TEjOgL1S/oe1vZuv4TCSaZpTDufY+uEcLyuCbjiQhPSruXYCTm7 Zzn/+AvUUbJ3NYHl+tMM+wuJNRrVlTzy03hikk34GjSz07RRaYWPUm4t9iRpjeN5GEkO tM83O/ICMCem2mMLASyxHhmgrcmlG9qE3WYIrva0Obrs74qst1Q20X6O1QmafDWDk/Dw 6e2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765880408; x=1766485208; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-beenthere:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ODNwW7rWAkEDqJpiXtguKvVuc5d17phX2M0Djq03IbI=; b=iYfEma3t/E2QmlYYazy+4g5D2N6Y97OI2BLxTrwNf/MKudu18xn6PDuCOt9DLwZ1xm jziFX9o59sd08h++qF6/xdNYIPUXD7ZCOP+23y1qJV21gLJfMnHVUN+DR2qJACFcyod1 XGWDmtm01LCF4ggvXsliW7F5dxPjv3NIqF8udgOzWtOVupTR3hgoyGdaACEACfin4PxH EgoFy7Rt3S52F4T9PgNQA0ApoMYEWTGTfkdYkr/QJJ8dr+HuWIEdQMgq8CjU5V9IRMQ8 Co/yw0IPNxdv4utSTqjM1zFMLFmjtHjN2f/mzKH14Msc7kegqx4+shCekRsg5N4r8GXw hRIg== X-Forwarded-Encrypted: i=2; AJvYcCVy6x/OowBX+lo7M/VVXZAOgS4HDe5RInBf6+fsdGid14MkfiFoWEGVokRxHIKKHyboXlKe@ilbers.de X-Gm-Message-State: AOJu0Yyrh0bgiMGxBtafmD+12dS+dtYqKdz3SsABaUWyTfL0bbfZVbUo sali4ZOGnp58Aa6yv5kxbA1QcekRd39RhIBCGoGvpTtYRzhC+Yqa8ipB X-Google-Smtp-Source: AGHT+IH9x3N6eJEj1dceVAtEu6gACLWVJkBZkj0cb68vKBX2214rp+qb+uvKAjKOPPs8Efw/cAOvMA== X-Received: by 2002:a05:600c:4e56:b0:477:569c:34e9 with SMTP id 5b1f17b1804b1-47a8f906ddemr134221245e9.23.1765880407802; Tue, 16 Dec 2025 02:20:07 -0800 (PST) X-BeenThere: isar-users@googlegroups.com; h="AWVwgWbr8NaEnXkzN+YnKDB/U6V9ubzMiOTNjeIS9iUSAuUWMg==" Received: by 2002:a05:600c:19ca:b0:477:a036:8e80 with SMTP id 5b1f17b1804b1-47a8ea2a054ls22244515e9.0.-pod-prod-07-eu; Tue, 16 Dec 2025 02:20:04 -0800 (PST) X-Received: by 2002:a05:600c:3104:b0:477:fcb:2256 with SMTP id 5b1f17b1804b1-47a8f906dd3mr144985855e9.17.1765880404502; Tue, 16 Dec 2025 02:20:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1765880404; cv=none; d=google.com; s=arc-20240605; b=iZ9sNe2PU8RZ3nHk3YJ5EWWZG5IyXdalk82sTtdEfew+iDECtVdBf5ecMP7D8Vt1+O qu7GeyBnim7dP2Lp3eBqdLAKpa3kQYQHc4cmLeyNw7EHq37Z/+bNiLPBUPpFb3lv6/wT V5oy2Z0/ALdvhdPRiKAQoARlqQbJ5X0OaLRD8rNcr5whQAhBNMntF98b9z9vVYJpnS67 HlkqOQ6GhIO7kIeOk13zMH/w9NQ63xb6sbiqXETj6ckdmKhDg0AC84Q7GfMqkfxTd2TZ twHR+t51cQDDebruvNjIvrJ3G3M87TZOOgzMxK2uXlNcwsvQUTIZR+3q/wY1jijbLzOe Y0XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=feedback-id:content-transfer-encoding:mime-version:message-id:date :subject:cc:to:from:dkim-signature; bh=5O8kTry5Z0E50Jm77GxTRB5cyjMKgaL3I5RUYYDV1lg=; fh=dwnf3PiLoNuxEmlEQqfoWYSFcsr4isZMqOMz5uUNloE=; b=aMsKCjXf0am+5JbdaRHckFgkVb8uHhjDzWOC6kBxpipONnIXSLofFlLlM4ngRwLK8F lpMIqq+GDw84vyHDL4tV0APEnlgf1kEnvEqa218+scbLxTVKN8mKGr/gV0zBl/REN3xH 5APuJcmIEjcYGrR84WIyU5LKoKp3xMCBORJ/7pzeSa1fYEIv2hIXSuxW2+bd3SRlAp9M F430DuSz7ptxoklc3FLUivuYugF8KmSSc1r5OzvaNlvNfU8qYOnjT9l57KnXMNXEnvXH mjS/XjopzexLv45fAnmqx9ueyKn+HyxKARoh/PRiTb3JolCxqMNcUmbpZqkbBj3SyOOq OZKg==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=b7dKyC58; spf=pass (google.com: domain of fm-1333420-20251216102004fe25b9a080000207d5-ba7tbo@rts-flowmailer.siemens.com designates 185.136.65.225 as permitted sender) smtp.mailfrom=fm-1333420-20251216102004fe25b9a080000207d5-Ba7TBO@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from mta-65-225.siemens.flowmailer.net (mta-65-225.siemens.flowmailer.net. [185.136.65.225]) by gmr-mx.google.com with ESMTPS id ffacd0b85a97d-42fa8a69635si283921f8f.3.2025.12.16.02.20.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Dec 2025 02:20:04 -0800 (PST) Received-SPF: pass (google.com: domain of fm-1333420-20251216102004fe25b9a080000207d5-ba7tbo@rts-flowmailer.siemens.com designates 185.136.65.225 as permitted sender) client-ip=185.136.65.225; Received: by mta-65-225.siemens.flowmailer.net with ESMTPSA id 20251216102004fe25b9a080000207d5 for ; Tue, 16 Dec 2025 11:20:04 +0100 From: "'Rakesh Kumar' via isar-users" To: isar-users@googlegroups.com Cc: jan.kiszka@siemens.com, cedric.hombourger@siemens.com, Rakesh Kumar Subject: [PATCH] fix: preserve indentation in dracut module-setup.sh Date: Tue, 16 Dec 2025 15:49:36 +0530 Message-Id: <20251216101936.3259099-1-kumar.rakesh@siemens.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1333420:519-21489:flowmailer X-Original-Sender: kumar.rakesh@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=b7dKyC58; spf=pass (google.com: domain of fm-1333420-20251216102004fe25b9a080000207d5-ba7tbo@rts-flowmailer.siemens.com designates 185.136.65.225 as permitted sender) smtp.mailfrom=fm-1333420-20251216102004fe25b9a080000207d5-Ba7TBO@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com X-Original-From: Rakesh Kumar Reply-To: Rakesh Kumar Precedence: list Mailing-list: list isar-users@googlegroups.com; contact isar-users+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: isar-users@googlegroups.com X-Google-Group-Id: 914930254986 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-Spam-Status: No, score=-4.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,RCVD_IN_RP_CERTIFIED, RCVD_IN_RP_RNBL,RCVD_IN_RP_SAFE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-TUID: ohimO3Ler487 The marker replacement logic treated the inserted file content as plain text, which caused indentation to be lost in generated scripts (e.g. module-setup.sh). Update the replacement logic to detect the marker line=E2=80=99s indentation and apply the same indentation to all non-empty lines of the inserted content. This preserves the original formatting and avoids syntax and readability issues in the generated files. Signed-off-by: Rakesh Kumar --- doc/user_manual.md | 19 +++++++++++++--- meta/classes-recipe/dracut-module.bbclass | 27 +++++++++++++++++------ 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/doc/user_manual.md b/doc/user_manual.md index e7955c12..731e84f1 100644 --- a/doc/user_manual.md +++ b/doc/user_manual.md @@ -1763,9 +1763,22 @@ module in the initrd or as a dependency to other mod= ules. It defaults to `${PN}` without the prefix `dracut-`. - `DRACUT_MODULE_PATH` contains the path to the installed module. It is se= t to `${D}/usr/lib/dracut/modules.d/${DRACUT_MODULE_NO}${DRACUT_MODULE_NAME}= /` - -The `install()` function is added by storing the file `install.sh` in the -files directory of the dracut module. +- `DRACUT_CHECK_CONTENT_FILE_NAME` contents for check() function +- `DRACUT_DEPENDS_CONTENT_FILE_NAME` contents for depends() function +- `DRACUT_CMDLINE_CONTENT_FILE_NAME` contents for cmdline() function +- `DRACUT_INSTALL_CONTENT_FILE_NAME` contents for install() function +- `DRACUT_INSTALLKERNEL_CONTENT_FILE_NAME` contents for installkernel() fu= nction + +Hook functions such as check(), depends(), cmdline(), install(), and +installkernel() are provided by replacing placeholders in dracut module +module-setup.sh template with content from individual files, selected via +the corresponding `DRACUT__CONTENT_FILE_NAME` variables. + +Example: + +The `install()` function can be provided by placing a file (for example, +`install.sh`) in the dracut module=E2=80=99s files directory and assigning= it to +`DRACUT_INSTALL_CONTENT_FILE_NAME`. =20 Other files can by added to the module by coping them to the Module folder with: diff --git a/meta/classes-recipe/dracut-module.bbclass b/meta/classes-recip= e/dracut-module.bbclass index 364fb5b4..eb1e4fb6 100644 --- a/meta/classes-recipe/dracut-module.bbclass +++ b/meta/classes-recipe/dracut-module.bbclass @@ -37,15 +37,28 @@ def add_file_if_variable_is_set(d, variable_name, prefi= x): return '' =20 def replace_marker_with_file_content(template_file, content_file, marker): - with open(template_file, 'r') as template_fd: - tmpl_content =3D template_fd.read() + import re, bb =20 - with open(content_file, 'r') as content_fd: - content =3D content_fd.read() + tmpl =3D open(template_file).read() + content =3D open(content_file).read().rstrip('\n') =20 - new_tpml_content =3D tmpl_content.replace(marker, content) - with open(template_file, 'w') as tmpl_fd: - tmpl_fd.write(new_tpml_content) + # locate marker and its indentation + m =3D re.search(rf'^(?P\s*){re.escape(marker)}\s*$', tmpl, re.= MULTILINE) + if not m: + bb.fatal(f"Marker '{marker}' not found in {template_file}") + + indent =3D m.group('indent') + + # indent all non-blank lines + indented =3D '\n'.join( + (indent + line) if line.strip() else '' + for line in content.splitlines() + ) + + # replace the exact marker line + new_tmpl =3D tmpl[:m.start()] + indented + tmpl[m.end():] + + open(template_file, 'w').write(new_tmpl) =20 SRC_URI:append =3D " ${@ add_file_if_variable_is_set(d, 'DRACUT_CHECK_CONT= ENT_FILE_NAME', 'file://')} \ ${@ add_file_if_variable_is_set(d, 'DRACUT_DEPENDS_CONTENT_FIL= E_NAME', 'file://')} \ --=20 2.39.5 --=20 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 e= mail to isar-users+unsubscribe@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/isar-users/= 20251216101936.3259099-1-kumar.rakesh%40siemens.com.