From patchwork Wed Apr 14 00:36:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "MOESSBAUER, Felix" X-Patchwork-Id: 417 Return-Path: Delivered-To: ilbers.mnt@gmail.com Received: by 2002:a4a:c543:0:0:0:0:0 with SMTP id j3csp3162336ooq; Wed, 14 Apr 2021 01:36:35 -0700 (PDT) X-Received: by 2002:ac2:5f6a:: with SMTP id c10mr907556lfc.286.1618389394988; Wed, 14 Apr 2021 01:36:34 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1618389394; cv=pass; d=google.com; s=arc-20160816; b=w2yPYZYaQZnYNr6nRjzuQixGlisD/pGKBTaQiF6oLOgOrBnU9nA20V7HOEuOp+lhrd O4A+uZSBJi/a9gFqg7TgIkhBFhh97qeN82YYDx2tWkz4dyG7VYE8rWwEjl98Gr+8oNaE /uIaOmBUbsSdMcVADbL5CE9eV/V2nWjrlzLiGB5jcakTde0sksFkYeTDXXdMVyVX8C+r 3hkeW9p6zO5wXrt65d3ytm9lnu7reSwKh5ui++sHjJEC4JshHdqKqYtssUkXowOhazoE NAa531XZqeO3qyYE0YD1Iy37g7lGjyxtHrxmGbOfUgZNR4qtZifM0RnXu2wyt8LjyJMg /LGw== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=Q7e1bzmElfjUctdK09Rc8OMzP+o1I1uqv9lHV7A0uBM=; b=DjxuJfSlj8hxtWhj/82nzDQYowP/7VAsnPKCP8BIFXqELdsvZu6QC7Dhh3J4RQ+Ggr HB2YVvJliWrTe6ooum+VcdB0cy2rTBwOsjNBa5OqczqrYYRlz62Im1r/uPk2rihvTfuI p78lV+1ax+X2MIYlgKSbVddwhLRBohPEZmcrvDapjgm9Tl49eGon3vQ0fyoStlLm8IkK UJfHPlQdBsPWZYjFqydZq5eoIlskTFbCSNIGbE9ECB112y87AoWupzMqjDODCVBlzu0P a0oXPYX2dRKfwZegSbs1cIKts3DaQbKMXS++/54D9p8BWbIY9yqedo3L3FJI4FRk2r8t 45Ew== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@googlegroups.com header.s=20161025 header.b=NluP3U+f; arc=pass (i=2 spf=pass spfdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of isar-users+bncbczk33mgwucrbewt3kbqmgqeww7opja@googlegroups.com designates 209.85.220.55 as permitted sender) smtp.mailfrom=isar-users+bncBCZK33MGWUCRBEWT3KBQMGQEWW7OPJA@googlegroups.com; dmarc=fail (p=NONE sp=NONE dis=NONE arc=pass) header.from=siemens.com Received: from mail-sor-f55.google.com (mail-sor-f55.google.com. [209.85.220.55]) by mx.google.com with SMTPS id u12sor2902962lji.24.2021.04.14.01.36.34 (Google Transport Security); Wed, 14 Apr 2021 01:36:34 -0700 (PDT) Received-SPF: pass (google.com: domain of isar-users+bncbczk33mgwucrbewt3kbqmgqeww7opja@googlegroups.com designates 209.85.220.55 as permitted sender) client-ip=209.85.220.55; Authentication-Results: mx.google.com; dkim=pass header.i=@googlegroups.com header.s=20161025 header.b=NluP3U+f; arc=pass (i=2 spf=pass spfdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of isar-users+bncbczk33mgwucrbewt3kbqmgqeww7opja@googlegroups.com designates 209.85.220.55 as permitted sender) smtp.mailfrom=isar-users+bncBCZK33MGWUCRBEWT3KBQMGQEWW7OPJA@googlegroups.com; dmarc=fail (p=NONE sp=NONE dis=NONE arc=pass) header.from=siemens.com ARC-Seal: i=2; a=rsa-sha256; t=1618389394; cv=pass; d=google.com; s=arc-20160816; b=luLTuSlXrfIMFaboWT7SeosFYhxdCR2IT8rvhfnqLoFe50O2uFzWHTweqqr5+SFJFm HC/dsX8MvbqGmXdSCHBI01ldM62/gQitQXv8WfRLUKEfR8XWe8t2qhXj5h7hVuuzZz1p 4sIjZC+HqM9Lo9yyHTqN0c8I+oceY9O2H0b11w9TZikk+ZmwoWO+uThF2yXkKqwwRgB0 fFao6IfXfCr8sHvCduDq2LniFDSsmOx2MtYQ04ex1yjFIXzDj+j4BIJLmivm+9OW9PvM FT4GW65d8mpDoEXHTUYK1izr5B0d0p4mByIdlxNNQo007DsqtPIIYJynUHmyOlq6sDvL /1cw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=Q7e1bzmElfjUctdK09Rc8OMzP+o1I1uqv9lHV7A0uBM=; b=NIc7GdGbk2N7x6u+VgDzuvgeMq8YYXn1KTcxQOJDwdgRUJwC5NSHs8J5dUGlMtQHgL UR0geliKVvH4JJXSTjS1DeaCYIjB47uKfksmuD4B3cU8Vucm8T9PnqS2OixQlt3O8tW1 It3jNedjAHI+LU/ndbnrP8GiVY1/D1Z2SCIMux9ElGvJfXPnsvZ1ccyyu3SDbdnz2blC ywiuSyJM67Rcq6KO3oHtIsgDVrhbI78elnSt/WaWdbuM4RAJ0e7dWr6/As4IgWZWRTww 3bNowC2CQycJ0ijf2aIgV0L8yGj0Ktv5hfMK7pOqQ9Pcvhx++xpE1VRU4D3fr1jFHhWW ZYew== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of felix.moessbauer@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=felix.moessbauer@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Q7e1bzmElfjUctdK09Rc8OMzP+o1I1uqv9lHV7A0uBM=; b=NluP3U+fRyP9FYPP1JBY8jD6W6dDDL/yhT9xaiIIfyoD6N6VaoW8Fw0uTBVFas/3Kw SmTowXlugWelQdjwaIMYbV7EcdQSe6yVZktSza/yM40DUesHpS7hysamwg/WQqOuLy6/ 8cwMVwgGDlN+h9vX4Q3bGmfhh0Fz29gb0CYMj8nuemPyCA0dZlhuQRwBEc7lNa8a2iOf Mr2DD4/4geBtlVhM/uiUHpcsNy74rYehhM1lku+VWmRwC5OWkzMG99qNPJ2NllMJ+1ZS TduOUz5NCOoMhpcyorew6tPsM7TAKMqM97GCjRRDIRzQh0ugRWW9A71pA1HqRfpZo2hr 57mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Q7e1bzmElfjUctdK09Rc8OMzP+o1I1uqv9lHV7A0uBM=; b=TUPpYyY9E66FJowRBWIDjgaA8ffioVQFpIhZ08r9n246Q7P1wjAy2xJ9ShX0ZR1uDL 4bcZMWA8ID4kCc/9ea/U/a/kBgZi4VXNFgpf1lX86PXsibEEiQAicXxdRQ5PCkabiJuW Z5FpoAUE/XBhwpciFXSjAdJ8CVDxbeBw4aTPg/cEFGa/oy5SKrA1naL2aKi7JLUb0yFT DT98DvdHUc5DBoAbyskXSxBSRLnYoyNrZkn2/OyL5h2bMSWG2LBxSllbcZPF1KTuEFhK sFVy/3Ufkp6NdPAw2sEBKl/Jq3hV7bQylJX5XQt6vb79guz0FpT52k3ok0/5X+RogvIw +/WA== Sender: isar-users@googlegroups.com X-Gm-Message-State: AOAM533Rv6P0JWYq4yRERViQODK71GlNMtlYF1wVc7qBzxiLknNM0Spt L+cbqppkItUSxz5dn95qiEQ= X-Google-Smtp-Source: ABdhPJz0/tG3LcVYlY+A2jGfFOpV/zxs0XFGhG1PnYhbany5XtHXC09MVrrlcSrle+KDKWTgP5ySoA== X-Received: by 2002:a2e:968c:: with SMTP id q12mr22729706lji.317.1618389394205; Wed, 14 Apr 2021 01:36:34 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a19:48c6:: with SMTP id v189ls1439470lfa.0.gmail; Wed, 14 Apr 2021 01:36:33 -0700 (PDT) X-Received: by 2002:ac2:44c8:: with SMTP id d8mr3532610lfm.67.1618389393257; Wed, 14 Apr 2021 01:36:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618389393; cv=none; d=google.com; s=arc-20160816; b=ALL1t4KPCfLE1lSxq0LN0evh9ICeoSq/Y2jq2S3eTg8PCRtykCjjlf0k7tV6gXVkkr y30s3WW6aFBLpJ0z3yPxcW+IBvhk2JvW0dJ2shS53l0lAClU8+acCVmLfjFcrR1yd96p ekQuDRmEG+RiIJbvqPbzuTEKQ4TNSf0WBi1K1NvRBv+Bs+xL+3O1Ic4CeL0W4WyKPnqA gWOJgmiBM+wIpu3cBtgUqoDAo+8/pPcalGGKJNToEuaYrmYJq6Pn6IE4AtO9WeYGc6vi T0yWi08ipi6IOrAtCLhw2pokf5tsXpoZUORHhlAHESaDmqAxYc6TsBZ1KLpBU8gl1Crr Vt8w== 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:cc:to:from; bh=7wNcfZtHsYbHT6t6ub6NIFBV55FtUT6MVdNYheHCAEg=; b=iv8m/3iADWtQqfzUOj2IcOavSeuk0A/pJDKBuL102hkQfZ79ti4rHpbQ7hj0wl3J69 MggRELLLh53swbI1GPqCfkcwbRQAtQpJxaCyR1o6GMUQtt+CARcBq8kSr6njC6lxD6o7 BqqXNWHH3at49lsR/i04VjdpQ6T5OR5pXoX56u3/M3MPzrNANxE8xrPg9GqlMcuMQtoM JjyDozGtaoZmIh/Kew4knur0SuwauBzUfI6umddHJc24tIkjb3k9qC0Qmf3BzpLzbcRN tLjzaZezZihC744TvAySZY8n8NQGAcIaDUPPmN5Bm5vqof15kKGakm0D/heQ8zTLTPee TB/g== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of felix.moessbauer@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=felix.moessbauer@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from gecko.sbs.de (gecko.sbs.de. [194.138.37.40]) by gmr-mx.google.com with ESMTPS id a10si1040558lfs.11.2021.04.14.01.36.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Apr 2021 01:36:33 -0700 (PDT) Received-SPF: pass (google.com: domain of felix.moessbauer@siemens.com designates 194.138.37.40 as permitted sender) client-ip=194.138.37.40; Received: from mail1.sbs.de (mail1.sbs.de [192.129.41.35]) by gecko.sbs.de (8.15.2/8.15.2) with ESMTPS id 13E8aWJM015525 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 14 Apr 2021 10:36:32 +0200 Received: from MD1T0KAC-VM.ad001.siemens.net (md1t0kac.ad001.siemens.net [139.25.0.7]) by mail1.sbs.de (8.15.2/8.15.2) with ESMTP id 13E8aPej023005; Wed, 14 Apr 2021 10:36:32 +0200 From: Felix Moessbauer To: isar-users@googlegroups.com Cc: henning.schild@siemens.com, jan.kiszka@siemens.com, Felix Moessbauer Subject: [PATCH 1/1] Add support to build binary version of DKMS kernel modules Date: Wed, 14 Apr 2021 10:36:17 +0200 Message-Id: <20210414083617.20940-2-felix.moessbauer@siemens.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210414083617.20940-1-felix.moessbauer@siemens.com> References: <20210414083617.20940-1-felix.moessbauer@siemens.com> MIME-Version: 1.0 X-Original-Sender: felix.moessbauer@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of felix.moessbauer@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=felix.moessbauer@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Precedence: list Mailing-list: list isar-users@googlegroups.com; contact isar-users+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: isar-users@googlegroups.com X-Google-Group-Id: 914930254986 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1697004278364144218?= X-GMAIL-MSGID: =?utf-8?q?1697004278364144218?= 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 --- .../example-dkms-module/igb-uio_20.11.bb | 14 ++++ meta/classes/dkms-module.bbclass | 68 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 meta-isar/recipes-kernel/example-dkms-module/igb-uio_20.11.bb create mode 100644 meta/classes/dkms-module.bbclass diff --git a/meta-isar/recipes-kernel/example-dkms-module/igb-uio_20.11.bb b/meta-isar/recipes-kernel/example-dkms-module/igb-uio_20.11.bb new file mode 100644 index 0000000..abb9922 --- /dev/null +++ b/meta-isar/recipes-kernel/example-dkms-module/igb-uio_20.11.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, 2018 +# +# SPDX-License-Identifier: MIT + +inherit dkms-module + +PN .= "-${KERNEL_NAME}" + +#package name (without -dkms. E.g "dpdk-kmods" for package "dpdk-kmods-dkms") +DKMS_PACKAGE_NAME = "dpdk-kmods" +AUTOLOAD += "igb_uio" diff --git a/meta/classes/dkms-module.bbclass b/meta/classes/dkms-module.bbclass new file mode 100644 index 0000000..d1dbba9 --- /dev/null +++ b/meta/classes/dkms-module.bbclass @@ -0,0 +1,68 @@ +# 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}, ${DKMS_PACKAGE_NAME}-dkms," + +# 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 + REVISION=$(find ${BUILDCHROOT_DIR}/usr/src/${DKMS_PACKAGE_NAME}-* -type d -exec basename {} + | sed 's/${DKMS_PACKAGE_NAME}-//g') + if ! dpkg -s --root=${BUILDCHROOT_DIR} linux-headers-${KERNEL_NAME} | grep "Depends:.*linux-headers"; then + # 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 + sudo sed -i 's/, linux-image-KERNEL_VERSION//' ${BUILDCHROOT_DIR}/etc/dkms/template-dkms-mkbmdeb/debian/control + fi + # build the module for all installed kernels (should be just one) + sudo -E chroot ${BUILDCHROOT_DIR} dkms mkbmdeb ${DKMS_PACKAGE_NAME}/${REVISION} --all + 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