From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7032253102499561472 X-Received: by 2002:ac2:55b2:: with SMTP id y18mr30704722lfg.63.1637325956596; Fri, 19 Nov 2021 04:45:56 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6512:2610:: with SMTP id bt16ls284196lfb.2.gmail; Fri, 19 Nov 2021 04:45:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyahdBQiW4/os9AlEKlrcpeiDSWzPnMj51RzzLFzxVy1oAdOKiX5nbsL+3Ocfsd+2o20cD/ X-Received: by 2002:a05:6512:2111:: with SMTP id q17mr31838684lfr.371.1637325955457; Fri, 19 Nov 2021 04:45:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637325955; cv=none; d=google.com; s=arc-20160816; b=T4+saG/J1xikg+aOhd4/RIbNGLSbo2Fk4JBtHUzKmVtRBoJSx+/AVktln/suPnoVMO SuWLIo5FTksg9VAayMAduzg04B52a/u+Y15pv8ezyG1HO0/Gil9tiWA+jkP7hoYGNum7 W1OTr7V3AiMEAxUH3fyo82yyahqz3z6pJrJ6kN3SyW0StCnWGVIfrdouEeNfYKF5DG/Z 84oBoTUmiOSfLYwCg4FxtV5toGPomJ5kq64Mz5NiALjbYh13eEqC3Nmy28eVGMkistv5 fDqOEO+QKt3enQinRhuunCbMihFvrdxdYQD0AaXIA8qgY9YFRFQVyBwPQSX6t4XUd0jf 2Wbw== 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:references:to:from:subject; bh=d69Oe3H3y+Zl4ijmlaJhYGqERnTV+qRyz+cmZEeSf0c=; b=chsH6mI+hQrfpkgZy44fCELwDRjuR30RVE/4UfrK8v5zE+KnyJ3yJ9l3PbySBGL93C wQvlPRX8SRIqh9DQPILlQ0IpQo4kjCBJ1Y+h2MdRiwia3N8iM5rM2i47PUyFBmx3fl5a hxWXc5c6vObsGbEZchVxKdEuVMbRa6cyCT/8Oz1mPzTD1yYff0w2ipDAJXPZy1lPVHLK jP2FWZjspi5hwnmjjWVGVGb8CoUKkEUAolPXQjBP0jPiIsO0SC+RO9byUb3Ct4YCBXIw JHXv/GvB/i7v1BSDRyCmvDXFDKaqP9nBP9rAxZywzIN3drxnoXXYlMOV8p0HoynFSSuJ FH6g== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.14 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 david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id d8si160714lfv.13.2021.11.19.04.45.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Nov 2021 04:45:55 -0800 (PST) Received-SPF: pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.14 as permitted sender) client-ip=192.35.17.14; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.14 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 david.siemens.de (8.15.2/8.15.2) with ESMTPS id 1AJCjsIb026407 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Nov 2021 13:45:54 +0100 Received: from [167.87.1.34] ([167.87.1.34]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 1AJCjsLb028001; Fri, 19 Nov 2021 13:45:54 +0100 Subject: Re: [PATCH v2 04/24] linux-module: Do not use shell environment From: Jan Kiszka To: Uladzimir Bely , isar-users@googlegroups.com References: <20211119121333.13805-1-ubely@ilbers.de> <20211119121333.13805-5-ubely@ilbers.de> <1bc95be7-e603-966b-5326-962362548e2c@siemens.com> Message-ID: <3f1fb8d1-72c3-23d7-6e22-5f9f127b8ae3@siemens.com> Date: Fri, 19 Nov 2021 13:45:54 +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: <1bc95be7-e603-966b-5326-962362548e2c@siemens.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: u/xMnmgB4Pn2 On 19.11.21 13:44, Jan Kiszka wrote: > 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). > Oh, and then you still also add sbuild_export - why not use that for cases that are ugly to convert (like this one)? Jan -- Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux