From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7032253102499561472 X-Received: by 2002:ac8:5916:: with SMTP id 22mr5680996qty.232.1637325855627; Fri, 19 Nov 2021 04:44:15 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:ac8:5fd4:: with SMTP id k20ls1588672qta.8.gmail; Fri, 19 Nov 2021 04:44:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyBAHacy+A0+C71JKcX9LIewE5qY3MEymAy8OZC2zaotwNPagxtpkJmmTPhjkN2cyD9X330 X-Received: by 2002:ac8:5848:: with SMTP id h8mr5607487qth.339.1637325855130; Fri, 19 Nov 2021 04:44:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637325855; cv=none; d=google.com; s=arc-20160816; b=Vp/QvVxIizZkseQLvTdxiNeeTv93EVGidl1BwsiZso11vkjzuLKz4PmzigvVnfxFd4 cC1ZmJsHyCIVx7TV3afIhVaB7dgBlJJouf6KVAez7wfc/jte+Ele6mXWDKx7IoNGpUoj 6BozII4XO9BofoDG52Htf5rhcv8+bbzkb2caFyZ3f1eSDilf9VgQq/RRnzaSi81ObheK 9NLvd/egEoG2RdrK9yUx7tQGhevVFtG1CR83N+fs+pu3H1NIQNsAaxmVMgagNseUpnf1 2JHeMs2hgXGP+Y5p6zkKFyNsGw34hh7CAlunBJgO3ZtIhTyyNuzPaPnZwu2gNlMFZp/s 7S1w== 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=oE9NOo/XAz6lnoa1U3Zttetu336wH/F5I/pcGpaVSuQ=; b=0+xDxgdhdi3p+FmZGQOLu0W7zUBxZ4LIseySvmhL5AUSd6yQXKGXnKwne3ZLz0N8U8 WQzLlj5BBK1XSHrR2hFuj4m11PoXCdgbnOBKcAVHUUN/nRdrgBP4B1IKz7WaYq/RAQa0 Q4JP2YGJqMvLnLknyKkOYxy8LcgltIeXroGiGB8tauSBLai77B/8weEk8l2p6bc0Lu/E xY7RSaMHgPuZ7YyUrvA7VffTzrShrZNSzxpJ6MYtJSTy2Huh1L5d6K4x/S/40lgqvH1O VCmUXn6kpjdh+XpEY5CO0ew7MW3FS181OsvN0FCFpHDY+aCCR0DlEk0Uum+pOU5wNyD5 W6hA== 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 y15si386378qkp.0.2021.11.19.04.44.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Nov 2021 04:44:15 -0800 (PST) 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 1AJCiC3t021269 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Nov 2021 13:44:13 +0100 Received: from [167.87.1.34] ([167.87.1.34]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 1AJCiCx7027366; Fri, 19 Nov 2021 13:44:12 +0100 Subject: Re: [PATCH v2 04/24] linux-module: Do not use shell environment To: Uladzimir Bely , isar-users@googlegroups.com References: <20211119121333.13805-1-ubely@ilbers.de> <20211119121333.13805-5-ubely@ilbers.de> From: Jan Kiszka Message-ID: <1bc95be7-e603-966b-5326-962362548e2c@siemens.com> Date: Fri, 19 Nov 2021 13:44:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20211119121333.13805-5-ubely@ilbers.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: iAwB968O01D+ On 19.11.21 13:13, Uladzimir Bely wrote: > From: Anton Mikanovich > > 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 > Signed-off-by: Uladzimir Bely > --- > .../files/debian/{rules => rules.tmpl} | 14 ++++++++++- > meta/recipes-kernel/linux-module/module.inc | 23 +++++++------------ > 2 files changed, 21 insertions(+), 16 deletions(-) > rename meta/recipes-kernel/linux-module/files/debian/{rules => rules.tmpl} (50%) > > diff --git a/meta/recipes-kernel/linux-module/files/debian/rules b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl > similarity index 50% > rename from meta/recipes-kernel/linux-module/files/debian/rules > rename to meta/recipes-kernel/linux-module/files/debian/rules.tmpl > index 59720b37..d8f1d48a 100755 > --- a/meta/recipes-kernel/linux-module/files/debian/rules > +++ b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl > @@ -24,14 +24,26 @@ 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/') Could we wrap this long line? > +KDIR := $(shell dpkg -L $(KERNEL_DEP) | grep "/lib/modules/.*/build") > +endif > + > +# With sbuild `dh clean` is called before chroot's apt database updated. So, > +# KDIR is empty at that moment and the override causes error. Will skip it. > +ifneq ($(KDIR),) > override_dh_auto_clean: > $(MAKE) -C $(KDIR) M=$(PWD) clean > +endif This looks wrong, or at least fragile. Why can we live without a proper clean on the kernel tree? > > 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 0515621a..5b086233 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 Hmm... > + > + # restore execute permissions > + chmod a+x ${S}/debian/rules The mode should be fixed (aligned to the template) in template.bbclass to avoid bothering every recipe with such boilerplate code. I'm seeing this in other changes as well. With all those "do not use shell env" - how will a downstream user detect that a recipe is not properly converted? That looks like a nice trap during migration to sbuild (because of silent / non-obvious errors). Jan -- Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux