From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6950929522725224448 X-Received: by 2002:adf:e686:: with SMTP id r6mr8122467wrm.187.1619803160859; Fri, 30 Apr 2021 10:19:20 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a5d:6da1:: with SMTP id u1ls5727166wrs.1.gmail; Fri, 30 Apr 2021 10:19:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxypi6+gdusEgAhNmZ9zKDI7HtPfOtWFbOdtwnMlHP0pRMiS1jLZaaY3C2me8P1TbIVgPt+ X-Received: by 2002:a05:6000:108f:: with SMTP id y15mr3510842wrw.115.1619803159979; Fri, 30 Apr 2021 10:19:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619803159; cv=none; d=google.com; s=arc-20160816; b=u0yK8PjQbmJR8al7JzkqYPKPjh5OX8vVOz97NVJ3JSEr9IPeU72tP9At9/z2kbA0XT esjCkP5aDf64XXBuHdLNY7atmTE/3fd+Fdz85McEepeMXr9XSuUPTCj7FWWxs0200P1b fF8c8c4+muxYMyCQL1XsRgd1EqFsMDQAs8d809dV9eVcY1tKBpOwEf4NadAwEE7P/LXI Xq6EYNFD/EfgZAm8LLCDicyY59Dz0T14bPSziGWX3wReOGkG52TOq4c/31Eu8NghV/Oq VLjgxTn+yBNY2hXnD0QbHRDEvpzqUlmVzSGwc25RbLD6oUIQ3eRx8fCO3q2RVHvytfeq 4zGA== 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:subject:cc:to:from:date; bh=J4FDDvNxvgKEjePXxz4wdG6pzWJh3HmCzT76WwDfHEs=; b=EEJMjCoiezSQ+eIl9xKJxZw/aie+QnBnEGV0+Xon1DnOcj9Q/JWtf4TFhdO249ekmJ nHLi7tZN1PrjuhdwkCr/L0p69Y0xqH5hzBsLdq2VkYbikFnMUXPcqWbGGa5zW3UEmXtR XRPa4QPJiSGC51xgitzA5oJN224BaUWLVRPNC9DbouxDvUQLB938FhEylEuRLpF40Jdy Mb217M2opnLpd1l8iu/6AU8osGHVQpxUBwJLB13+t9F00MuCGfn5hBPW+W8BE3uwhpyP HQ5qcnQRwsu3eRRb2Vjp+vxn31FumbDOm40Yc6+cez608hiOcbdgPkaQbZ57nbpRDXjP Bufw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=henning.schild@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from lizzard.sbs.de (lizzard.sbs.de. [194.138.37.39]) by gmr-mx.google.com with ESMTPS id c9si485426wml.2.2021.04.30.10.19.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Apr 2021 10:19:19 -0700 (PDT) Received-SPF: pass (google.com: domain of henning.schild@siemens.com designates 194.138.37.39 as permitted sender) client-ip=194.138.37.39; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=henning.schild@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by lizzard.sbs.de (8.15.2/8.15.2) with ESMTPS id 13UHJJos012160 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 30 Apr 2021 19:19:19 +0200 Received: from md1za8fc.ad001.siemens.net ([167.87.44.242]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 13UHJJTw018574; Fri, 30 Apr 2021 19:19:19 +0200 Date: Fri, 30 Apr 2021 19:19:18 +0200 From: Henning Schild To: Felix Moessbauer Cc: , Subject: Re: [PATCH v3 1/1] Add support to build binary version of DKMS kernel modules Message-ID: <20210430191918.54c897e4@md1za8fc.ad001.siemens.net> In-Reply-To: <20210430140252.8624-2-felix.moessbauer@siemens.com> References: <20210430140252.8624-1-felix.moessbauer@siemens.com> <20210430140252.8624-2-felix.moessbauer@siemens.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TUID: gbahchuRpq3M Hi Felix, one generic question ... does this potentially also have sort of a "apt-get update" problem? Say we build with isar and deploy a package feed to our target, would that target be able to update its kernel and the package ... having both module versions installed and working depending which kernel is booted? Am Fri, 30 Apr 2021 16:02:52 +0200 schrieb Felix Moessbauer : > This patch adds support to build and install a kernel module that is > available via a debian DKMS package. > As it is hard to directly build and install the package we create and > distribute a meta package that is independent of the kernel version. > In that package, we depend on the versioned prebuild kernel module > package. > > To build the dkms module, we add two tasks and directly > use dkms to build the debian package containing the binary module > Then we just copy the binary-module debian package to the workdir, > > Signed-off-by: Felix Moessbauer > --- > meta-isar/conf/local.conf.sample | 5 +- > .../example-dkms-module.bb | 14 ++++ > meta/classes/dkms-module.bbclass | 76 > +++++++++++++++++++ scripts/ci_build.sh | > 1 + 4 files changed, 95 insertions(+), 1 deletion(-) > create mode 100644 > meta-isar/recipes-kernel/example-dkms-module/example-dkms-module.bb > create mode 100644 meta/classes/dkms-module.bbclass > > diff --git a/meta-isar/conf/local.conf.sample > b/meta-isar/conf/local.conf.sample index 77585ec..67a98d6 100644 > --- a/meta-isar/conf/local.conf.sample > +++ b/meta-isar/conf/local.conf.sample > @@ -178,7 +178,10 @@ CONF_VERSION = "1" > > # > # The default list of extra packages to be installed. > -IMAGE_INSTALL = "hello-isar example-raw > example-module-${KERNEL_NAME} enable-fsck isar-exclude-docs samefile > hello isar-disable-apt-cache cowsay example-prebuilt" +IMAGE_INSTALL > = "hello-isar example-raw example-module-${KERNEL_NAME} > example-dkms-module-${KERNEL_NAME} enable-fsck isar-exclude-docs > samefile hello isar-disable-apt-cache cowsay example-prebuilt" + +# > v4l2loopback module does not build on armhf > +IMAGE_INSTALL_remove_armhf = "example-dkms-module-${KERNEL_NAME}" # > # Enable cross-compilation support diff --git > a/meta-isar/recipes-kernel/example-dkms-module/example-dkms-module.bb > b/meta-isar/recipes-kernel/example-dkms-module/example-dkms-module.bb > new file mode 100644 index 0000000..113f232 --- /dev/null > +++ > b/meta-isar/recipes-kernel/example-dkms-module/example-dkms-module.bb > @@ -0,0 +1,14 @@ +# Example recipe for building the binary version of > a DKMS module +# > +# This software is a part of ISAR. > +# Copyright (c) Siemens AG, 2021 > +# > +# SPDX-License-Identifier: MIT > + > +inherit dkms-module > + > +PN .= "-${KERNEL_NAME}" > + > +#package name (without -dkms. E.g "v4l2loopback" for package > "v4l2loopback-dkms") +DKMS_PACKAGE_NAME = "v4l2loopback" > +AUTOLOAD += "v4l2loopback" > diff --git a/meta/classes/dkms-module.bbclass > b/meta/classes/dkms-module.bbclass new file mode 100644 > index 0000000..283bff7 > --- /dev/null > +++ b/meta/classes/dkms-module.bbclass > @@ -0,0 +1,76 @@ > +# This software is a part of ISAR. > +# Copyright (C) 2021 Siemens AG > +# > +# SPDX-License-Identifier: MIT > + > +inherit dpkg-raw > + > +# Build and install a kernel module that is available via a debian > DKMS package. +# As it is hard to directly build and install the > package we create and distribute +# a meta package that is > independent of the kernel version. +# In that package, we depend on > the versioned prebuild kernel module package. +# > +# To build the dkms module, we add two tasks and directly > +# use dkms to build the debian package containing the binary module > +# Then we just copy the binary-module debian package to the workdir, > +# so ISAR's do_deploy_deb picks it up. > + > +#package name (without -dkms. E.g "dpdk-kmods" for package > "dpdk-kmods-dkms") +DKMS_PACKAGE_NAME ?= "" > +AUTOLOAD ?= "" > + > +DESCRIPTION ?= "Kernel module from DKMS package for ${PN}" > +DEPENDS += "linux-headers-${KERNEL_NAME}" > +DEBIAN_DEPENDS += "${DKMS_PACKAGE_NAME}-modules," > +DEBIAN_BUILD_DEPENDS += "linux-headers-${KERNEL_NAME}, why do those three to += ? i would imagine a recipe using += or a class using ?= > ${DKMS_PACKAGE_NAME}-dkms," + > +ISAR_CROSS_COMPILE = "0" > + > +# install configuration to auto-load the modules in ${AUTOLOAD} > +do_install() { > + # auto load the module > + install -v -d ${D}/etc/modules-load.d > + for module in "${AUTOLOAD}"; do > + echo $module > ${D}/etc/modules-load.d/${PN}.conf > + done > +} > + > +# build the binary kernel module and package as debian package > (versioned) +do_module_build() { > + # we have to find out the module version, e.g. > dpdk-kmods/0~20201113+git -k 5.10.0-3-rt-amd64/x86_64 switch comment to v4l? > + REVISION=$(find > ${BUILDCHROOT_DIR}/usr/src/${DKMS_PACKAGE_NAME}-* -type d -exec > basename {} + | sed 's/${DKMS_PACKAGE_NAME}-//g') > + DKMS_ARCH=$(echo ${DISTRO_ARCH} | sed 's/amd64/x86_64/g' | sed > 's/arm64/aarch64/g' | sed 's/i386/i686/g') > + if ! dpkg -s --root=${BUILDCHROOT_DIR} > linux-headers-${KERNEL_NAME} | grep "Depends:.*linux-headers"; then can be convice that first command to use a format we do not need to parse with grep? Along the lines of "dpkg-deb --show --showformat '${Version}'" > + # custom kernels directly place their files in > linux-image-KERNEL-NAME, instead > + # of using a meta package + a versioned package with the > resources > + # The prebuild DKMS binary package depends on the versioned > kernel package, > + # but that is not available on custom kernels. Hence, we > just remove the dependency. > + bbnote "Building ${DKMS_PACKAGE_NAME} for custom kernel > ${KERNEL_NAME}" > + cp > ${BUILDCHROOT_DIR}/etc/dkms/template-dkms-mkbmdeb/debian/control > ${WORKDIR}/control.dkms.orig good idea to keep that backup, but i guess if we run this task twice because it failed inbetween, that might not work usual solutions are "rm -rf" or [cleandirs] ... maybe that is in here but i did not see it Henning > + sudo sed -i 's/, linux-image-KERNEL_VERSION//' > ${BUILDCHROOT_DIR}/etc/dkms/template-dkms-mkbmdeb/debian/control > + KERNEL_FULLNAME=${KERNEL_NAME} > + else > + KERNEL_FULLNAME=$(dpkg -s --root=${BUILDCHROOT_DIR} > linux-headers-${KERNEL_NAME} | grep "Depends:.*linux-headers" | sed > 's/Depends: linux-headers-//g') > + bbnote "Building for kernel $KERNEL_FULLNAME" > + fi > + # build the module for all installed kernels (should be just one) > + sudo -E chroot ${BUILDCHROOT_DIR} dkms build > ${DKMS_PACKAGE_NAME}/${REVISION} -k ${KERNEL_FULLNAME}/${DKMS_ARCH} > + sudo -E chroot ${BUILDCHROOT_DIR} dkms mkbmdeb > ${DKMS_PACKAGE_NAME}/${REVISION} -k ${KERNEL_FULLNAME}/${DKMS_ARCH} > + DKMS_PACKAGE_VERSIONED=$(find > ${BUILDCHROOT_DIR}/var/lib/dkms/${DKMS_PACKAGE_NAME}/ -name > "${DKMS_PACKAGE_NAME}-modules*.deb" -exec dpkg -I {} + | grep > "Package:" | awk '{print $2}') > + if [ -z "$DKMS_PACKAGE_VERSIONED" ]; then > + bberror "No prebuild dkms module found" > + exit 1 > + fi > + # restore dkms template (if any) > + cp ${WORKDIR}/control.dkms.orig > ${BUILDCHROOT_DIR}/etc/dkms/template-dkms-mkbmdeb/debian/control || > true +} + > +# simply copy our module from the build tree to the expected output > location +# of this recipe. Then, do_deploy_dep finds it and adds it > to the +# debian isar repo > +do_module_deploy() { > + cp > ${BUILDCHROOT_DIR}/var/lib/dkms/${DKMS_PACKAGE_NAME}/*/bmdeb/*.deb > ${S}/../ +} + > +addtask module_build after do_install_builddeps before do_dpkg_build > +addtask module_deploy after do_module_build before do_deploy_deb > diff --git a/scripts/ci_build.sh b/scripts/ci_build.sh > index adc22e4..1426569 100755 > --- a/scripts/ci_build.sh > +++ b/scripts/ci_build.sh > @@ -259,6 +259,7 @@ mv > ${BUILDDIR}/tmp/deploy/images/qemuamd64/isar-image-base-debian-stretch-qemuam > # Finalize with containerized images, since they remove some > not-needed packages from the local.conf sed -i -e 's/\(IMAGE_INSTALL > = .*\) example-module-${KERNEL_NAME}\(.*\)/\1\2/g' conf/local.conf > +sed -i -e 's/\(IMAGE_INSTALL = .*\) > example-dkms-module-${KERNEL_NAME}\(.*\)/\1\2/g' conf/local.conf sed > -i -e 's/\(IMAGE_INSTALL = .*\) enable-fsck\(.*\)/\1\2/g' > conf/local.conf bitbake $BB_ARGS $TARGETS_CONTAINERS while [ -e > bitbake.sock ]; do sleep 1; done