From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6808879013169201152 X-Received: by 2002:adf:fd81:: with SMTP id d1mr5440341wrr.96.1592495683909; Thu, 18 Jun 2020 08:54:43 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a1c:a94e:: with SMTP id s75ls903129wme.3.canary-gmail; Thu, 18 Jun 2020 08:54:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwe3w2DV3wZRSzNpWE59aeKtSlPK3SSCIoFr6RMZ84899nVTfulhH2JrweG9OqDCpO3bhk0 X-Received: by 2002:a7b:c08e:: with SMTP id r14mr4994548wmh.78.1592495683294; Thu, 18 Jun 2020 08:54:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592495683; cv=none; d=google.com; s=arc-20160816; b=y6O42x2KYghDTBzmhnQn9X4NALvHEe6mkXSQuCWceaXpPngK8j5bvKat8bGaDyZgNm lvfeMxLGgM8fdHdgZ68MzoNdddLgLr/yKtjnYHOHpaVB4FKaWUc6BzjyjafHFcsE4Bec PvXt692LwtEJluJ9LKsty8YWCCyj0maVer7upI03jO177CYwxV9vXRWWeM/banx3e2su DKYzkWIRiqNResOVdfKtLRyw4i4P1kvMmZRtvJ0OM5Q6upoQE2cWdRLBBFITSphwoXyk Up7Fi90NqQaJ5xaPIcw9E7Iudj0fbLvaScmxJR0Y07/lBWj9x1xoQDi5U8kUFmnMxon8 rEOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:to:from:subject:message-id; bh=VOfqwvgmhUWLmcTCNKIuBmNz9+I2JsH+xFvhFl+fOWY=; b=a2KdvyntzFlClpKUpWnCmVdOfaXcxtLJNtn7BR4aGnCGoxmkUwlfnUQG5+ZgHbd7aQ 7hX9TWWWUzbqtck9wqBXAFqNlFuDzLSONOi1pKrTX9/mYo7N8t6d321ozxGQqpExSBLj l0WysXfgs5FntvSWx7vJ9djKPqwP/Ep1V4hiLRjsksPvS6QeKK6iLPy8Dnp6qEyZW09a xLv3xoDcGUMZlUYEyTTJw6vx0OTd/DJez+qZS7MRcAsnKtfnb3YmBZX1qWUyt4jR8C4f VQmjMSLO0QxIgOscTObklY27lVs1S4KGrMhhBIBKGdoNx6rmx2l82OrTGl78cSZZ6kwR vijA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for domain of hws@denx.de) smtp.mailfrom=hws@denx.de Return-Path: Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.10]) by gmr-mx.google.com with ESMTPS id r204si496037wma.1.2020.06.18.08.54.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jun 2020 08:54:43 -0700 (PDT) Received-SPF: neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for domain of hws@denx.de) client-ip=212.18.0.10; Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for domain of hws@denx.de) smtp.mailfrom=hws@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 49nmhy6vwyz1rvRp; Thu, 18 Jun 2020 17:54:42 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 49nmhy6VM6z1qqkZ; Thu, 18 Jun 2020 17:54:42 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id owAu9fhFeenL; Thu, 18 Jun 2020 17:54:41 +0200 (CEST) X-Auth-Info: ZVH+VUjafT6ykzZPytl+jkj9fZYdrRjISuQdyQ2x9pA= Received: from maia.denx.de (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 18 Jun 2020 17:54:41 +0200 (CEST) Message-ID: Subject: Re: [PATCH v5 1/3] meta/support: Generate a custom initramfs From: Harald Seiler To: "Q. Gylstorff" , isar-users@googlegroups.com, Jan.Kiszka@siemens.com Date: Thu, 18 Jun 2020 17:54:41 +0200 In-Reply-To: <20200423094636.24511-2-Quirin.Gylstorff@siemens.com> References: <6ec0f368-2832-07ab-1fa0-b9704b115c01@siemens.com> <20200423094636.24511-1-Quirin.Gylstorff@siemens.com> <20200423094636.24511-2-Quirin.Gylstorff@siemens.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-TUID: Bn8MNetDIBbC Hello Quirin, I'm currently trying out the MR you prepared for me. As this patch is a part of it, and it concerns ISAR upstream, I think talking about it here makes more sense than only internally. On Thu, 2020-04-23 at 11:46 +0200, Q. Gylstorff wrote: > From: Quirin Gylstorff > > This package sets the Parameters for mkinitramfs/update-intramfs > before it regenerates the initrd.img of debian with a modified version. > > Use cases are the remove unnecessary kernel modules to reduce the > size of the initrd by using the parameters: > ``` > INITRAMFS_MODULES = "list" > INITRAMFS_MODULE_LIST += "ext4" > ``` > > Set the boot root during the initrd generation by setting `INITRAMFS_ROOT`. > > see also man pages of mkinitramfs and initramfs.conf. > > Signed-off-by: Quirin Gylstorff > --- > .../initramfs-config/files/control.tmpl | 12 +++++ > .../initramfs-config/files/postinst.tmpl | 50 +++++++++++++++++++ > .../initramfs-config/files/postrm.tmpl | 41 +++++++++++++++ > .../initramfs-config/initramfs-config_0.1.bb | 32 ++++++++++++ > 4 files changed, 135 insertions(+) > create mode 100644 meta/recipes-support/initramfs-config/files/control.tmpl > create mode 100644 meta/recipes-support/initramfs-config/files/postinst.tmpl > create mode 100644 meta/recipes-support/initramfs-config/files/postrm.tmpl > create mode 100644 meta/recipes-support/initramfs-config/initramfs-config_0.1.bb > > diff --git a/meta/recipes-support/initramfs-config/files/control.tmpl b/meta/recipes-support/initramfs-config/files/control.tmpl > new file mode 100644 > index 0000000..e0f5543 > --- /dev/null > +++ b/meta/recipes-support/initramfs-config/files/control.tmpl > @@ -0,0 +1,12 @@ > +Source: initramfs-config > +Section: misc > +Priority: optional > +Standards-Version: 3.9.6 > +Maintainer: isar-users > +Build-Depends: debhelper (>= 9) > + > + > +Package: initramfs-config > +Architecture: any > +Depends: ${shlibs:Depends}, ${misc:Depends}, initramfs-tools-core, ${DEBIAN_DEPENDS} > +Description: Configuration files for a custom initramfs > diff --git a/meta/recipes-support/initramfs-config/files/postinst.tmpl b/meta/recipes-support/initramfs-config/files/postinst.tmpl > new file mode 100644 > index 0000000..e523906 > --- /dev/null > +++ b/meta/recipes-support/initramfs-config/files/postinst.tmpl > @@ -0,0 +1,50 @@ > +#!/bin/sh > +# postinst script for initramfs-config > +# > +# see: dh_installdeb(1) > + > +set -e > + > +case "$1" in > + configure) > + INITRAMFS_CONF=/etc/initramfs-tools/initramfs.conf > + if [ -f ${INITRAMFS_CONF} ]; then > + sed -i -E 's/(^MODULES=).*/\1${INITRAMFS_MODULES}/' ${INITRAMFS_CONF} > + sed -i -E 's/(^BUSYBOX=).*/\1${INITRAMFS_BUSYBOX}/' ${INITRAMFS_CONF} > + sed -i -E 's/(^COMPRESS=).*/\1${INITRAMFS_COMPRESS}/' ${INITRAMFS_CONF} > + sed -i -E 's/(^KEYMAP=).*/\1${INITRAMFS_KEYMAP}/' ${INITRAMFS_CONF} > + sed -i -E 's/(^DEVICE=).*/\1${INITRAMFS_NET_DEVICE}/' ${INITRAMFS_CONF} > + sed -i -E 's/(^NFSROOT=).*/\1${INITRAMFS_NFSROOT}/' ${INITRAMFS_CONF} > + sed -i -E 's/(^RUNSIZE=).*/\1${INITRAMFS_RUNSIZE}/' ${INITRAMFS_CONF} > + if grep -Fxq "ROOT=" "${INITRAMFS_CONF}"; then > + sed -i -E 's/(^ROOT=).*/\1${INITRAMFS_ROOT}/' ${INITRAMFS_CONF} > + else > + sed -i -E "\$aROOT=${INITRAMFS_ROOT}" ${INITRAMFS_CONF} > + fi > + fi > + > + MODULES_LIST_FILE=/etc/initramfs-tools/modules > + if [ -f ${MODULES_LIST_FILE} ]; then > + for modname in ${INITRAMFS_MODULE_LIST}; do > + if ! grep -Fxq "$modname" "${MODULES_LIST_FILE}"; then > + echo "$modname" >> "${MODULES_LIST_FILE}" > + fi > + done > + fi > + > + update-initramfs -v -u > + > + ;; > + abort-upgrade|abort-remove|abort-deconfigure) > + ;; > + > + *) > + echo "postinst called with unknown argument \`$1'" >&2 > + exit 1 > + ;; > +esac > +# dh_installdeb will replace this with shell code automatically > +# generated by other debhelper scripts. > +#DEBHELPER# > + > +exit 0 > diff --git a/meta/recipes-support/initramfs-config/files/postrm.tmpl b/meta/recipes-support/initramfs-config/files/postrm.tmpl > new file mode 100644 > index 0000000..115d9b6 > --- /dev/null > +++ b/meta/recipes-support/initramfs-config/files/postrm.tmpl > @@ -0,0 +1,41 @@ > +#!/bin/sh > +# postrm script for initramfs-config > +# > +# see: dh_installdeb(1) > + > +set -e > + > +case "$1" in > + purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) > + # back to the debian defaults > + INITRAMFS_CONF=/etc/initramfs-tools/initramfs.conf > + sed -i -E 's/(^MODULES=).*/\1most/' ${INITRAMFS_CONF} > + sed -i -E 's/(^BUSYBOX=).*/\1auto/' ${INITRAMFS_CONF} > + sed -i -E 's/(^COMPRESS=).*/\1gzip/' ${INITRAMFS_CONF} > + sed -i -E 's/(^KEYMAP=).*/\1n/' ${INITRAMFS_CONF} > + sed -i -E 's/(^DEVICE=).*/\1/' ${INITRAMFS_CONF} > + sed -i -E 's/(^NFSROOT=).*/\1auto/' ${INITRAMFS_CONF} > + sed -i -E 's/(^RUNSIZE=).*/\110%/' ${INITRAMFS_CONF} > + sed -i -E 's/(^ROOT=).*//' ${INITRAMFS_CONF} > + > + # remove the added modules > + MODULES_LIST_FILE=/etc/initramfs-tools/modules > + for modname in ${INITRAMFS_MODULE_LIST}; do > + sed -i -E 's/$modname//' > + done > + > + update-initramfs -v -u > + ;; > + > + *) > + echo "postrm called with unknown argument \`$1'" >&2 > + exit 1 > + ;; > +esac > + > +# dh_installdeb will replace this with shell code automatically > +# generated by other debhelper scripts. > + > +#DEBHELPER# > + > +exit 0 > diff --git a/meta/recipes-support/initramfs-config/initramfs-config_0.1.bb b/meta/recipes-support/initramfs-config/initramfs-config_0.1.bb > new file mode 100644 > index 0000000..34bb25b > --- /dev/null > +++ b/meta/recipes-support/initramfs-config/initramfs-config_0.1.bb Shouldn't this be a .inc file instead of a concrete recipe (similar to u-boot-custom.inc)? The way it is right now, customizations to the recipe via bbappend files are always pulled in. This means if a layer I pull in customizes this recipe, I can't decide whether I want those changes or not. With an inc-file, layers would instead provide individual recipes for each initramfs config change which a downstream layer could then decide to pull in, or not to pull in. Each of these recipes 'requires' this base inc-file. I think this pattern would compose better. > @@ -0,0 +1,32 @@ > +# This software is a part of ISAR. > +# Copyright (C) 2020 Siemens AG > +# > +# SPDX-License-Identifier: MIT > +inherit dpkg-raw > +inherit template > +DESCRIPTION = "Recipe to set the initramfs configuration and generate a new ramfs" > + > + > +SRC_URI = "file://postinst.tmpl \ > + file://postrm.tmpl \ > + file://control.tmpl \ > + " > + > +INITRAMFS_MODULES ?= "most" > +INITRAMFS_BUSYBOX ?= "auto" > +INITRAMFS_COMPRESS ?= "gzip" > +INITRAMFS_KEYMAP ?= "n" > +INITRAMFS_NET_DEVICE ?= "" > +INITRAMFS_NFSROOT ?= "auto" > +INITRAMFS_RUNSIZE ?= "10%" > +INITRAMFS_ROOT ?= "" > +INITRAMFS_MODULE_LIST ?= "" > +CREATE_NEW_INITRAMFS ?= "n" > +KERNEL_PACKAGE = "${@ ("linux-image-" + d.getVar("KERNEL_NAME", True)) if d.getVar("KERNEL_NAME", True) else ""}" > +DEBIAN_DEPENDS += ", ${KERNEL_PACKAGE}" > +TEMPLATE_FILES = "postinst.tmpl control.tmpl postrm.tmpl" > +TEMPLATE_VARS += "INITRAMFS_MODULES INITRAMFS_BUSYBOX INITRAMFS_COMPRESS \ > + INITRAMFS_KEYMAP INITRAMFS_NET_DEVICE INITRAMFS_NFSROOT \ > + INITRAMFS_RUNSIZE INITRAMFS_ROOT INITRAMFS_MODULE_LIST CREATE_NEW_INITRAMFS DEBIAN_DEPENDS" > + > + > -- > 2.20.1 > -- Harald DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-62 Fax: +49-8142-66989-80 Email: hws@denx.de