From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7032253102499561472 X-Received: by 2002:a05:600c:3c91:: with SMTP id bg17mr6317324wmb.80.1637324017190; Fri, 19 Nov 2021 04:13:37 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:adf:f1c2:: with SMTP id z2ls2905495wro.2.gmail; Fri, 19 Nov 2021 04:13:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8rDbOdAxTl5Ha9DU9hMHiWK5FEirSREDdXsaFbpGZyY0W9laXro8I5NhJ9KXkwz6NlJre X-Received: by 2002:a5d:68ce:: with SMTP id p14mr6693608wrw.116.1637324016141; Fri, 19 Nov 2021 04:13:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637324016; cv=none; d=google.com; s=arc-20160816; b=t2aDQgzXCI1IHvvqZu2gDSrNNXILt5ecO1hKXRlC7kRuIKdP+GS18t07/9ha7VqPob yiolqhTV23NOnp1Kt457Nm5OldfcSWNYaXO5W7va/R6JxOQtX+pm+dqKs66hoApR4zcl grpRzb9WYBbZg/EnBa0j5QHR4gHX8VmB3e+PTmQwbMbfupuAQ3K/pljOVTkXvGw8aOsd C3tHC986rxiI6ESVk/kWDYT/NtsCGsD31yyo3GNbFgzZr1xzazH3rCV6bA4yG3uEkyAI q8Ezn/vwOyNtuapYV9sZJnbZydOBcC4NMODfJplaQ0ddCtcv8Mm/PgPf1r3uuzlzo1Py 1nSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from; bh=H0oGVTcj1dOYaiDAv8dVN1ZL9ijqcbV8HX1JQBSqZC4=; b=KwS2US7569IcZQIpatudW/U19K4xvDQD7xiebuDpwqzkpGUOteKnztSNSKWw6Ryo9D HuTDzLR3dSryv6mjZBaQQFQV1ZGfHd2ZGPfCWCGZEmh6qkVrf0ma8Dikki+JeGDh5I1e 5whcqGLBVxnRmalr9yeKwxknIsDmRiGaeUmNQchhhDqLtUtZ/YGNwD1w4pCMrG8ENqLF jFWSJda/j5nwSYMfJTHV2Ct+S2HsZTFHcnu+GODj8EZWK1typ6CYYXtUg+Nv1MmnANeX YW2LIRq11kDFge+PO6AHyS9Cua4fd373VYXxqmA1DSFKJ67zYDCWkY5ZKzZfcmFD7Ovc 6+dw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=ubely@ilbers.de Return-Path: Received: from shymkent.ilbers.de (shymkent.ilbers.de. [85.214.156.166]) by gmr-mx.google.com with ESMTPS id 201si145946wma.1.2021.11.19.04.13.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Nov 2021 04:13:36 -0800 (PST) Received-SPF: pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) client-ip=85.214.156.166; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=ubely@ilbers.de Received: from baighyz.m.ilbers.de (host-80-81-17-52.static.customer.m-online.net [80.81.17.52]) (authenticated bits=0) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8) with ESMTPSA id 1AJCDX7E021829 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 19 Nov 2021 13:13:35 +0100 From: Uladzimir Bely To: isar-users@googlegroups.com Subject: [PATCH v2 04/24] linux-module: Do not use shell environment Date: Fri, 19 Nov 2021 13:13:13 +0100 Message-Id: <20211119121333.13805-5-ubely@ilbers.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211119121333.13805-1-ubely@ilbers.de> References: <20211119121333.13805-1-ubely@ilbers.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-TUID: zr6Vhrs3PIrh 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/') +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 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 + + # restore execute permissions + chmod a+x ${S}/debian/rules } -- 2.20.1