From patchwork Mon Nov 11 20:50:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 3917 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Mon, 11 Nov 2024 21:50:40 +0100 X-Sieve: CMU Sieve 2.4 Received: from mail-pg1-f183.google.com (mail-pg1-f183.google.com [209.85.215.183]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 4ABKocnn014871 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 11 Nov 2024 21:50:39 +0100 Received: by mail-pg1-f183.google.com with SMTP id 41be03b00d2f7-7ea0069a8b0sf4107452a12.0 for ; Mon, 11 Nov 2024 12:50:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1731358229; cv=pass; d=google.com; s=arc-20240605; b=H8jxzHQxPDUK8DfJBRYmwI+4UqYXtLgIiB5P/Xr8g6J328T1UbSGU3ExsrbCgQZ5VB jR4JqESHsbwzs/3LNo1Gkd7JQYrH4O0G7cyHGtM9zfkc2Iz9weinlKFcKocr97495wG2 B/kW/Q5bnDJnOkp/mMg4u9lAhz+Lk1L90xCiizLIsB2yFWZn8h9QCvdr9p4ZsM87zO2S Ir/8Kax2njavrExFti/We3aVMb6+h/w1mxiOFGL0zq0LrdCaxPbqPn2RfLgfMRvn70uU 6VwL1T6lmeyx8uHBDN2hxiu5AT0WFL7DQB3rO2FOuNX4ehVM4lJvx2tOWAWpDVRAPHfq nCQg== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Pe3JLq9PvGcg7pLbo6vQXJXa68LjxYeiFSBHDOG0cqM=; fh=6erkcYCQp7GLnWFhJl4jLTJQPY7OJy44WtmvsgdA4b8=; b=Ge6mpuoG9IsRPr9HFyYDk5ONjK4nG/ansM/MNH/IorB9oyUrz083iu5ygsd0Bsyqfa 4ufFPaR0oF3bXgnZK2y7oFnNHd9yhsrEcH2qYPkjRvk+8oE5nXwiXys9+QZjMtzw4BNp nDLeeRm3rowyaNxxx5dARH8NDdTeaJ+aCNSZqgQaFH2+BBpuBgZHz+KGsBZNJt4FIe3h 6WGFCJUO1NIzPBwCoWqnwA/qGlK3iGCOiaTIJwBt8C+Ulbo90WyoxjedgpnH2VwwBq5B rRi9zWsmLJJMALIE5+EbQFSEaK7EF9ceq57dse5KrZutqe01ELl8oTgpXHXyC1Owgevr /Q3w==; darn=isar-build.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=CidoKSHo; spf=pass (google.com: domain of fm-294854-20241111205025b6a977e253c3078f27-p_jmbz@rts-flowmailer.siemens.com designates 185.136.65.225 as permitted sender) smtp.mailfrom=fm-294854-20241111205025b6a977e253c3078f27-P_jmbz@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=1731358229; x=1731963029; darn=isar-build.org; 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 :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Pe3JLq9PvGcg7pLbo6vQXJXa68LjxYeiFSBHDOG0cqM=; b=cOzsPDFFeGHDaQxBDR9TzaVr7uSZqKdkZVFJ2bwG1QG8tDH7ImRmhTTsoRcYgBvgFE rx6WM+9sHgTBM09qw+j/8eQdS5RCMh5RW2gIuq18dGSd+JFzbQ2Fox7RPs9XVjPcNCK2 H1RccxW4pULD8Xid/n7Psk28TNH2qxEwq5okz24W7kPp3PO+VoyALJSPVnBwHUZHmbbZ WA+1NyZXyroKJ27z5YU23FFGgcC0iy+5D9zXkLV9LBAitlqK5F1Xuj9lRlLid8GPSNLE 0ipP4gQ+RI7KdeBeBAz5TKRNE37zA4Vdxv5ntB0aeGCVg7x8wWftt8fAQI6h43yZuBkn H/7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731358229; x=1731963029; 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 :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-beenthere:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Pe3JLq9PvGcg7pLbo6vQXJXa68LjxYeiFSBHDOG0cqM=; b=gOOW9HmGJNAJ5K9BeaBSX6RTpvkCmaF0sRo8YDmxRVySR+cfz4PMKJRLXfR5hU39f/ JI9dJDhvd/A16WWzyb7njo5ktgWQcl2Xurzq0uYG5w4WjE32TS/d+yi/0E8rRkB8SzYV UwzXer9vFoZoAIKiYsQcuUdQBMf3+eZ4dvu8q/CIbWZJl1RDPx0ScQLTkGhuBU4+rRTn 4eIguISJJiAOsMu6kU11aC0OsZLqe//RYlK9pN+5OXw0LHuy0XRWdZSFOPLa7mB0I3xw h9RFgbcrKQNizM96E/UScGGo8rIY+1H5yjyg8nzzfffBVMvCNaT0RE8tS6HOIXuCdmzm sdQA== X-Forwarded-Encrypted: i=2; AJvYcCWhN4p5IQViQf6pxMiBSVt5bySrkz87c7JRrVphkoOTLZqjpo54vkbHLF11emLbh65XYadsitk=@isar-build.org X-Gm-Message-State: AOJu0YzSF0DU7Nnycfl0JGD8hQk943vip9CSSJV3VdNXPZmdkNW7Gxnn UD0p8FySU0ISnUEWe1VzdS3kFXbW+Yw8dBRBEeyxNxt3zotqZNPI X-Google-Smtp-Source: AGHT+IFzyiE2UiqS889gw3qXSX1Iyaf6aEEyUggS1Lu7wSBTl9bnNqjYT3po1Y2AlVAfSlswiYGsZg== X-Received: by 2002:a17:903:1c6:b0:20c:a19b:8ddd with SMTP id d9443c01a7336-211aba2a94amr1003715ad.51.1731358229382; Mon, 11 Nov 2024 12:50:29 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a17:90b:3841:b0:2e9:b4a5:8590 with SMTP id 98e67ed59e1d1-2e9b4a58be5ls750231a91.1.-pod-prod-01-us; Mon, 11 Nov 2024 12:50:28 -0800 (PST) X-Received: by 2002:a17:90b:3c01:b0:2e0:db81:4f79 with SMTP id 98e67ed59e1d1-2e9e4aa86bcmr463184a91.2.1731358227962; Mon, 11 Nov 2024 12:50:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731358227; cv=none; d=google.com; s=arc-20240605; b=cfo6rQr1qjaDO7B3naEDZx5NyrmLn6UA1w43HaCk9pRSwrtt59luuFBID+VgaHj8g8 TayBHLTTsyR57oUmN19WpPlCNScKEjQrE4vJdI7L3sj9gurQiHVLB8Rg3UmOPw2hlLB0 d8sfYuTGyW/pGXyIVuKXzch795DLkBIA6UuNiEmD+AsaQQf7lnlyr5wgBDgn0Wpx8Yqs sXjLF1b6f1MPtg6Fu8IKG2G8uCYLyMtRUeKczgiSZqp3jIyiBSTUoD0dMvuWpxtXkhKP m9fpatUzX2G3gEbTQIRDbyuQnjVHjy4ZgSCLT4KKyBUr06hArL0lhEHm4pFDIweJcA2C BEHA== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=5suEqm6pVSLa/ArbhlWF4UYRLfnkMjT7DxjtmPc4baQ=; fh=TWGwN84gUgHIe5O4CbyH9KISyeWwGbvUX7cnJPxVD70=; b=R8USPyIcq7jwNrqtMPJBSR+aWcPJmsQJia/20ci16xoTsn0N6Z5VUNjtc2CJ4xvHCV sK35GyP2pkPqWHC9R/UEsMxTxPzLf5lywXXv0gmCEK0L0XoL37WJYS0FUfXvI+67kLio OmWIN4KDTorZYR16DzlCssJlo6+eiMhJNWr1wEu/WyZ33gTGbPKtK3ZAC8qP8EkZNHI4 uc31B67o6P04uytKio3z605GRq7gXn246fi9cHqBB8+8Q95JFrlUoI5DYowoaraYzYSc WOkZ/h+s/MKU4lIoaogNpSmAFTYUKrvlglIeKopB8t328b7IQ3kCRPyHjQm4QgXwZAjr MEYQ==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=CidoKSHo; spf=pass (google.com: domain of fm-294854-20241111205025b6a977e253c3078f27-p_jmbz@rts-flowmailer.siemens.com designates 185.136.65.225 as permitted sender) smtp.mailfrom=fm-294854-20241111205025b6a977e253c3078f27-P_jmbz@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 98e67ed59e1d1-2e9e34ae273si28452a91.1.2024.11.11.12.50.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Nov 2024 12:50:27 -0800 (PST) Received-SPF: pass (google.com: domain of fm-294854-20241111205025b6a977e253c3078f27-p_jmbz@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 20241111205025b6a977e253c3078f27 for ; Mon, 11 Nov 2024 21:50:25 +0100 X-Patchwork-Original-From: "'Jan Kiszka' via isar-users" From: Jan Kiszka To: isar-users Cc: Quirin Gylstorff Subject: [PATCH 1/7] initramfs-hook: Add infrastructure to ease writing hooks Date: Mon, 11 Nov 2024 21:50:18 +0100 Message-ID: <934f188717e95b8c019736e4546d57e90a247327.1731358224.git.jan.kiszka@siemens.com> In-Reply-To: References: MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-294854:519-21489:flowmailer X-Original-Sender: jan.kiszka@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=CidoKSHo; spf=pass (google.com: domain of fm-294854-20241111205025b6a977e253c3078f27-p_jmbz@rts-flowmailer.siemens.com designates 185.136.65.225 as permitted sender) smtp.mailfrom=fm-294854-20241111205025b6a977e253c3078f27-P_jmbz@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com X-Original-From: Jan Kiszka Reply-To: Jan Kiszka 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_H3,RCVD_IN_MSPIKE_WL, 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= From: Jan Kiszka xxx Signed-off-by: Jan Kiszka --- .../initramfs-hook/files/hook-header.tmpl | 39 ++++++++++ .../initramfs-hook/files/script-header.tmpl | 26 +++++++ .../recipes-initramfs/initramfs-hook/hook.inc | 74 +++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 meta/recipes-initramfs/initramfs-hook/files/hook-header.tmpl create mode 100644 meta/recipes-initramfs/initramfs-hook/files/script-header.tmpl create mode 100644 meta/recipes-initramfs/initramfs-hook/hook.inc diff --git a/meta/recipes-initramfs/initramfs-hook/files/hook-header.tmpl b/meta/recipes-initramfs/initramfs-hook/files/hook-header.tmpl new file mode 100644 index 00000000..ee30d691 --- /dev/null +++ b/meta/recipes-initramfs/initramfs-hook/files/hook-header.tmpl @@ -0,0 +1,39 @@ +#!/bin/sh +# +# Copyright (c) Siemens AG, 2024 +# +# Authors: +# Jan Kiszka +# +# SPDX-License-Identifier: MIT +# + +set -e + +prereqs() +{ + echo "${HOOK_PREREQ}" +} + +case $1 in +prereqs) + prereqs + exit 0 + ;; +esac + +. /usr/share/initramfs-tools/hook-functions + +for module in ${HOOK_ADD_MODULES}; do + manual_add_modules $module +done + +for executable in ${HOOK_COPY_EXECS}; do + if exec_path=$(command -v $executable 2>/dev/null); then + copy_exec "$exec_path" + else + echo "(ERROR): Unable to copy $executable" >&2 + exit 1 + fi +done + diff --git a/meta/recipes-initramfs/initramfs-hook/files/script-header.tmpl b/meta/recipes-initramfs/initramfs-hook/files/script-header.tmpl new file mode 100644 index 00000000..faa1a644 --- /dev/null +++ b/meta/recipes-initramfs/initramfs-hook/files/script-header.tmpl @@ -0,0 +1,26 @@ +#!/bin/sh +# +# Copyright (c) Siemens AG, 2024 +# +# Authors: +# Jan Kiszka +# +# SPDX-License-Identifier: MIT +# + +set -e + +prereqs() +{ + echo "${SCRIPT_PREREQ}" +} + +case $1 in +prereqs) + prereqs + exit 0 + ;; +esac + +. /scripts/functions + diff --git a/meta/recipes-initramfs/initramfs-hook/hook.inc b/meta/recipes-initramfs/initramfs-hook/hook.inc new file mode 100644 index 00000000..5509c074 --- /dev/null +++ b/meta/recipes-initramfs/initramfs-hook/hook.inc @@ -0,0 +1,74 @@ +# +# Copyright (c) Siemens AG, 2024 +# +# Authors: +# Jan Kiszka +# +# SPDX-License-Identifier: MIT +# + +FILESPATH:append := ":${FILE_DIRNAME}/files" + +inherit dpkg-raw + +SRC_URI = " \ + file://hook-header.tmpl \ + file://script-header.tmpl" + +TEMPLATE_FILES = " \ + hook-header.tmpl \ + script-header.tmpl" + +TEMPLATE_VARS:append = " \ + HOOK_PREREQ \ + HOOK_ADD_MODULES \ + HOOK_COPY_EXECS \ + SCRIPT_PREREQ" + +HOOK_PREREQ ?= "" +HOOK_ADD_MODULES ?= "" +HOOK_COPY_EXECS ?= "" +SCRIPT_PREREQ ?= "" + +DEBIAN_DEPENDS = "initramfs-tools" + +def get_initramfs_hook_name(d): + name = d.getVar('BPN') + if name.startswith("initramfs-"): + name = name[10:] + if name.endswith("-hook"): + name = name[:-5] + return name + +INITRAMFS_HOOK_NAME ?= "${@get_initramfs_hook_name(d)}" + +do_install() { + if [ -f "${WORKDIR}/hook" ] || [ -n "${HOOK_COPY_EXECS}" ] || \ + [ -n "${HOOK_ADD_MODULES}" ]; then + rm -rf "${D}/usr/share/initramfs-tools/hooks" + install -d -m 0755 "${D}/usr/share/initramfs-tools/hooks" + + install -m 0755 "${WORKDIR}/hook-header" \ + "${D}/usr/share/initramfs-tools/hooks/${INITRAMFS_HOOK_NAME}" + if [ -f "${WORKDIR}/hook" ]; then + cat "${WORKDIR}/hook" >> \ + "${D}/usr/share/initramfs-tools/hooks/${INITRAMFS_HOOK_NAME}" + else + echo "exit 0" >> \ + "${D}/usr/share/initramfs-tools/hooks/${INITRAMFS_HOOK_NAME}" + fi + fi + + for script in init-top init-premount local-top nfs-top local-block \ + local-premount nfs-premount local-bottom nfs-bottom \ + init-bottom; do + if [ ! -f "${WORKDIR}/$script" ]; then + continue + fi + + rm -rf "${D}/usr/share/initramfs-tools/scripts/$script" + install -d -m 0755 "${D}/usr/share/initramfs-tools/scripts/$script" + install -m 0755 "${WORKDIR}/$script" \ + "${D}/usr/share/initramfs-tools/scripts/$script/${INITRAMFS_HOOK_NAME}" + done +}