From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7057120643105423360 X-Received: by 2002:ac2:5f4f:: with SMTP id 15mr7114457lfz.321.1643113942430; Tue, 25 Jan 2022 04:32:22 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:651c:39b:: with SMTP id e27ls2894751ljp.6.gmail; Tue, 25 Jan 2022 04:32:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJyRHH6CO1U/z+PRXBmhLFjNPtQFLr5Bhdo2na8/98PAzfMF+97B6uL27m4pPLSIaKo0Ajql X-Received: by 2002:a2e:b8c9:: with SMTP id s9mr14516972ljp.136.1643113941347; Tue, 25 Jan 2022 04:32:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643113941; cv=none; d=google.com; s=arc-20160816; b=mo6CX2dQ6caDWPBmM5Myf36AuIAmll+F/KFPD7c7hleV4Uy0TDsig7Qj75/3tTvEEO M2RfZjbB6t6u5ashSSM/6Lbq7KJlEttQxhHqyGBSkltRbAshPeiQF+bBsWLVSwoqhbIj j0hLlfT/vX9PFXOYTCypqBqB4xFXcM/SEn6jxvjFGcaS3ARUnuG6RHaaVkbWvylV/pfp 4rRwivgrosCngS3xaxpAdusw+99CE9AHr2UCYeSnsISQLbJOcsiOA93+BkewGqwxWsif ssKgxSKWUihyqQDu2syaKWPqQjx0Tqm3fGvTG61AJEIndMzvStb8uDPiNfk55sUHfmb1 b92A== 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=FJTKjFTZLQnWMls4UekF4WhyLusKiSddARmHes38gCw=; b=dFF3/gPIp8+owUyCmA/TrI/RdytNlGi3YPEEtVGaYiBurjP8gkQ/R/n43vAxtZ92dc GIyEd40yVaBPpNr+u4prENLwzkUx8SYVTIFPYIy8/p4GNdiqyMPhMKfLLqlJinRM+Pbz HaVovG4EE0Yl5SY0l22P0c+PC/g5Rd8AOSp6lMpIK7jgZnX1BBcwm++8VQIuYvEH+cEV r9ManIiZX1f+8W5N1AS02qvJXicP3GEkxFGlSLSuydITYf3X5+8lrDeCT1CcYz+FKevG cw6tERrRNqT243oLKR8f3C1whA6f7CEWi3etw0Zu6yRc3m5XH2S5niStkhC8+6GEn6PE /MIQ== 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 bp40si624872lfb.0.2022.01.25.04.32.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jan 2022 04:32:21 -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 20PCWJHo019024 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Jan 2022 13:32:20 +0100 From: Uladzimir Bely To: isar-users@googlegroups.com Subject: [PATCH v2 2/9] linux-module: Do not use shell environment Date: Tue, 25 Jan 2022 13:32:12 +0100 Message-Id: <20220125123219.32395-3-ubely@ilbers.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220125123219.32395-1-ubely@ilbers.de> References: <20220125123219.32395-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: DW6qV7OqjO5b 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 --- .../linux-module/files/debian/rules | 37 ------------- .../linux-module/files/debian/rules.tmpl | 52 +++++++++++++++++++ meta/recipes-kernel/linux-module/module.inc | 19 ++----- 3 files changed, 55 insertions(+), 53 deletions(-) delete mode 100755 meta/recipes-kernel/linux-module/files/debian/rules create mode 100755 meta/recipes-kernel/linux-module/files/debian/rules.tmpl diff --git a/meta/recipes-kernel/linux-module/files/debian/rules b/meta/recipes-kernel/linux-module/files/debian/rules deleted file mode 100755 index 59720b37..00000000 --- a/meta/recipes-kernel/linux-module/files/debian/rules +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/make -f - -# Debian rules for custom kernel module build -# -# This software is a part of ISAR. -# Copyright (c) Siemens AG, 2018 -# -# SPDX-License-Identifier: MIT - -export DEB_BUILD_OPTIONS=parallel=$(shell nproc) - -export CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)- - -ifeq ($(DEB_HOST_GNU_CPU), arm) -export ARCH=arm -endif -ifeq ($(DEB_HOST_GNU_CPU), aarch64) -export ARCH=arm64 -endif -ifeq ($(DEB_HOST_GNU_CPU), riscv64) -export ARCH=riscv -endif -ifneq (,$(findstring 86,$(DEB_HOST_GNU_CPU))) -export ARCH=x86 -endif - -override_dh_auto_clean: - $(MAKE) -C $(KDIR) M=$(PWD) clean - -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 - -%: - CFLAGS= LDFLAGS= dh $@ --parallel diff --git a/meta/recipes-kernel/linux-module/files/debian/rules.tmpl b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl new file mode 100755 index 00000000..52453e5f --- /dev/null +++ b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl @@ -0,0 +1,52 @@ +#!/usr/bin/make -f + +# Debian rules for custom kernel module build +# +# This software is a part of ISAR. +# Copyright (c) Siemens AG, 2018 +# +# SPDX-License-Identifier: MIT + +export DEB_BUILD_OPTIONS=parallel=$(shell nproc) + +export CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)- + +ifeq ($(DEB_HOST_GNU_CPU), arm) +export ARCH=arm +endif +ifeq ($(DEB_HOST_GNU_CPU), aarch64) +export ARCH=arm64 +endif +ifeq ($(DEB_HOST_GNU_CPU), riscv64) +export ARCH=riscv +endif +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 some build systems like sbuild `dh clean` can be called twice: +# first, by build system itself before chroot's apt database updated, +# second, by dpkg-buildpackage during build. So, KDIR may be empty +# in first case (while no dependencies are yet installed), and a broken +# 'make ... clean' command is produced. Just skip override in this case. +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 + +%: + CFLAGS= LDFLAGS= dh $@ --parallel diff --git a/meta/recipes-kernel/linux-module/module.inc b/meta/recipes-kernel/linux-module/module.inc index 0515621a..9ae3af9b 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}/ @@ -32,17 +33,3 @@ do_prepare_build() { 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} -} -- 2.20.1