* [PATCH 0/1] Add support to build binary version of DKMS kernel @ 2021-04-14 8:36 Felix Moessbauer 2021-04-14 8:36 ` [PATCH 1/1] Add support to build binary version of DKMS kernel modules Felix Moessbauer 0 siblings, 1 reply; 18+ messages in thread From: Felix Moessbauer @ 2021-04-14 8:36 UTC (permalink / raw) To: isar-users; +Cc: henning.schild, jan.kiszka, Felix Moessbauer DKMS kernel modules provide a way to deliver the sources of a kernel module along with a machine readable specification of how to build the module for the currently active kernel. Debian already ships a lot of kernel modules as DKMS packages. For embedded images, these DKMS modules are not really an option, as it would require the image to provide a compiler and build system as well. For this use-case, DKMS provides a way to pre-build a binary version of the module for a specific kernel and ship that as a debian package. Note, that this support is not implemented as part of the debhelpers, but by DKMS itself. This series adds support for the described use-case in ISAR. By that, upstream DKMS modules can be fetched and build for the image's kernel in ISAR. The generated binary package can then be installed onto the target image. To show how to use that, an example is provided in meta-isar. Best regards, Felix Moessbauer Felix Moessbauer (1): Add support to build binary version of DKMS kernel modules .../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 -- 2.20.1 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 1/1] Add support to build binary version of DKMS kernel modules 2021-04-14 8:36 [PATCH 0/1] Add support to build binary version of DKMS kernel Felix Moessbauer @ 2021-04-14 8:36 ` Felix Moessbauer 2021-04-14 8:52 ` Henning Schild 2021-04-22 10:44 ` Anton Mikanovich 0 siblings, 2 replies; 18+ messages in thread From: Felix Moessbauer @ 2021-04-14 8:36 UTC (permalink / raw) To: isar-users; +Cc: henning.schild, jan.kiszka, 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 <felix.moessbauer@siemens.com> --- .../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 -- 2.20.1 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/1] Add support to build binary version of DKMS kernel modules 2021-04-14 8:36 ` [PATCH 1/1] Add support to build binary version of DKMS kernel modules Felix Moessbauer @ 2021-04-14 8:52 ` Henning Schild 2021-04-14 9:03 ` Jan Kiszka 2021-04-22 10:44 ` Anton Mikanovich 1 sibling, 1 reply; 18+ messages in thread From: Henning Schild @ 2021-04-14 8:52 UTC (permalink / raw) To: Felix Moessbauer; +Cc: isar-users, jan.kiszka Hi Felix, thanks for pushing this one upstream. We will need a testcase for it, so make sure to enter into "scripts/ci_build.sh" I would suggest the virtualbox modules or maybe vmware modules instead. This way we would probably have more distro coverage and in fact have a useful example for people doing virtualbox (the one i would prefer). Not sure that is possible or why you picked dpdk. Am Wed, 14 Apr 2021 10:36:17 +0200 schrieb Felix Moessbauer <felix.moessbauer@siemens.com>: > 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 <felix.moessbauer@siemens.com> > --- > .../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 I think this might need an "update-initramfs -u" in postinst, but i am not sure, check the other autoloader code and see if you can share. Such modules probably do not need early loading in initrd, but "/etc/modules-load.d" is mirrored into the initrd so we should not get out of sync. It is important that both autoloaders do the same or similar things, initrd could stay open if the other one also does not care. Henning > +} > + > +# 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 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/1] Add support to build binary version of DKMS kernel modules 2021-04-14 8:52 ` Henning Schild @ 2021-04-14 9:03 ` Jan Kiszka 2021-04-15 12:26 ` Henning Schild 0 siblings, 1 reply; 18+ messages in thread From: Jan Kiszka @ 2021-04-14 9:03 UTC (permalink / raw) To: Henning Schild, Felix Moessbauer; +Cc: isar-users On 14.04.21 10:52, Henning Schild wrote: > Hi Felix, > > thanks for pushing this one upstream. > > We will need a testcase for it, so make sure to enter into > "scripts/ci_build.sh" > > I would suggest the virtualbox modules or maybe vmware modules instead. > This way we would probably have more distro coverage and in fact have a > useful example for people doing virtualbox (the one i would prefer). > Not sure that is possible or why you picked dpdk. None of those crappy modules will build on non-x86. We should look for a portable example. Jan > > Am Wed, 14 Apr 2021 10:36:17 +0200 > schrieb Felix Moessbauer <felix.moessbauer@siemens.com>: > >> 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 <felix.moessbauer@siemens.com> >> --- >> .../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 > > I think this might need an "update-initramfs -u" in postinst, but i am > not sure, check the other autoloader code and see if you can share. > Such modules probably do not need early loading in initrd, but > "/etc/modules-load.d" is mirrored into the initrd so we should not get > out of sync. > It is important that both autoloaders do the same or similar things, > initrd could stay open if the other one also does not care. > > Henning > >> +} >> + >> +# 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 > -- Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/1] Add support to build binary version of DKMS kernel modules 2021-04-14 9:03 ` Jan Kiszka @ 2021-04-15 12:26 ` Henning Schild 2021-04-15 12:41 ` Raphael Lisicki 2021-04-15 12:52 ` Jan Kiszka 0 siblings, 2 replies; 18+ messages in thread From: Henning Schild @ 2021-04-15 12:26 UTC (permalink / raw) To: Jan Kiszka; +Cc: Felix Moessbauer, isar-users Am Wed, 14 Apr 2021 11:03:50 +0200 schrieb Jan Kiszka <jan.kiszka@siemens.com>: > On 14.04.21 10:52, Henning Schild wrote: > > Hi Felix, > > > > thanks for pushing this one upstream. > > > > We will need a testcase for it, so make sure to enter into > > "scripts/ci_build.sh" > > > > I would suggest the virtualbox modules or maybe vmware modules > > instead. This way we would probably have more distro coverage and > > in fact have a useful example for people doing virtualbox (the one > > i would prefer). Not sure that is possible or why you picked dpdk. > > None of those crappy modules will build on non-x86. We should look > for a portable example. Yes ideally we find a dkms package that exists on all distros and arches, not sure that exists. Would also allow testing the Isar crossbuild on that feature. If cross causes issues ISAR_CROSS_COMPILE = "0" in the class might be acceptable, would be to me. If we do not find such a generic module, all i said is that vbox is probably more useful than igb_uio. And probably more available across distros. Henning > Jan > > > > > Am Wed, 14 Apr 2021 10:36:17 +0200 > > schrieb Felix Moessbauer <felix.moessbauer@siemens.com>: > > > >> 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 <felix.moessbauer@siemens.com> > >> --- > >> .../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 > > > > I think this might need an "update-initramfs -u" in postinst, but i > > am not sure, check the other autoloader code and see if you can > > share. Such modules probably do not need early loading in initrd, > > but "/etc/modules-load.d" is mirrored into the initrd so we should > > not get out of sync. > > It is important that both autoloaders do the same or similar things, > > initrd could stay open if the other one also does not care. > > > > Henning > > > >> +} > >> + > >> +# 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 > > > ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/1] Add support to build binary version of DKMS kernel modules 2021-04-15 12:26 ` Henning Schild @ 2021-04-15 12:41 ` Raphael Lisicki 2021-04-15 12:52 ` Jan Kiszka 1 sibling, 0 replies; 18+ messages in thread From: Raphael Lisicki @ 2021-04-15 12:41 UTC (permalink / raw) To: [ext] Henning Schild, Jan Kiszka; +Cc: Felix Moessbauer, isar-users Hi, maybe V4L2 loopback could be this example module: https://packages.debian.org/buster/v4l2loopback-dkms best regards Raphael On 15.04.21 14:26, [ext] Henning Schild wrote: > Am Wed, 14 Apr 2021 11:03:50 +0200 > schrieb Jan Kiszka <jan.kiszka@siemens.com>: > >> On 14.04.21 10:52, Henning Schild wrote: >>> Hi Felix, >>> >>> thanks for pushing this one upstream. >>> >>> We will need a testcase for it, so make sure to enter into >>> "scripts/ci_build.sh" >>> >>> I would suggest the virtualbox modules or maybe vmware modules >>> instead. This way we would probably have more distro coverage and >>> in fact have a useful example for people doing virtualbox (the one >>> i would prefer). Not sure that is possible or why you picked dpdk. >> >> None of those crappy modules will build on non-x86. We should look >> for a portable example. > > Yes ideally we find a dkms package that exists on all distros and > arches, not sure that exists. Would also allow testing the Isar > crossbuild on that feature. > > If cross causes issues ISAR_CROSS_COMPILE = "0" in the class might be > acceptable, would be to me. > > If we do not find such a generic module, all i said is that vbox is > probably more useful than igb_uio. And probably more available across > distros. > > Henning > > >> Jan >> >>> >>> Am Wed, 14 Apr 2021 10:36:17 +0200 >>> schrieb Felix Moessbauer <felix.moessbauer@siemens.com>: >>> >>>> 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 <felix.moessbauer@siemens.com> >>>> --- >>>> .../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 >>> >>> I think this might need an "update-initramfs -u" in postinst, but i >>> am not sure, check the other autoloader code and see if you can >>> share. Such modules probably do not need early loading in initrd, >>> but "/etc/modules-load.d" is mirrored into the initrd so we should >>> not get out of sync. >>> It is important that both autoloaders do the same or similar things, >>> initrd could stay open if the other one also does not care. >>> >>> Henning >>> >>>> +} >>>> + >>>> +# 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 >>> >> > ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/1] Add support to build binary version of DKMS kernel modules 2021-04-15 12:26 ` Henning Schild 2021-04-15 12:41 ` Raphael Lisicki @ 2021-04-15 12:52 ` Jan Kiszka 2021-04-19 12:45 ` Moessbauer, Felix 1 sibling, 1 reply; 18+ messages in thread From: Jan Kiszka @ 2021-04-15 12:52 UTC (permalink / raw) To: Henning Schild; +Cc: Felix Moessbauer, isar-users On 15.04.21 14:26, Henning Schild wrote: > Am Wed, 14 Apr 2021 11:03:50 +0200 > schrieb Jan Kiszka <jan.kiszka@siemens.com>: > >> On 14.04.21 10:52, Henning Schild wrote: >>> Hi Felix, >>> >>> thanks for pushing this one upstream. >>> >>> We will need a testcase for it, so make sure to enter into >>> "scripts/ci_build.sh" >>> >>> I would suggest the virtualbox modules or maybe vmware modules >>> instead. This way we would probably have more distro coverage and >>> in fact have a useful example for people doing virtualbox (the one >>> i would prefer). Not sure that is possible or why you picked dpdk. >> >> None of those crappy modules will build on non-x86. We should look >> for a portable example. > > Yes ideally we find a dkms package that exists on all distros and > arches, not sure that exists. Would also allow testing the Isar > crossbuild on that feature. > > If cross causes issues ISAR_CROSS_COMPILE = "0" in the class might be > acceptable, would be to me. > Would enforce CROSS = "0" on a potential custom kernel as well, just to remind this. Jan > If we do not find such a generic module, all i said is that vbox is > probably more useful than igb_uio. And probably more available across > distros. > > Henning > > >> Jan >> >>> >>> Am Wed, 14 Apr 2021 10:36:17 +0200 >>> schrieb Felix Moessbauer <felix.moessbauer@siemens.com>: >>> >>>> 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 <felix.moessbauer@siemens.com> >>>> --- >>>> .../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 >>> >>> I think this might need an "update-initramfs -u" in postinst, but i >>> am not sure, check the other autoloader code and see if you can >>> share. Such modules probably do not need early loading in initrd, >>> but "/etc/modules-load.d" is mirrored into the initrd so we should >>> not get out of sync. >>> It is important that both autoloaders do the same or similar things, >>> initrd could stay open if the other one also does not care. >>> >>> Henning >>> >>>> +} >>>> + >>>> +# 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 >>> >> > -- Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 18+ messages in thread
* RE: [PATCH 1/1] Add support to build binary version of DKMS kernel modules 2021-04-15 12:52 ` Jan Kiszka @ 2021-04-19 12:45 ` Moessbauer, Felix 2021-04-19 13:33 ` Jan Kiszka 0 siblings, 1 reply; 18+ messages in thread From: Moessbauer, Felix @ 2021-04-19 12:45 UTC (permalink / raw) To: jan.kiszka, henning.schild; +Cc: isar-users Hi, I just added it to the CI and did some early tests with the v4l2loopback module. For x86 and arm64, things run smooth, but for armv7 the module cannot be build (even after disabling crossbuilds). This seems to be not an ISAR issue, but an upstream bug in the module DKMS itself. I'll have a closer look at that and push a v2 soon. Best regards, Felix > -----Original Message----- > From: Jan Kiszka <jan.kiszka@siemens.com> > Sent: Thursday, April 15, 2021 2:53 PM > To: Schild, Henning (T RDA IOT SES-DE) <henning.schild@siemens.com> > Cc: Moessbauer, Felix (T RDA IOT SES-DE) <felix.moessbauer@siemens.com>; > isar-users@googlegroups.com > Subject: Re: [PATCH 1/1] Add support to build binary version of DKMS kernel > modules > > On 15.04.21 14:26, Henning Schild wrote: > > Am Wed, 14 Apr 2021 11:03:50 +0200 > > schrieb Jan Kiszka <jan.kiszka@siemens.com>: > > > >> On 14.04.21 10:52, Henning Schild wrote: > >>> Hi Felix, > >>> > >>> thanks for pushing this one upstream. > >>> > >>> We will need a testcase for it, so make sure to enter into > >>> "scripts/ci_build.sh" > >>> > >>> I would suggest the virtualbox modules or maybe vmware modules > >>> instead. This way we would probably have more distro coverage and in > >>> fact have a useful example for people doing virtualbox (the one i > >>> would prefer). Not sure that is possible or why you picked dpdk. > >> > >> None of those crappy modules will build on non-x86. We should look > >> for a portable example. > > > > Yes ideally we find a dkms package that exists on all distros and > > arches, not sure that exists. Would also allow testing the Isar > > crossbuild on that feature. > > > > If cross causes issues ISAR_CROSS_COMPILE = "0" in the class might be > > acceptable, would be to me. > > > > Would enforce CROSS = "0" on a potential custom kernel as well, just to remind > this. > > Jan > > > If we do not find such a generic module, all i said is that vbox is > > probably more useful than igb_uio. And probably more available across > > distros. > > > > Henning > > > > > >> Jan > >> > >>> > >>> Am Wed, 14 Apr 2021 10:36:17 +0200 > >>> schrieb Felix Moessbauer <felix.moessbauer@siemens.com>: > >>> > >>>> 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 <felix.moessbauer@siemens.com> > >>>> --- > >>>> .../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 > >>> > >>> I think this might need an "update-initramfs -u" in postinst, but i > >>> am not sure, check the other autoloader code and see if you can > >>> share. Such modules probably do not need early loading in initrd, > >>> but "/etc/modules-load.d" is mirrored into the initrd so we should > >>> not get out of sync. > >>> It is important that both autoloaders do the same or similar things, > >>> initrd could stay open if the other one also does not care. > >>> > >>> Henning > >>> > >>>> +} > >>>> + > >>>> +# 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/*.de > b > >>>> ${S}/../ +} + > >>>> +addtask module_build after do_install_builddeps before > >>>> do_dpkg_build +addtask module_deploy after do_module_build before > >>>> do_deploy_deb > >>> > >> > > > > -- > Siemens AG, T RDA IOT > Corporate Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/1] Add support to build binary version of DKMS kernel modules 2021-04-19 12:45 ` Moessbauer, Felix @ 2021-04-19 13:33 ` Jan Kiszka 0 siblings, 0 replies; 18+ messages in thread From: Jan Kiszka @ 2021-04-19 13:33 UTC (permalink / raw) To: Moessbauer, Felix (T RDA IOT SES-DE), Schild, Henning (T RDA IOT SES-DE) Cc: isar-users On 19.04.21 14:45, Moessbauer, Felix (T RDA IOT SES-DE) wrote: > Hi, > > I just added it to the CI and did some early tests with the v4l2loopback module. > For x86 and arm64, things run smooth, but for armv7 the module cannot be build (even after disabling crossbuilds). > > This seems to be not an ISAR issue, but an upstream bug in the module DKMS itself. > > I'll have a closer look at that and push a v2 soon. If it is an upstream bug, excluding that arch for now (with reference to the Debian bug) would be fine. Jan -- Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/1] Add support to build binary version of DKMS kernel modules 2021-04-14 8:36 ` [PATCH 1/1] Add support to build binary version of DKMS kernel modules Felix Moessbauer 2021-04-14 8:52 ` Henning Schild @ 2021-04-22 10:44 ` Anton Mikanovich 2021-04-22 16:02 ` [PATCH v2 0/1] " Felix Moessbauer ` (3 more replies) 1 sibling, 4 replies; 18+ messages in thread From: Anton Mikanovich @ 2021-04-22 10:44 UTC (permalink / raw) To: Felix Moessbauer, isar-users; +Cc: henning.schild, jan.kiszka 14.04.2021 11:36, Felix Moessbauer wrote: > 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 Should it be 2021 maybe? > +# > +# 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" -- Anton Mikanovich Promwad Ltd. External service provider of ilbers GmbH Maria-Merian-Str. 8 85521 Ottobrunn, Germany +49 (89) 122 67 24-0 Commercial register Munich, HRB 214197 General Manager: Baurzhan Ismagulov ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 0/1] Add support to build binary version of DKMS kernel modules 2021-04-22 10:44 ` Anton Mikanovich @ 2021-04-22 16:02 ` Felix Moessbauer 2021-04-23 6:03 ` Jan Kiszka 2021-04-22 16:02 ` [PATCH v2 1/1] " Felix Moessbauer ` (2 subsequent siblings) 3 siblings, 1 reply; 18+ messages in thread From: Felix Moessbauer @ 2021-04-22 16:02 UTC (permalink / raw) To: isar-users, amikan, jan.kiszka; +Cc: henning.schild, Felix Moessbauer Hi Jan, Hi Anton, thanks for the review comments. These are now reflected in version 2. Unfortunately, the v4l2loopback module does not compile on armhf. This seems to be an upstream bug. Is there a way to disable the recipe just for this architecture? Changes since v1: - add example to local.conf.sample (for CI) - disable crossbuilds - fix copyright header Best regards, Felix Felix Moessbauer (1): Add support to build binary version of DKMS kernel modules meta-isar/conf/local.conf.sample | 2 +- .../example-dkms-module.bb | 14 ++++ meta/classes/dkms-module.bbclass | 70 +++++++++++++++++++ scripts/ci_build.sh | 1 + 4 files changed, 86 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 -- 2.20.1 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 0/1] Add support to build binary version of DKMS kernel modules 2021-04-22 16:02 ` [PATCH v2 0/1] " Felix Moessbauer @ 2021-04-23 6:03 ` Jan Kiszka 0 siblings, 0 replies; 18+ messages in thread From: Jan Kiszka @ 2021-04-23 6:03 UTC (permalink / raw) To: Felix Moessbauer, isar-users, amikan; +Cc: henning.schild On 22.04.21 18:02, Felix Moessbauer wrote: > Hi Jan, > Hi Anton, > > thanks for the review comments. These are now reflected in version 2. > Unfortunately, the v4l2loopback module does not compile on armhf. > This seems to be an upstream bug. Is there a way to disable the recipe just for this architecture? > IMAGE_INSTALL_remove_armhf in local.conf.sample could be an option. Jan > Changes since v1: > > - add example to local.conf.sample (for CI) > - disable crossbuilds > - fix copyright header > > Best regards, > Felix > > Felix Moessbauer (1): > Add support to build binary version of DKMS kernel modules > > meta-isar/conf/local.conf.sample | 2 +- > .../example-dkms-module.bb | 14 ++++ > meta/classes/dkms-module.bbclass | 70 +++++++++++++++++++ > scripts/ci_build.sh | 1 + > 4 files changed, 86 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 > -- Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 1/1] Add support to build binary version of DKMS kernel modules 2021-04-22 10:44 ` Anton Mikanovich 2021-04-22 16:02 ` [PATCH v2 0/1] " Felix Moessbauer @ 2021-04-22 16:02 ` Felix Moessbauer 2021-04-26 16:16 ` [PATCH v3 0/1] " Felix Moessbauer 2021-04-26 16:16 ` [PATCH v3 1/1] " Felix Moessbauer 3 siblings, 0 replies; 18+ messages in thread From: Felix Moessbauer @ 2021-04-22 16:02 UTC (permalink / raw) To: isar-users, amikan, jan.kiszka; +Cc: henning.schild, 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 <felix.moessbauer@siemens.com> --- meta-isar/conf/local.conf.sample | 2 +- .../example-dkms-module.bb | 14 ++++ meta/classes/dkms-module.bbclass | 70 +++++++++++++++++++ scripts/ci_build.sh | 1 + 4 files changed, 86 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..678d2f0 100644 --- a/meta-isar/conf/local.conf.sample +++ b/meta-isar/conf/local.conf.sample @@ -178,7 +178,7 @@ 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" # # 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..9fbf4c2 --- /dev/null +++ b/meta/classes/dkms-module.bbclass @@ -0,0 +1,70 @@ +# 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," + +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 + 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 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 -- 2.20.1 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 0/1] Add support to build binary version of DKMS kernel modules 2021-04-22 10:44 ` Anton Mikanovich 2021-04-22 16:02 ` [PATCH v2 0/1] " Felix Moessbauer 2021-04-22 16:02 ` [PATCH v2 1/1] " Felix Moessbauer @ 2021-04-26 16:16 ` Felix Moessbauer 2021-04-26 16:16 ` [PATCH v3 1/1] " Felix Moessbauer 3 siblings, 0 replies; 18+ messages in thread From: Felix Moessbauer @ 2021-04-26 16:16 UTC (permalink / raw) To: isar-users, amikan, jan.kiszka; +Cc: henning.schild, Felix Moessbauer Hi Jan, Anton, while playing around with various targets, I noticed that the auto-detection of the current kernel does not work well in the chroot environments. Instead, we now tell dkms the exact kernel version and architecture based on the debian kernel image and the target architecture. Changes since v2: - do not auto-detect kernel, but extract it from the ISAR arch + kernel image name - fix builds on ubuntu Best regards, Felix Felix Moessbauer (1): Add support to build binary version of DKMS kernel modules meta-isar/conf/local.conf.sample | 5 +- .../example-dkms-module.bb | 14 ++++ meta/classes/dkms-module.bbclass | 75 +++++++++++++++++++ scripts/ci_build.sh | 1 + 4 files changed, 94 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 -- 2.20.1 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 1/1] Add support to build binary version of DKMS kernel modules 2021-04-22 10:44 ` Anton Mikanovich ` (2 preceding siblings ...) 2021-04-26 16:16 ` [PATCH v3 0/1] " Felix Moessbauer @ 2021-04-26 16:16 ` Felix Moessbauer 2021-04-28 11:03 ` Anton Mikanovich 3 siblings, 1 reply; 18+ messages in thread From: Felix Moessbauer @ 2021-04-26 16:16 UTC (permalink / raw) To: isar-users, amikan, jan.kiszka; +Cc: henning.schild, 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 <felix.moessbauer@siemens.com> --- meta-isar/conf/local.conf.sample | 5 +- .../example-dkms-module.bb | 14 ++++ meta/classes/dkms-module.bbclass | 75 +++++++++++++++++++ scripts/ci_build.sh | 1 + 4 files changed, 94 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..f656f07 --- /dev/null +++ b/meta/classes/dkms-module.bbclass @@ -0,0 +1,75 @@ +# 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," + +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 + 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') + 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 + 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 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 -- 2.20.1 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 1/1] Add support to build binary version of DKMS kernel modules 2021-04-26 16:16 ` [PATCH v3 1/1] " Felix Moessbauer @ 2021-04-28 11:03 ` Anton Mikanovich 0 siblings, 0 replies; 18+ messages in thread From: Anton Mikanovich @ 2021-04-28 11:03 UTC (permalink / raw) To: Felix Moessbauer, isar-users, jan.kiszka; +Cc: henning.schild 26.04.2021 19:16, Felix Moessbauer wrote: > 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 <felix.moessbauer@siemens.com> There is an issue on building example-dkms-module-686-pae for mc:qemui386-stretch:isar-image-base target in case of ISAR_CROSS_COMPILE is set to 0: >Gathering binaries...Error! No modules built for 4.9.0-15-686-pae (i386). Please try and fix. -- Anton Mikanovich Promwad Ltd. External service provider of ilbers GmbH Maria-Merian-Str. 8 85521 Ottobrunn, Germany +49 (89) 122 67 24-0 Commercial register Munich, HRB 214197 General Manager: Baurzhan Ismagulov ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 0/1] Add support to build binary version of DKMS kernel modules @ 2021-04-30 14:02 Felix Moessbauer 2021-04-30 14:02 ` [PATCH v3 1/1] " Felix Moessbauer 0 siblings, 1 reply; 18+ messages in thread From: Felix Moessbauer @ 2021-04-30 14:02 UTC (permalink / raw) To: isar-users; +Cc: henning.schild, jan.kiszka, Felix Moessbauer Hi, this also fixes the build for i386. Changes since v3: - ensure that the module is build before packaging (fixes i386) - add mapping between ISAR arch name and kernel (machine) arch Best regards, Felix Felix Moessbauer (1): Add support to build binary version of DKMS kernel modules 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 -- 2.20.1 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 1/1] Add support to build binary version of DKMS kernel modules 2021-04-30 14:02 [PATCH v3 0/1] " Felix Moessbauer @ 2021-04-30 14:02 ` Felix Moessbauer 2021-04-30 17:19 ` Henning Schild 0 siblings, 1 reply; 18+ messages in thread From: Felix Moessbauer @ 2021-04-30 14:02 UTC (permalink / raw) To: isar-users; +Cc: henning.schild, jan.kiszka, 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 <felix.moessbauer@siemens.com> --- 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}, ${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 + 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 + # 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 + 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 -- 2.20.1 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 1/1] Add support to build binary version of DKMS kernel modules 2021-04-30 14:02 ` [PATCH v3 1/1] " Felix Moessbauer @ 2021-04-30 17:19 ` Henning Schild 0 siblings, 0 replies; 18+ messages in thread From: Henning Schild @ 2021-04-30 17:19 UTC (permalink / raw) To: Felix Moessbauer; +Cc: isar-users, jan.kiszka 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 <felix.moessbauer@siemens.com>: > 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 <felix.moessbauer@siemens.com> > --- > 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 ^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2021-04-30 17:19 UTC | newest] Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-04-14 8:36 [PATCH 0/1] Add support to build binary version of DKMS kernel Felix Moessbauer 2021-04-14 8:36 ` [PATCH 1/1] Add support to build binary version of DKMS kernel modules Felix Moessbauer 2021-04-14 8:52 ` Henning Schild 2021-04-14 9:03 ` Jan Kiszka 2021-04-15 12:26 ` Henning Schild 2021-04-15 12:41 ` Raphael Lisicki 2021-04-15 12:52 ` Jan Kiszka 2021-04-19 12:45 ` Moessbauer, Felix 2021-04-19 13:33 ` Jan Kiszka 2021-04-22 10:44 ` Anton Mikanovich 2021-04-22 16:02 ` [PATCH v2 0/1] " Felix Moessbauer 2021-04-23 6:03 ` Jan Kiszka 2021-04-22 16:02 ` [PATCH v2 1/1] " Felix Moessbauer 2021-04-26 16:16 ` [PATCH v3 0/1] " Felix Moessbauer 2021-04-26 16:16 ` [PATCH v3 1/1] " Felix Moessbauer 2021-04-28 11:03 ` Anton Mikanovich 2021-04-30 14:02 [PATCH v3 0/1] " Felix Moessbauer 2021-04-30 14:02 ` [PATCH v3 1/1] " Felix Moessbauer 2021-04-30 17:19 ` Henning Schild
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox