From: Jan Kiszka <jan.kiszka@siemens.com>
To: Anton Mikanovich <amikan@ilbers.de>, isar-users@googlegroups.com
Subject: Re: [RFC 04/15] linux-module: Do not use shell environment
Date: Mon, 26 Jul 2021 16:40:45 +0200 [thread overview]
Message-ID: <6faab3dc-8abe-9393-704a-67766a1addf4@siemens.com> (raw)
In-Reply-To: <20210726134636.30800-5-amikan@ilbers.de>
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 <amikan@ilbers.de>
> ---
> .../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
next prev parent reply other threads:[~2021-07-26 14:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-26 13:46 [RFC 00/15] Sbuild/Schroot migration Anton Mikanovich
2021-07-26 13:46 ` [RFC 01/15] dpkg: Install raw package files to source root Anton Mikanovich
2021-07-26 13:46 ` [RFC 02/15] dpkg-gbp: Use separate export-orig command Anton Mikanovich
2021-07-26 13:46 ` [RFC 03/15] isar-bootstrap: Export bootstrap to schroot config Anton Mikanovich
2021-07-26 13:46 ` [RFC 04/15] linux-module: Do not use shell environment Anton Mikanovich
2021-07-26 14:40 ` Jan Kiszka [this message]
2021-07-26 13:46 ` [RFC 05/15] u-boot: " Anton Mikanovich
2021-07-26 14:50 ` Jan Kiszka
2021-07-26 13:46 ` [RFC 06/15] trusted-firmware: " Anton Mikanovich
2021-07-26 13:46 ` [RFC 07/15] optee-os: " Anton Mikanovich
2021-07-26 13:46 ` [RFC 08/15] kselftest: " Anton Mikanovich
2021-07-26 13:46 ` [RFC 09/15] dpkg: Build packages with sbuild Anton Mikanovich
2021-07-26 13:46 ` [RFC 10/15] sbuild: Introduce environment variables export API Anton Mikanovich
2021-07-26 14:47 ` Jan Kiszka
2021-07-26 13:46 ` [RFC 11/15] dpkg: Remove builddeps install task Anton Mikanovich
2021-07-26 13:46 ` [RFC 12/15] dpkg-gbp: Migrate to schroot Anton Mikanovich
2021-07-26 13:46 ` [RFC 13/15] img: Use schroot for image prepare Anton Mikanovich
2021-07-26 13:46 ` [RFC 14/15] linux-mainline: Move cfg fragment test to debian/rules Anton Mikanovich
2021-07-26 14:48 ` Jan Kiszka
2021-07-26 13:46 ` [RFC 15/15] linux-custom: Prepare kernel config inside sbuild Anton Mikanovich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6faab3dc-8abe-9393-704a-67766a1addf4@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=amikan@ilbers.de \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox