From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7057120643105423360 X-Received: by 2002:a17:907:3e24:: with SMTP id hp36mr7176181ejc.530.1644738073837; Sat, 12 Feb 2022 23:41:13 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a17:907:8d09:: with SMTP id tc9ls5030807ejc.7.gmail; Sat, 12 Feb 2022 23:41:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0OKSCo7XuF5Cj7jhvlV6cZYNIH0/5cCBUjAT847nmGZVsIlsR3kOpZclotFVQI+kgOGZ6 X-Received: by 2002:a17:906:a956:: with SMTP id hh22mr7049475ejb.577.1644738072791; Sat, 12 Feb 2022 23:41:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644738072; cv=none; d=google.com; s=arc-20160816; b=pEDxksr9C+Ap6p6ziQawJakAbHwMXu4UQ1Lt3xQ41MgArDt641c4a8JXnXWoO9d6rA mWBy2p3ckWhInEZ5g4F+nZnU11kRK8RzNxsdGExuvWUrYH/zu4lfQ0ADWZ8po5KKDsAr YGTHS2onw54rZg/EwccYp3Ov7LrXL8nohWISfpIgJSz3FejJqn3YrnYBG9WlHHyuvQv3 +A0xXsLW2oF1lRXx1CRB4jOl7ef1GnlU9db6dekhAfYdCdy/2lkBm5UJN0Eqr9M9Gz51 m+RVfGqK9ue8du3L6NroJU/OjlyTrX0Rg8wVyrzjY24tk8o0wiBWMv8Gxr14arOvcJIg h95Q== 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=lCN5795W7/5LGetBY7kfxNX5te9HZ2FkIDf3Etry6pM=; b=ch0Es1rPTtXMCAY5xsY8sT3t0oG9PTUHorLQa6q9re/C5mh1VFlAHH1guBxeHLSSy0 icNzy0Puqy5f15tyvgR/FMpowjS3yLC/+xM9TumvbypvQ4/amTbsZRtlU6yji6WN0d9Q 2HP9Y77+mcnOF4EYcXxXP//G0QUO9y6GwADCMxpt4aex3uiPbZhp4QycHhy6CDCZb9mL DIyW/jl/QYHVK7/eLFhY2viWe/MQYnctYm3lR/+0kJ3EsOsSq/4eMVrJ3k0IcTC6RlsR DbIIQe8m2g+vrbiUOAuzOA7vJi7VA40sIMNA7hVZNjSRic37iKSxzCYO5UFOyGOHKmVb etJA== 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 g4si330430ejb.0.2022.02.12.23.41.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 12 Feb 2022 23:41:12 -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 21D7fBw6010231 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 13 Feb 2022 08:41:12 +0100 From: Uladzimir Bely To: isar-users@googlegroups.com Subject: [PATCH v5 2/9] linux-module: Do not use shell environment Date: Sun, 13 Feb 2022 08:41:04 +0100 Message-Id: <20220213074111.23232-3-ubely@ilbers.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220213074111.23232-1-ubely@ilbers.de> References: <20220213074111.23232-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: SVy7uJ9Sc5iM 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 | 60 +++++++++++++++++++ meta/recipes-kernel/linux-module/module.inc | 34 +---------- 3 files changed, 63 insertions(+), 68 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..d3bd7dc3 --- /dev/null +++ b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl @@ -0,0 +1,60 @@ +#!/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 + +ifeq (${KERNEL_TYPE}, raspios) +# In RaspiOS one package provides several headers +KERNEL_SUFFIX := "+" +ifeq (${KERNEL_NAME}, kernel8) +KERNEL_SUFFIX := "-v8+" +else ifeq (${KERNEL_NAME}, kernel7l) +KERNEL_SUFFIX := "-v7l+" +else ifeq (${KERNEL_NAME}, kernel7) +KERNEL_SUFFIX := "-v7+" +endif +KDIR := $(shell dpkg -L ${KERNEL_HEADERS_PKG} | grep "/lib/modules/.*${KERNEL_SUFFIX}/build" | head -n1) +endif + +ifeq ($(KDIR),) +# Custom kernels contain the build folder directly. +KDIR := $(shell dpkg -L ${KERNEL_HEADERS_PKG} | grep "/lib/modules/.*/build") +endif +ifeq ($(KDIR),) +# Debian kernels install that folder indirectly via a dependency. +KERNEL_DEP := $(shell dpkg-query -W -f '$${Depends}' ${KERNEL_HEADERS_PKG} | sed 's/.*\(linux-headers-[[:graph:]]*\).*/\1/') +KDIR := $(shell dpkg -L $(KERNEL_DEP) | grep "/lib/modules/.*/build") +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/module.inc b/meta/recipes-kernel/linux-module/module.inc index 968ac4c7..75dc4374 100644 --- a/meta/recipes-kernel/linux-module/module.inc +++ b/meta/recipes-kernel/linux-module/module.inc @@ -24,8 +24,9 @@ AUTOLOAD ?= "" inherit dpkg TEMPLATE_FILES = "debian/control.tmpl \ - debian/changelog.tmpl" -TEMPLATE_VARS += "KERNEL_IMAGE_PKG KERNEL_HEADERS_PKG" + debian/changelog.tmpl \ + debian/rules.tmpl" +TEMPLATE_VARS += "KERNEL_NAME KERNEL_TYPE KERNEL_IMAGE_PKG KERNEL_HEADERS_PKG PN" do_prepare_build() { cp -r ${WORKDIR}/debian ${S}/ @@ -34,32 +35,3 @@ do_prepare_build() { echo "echo $module >> /etc/modules" >> ${S}/debian/postinst done } - -dpkg_runbuild_prepend() { - if [ "${KERNEL_TYPE}" = "raspios" ]; then - # In RaspiOS one package provides several headers - KERNEL_SUFFIX="+" - if [ "${KERNEL_NAME}" = "kernel8" ]; then - KERNEL_SUFFIX="-v8+" - elif [ "${KERNEL_NAME}" = "kernel7l" ]; then - KERNEL_SUFFIX="-v7l+" - elif [ "${KERNEL_NAME}" = "kernel7" ]; then - KERNEL_SUFFIX="-v7+" - fi - export KDIR=$(dpkg -L --root=${BUILDCHROOT_DIR} ${KERNEL_HEADERS_PKG} | \ - grep "/lib/modules/.*${KERNEL_SUFFIX}/build" | head -n1) - fi - if [ -z "$KDIR" ]; then - # Custom kernels contain the build folder directly. - export KDIR=$(dpkg -L --root=${BUILDCHROOT_DIR} ${KERNEL_HEADERS_PKG} | \ - grep "/lib/modules/.*/build") - fi - 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 \ - ${KERNEL_HEADERS_PKG} | 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