public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Anton Mikanovich <amikan@ilbers.de>
To: isar-users@googlegroups.com
Cc: Anton Mikanovich <amikan@ilbers.de>
Subject: [RFC 04/15] linux-module: Do not use shell environment
Date: Mon, 26 Jul 2021 16:46:25 +0300	[thread overview]
Message-ID: <20210726134636.30800-5-amikan@ilbers.de> (raw)
In-Reply-To: <20210726134636.30800-1-amikan@ilbers.de>

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
 }
-- 
2.25.1


  parent reply	other threads:[~2021-07-26 13:46 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 ` Anton Mikanovich [this message]
2021-07-26 14:40   ` [RFC 04/15] linux-module: Do not use shell environment Jan Kiszka
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=20210726134636.30800-5-amikan@ilbers.de \
    --to=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