From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6989231260094693376 X-Received: by 2002:a2e:9599:: with SMTP id w25mr12205156ljh.271.1627310447744; Mon, 26 Jul 2021 07:40:47 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6512:3b1e:: with SMTP id f30ls702669lfv.0.gmail; Mon, 26 Jul 2021 07:40:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBpGlfx18PG3Bbnom64+meFchYcHWXa1vBkncLtIXortlT4WYUSTc+2l+exjVpU8NyofRW X-Received: by 2002:ac2:52ac:: with SMTP id r12mr12594966lfm.364.1627310446575; Mon, 26 Jul 2021 07:40:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627310446; cv=none; d=google.com; s=arc-20160816; b=1K3GhlEri4sS7PXO4VgE2g7SoQ58cony9t4NHQaOGEHxAZZxR65q+iDt9Pxq5l5nTK f/WfYeOGZleLbWekbVgdaxhc+3qW+6K0zYKieW55KqISmA/E1opKod4hbSHfWdKauceU qgcNLOCB5S8qAABFpbR5Co2eEU9SesLLWObtanq09TCnglqwFrugyX98+c53sf1fuFHR AjEb8k2OfRjlTu5kpDHU/8WiZ2Kxs+Kfsrb4MNC+VrIQe0CQrwD6jjMUk03GpQmtcf04 GVYQdZAqaxGFM2XvfIRwrLVh8NjR2sYbfec/QekgsVCYXh1SjGIl5j1s4oc8FBWIXKYU t+uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject; bh=pkjcovznfWIpeb4fljdcT01xh50I6/86ifzX7zLwxfk=; b=SKNq1inqYmEWGRUEvruhJUIOrRR2By6jIPEG4daWqQ6iV+Fcrd+nTUBBb+IWt7xtfj cs7ln8igkA9lIrAejYYLaVukXNRf/7vLszzo4gAOksauvU6o/Cmo0VHvw/AkkpX77msk p6k6Bk9B1Ov32VVUBtlqASlPEpM5yvS1V6EJG2JELnt2r01kS456PHKa0KW76PeEkWxV NqYtLzfnpz0x+ogUIoxYvtRJJ7SU9Nrn8oOK6+iwBFcIyjUZ6kOX2xj8+A8V9oFuOG3K B4ClLcflPKaX2Q5YH6xgyWD1Q7+7TjJY7rvCqtTpFy5zcqmHqHiumhu1/rei0Oeq9dl+ h8Rg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from gecko.sbs.de (gecko.sbs.de. [194.138.37.40]) by gmr-mx.google.com with ESMTPS id 14si6373lfq.2.2021.07.26.07.40.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Jul 2021 07:40:46 -0700 (PDT) Received-SPF: pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.40 as permitted sender) client-ip=194.138.37.40; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by gecko.sbs.de (8.15.2/8.15.2) with ESMTPS id 16QEejTj011260 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Jul 2021 16:40:45 +0200 Received: from [167.87.33.191] ([167.87.33.191]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 16QEejmM031908; Mon, 26 Jul 2021 16:40:45 +0200 Subject: Re: [RFC 04/15] linux-module: Do not use shell environment To: Anton Mikanovich , isar-users@googlegroups.com References: <20210726134636.30800-1-amikan@ilbers.de> <20210726134636.30800-5-amikan@ilbers.de> From: Jan Kiszka Message-ID: <6faab3dc-8abe-9393-704a-67766a1addf4@siemens.com> Date: Mon, 26 Jul 2021 16:40:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210726134636.30800-5-amikan@ilbers.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: 5JRiQxx5EtYc On 26.07.21 15:46, Anton Mikanovich wrote: > To make package build process independent of the shell environment we > should remove KDIR and PN passing through export call. > KDIR can be prepared during package build. This also will allow not to > rely on previous builddeps install task. > To pass PN variable we can just migrate to template-based debian/rules > file. > > Signed-off-by: Anton Mikanovich > --- > .../files/debian/{rules => rules.tmpl} | 10 +++++++- > meta/recipes-kernel/linux-module/module.inc | 23 +++++++------------ > 2 files changed, 17 insertions(+), 16 deletions(-) > rename meta/recipes-kernel/linux-module/files/debian/{rules => rules.tmpl} (55%) > > diff --git a/meta/recipes-kernel/linux-module/files/debian/rules b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl > similarity index 55% > rename from meta/recipes-kernel/linux-module/files/debian/rules > rename to meta/recipes-kernel/linux-module/files/debian/rules.tmpl > index c476bf3..39abc52 100755 > --- a/meta/recipes-kernel/linux-module/files/debian/rules > +++ b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl > @@ -24,11 +24,19 @@ ifneq (,$(findstring 86,$(DEB_HOST_GNU_CPU))) > export ARCH=x86 > endif > > +# Custom kernels contain the build folder directly. > +KDIR := $(shell dpkg -L linux-headers-${KERNEL_NAME} | grep "/lib/modules/.*/build") > +ifeq ($(KDIR),) > +# Debian kernels install that folder indirectly via a dependency. > +KERNEL_DEP := $(shell dpkg-query -W -f '$${Depends}' linux-headers-${KERNEL_NAME} | sed 's/.*\(linux-headers-[[:graph:]]*\).*/\1/') > +KDIR := $(shell dpkg -L $(KERNEL_DEP) | grep "/lib/modules/.*/build") > +endif > + > override_dh_auto_build: > $(MAKE) -C $(KDIR) M=$(PWD) modules > > override_dh_auto_install: > - $(MAKE) -C $(KDIR) M=$(PWD) INSTALL_MOD_PATH=$(PWD)/debian/$(PN) modules_install > + $(MAKE) -C $(KDIR) M=$(PWD) INSTALL_MOD_PATH=$(PWD)/debian/${PN} modules_install > > %: > CFLAGS= LDFLAGS= dh $@ --parallel > diff --git a/meta/recipes-kernel/linux-module/module.inc b/meta/recipes-kernel/linux-module/module.inc > index 0515621..5b08623 100644 > --- a/meta/recipes-kernel/linux-module/module.inc > +++ b/meta/recipes-kernel/linux-module/module.inc > @@ -22,8 +22,9 @@ AUTOLOAD ?= "" > inherit dpkg > > TEMPLATE_FILES = "debian/control.tmpl \ > - debian/changelog.tmpl" > -TEMPLATE_VARS += "KERNEL_NAME" > + debian/changelog.tmpl \ > + debian/rules.tmpl" > +TEMPLATE_VARS += "KERNEL_NAME PN" > > do_prepare_build() { > cp -r ${WORKDIR}/debian ${S}/ > @@ -31,18 +32,10 @@ do_prepare_build() { > for module in "${AUTOLOAD}"; do > echo "echo $module >> /etc/modules" >> ${S}/debian/postinst > done > -} > > -dpkg_runbuild_prepend() { > - # Custom kernels contain the build folder directly. > - export KDIR=$(dpkg -L --root=${BUILDCHROOT_DIR} linux-headers-${KERNEL_NAME} | \ > - grep "/lib/modules/.*/build") > - if [ -z "$KDIR" ]; then > - # Debian kernels install that folder indirectly via a dependency. > - KERNEL_DEP=$(dpkg-query -W -f '${Depends}' --admindir=${BUILDCHROOT_DIR}/var/lib/dpkg \ > - linux-headers-${KERNEL_NAME} | sed 's/.*\(linux-headers-[[:graph:]]*\).*/\1/') > - export KDIR=$(dpkg -L --root=${BUILDCHROOT_DIR} ${KERNEL_DEP} | \ > - grep "/lib/modules/.*/build") > - fi > - export PN=${PN} > + # remove templates from the source tree > + find ${S}/debian -name *.tmpl | xargs rm -f > + > + # restore execute permissions > + chmod a+x ${S}/debian/rules > } > Exporting build vars via the shell is a fairly common pattern by now, not only in the many recipes and includes you had to patch in isar. Can't we do something that people do not have to fork rules files into rules.tmpl in order to inject variables set in recipes? Jan -- Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux