public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Uladzimir Bely <ubely@ilbers.de>
To: isar-users@googlegroups.com
Subject: [PATCH v2 1/6] linux: Allow to use custom packages for linux headers and image
Date: Mon, 17 Jan 2022 09:08:26 +0100	[thread overview]
Message-ID: <20220117080831.13345-2-ubely@ilbers.de> (raw)
In-Reply-To: <20220117080831.13345-1-ubely@ilbers.de>

Some distros like recent Raspbian may not provide packages named
'linux-image-${KERNEL_NAME}' and 'linux-image-${KERNEL_NAME}' and
use some custom namings.

This patch adds support of such distro-provided package name for packages
containing linux image and linux headers.

Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
 RECIPE-API-CHANGELOG.md                                |  9 +++++++++
 meta/classes/image.bbclass                             |  3 ++-
 .../linux-module/files/debian/control.tmpl             |  4 ++--
 meta/recipes-kernel/linux-module/module.inc            | 10 ++++++----
 meta/recipes-kernel/linux/linux-distro.bb              |  4 ++++
 5 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md
index 3bbb42a9..95750f9d 100644
--- a/RECIPE-API-CHANGELOG.md
+++ b/RECIPE-API-CHANGELOG.md
@@ -314,3 +314,12 @@ The "NAME" used to be rather static and the TAG was always "latest", now the val
 ### Renamed variable CONTAINER_FORMATS to CONTAINER_IMAGE_FORMATS
 
 The meaning remains the same, just the name changed.
+
+### Using custom package name for linux kernel and headers
+
+Isar assumes that linux kernel is provided by linux-image-${KERNEL_NAME}
+package, while headers are provided by linux-image-${KERNEL_NAME} package.
+This naming may be different in other distributions like Raspberry Pi OS.
+
+KERNEL_IMAGE_PKG and KERNEL_HEADERS_PKG variables allow to use custom package
+names for kernel/headers.
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index a10f0d7b..c334f4bb 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -15,7 +15,8 @@ IMAGE_INSTALL ?= ""
 IMAGE_FSTYPES ?= "${@ d.getVar("IMAGE_TYPE", True) if d.getVar("IMAGE_TYPE", True) else "ext4-img"}"
 IMAGE_ROOTFS ?= "${WORKDIR}/rootfs"
 
-IMAGE_INSTALL += "${@ ("linux-image-" + d.getVar("KERNEL_NAME", True)) if d.getVar("KERNEL_NAME", True) else ""}"
+KERNEL_IMAGE_PKG ??= "${@ ("linux-image-" + d.getVar("KERNEL_NAME", True)) if d.getVar("KERNEL_NAME", True) else ""}"
+IMAGE_INSTALL += "${KERNEL_IMAGE_PKG}"
 
 # Name of the image including distro&machine names
 IMAGE_FULLNAME = "${PN}-${DISTRO}-${MACHINE}"
diff --git a/meta/recipes-kernel/linux-module/files/debian/control.tmpl b/meta/recipes-kernel/linux-module/files/debian/control.tmpl
index 3b3292d9..d3f4dfe9 100644
--- a/meta/recipes-kernel/linux-module/files/debian/control.tmpl
+++ b/meta/recipes-kernel/linux-module/files/debian/control.tmpl
@@ -2,10 +2,10 @@ Source: ${PN}
 Section: kernel
 Priority: optional
 Standards-Version: 3.9.6
-Build-Depends: linux-headers-${KERNEL_NAME}
+Build-Depends: ${KERNEL_HEADERS_PKG}
 Maintainer: ISAR project <isar-users@googlegroups.com>
 
 Package: ${PN}
 Architecture: any
-Depends: linux-image-${KERNEL_NAME}, kmod
+Depends: ${KERNEL_IMAGE_PKG}, kmod
 Description: ${DESCRIPTION}
diff --git a/meta/recipes-kernel/linux-module/module.inc b/meta/recipes-kernel/linux-module/module.inc
index 0515621a..fecc5b3c 100644
--- a/meta/recipes-kernel/linux-module/module.inc
+++ b/meta/recipes-kernel/linux-module/module.inc
@@ -13,7 +13,9 @@ KERNEL_NAME ?= ""
 
 PN .= "-${KERNEL_NAME}"
 
-DEPENDS += "linux-headers-${KERNEL_NAME}"
+KERNEL_IMAGE_PKG ??= "linux-image-${KERNEL_NAME}"
+KERNEL_HEADERS_PKG ??= "linux-headers-${KERNEL_NAME}"
+DEPENDS += "${KERNEL_HEADERS_PKG}"
 
 SRC_URI += "file://debian/"
 
@@ -23,7 +25,7 @@ inherit dpkg
 
 TEMPLATE_FILES = "debian/control.tmpl \
                   debian/changelog.tmpl"
-TEMPLATE_VARS += "KERNEL_NAME"
+TEMPLATE_VARS += "KERNEL_IMAGE_PKG KERNEL_HEADERS_PKG"
 
 do_prepare_build() {
     cp -r ${WORKDIR}/debian ${S}/
@@ -35,12 +37,12 @@ do_prepare_build() {
 
 dpkg_runbuild_prepend() {
     # Custom kernels contain the build folder directly.
-    export KDIR=$(dpkg -L --root=${BUILDCHROOT_DIR} linux-headers-${KERNEL_NAME} | \
+    export KDIR=$(dpkg -L --root=${BUILDCHROOT_DIR} ${KERNEL_HEADERS_PKG} | \
                   grep "/lib/modules/.*/build")
     if [ -z "$KDIR" ]; then
         # Debian kernels install that folder indirectly via a dependency.
         KERNEL_DEP=$(dpkg-query -W -f '${Depends}' --admindir=${BUILDCHROOT_DIR}/var/lib/dpkg \
-                     linux-headers-${KERNEL_NAME} | sed 's/.*\(linux-headers-[[:graph:]]*\).*/\1/')
+                     ${KERNEL_HEADERS_PKG} | sed 's/.*\(linux-headers-[[:graph:]]*\).*/\1/')
         export KDIR=$(dpkg -L --root=${BUILDCHROOT_DIR} ${KERNEL_DEP} | \
                       grep "/lib/modules/.*/build")
     fi
diff --git a/meta/recipes-kernel/linux/linux-distro.bb b/meta/recipes-kernel/linux/linux-distro.bb
index 2a248f80..bfc8be9f 100644
--- a/meta/recipes-kernel/linux/linux-distro.bb
+++ b/meta/recipes-kernel/linux/linux-distro.bb
@@ -10,4 +10,8 @@ python() {
     for kernel in distro_kernels.split():
         d.appendVar('PROVIDES', ' linux-image-' + kernel)
         d.appendVar('PROVIDES', ' linux-headers-' + kernel)
+    if d.getVar('KERNEL_IMAGE_PKG', True):
+        d.appendVar('PROVIDES', ' ' + d.getVar('KERNEL_IMAGE_PKG', True))
+    if d.getVar('KERNEL_HEADERS_PKG', True):
+        d.appendVar('PROVIDES', ' ' + d.getVar('KERNEL_HEADERS_PKG', True))
 }
-- 
2.20.1


  reply	other threads:[~2022-01-17  8:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17  8:08 [PATCH v2 0/6] Update rpi targets to bullseye Uladzimir Bely
2022-01-17  8:08 ` Uladzimir Bely [this message]
2022-01-17  8:08 ` [PATCH v2 2/6] rpi-sdimage: Change deployed image name Uladzimir Bely
2022-01-17  8:08 ` [PATCH v2 3/6] rpi: Added raspios-bullseye configs Uladzimir Bely
2022-01-17  8:08 ` [PATCH v2 4/6] raspios: resize rootfs on first boot Uladzimir Bely
2022-01-17  8:08 ` [PATCH v2 5/6] CI: Switch rpi targets to bullseye Uladzimir Bely
2022-01-17  8:08 ` [PATCH v2 6/6] doc: Add notes about raspios-bullseye Uladzimir Bely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220117080831.13345-2-ubely@ilbers.de \
    --to=ubely@ilbers.de \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox