* [PATCH v5 0/5] linux-custom recipe rework @ 2019-12-10 18:22 Jan Kiszka 2019-12-10 18:22 ` [PATCH v5 1/5] recipes-kernel/linux: make KERNEL_DEFCONFIG support in-tree defconfigs Jan Kiszka ` (5 more replies) 0 siblings, 6 replies; 16+ messages in thread From: Jan Kiszka @ 2019-12-10 18:22 UTC (permalink / raw) To: isar-users; +Cc: Cedric Hombourger Adopting Cedric patches, removing the qemu-user trick for now, re-adding test cases for the config fragments and bumping the kernel to 4.19.88. CI tests look good so far. I tested a functionally identical version against jailhouse-images earlier already. Jan CC: Cedric Hombourger <Cedric_Hombourger@mentor.com> Cedric Hombourger (4): recipes-kernel/linux: make KERNEL_DEFCONFIG support in-tree defconfigs linux-mainline: fix stripping of .0 from the kernel version linux-mainline: update from 4.19.0 to 4.19.88 linux-custom: rewrite to no longer depend on the kernel's builddeb Jan Kiszka (1): linux-mainline: Test config fragments RECIPE-API-CHANGELOG.md | 8 + doc/custom_kernel.md | 83 ++++++++ .../recipes-kernel/linux/files/no-root-nfs.cfg | 1 + .../recipes-kernel/linux/files/no-ubifs-fs.cfg | 1 + .../recipes-kernel/linux/linux-mainline_4.19.0.bb | 22 --- .../recipes-kernel/linux/linux-mainline_4.19.88.bb | 33 ++++ meta/recipes-kernel/linux/files/build-kernel.sh | 129 ------------- meta/recipes-kernel/linux/files/debian/compat | 1 + .../recipes-kernel/linux/files/debian/control.tmpl | 37 ++++ .../linux/files/debian/isar/build.tmpl | 45 +++++ .../linux/files/debian/isar/clean.tmpl | 21 +++ .../linux/files/debian/isar/common.tmpl | 50 +++++ .../linux/files/debian/isar/install.tmpl | 192 +++++++++++++++++++ .../linux/files/debian/isar/version.cfg.tmpl | 2 + .../linux/files/debian/linux-image.postinst.tmpl | 29 +++ .../linux/files/debian/linux-image.postrm.tmpl | 35 ++++ .../linux/files/debian/linux-image.preinst.tmpl | 25 +++ .../linux/files/debian/linux-image.prerm.tmpl | 21 +++ meta/recipes-kernel/linux/files/debian/rules.tmpl | 39 ++++ meta/recipes-kernel/linux/linux-custom.inc | 209 +++++++++++++++------ 20 files changed, 778 insertions(+), 205 deletions(-) create mode 100644 doc/custom_kernel.md create mode 100644 meta-isar/recipes-kernel/linux/files/no-root-nfs.cfg create mode 100644 meta-isar/recipes-kernel/linux/files/no-ubifs-fs.cfg delete mode 100644 meta-isar/recipes-kernel/linux/linux-mainline_4.19.0.bb create mode 100644 meta-isar/recipes-kernel/linux/linux-mainline_4.19.88.bb delete mode 100644 meta/recipes-kernel/linux/files/build-kernel.sh create mode 100644 meta/recipes-kernel/linux/files/debian/compat create mode 100644 meta/recipes-kernel/linux/files/debian/control.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/isar/build.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/isar/clean.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/isar/common.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/isar/install.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/linux-image.postinst.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/linux-image.postrm.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/linux-image.preinst.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/linux-image.prerm.tmpl create mode 100755 meta/recipes-kernel/linux/files/debian/rules.tmpl -- 2.16.4 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v5 1/5] recipes-kernel/linux: make KERNEL_DEFCONFIG support in-tree defconfigs 2019-12-10 18:22 [PATCH v5 0/5] linux-custom recipe rework Jan Kiszka @ 2019-12-10 18:22 ` Jan Kiszka 2019-12-10 18:22 ` [PATCH v5 2/5] linux-mainline: fix stripping of .0 from the kernel version Jan Kiszka ` (4 subsequent siblings) 5 siblings, 0 replies; 16+ messages in thread From: Jan Kiszka @ 2019-12-10 18:22 UTC (permalink / raw) To: isar-users From: Cedric Hombourger <Cedric_Hombourger@mentor.com> The recipe expected the specified KERNEL_DEFCONFIG to be provided as a SRC_URI while the kernel already provides many useful defconfigs. The recipe will now check if the specified configuration can be found in WORKDIR. If it is found, it will then be used via "make olddefconfig" as before. It will otherwise assume that it is an in-tree defconfig and attempt a "make foobar_defconfig" (where foobar_defconfig is the user-provided KERNEL_DEFCONFIG setting). To support this change, a KERNEL_CONFIG_TARGET variable is passed to the build-kernel.sh script via the environment. Signed-off-by: Cedric Hombourger <Cedric_Hombourger@mentor.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> --- meta/recipes-kernel/linux/files/build-kernel.sh | 6 +----- meta/recipes-kernel/linux/linux-custom.inc | 9 ++++++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/meta/recipes-kernel/linux/files/build-kernel.sh b/meta/recipes-kernel/linux/files/build-kernel.sh index b46cefa..386e58b 100644 --- a/meta/recipes-kernel/linux/files/build-kernel.sh +++ b/meta/recipes-kernel/linux/files/build-kernel.sh @@ -36,11 +36,7 @@ REPACK_DIR="$1/../repack" REPACK_LINUX_IMAGE_DIR="${REPACK_DIR}/linux-image" REPACK_LINUX_HEADERS_DIR="${REPACK_DIR}/linux-headers" -if [ -e .config ]; then - make olddefconfig -else - make defconfig -fi +make ${KERNEL_CONFIG_TARGET} || exit ${?} KV=$( make -s kernelrelease ) if [ "${KV}" != "${PV}" ]; then diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc index 17f8464..712f52b 100644 --- a/meta/recipes-kernel/linux/linux-custom.inc +++ b/meta/recipes-kernel/linux/linux-custom.inc @@ -61,8 +61,14 @@ addtask devshell after do_install_builddeps dpkg_runbuild() { chmod +x ${WORKDIR}/build-kernel.sh + KERNEL_CONFIG_TARGET="${KERNEL_DEFCONFIG}" if [ -n "${KERNEL_DEFCONFIG}" ]; then - cp ${WORKDIR}/${KERNEL_DEFCONFIG} ${S}/.config + if [ -e "${WORKDIR}/${KERNEL_DEFCONFIG}" ]; then + cp ${WORKDIR}/${KERNEL_DEFCONFIG} ${S}/.config + KERNEL_CONFIG_TARGET="olddefconfig" + fi + else + KERNEL_CONFIG_TARGET="defconfig" fi E="${@ isar_export_proxies(d)}" @@ -71,6 +77,7 @@ dpkg_runbuild() { export KERNEL_NAME=${KERNEL_NAME_PROVIDED} export KBUILD_DEPENDS="${KBUILD_DEPENDS}" + export KERNEL_CONFIG_TARGET export KERNEL_DEBIAN_DEPENDS="${KERNEL_DEBIAN_DEPENDS}" export KERNEL_FILE="${KERNEL_FILE}" export KERNEL_HEADERS_DEBIAN_DEPENDS="${KERNEL_HEADERS_DEBIAN_DEPENDS}" -- 2.16.4 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v5 2/5] linux-mainline: fix stripping of .0 from the kernel version 2019-12-10 18:22 [PATCH v5 0/5] linux-custom recipe rework Jan Kiszka 2019-12-10 18:22 ` [PATCH v5 1/5] recipes-kernel/linux: make KERNEL_DEFCONFIG support in-tree defconfigs Jan Kiszka @ 2019-12-10 18:22 ` Jan Kiszka 2019-12-10 18:22 ` [PATCH v5 3/5] linux-mainline: update from 4.19.0 to 4.19.88 Jan Kiszka ` (3 subsequent siblings) 5 siblings, 0 replies; 16+ messages in thread From: Jan Kiszka @ 2019-12-10 18:22 UTC (permalink / raw) To: isar-users From: Cedric Hombourger <Cedric_Hombourger@mentor.com> The strip() function was used to strip the trailing .0 from the kernel version since it is omitted in the upstream archive file names. That function is actually taking a character set as argument not a substring. This was causing ARCHIVE_VERSION to expand to "4.19.8" when the user provided version was "4.19.80". The inline python code was changed to check if the version ends with ".0" and only then remove the last two characters. Signed-off-by: Cedric Hombourger <Cedric_Hombourger@mentor.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> --- meta-isar/recipes-kernel/linux/linux-mainline_4.19.0.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta-isar/recipes-kernel/linux/linux-mainline_4.19.0.bb b/meta-isar/recipes-kernel/linux/linux-mainline_4.19.0.bb index e50e149..127f6e2 100644 --- a/meta-isar/recipes-kernel/linux/linux-mainline_4.19.0.bb +++ b/meta-isar/recipes-kernel/linux/linux-mainline_4.19.0.bb @@ -7,7 +7,7 @@ require recipes-kernel/linux/linux-custom.inc -ARCHIVE_VERSION = "${@d.getVar('PV').strip('.0')}" +ARCHIVE_VERSION = "${@ d.getVar('PV')[:-2] if d.getVar('PV').endswith('.0') else d.getVar('PV') }" SRC_URI += " \ https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-${ARCHIVE_VERSION}.tar.xz \ -- 2.16.4 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v5 3/5] linux-mainline: update from 4.19.0 to 4.19.88 2019-12-10 18:22 [PATCH v5 0/5] linux-custom recipe rework Jan Kiszka 2019-12-10 18:22 ` [PATCH v5 1/5] recipes-kernel/linux: make KERNEL_DEFCONFIG support in-tree defconfigs Jan Kiszka 2019-12-10 18:22 ` [PATCH v5 2/5] linux-mainline: fix stripping of .0 from the kernel version Jan Kiszka @ 2019-12-10 18:22 ` Jan Kiszka 2019-12-10 18:22 ` [PATCH v5 4/5] linux-custom: rewrite to no longer depend on the kernel's builddeb Jan Kiszka ` (2 subsequent siblings) 5 siblings, 0 replies; 16+ messages in thread From: Jan Kiszka @ 2019-12-10 18:22 UTC (permalink / raw) To: isar-users From: Cedric Hombourger <Cedric_Hombourger@mentor.com> In preparation for a new machine addition, update the linux-mainline kernel from 4.19.0 to 4.19.88. This is needed to get some of the mips fixes that were integrated in this longterm kernel version (and in particular: MIPS: have "plain" make calls build dtbs for selected platforms, i.e. 637dfa0fad6d91a9a709dc70549a6d20fa77f615 upstream) Signed-off-by: Cedric Hombourger <Cedric_Hombourger@mentor.com> [Jan: refresh from .80 to .88] Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> --- .../linux/{linux-mainline_4.19.0.bb => linux-mainline_4.19.88.bb} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename meta-isar/recipes-kernel/linux/{linux-mainline_4.19.0.bb => linux-mainline_4.19.88.bb} (87%) diff --git a/meta-isar/recipes-kernel/linux/linux-mainline_4.19.0.bb b/meta-isar/recipes-kernel/linux/linux-mainline_4.19.88.bb similarity index 87% rename from meta-isar/recipes-kernel/linux/linux-mainline_4.19.0.bb rename to meta-isar/recipes-kernel/linux/linux-mainline_4.19.88.bb index 127f6e2..695eb39 100644 --- a/meta-isar/recipes-kernel/linux/linux-mainline_4.19.0.bb +++ b/meta-isar/recipes-kernel/linux/linux-mainline_4.19.88.bb @@ -12,7 +12,7 @@ ARCHIVE_VERSION = "${@ d.getVar('PV')[:-2] if d.getVar('PV').endswith('.0') else SRC_URI += " \ https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-${ARCHIVE_VERSION}.tar.xz \ file://x86_64_defconfig" -SRC_URI[sha256sum] = "0c68f5655528aed4f99dae71a5b259edc93239fa899e2df79c055275c21749a1" +SRC_URI[sha256sum] = "c1923b6bd166e6dd07be860c15f59e8273aaa8692bc2a1fce1d31b826b9b3fbe" SRC_URI_append_de0-nano-soc = " \ file://0001-ARM-dts-socfpga-Rename-socfpga_cyclone5_de0_-sockit-.patch" -- 2.16.4 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v5 4/5] linux-custom: rewrite to no longer depend on the kernel's builddeb 2019-12-10 18:22 [PATCH v5 0/5] linux-custom recipe rework Jan Kiszka ` (2 preceding siblings ...) 2019-12-10 18:22 ` [PATCH v5 3/5] linux-mainline: update from 4.19.0 to 4.19.88 Jan Kiszka @ 2019-12-10 18:22 ` Jan Kiszka 2019-12-11 14:40 ` Jan Kiszka 2019-12-11 15:20 ` Gylstorff Quirin 2019-12-10 18:22 ` [PATCH v5 5/5] linux-mainline: Test config fragments Jan Kiszka 2019-12-19 15:19 ` [PATCH v5 0/5] linux-custom recipe rework cedric_hombourger 5 siblings, 2 replies; 16+ messages in thread From: Jan Kiszka @ 2019-12-10 18:22 UTC (permalink / raw) To: isar-users From: Cedric Hombourger <Cedric_Hombourger@mentor.com> Regain control over the packaging of the Linux kernel by providing our own debian recipes (debian,{control,rules} files and friends) instead of using the kernel's builddeb script. This will allow generation of packages for "perf" (not included in this changeset) with per distro scheme (Debian and Ubuntu have differences) and maintain compatibility with upstream packages generated from different source packages but dependent on a certain deployment scheme (e.g. linux-base for Debian) Signed-off-by: Cedric Hombourger <Cedric_Hombourger@mentor.com> [Jan: continue to build kernel-headers for the host, add changelog entry] Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> --- RECIPE-API-CHANGELOG.md | 8 + doc/custom_kernel.md | 83 ++++++++ meta/recipes-kernel/linux/files/build-kernel.sh | 125 ------------ meta/recipes-kernel/linux/files/debian/compat | 1 + .../recipes-kernel/linux/files/debian/control.tmpl | 37 ++++ .../linux/files/debian/isar/build.tmpl | 45 +++++ .../linux/files/debian/isar/clean.tmpl | 21 +++ .../linux/files/debian/isar/common.tmpl | 50 +++++ .../linux/files/debian/isar/install.tmpl | 192 +++++++++++++++++++ .../linux/files/debian/isar/version.cfg.tmpl | 2 + .../linux/files/debian/linux-image.postinst.tmpl | 29 +++ .../linux/files/debian/linux-image.postrm.tmpl | 35 ++++ .../linux/files/debian/linux-image.preinst.tmpl | 25 +++ .../linux/files/debian/linux-image.prerm.tmpl | 21 +++ meta/recipes-kernel/linux/files/debian/rules.tmpl | 39 ++++ meta/recipes-kernel/linux/linux-custom.inc | 210 +++++++++++++++------ 16 files changed, 740 insertions(+), 183 deletions(-) create mode 100644 doc/custom_kernel.md delete mode 100644 meta/recipes-kernel/linux/files/build-kernel.sh create mode 100644 meta/recipes-kernel/linux/files/debian/compat create mode 100644 meta/recipes-kernel/linux/files/debian/control.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/isar/build.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/isar/clean.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/isar/common.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/isar/install.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/linux-image.postinst.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/linux-image.postrm.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/linux-image.preinst.tmpl create mode 100644 meta/recipes-kernel/linux/files/debian/linux-image.prerm.tmpl create mode 100755 meta/recipes-kernel/linux/files/debian/rules.tmpl diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md index 508e3f5..86c8418 100644 --- a/RECIPE-API-CHANGELOG.md +++ b/RECIPE-API-CHANGELOG.md @@ -193,6 +193,7 @@ files and patches using bbappend a lot easier. For example: ``` FILESEXTRAPATHS_prepend := "$THISDIR/files:" +``` ### multiconfig build targets were renamed @@ -209,3 +210,10 @@ The old syntax is no longer supported and will produce an error: ``` bitbake multiconfig:qemuarm-stretch:isar-image-base ``` + +### Support for kernel config fragments + +Kernels built via linux-custom.inc will now get configuration fragments listed +in SRC_URI automatically applied. Config fragment files need to end on .cfg. +If such a file should not by applied, append `;apply=no` to the respective +SRC_URI entry. diff --git a/doc/custom_kernel.md b/doc/custom_kernel.md new file mode 100644 index 0000000..ffeaddc --- /dev/null +++ b/doc/custom_kernel.md @@ -0,0 +1,83 @@ +# Custom kernel recipe for Isar + +## Contents + + - [Summary](#summary) + - [Features](#features) + - [Future](#future) + - [Examples](#examples) + +## Summary + +Isar provides a recipe to build custom kernels for Debian-based distributions. +It uses templates to generate the debian meta-data (such as debian/control) and +Debian's [BuildProfiles](https://wiki.debian.org/BuildProfileSpec) to handle +some of the distro specific variations. It should be noted that Isar has moved +away from using the kernel's builddeb script since it would not generate all +the packages we need (and in particular perf). + +## Features + +The linux-custom recipe provides support for: + + 1. Sources to the custom Linux kernel may be specified via `SRC_URI` + + 2. Configure the kernel via an in-tree or an external `defconfig` via + `KERNEL_DEFCONFIG` + + 3. Integrate kernel configuration tweaks via configuration fragments (`.cfg` + files) + + 4. Patches to the linux kernel may be specified via `SRC_URI` + + 5. Ensure that the Isar recipe `PV` matches the kernel release identifier + (`KERNEL_RELEASE`) + + 6. Produce a `linux-image` package that ships the kernel image and modules + + 7. Allow the name of the kernel image to be changed via `KERNEL_FILE` (defaults + to `vmlinuz`) + + 8. Produce a `linux-headers` package which includes kernel headers and kbuild + scripts/tools + + 9. The `linux-headers` package shall support native and cross compiles of + out-of-tree kernel modules. However, when built in cross-compilation mode, + it cannot be used on the target so far. + + 10. Produce a `linux-libc-dev` package to support user-land builds + + 11. Only build/ship the `linux-libc-dev` package if instructed to + (`KERNEL_LIBC_DEV_DEPLOY` equals to `"1"`) + + 12. Support both native and cross compiles (`ISAR_CROSS_COMPILE`) + + 13. Support for the following kernel architectures: + + * arm + * arm64 + * mips + * x86 + + 14. Support `devshell` (kernel configuration shall be applied) + +## Future + +In the future, the recipe may be extended to: + + 1. Package perf + + 2. Support inclusion/build of dts files listed in `SRC_URI` + + 3. Be compatible with Ubuntu + + 4. When cross-building, generate kernel-headers for both host and target + +## Examples + +The linux-custom recipe is currently used by the linux-mainline package and is +used mainline recipe may be used for some basic testing. This recipe is being +used by the following machines: + + * de0-nano-soc + * qemumipsel diff --git a/meta/recipes-kernel/linux/files/build-kernel.sh b/meta/recipes-kernel/linux/files/build-kernel.sh deleted file mode 100644 index 386e58b..0000000 --- a/meta/recipes-kernel/linux/files/build-kernel.sh +++ /dev/null @@ -1,125 +0,0 @@ -#!/bin/bash -# -# Custom kernel build -# -# This software is a part of ISAR. -# Copyright (c) Siemens AG, 2018 -# -# SPDX-License-Identifier: MIT - -source /isar/common.sh - -host_arch=$(dpkg --print-architecture) - -if [ "$host_arch" != "$target_arch" ]; then - case $target_arch in - armhf) - export ARCH=arm - export CROSS_COMPILE="arm-linux-gnueabihf-" - ;; - arm64) - export ARCH=arm64 - export CROSS_COMPILE="aarch64-linux-gnu-" - ;; - mipsel) - export ARCH=mips - export CROSS_COMPILE="mipsel-linux-gnu-" - ;; - *) - echo "error: unsupported architecture ($target_arch)" - exit 1 - ;; - esac -fi - -REPACK_DIR="$1/../repack" -REPACK_LINUX_IMAGE_DIR="${REPACK_DIR}/linux-image" -REPACK_LINUX_HEADERS_DIR="${REPACK_DIR}/linux-headers" - -make ${KERNEL_CONFIG_TARGET} || exit ${?} - -KV=$( make -s kernelrelease ) -if [ "${KV}" != "${PV}" ]; then - echo "ERROR: Recipe PV is \"${PV}\" but should be \"${KV}\"" 1>&2 - echo "ERROR: Probably due to CONFIG_LOCALVERSION" 1>&2 - exit 1 -fi - -rm -f .version -KBUILD_DEBARCH=$target_arch make -j $(($(nproc) * 2)) deb-pkg - -rm -rf "${REPACK_DIR}" -mkdir -p "${REPACK_DIR}" -mkdir -p "${REPACK_LINUX_IMAGE_DIR}" -mkdir -p "${REPACK_LINUX_HEADERS_DIR}" - -cp -a debian "${REPACK_DIR}" - -# dpkg-gencontrol performs cross-incompatible checks on the -# Architecture field; trick it to accept the control file -sed -i "s/Architecture: .*/Architecture: any/" "${REPACK_DIR}/debian/control" - -cd .. - -dpkg-deb -R linux-image-${PV}_${PV}-1_*.deb "${REPACK_LINUX_IMAGE_DIR}" -dpkg-deb -R linux-headers-${PV}_${PV}-1_*.deb "${REPACK_LINUX_HEADERS_DIR}" - -dpkg-gencontrol -crepack/debian/control \ - -lrepack/debian/changelog \ - -frepack/debian/files \ - -plinux-image-${PV} \ - -P"${REPACK_LINUX_IMAGE_DIR}" \ - -DPackage="linux-image-${KERNEL_NAME}" \ - -DSection=kernel \ - -DPriority=required \ - -DDepends="${KERNEL_DEBIAN_DEPENDS}" \ - -DArchitecture=$target_arch - -# Add Debian-like link installation to postinst -mkdir -p ${REPACK_LINUX_IMAGE_DIR}/lib/modules/${PV} -touch "${REPACK_LINUX_IMAGE_DIR}/lib/modules/${PV}/.fresh-install" -sed -i "${REPACK_LINUX_IMAGE_DIR}/DEBIAN/postinst" \ - -e "/^set -e$/a\\ -\\ -if [ -f /lib/modules/${PV}/.fresh-install ]; then\\ - change=install\\ -else\\ - change=upgrade\\ -fi\\ -linux-update-symlinks \$change ${PV} /boot/${KERNEL_FILE}-${PV}\\ -rm -f /lib/modules/${PV}/.fresh-install" - -# Add Debian-like link removal to postrm -sed -i "${REPACK_LINUX_IMAGE_DIR}/DEBIAN/postrm" \ - -e "/^set -e$/a\\ -\\ -rm -f /lib/modules/${PV}/.fresh-install\\ -\\ -if [ \"\$1\" != upgrade ] && command -v linux-update-symlinks >/dev/null; then\\ - linux-update-symlinks remove ${PV} /boot/${KERNEL_FILE}-${PV}\\ -fi" - -# Make sure arm64 kernels are decompressed -if [ "$target_arch" = "arm64" ]; then - kernel_file="${REPACK_LINUX_IMAGE_DIR}/boot/${KERNEL_FILE}-${PV}" - mv "${kernel_file}" "${kernel_file}.gz" - gunzip "${kernel_file}.gz" -fi - -dpkg-gencontrol -crepack/debian/control \ - -lrepack/debian/changelog \ - -frepack/debian/files \ - -plinux-headers-${PV} \ - -P"${REPACK_LINUX_HEADERS_DIR}" \ - -Vkernel:debarch="${KERNEL_NAME}" \ - -DPackage="linux-headers-${KERNEL_NAME}" \ - -DSection=kernel \ - -DDepends="${KERNEL_HEADERS_DEBIAN_DEPENDS}" \ - -DArchitecture=$target_arch - -fakeroot dpkg-deb -b "${REPACK_LINUX_IMAGE_DIR}" \ - linux-image-${KERNEL_NAME}_${PV}-1_${KERNEL_NAME}.deb -rm -f linux-image-${PV}_${PV}-1_*.deb -fakeroot dpkg-deb -b "${REPACK_LINUX_HEADERS_DIR}" \ - linux-headers-${KERNEL_NAME}_${PV}-1_${KERNEL_NAME}.deb -rm -f linux-headers-${PV}_${PV}-1_*.deb diff --git a/meta/recipes-kernel/linux/files/debian/compat b/meta/recipes-kernel/linux/files/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/meta/recipes-kernel/linux/files/debian/compat @@ -0,0 +1 @@ +9 diff --git a/meta/recipes-kernel/linux/files/debian/control.tmpl b/meta/recipes-kernel/linux/files/debian/control.tmpl new file mode 100644 index 0000000..7236732 --- /dev/null +++ b/meta/recipes-kernel/linux/files/debian/control.tmpl @@ -0,0 +1,37 @@ +Source: linux-${KERNEL_NAME_PROVIDED} +Section: kernel +Priority: optional +Maintainer: ${MAINTAINER} +Build-Depends: bc, kmod, cpio, ${KBUILD_DEPENDS} +Homepage: http://www.kernel.org/ + +Package: linux-image-${KERNEL_NAME_PROVIDED} +Architecture: any +Depends: ${KERNEL_DEBIAN_DEPENDS} +Description: ${KERNEL_NAME_PROVIDED} Linux kernel, version ${PV}-${KERNEL_LOCALVERSION} + This package contains the Linux kernel, modules and corresponding other + files, version: ${PV}-${KERNEL_LOCALVERSION}. + +Package: linux-headers-${KERNEL_NAME_PROVIDED} +Architecture: any +Depends: ${KERNEL_HEADERS_DEBIAN_DEPENDS}, ${perl:Depends}, ${shlib:Depends} +Description: ${KERNEL_NAME_PROVIDED} Linux kernel headers for ${PV}-${KERNEL_LOCALVERSION} + This package provides kernel header files for ${PV}-${KERNEL_LOCALVERSION} on ${DISTRO_ARCH} + . + This is useful for people who need to build external modules + +Package: linux-libc-dev +Build-Profiles: <!nolibcdev> +Section: devel +Provides: linux-kernel-headers +Architecture: any +Description: Linux support headers for userspace development + This package provides userspaces headers from the Linux kernel. These headers + are used by the installed headers for GNU glibc and other system libraries. + +Package: linux-image-${KERNEL_NAME_PROVIDED}-dbg +Section: debug +Architecture: any +Description: Linux kernel debugging symbols for ${PV}-${KERNEL_LOCALVERSION} + This package will come in handy if you need to debug the kernel. It provides + all the necessary debug symbols for the kernel and its modules. diff --git a/meta/recipes-kernel/linux/files/debian/isar/build.tmpl b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl new file mode 100644 index 0000000..1775b19 --- /dev/null +++ b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl @@ -0,0 +1,45 @@ +#!/bin/bash +# Copyright (c) Mentor Graphics, a Siemens business, 2019 +# SPDX-License-Identifier: MIT + +# Load common stuff +. ${S}/debian/isar/common || exit ${?} + +do_build() { + + # Print a few things that are of particular interest + print_settings + + # Process existing kernel configuration to make sure it is complete + # (use defaults for options that were not specified) + ${MAKE} O=${KERNEL_BUILD_DIR} olddefconfig prepare || exit ${?} + + # Check if the recipe's PV makes sense + KR=$(${MAKE} O=${KERNEL_BUILD_DIR} -s --no-print-directory kernelrelease) + eval $(grep ^CONFIG_LOCALVERSION= ${KERNEL_BUILD_DIR}/${KCONF} || true) + if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then + echo "ERROR: Recipe version (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the kernelrelease (${KR})!" 1>&2 + echo "ERROR: Make sure the kernel version in your NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 + exit 1 + fi + + # Trace what we do here + set -x + + # Build the Linux kernel + ${MAKE} O=${KERNEL_BUILD_DIR} -j $(nproc) || exit ${?} + + # Stop tracing + set +x +} + +print_settings() { + cat <<EOF +# Build settings: +# --------------- +# ARCH=${ARCH} +# CROSS_COMPILE=${CROSS_COMPILE} +EOF +} + +main build ${*} diff --git a/meta/recipes-kernel/linux/files/debian/isar/clean.tmpl b/meta/recipes-kernel/linux/files/debian/isar/clean.tmpl new file mode 100644 index 0000000..f903987 --- /dev/null +++ b/meta/recipes-kernel/linux/files/debian/isar/clean.tmpl @@ -0,0 +1,21 @@ +#!/bin/bash +# Copyright (c) Mentor Graphics, a Siemens business, 2019 +# SPDX-License-Identifier: MIT + +# Load common stuff +. ${S}/debian/isar/common || exit ${?} + +do_clean() { + + # Trace what we do here + set -x + + rm -rf ${deb_img_dir} ${deb_dbg_dir} + rm -rf ${deb_kern_hdrdir} + rm -rf ${deb_libc_hdr_dir} + + # Stop tracing + set +x +} + +main clean ${*} diff --git a/meta/recipes-kernel/linux/files/debian/isar/common.tmpl b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl new file mode 100644 index 0000000..44f67b3 --- /dev/null +++ b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl @@ -0,0 +1,50 @@ +#!/bin/bash +# Copyright (c) Mentor Graphics, a Siemens business, 2019 +# SPDX-License-Identifier: MIT + +# Isar settings +ARCH=${KERNEL_ARCH} +KERNEL_PKG_IMAGE=linux-image-${KERNEL_NAME_PROVIDED} +KERNEL_PKG_KERN_HEADERS=linux-headers-${KERNEL_NAME_PROVIDED} +KERNEL_PKG_LIBC_HEADERS=linux-libc-dev + +# Constants +KCONF=.config + +# Target directories +deb_top_dir=${S}/debian +deb_img_dir=${deb_top_dir}/${KERNEL_PKG_IMAGE} +deb_dbg_dir=${deb_img_dir}-dbg +deb_dtb_dir=${deb_img_dir}/${KERNEL_DTB_DIR} +deb_kern_hdr_dir=${deb_top_dir}/${KERNEL_PKG_KERN_HEADERS} +deb_libc_hdr_dir=${deb_top_dir}/${KERNEL_PKG_LIBC_HEADERS} + +# Array of packages to be generated +declare -A kern_pkgs + +main() { + local target=${1} + + if [ ! -f ${S}/debian/isar/${target} ]; then + echo "error: ${target} is not a supported build target!" >&2 + return 1 + fi + + # create do_<x> variables for each package to be generated + for p in $(unset DEB_HOST_ARCH; dh_listpackages); do + kern_pkgs["${p}"]="1" + done + + # variables to be exported + export ARCH + + # are we cross-compiling? + BUILD_ARCH=$(dpkg-architecture -qDEB_BUILD_ARCH) + if [ "${BUILD_ARCH}" = "${DISTRO_ARCH}" ]; then + # no, make sure CROSS_COMPILE isn't set + unset CROSS_COMPILE + fi + + # call the actual target script + do_${target} || return ${?} +} diff --git a/meta/recipes-kernel/linux/files/debian/isar/install.tmpl b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl new file mode 100644 index 0000000..67b7ce3 --- /dev/null +++ b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl @@ -0,0 +1,192 @@ +#!/bin/bash +# Copyright (c) Mentor Graphics, a Siemens business, 2019 +# SPDX-License-Identifier: MIT + +# Load common stuff +. ${S}/debian/isar/common || exit ${?} + +# Stop on error +set -e + +do_install() { + + # check if our kernel was configured + if [ ! -f "${O}/.config" ]; then + echo "error: kernel not configured!" >&2 + return 1 + fi + + # load its configuration + . ${O}/.config + + kimage="$(${MAKE} O=${O} -s --no-print-directory image_name)" + krel="$(${MAKE} O=${O} -s --no-print-directory kernelrelease)" + case "${ARCH}" in + mips|powerpc) kimage_path="boot/vmlinux-${krel}" ;; + um) kimage_path="usr/bin/vmlinux-${krel}" ;; + *) kimage_path="boot/vmlinuz-${krel}" ;; + esac + + print_settings + + # Trace what we do here + set -x + + install_image + install_hooks + install_dtbs + install_kmods + install_headers + + # Stop tracing + set +x +} + +print_settings() { + cat <<EOF +Install settings: +----------------- +deb_dtb_dir=${deb_dtb_dir} +deb_hdr_dir=${deb_hdr_dir} +kimage=${kimage} +kimage_path=${kimage_path} + +EOF +} + +install_image() { + install -m 755 -d ${deb_img_dir}/$(dirname ${kimage_path}) + cp ${O}/${kimage} ${deb_img_dir}/${kimage_path} + + # Make sure arm64 kernels are decompressed + if [ "${ARCH}" = "arm64" ]; then + mv ${deb_img_dir}/${kimage_path} ${deb_img_dir}/${kimage_path}.gz + gunzip -f ${deb_img_dir}/${kimage_path}.gz + fi + + install_image_debug +} + +install_image_debug() { + # Different tools want the image in different locations + # perf + mkdir -p ${deb_dbg_dir}/usr/lib/debug/lib/modules/${krel}/ + cp ${O}/vmlinux ${deb_dbg_dir}/usr/lib/debug/lib/modules/${krel}/ + # systemtap + mkdir -p ${deb_dbg_dir}/usr/lib/debug/boot/ + ln -s ../lib/modules/$version/vmlinux ${deb_dbg_dir}/usr/lib/debug/boot/vmlinux-${krel} + # kdump-tools + ln -s lib/modules/${krel}/vmlinux ${deb_dbg_dir}/usr/lib/debug/vmlinux-${krel} +} + +install_hooks() { + install -m 755 -d ${deb_img_dir}/etc/kernel/install.d + install -m 755 -d ${deb_img_dir}/etc/kernel/postinst.d + install -m 755 -d ${deb_img_dir}/etc/kernel/postrm.d + install -m 755 -d ${deb_img_dir}/etc/kernel/prerm.d + + initrd="No" + [ -z "${CONFIG_BLK_DEV_INITRD}" ] || initrd="Yes" + + for script in postinst postrm preinst prerm; do + sed -i -e "s,INITRD=[A-Za-z0-9]*,INITRD=${initrd},g" ${S}/debian/linux-image*.${script} + sed -i -e "s,version=.*,version=${krel},g" ${S}/debian/linux-image*.${script} + done +} + +install_dtbs() { + [ -n "${CONFIG_OF}" ] || return 0 + ${MAKE} O=${O} INSTALL_DTBS_PATH=${deb_dtb_dir} dtbs_install +} + +install_kmods() { + [ -n "${CONFIG_MODULES}" ] || return 0 + ${MAKE} O=${O} INSTALL_MOD_PATH=${deb_img_dir} modules_install + touch ${deb_img_dir}/lib/modules/${krel}/.fresh-install + rm -fv ${deb_img_dir}/lib/modules/${krel}/build + rm -fv ${deb_img_dir}/lib/modules/${krel}/source + install_kmods_debug +} + +kmods_sign() { + [ -n "${CONFIG_MODULE_SIG_ALL}" ] || return 0 + ${MAKE} O=${O} INSTALL_MOD_PATH=${deb_img_dir} modules_sign +} + +install_kmods_debug() { + [ -n "${CONFIG_DEBUG_INFO}" ] || return 0 + + kmod_inst_dir=${deb_img_dir}/lib/modules + kmod_debug_dir=${deb_dbg_dir}/usr/lib/debug + + # copy kernels modules to usr/lib/debug + mkdir -p ${kmod_debug_dir} + tar -C ${kmod_inst_dir}/ -cO --exclude='modules.*' . | tar -C ${kmod_debug_dir}/ -xf - + # strip everything but debug sections for modules in usr/lib/debug + find ${kmod_debug_dir} -name *.ko -exec ${CROSS_COMPILE}objcopy --only-keep-debug {} \; + # and strip debug sections from modules in lib/modules + find ${kmod_inst_dir} -name *.ko -exec ${CROSS_COMPILE}objcopy --strip-debug {} \; + + # re-sign stripped kernel modules + kmods_sign +} + +headers_check() { + ${MAKE} O=${O} headers_check +} + +libc_headers() { + mkdir -p ${deb_libc_hdr_dir} + ${MAKE} O=${O} headers_install INSTALL_HDR_PATH=${deb_libc_hdr_dir}/usr + host_arch=$(dpkg-architecture -a${DISTRO_ARCH} -qDEB_HOST_MULTIARCH) + mkdir ${deb_libc_hdr_dir}/usr/include/${host_arch} + mv ${deb_libc_hdr_dir}/usr/include/asm ${deb_libc_hdr_dir}/usr/include/${host_arch}/ +} + +kernel_tools() { + # remove object files + find ${destdir}/scripts -type f -name '*.o' |xargs rm -f +} + +kernel_headers() { + destdir=${deb_kern_hdr_dir}/${KERNEL_HEADERS_DIR} + src_hdr_files=$(mktemp) + obj_hdr_files=$(mktemp) + + mkdir -p ${destdir} + mkdir -p ${deb_kern_hdr_dir}/lib/modules/${krel} + + (cd ${S}; find . -name 'Makefile*' -o -name 'Kconfig*' -o -name '*.pl') >>${src_hdr_files} + (cd ${S}; find arch/*/include include scripts -type f -o -type l) >>${src_hdr_files} + (cd ${S}; find arch/${ARCH} -name module.lds -o -name Kbuild.platforms -o -name Platform) >>${src_hdr_files} + (cd ${S}; find $(find arch/${ARCH} -name include -o -name scripts -type d) -type f) >>${src_hdr_files} + + (cd ${O}; find arch/${ARCH}/include Module.symvers include scripts -type f) >>${obj_hdr_files} + if [ -n "${CONFIG_STACK_VALIDATION}" ]; then + (cd ${O}; find tools/objtool -type f -executable) >>${obj_hdr_files} + fi + if [ -n "${CONFIG_GCC_PLUGINS}" ]; then + (cd ${O}; find scripts/gcc-plugins -name *.so -o -name gcc-common.h) >>${obj_hdr_files} + fi + + # deploy files that were matched above + tar -C ${S} -cf - -T - <${src_hdr_files} | tar -C ${destdir} -xf - + tar -C ${O} -cf - -T - <${obj_hdr_files} | tar -C ${destdir} -xf - + + # add the kernel config + cp ${O}/${KCONF} ${destdir}/.config + + # handle kernel development tools + kernel_tools + + # create symlinks + ln -sf /${KERNEL_HEADERS_DIR} ${deb_kern_hdr_dir}/lib/modules/${krel}/build +} + +install_headers() { + headers_check + [ -z ${kern_pkgs["linux-libc-headers"]} ] || libc_headers + kernel_headers +} + +main install ${*} diff --git a/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl b/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl new file mode 100644 index 0000000..09fa364 --- /dev/null +++ b/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl @@ -0,0 +1,2 @@ +CONFIG_LOCALVERSION="-${KERNEL_LOCALVERSION}" +# CONFIG_LOCALVERSION_AUTO is not set diff --git a/meta/recipes-kernel/linux/files/debian/linux-image.postinst.tmpl b/meta/recipes-kernel/linux/files/debian/linux-image.postinst.tmpl new file mode 100644 index 0000000..b373801 --- /dev/null +++ b/meta/recipes-kernel/linux/files/debian/linux-image.postinst.tmpl @@ -0,0 +1,29 @@ +#!/bin/sh +# based on https://salsa.debian.org/kernel-team/linux/blob/master/debian/templates/image.postinst.in + +# Tell initramfs builder whether it's wanted +export INITRD=Yes + +version=${PV}-${KERNEL_LOCALVERSION} +image_path=/boot/${KERNEL_FILE}-${version} + +if [ "$1" != configure ]; then + exit 0 +fi + +depmod $version + +if [ -f /lib/modules/$version/.fresh-install ]; then + change=install +else + change=upgrade +fi +linux-update-symlinks $change $version $image_path +rm -f /lib/modules/$version/.fresh-install + +if [ -d /etc/kernel/postinst.d ]; then + DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error --arg=$version \ + --arg=$image_path /etc/kernel/postinst.d +fi + +exit 0 diff --git a/meta/recipes-kernel/linux/files/debian/linux-image.postrm.tmpl b/meta/recipes-kernel/linux/files/debian/linux-image.postrm.tmpl new file mode 100644 index 0000000..1b5dbbe --- /dev/null +++ b/meta/recipes-kernel/linux/files/debian/linux-image.postrm.tmpl @@ -0,0 +1,35 @@ +#!/bin/sh -e +# based on https://salsa.debian.org/kernel-team/linux/blob/master/debian/templates/image.postrm.in + +# Tell initramfs builder whether it's wanted +export INITRD=Yes + +version=${PV}-${KERNEL_LOCALVERSION} +image_path=/boot/${KERNEL_FILE}-${version} + +rm -f /lib/modules/$version/.fresh-install + +if [ "$1" != upgrade ] && command -v linux-update-symlinks >/dev/null; then + linux-update-symlinks remove $version $image_path +fi + +if [ -d /etc/kernel/postrm.d ]; then + DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error --arg=$version \ + --arg=$image_path /etc/kernel/postrm.d +fi + +if [ "$1" = purge ]; then + for extra_file in modules.dep modules.isapnpmap modules.pcimap \ + modules.usbmap modules.parportmap \ + modules.generic_string modules.ieee1394map \ + modules.ieee1394map modules.pnpbiosmap \ + modules.alias modules.ccwmap modules.inputmap \ + modules.symbols modules.ofmap \ + modules.seriomap modules.\*.bin \ + modules.softdep modules.devname; do + eval rm -f /lib/modules/$version/$extra_file + done + rmdir /lib/modules/$version || true +fi + +exit 0 diff --git a/meta/recipes-kernel/linux/files/debian/linux-image.preinst.tmpl b/meta/recipes-kernel/linux/files/debian/linux-image.preinst.tmpl new file mode 100644 index 0000000..4f24019 --- /dev/null +++ b/meta/recipes-kernel/linux/files/debian/linux-image.preinst.tmpl @@ -0,0 +1,25 @@ +#!/bin/sh -e +# based on https://salsa.debian.org/kernel-team/linux/blob/master/debian/templates/image.preinst.in + +# Tell initramfs builder whether it's wanted +export INITRD=Yes + +version=${PV}-${KERNEL_LOCALVERSION} +image_path=/boot/${KERNEL_FILE}-${version} + +if [ "$1" = abort-upgrade ]; then + exit 0 +fi + +if [ "$1" = install ]; then + # Create a flag file for postinst + mkdir -p /lib/modules/$version + touch /lib/modules/$version/.fresh-install +fi + +if [ -d /etc/kernel/preinst.d ]; then + DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error --arg=$version \ + --arg=$image_path /etc/kernel/preinst.d +fi + +exit 0 diff --git a/meta/recipes-kernel/linux/files/debian/linux-image.prerm.tmpl b/meta/recipes-kernel/linux/files/debian/linux-image.prerm.tmpl new file mode 100644 index 0000000..cd697c0 --- /dev/null +++ b/meta/recipes-kernel/linux/files/debian/linux-image.prerm.tmpl @@ -0,0 +1,21 @@ +#!/bin/sh -e +# based on https://salsa.debian.org/kernel-team/linux/blob/master/debian/templates/image.prerm.in + +# Tell initramfs builder whether it's wanted +export INITRD=Yes + +version=${PV}-${KERNEL_LOCALVERSION} +image_path=/boot/${KERNEL_FILE}-${version} + +if [ "$1" != remove ]; then + exit 0 +fi + +linux-check-removal $version + +if [ -d /etc/kernel/prerm.d ]; then + DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error --arg=$version \ + --arg=$image_path /etc/kernel/prerm.d +fi + +exit 0 diff --git a/meta/recipes-kernel/linux/files/debian/rules.tmpl b/meta/recipes-kernel/linux/files/debian/rules.tmpl new file mode 100755 index 0000000..bea21f9 --- /dev/null +++ b/meta/recipes-kernel/linux/files/debian/rules.tmpl @@ -0,0 +1,39 @@ +#!/usr/bin/make -f + +CROSS_COMPILE:=$(DEB_HOST_GNU_TYPE)- + +O:=$(CURDIR)/${KERNEL_BUILD_DIR} +S:=$(CURDIR) +deb_top_dir:=$(S)/debian + +# Dynamic variables to be passed to Isar build scripts +isar_env=$(strip \ + export CROSS_COMPILE='$(CROSS_COMPILE)' && \ + export DEB_BUILD_PROFILES='$(DEB_BUILD_PROFILES)' && \ + export DEB_HOST_GNU_TYPE='$(DEB_HOST_GNU_TYPE)' && \ + export MAKE='$(MAKE)' && \ + export O='${O}' \ + export S='${S}' \ +) + +%: + dh $(@) + +.PHONY: override_dh_auto_clean +override_dh_auto_clean: + $(isar_env) && bash $(deb_top_dir)/isar/clean + +.PHONY: override_dh_auto_build +override_dh_auto_build: + $(isar_env) && bash $(deb_top_dir)/isar/build + +override_dh_auto_install: + $(isar_env) && bash $(deb_top_dir)/isar/install + +.PHONY: override_dh_auto_test +override_dh_auto_test: + true + +PHONY: override_dh_strip +override_dh_strip: + unset DEB_HOST_GNU_TYPE && dh_strip -Xvmlinux --no-automatic-dbgsym diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc index 712f52b..bf1646a 100644 --- a/meta/recipes-kernel/linux/linux-custom.inc +++ b/meta/recipes-kernel/linux/linux-custom.inc @@ -2,89 +2,183 @@ # # This software is a part of ISAR. # Copyright (c) Siemens AG, 2018 +# Copyright (c) Mentor Graphics, a Siemens business, 2019 # # SPDX-License-Identifier: MIT -FILESEXTRAPATHS_prepend := "${FILE_DIRNAME}/files:" +# Settings that would typically be done from the custom kernel recipe +# ------------------------------------------------------------------- +CHANGELOG_V = "${PV}+${PR}" DESCRIPTION ?= "Custom kernel" +MAINTAINER ?= "isar-users <isar-users@googlegroups.com>" + +KBUILD_DEPENDS ?= "build-essential:native, \ + libelf-dev:native, \ + libncurses-dev:native, \ + libssl-dev:native, \ + bc, \ + bison, \ + cpio, \ + flex, \ + git, \ + kmod, \ + libssl-dev," + +KERNEL_DEBIAN_DEPENDS ?= "initramfs-tools | linux-initramfs-tool, \ + kmod, \ + linux-base (>= 4.3~)," + +KERNEL_HEADERS_DEBIAN_DEPENDS ?= "libc6, \ + libssl1.1," + +KERNEL_LIBC_DEV_DEPLOY ?= "0" + +# Settings that may be changed on a per distro, machine or layer basis +# -------------------------------------------------------------------- + +KERNEL_LOCALVERSION ?= "-${KERNEL_NAME_PROVIDED}-${PR}" +KERNEL_DTB_DIR ?= "usr/lib/linux-image-${PV}-${KERNEL_LOCALVERSION}" +KERNEL_HEADERS_DIR ?= "usr/src/linux-headers-${PV}-${KERNEL_LOCALVERSION}" -KERNEL_NAME_PROVIDED ?= "${@ d.getVar('PN', True).partition('linux-')[2]}" KERNEL_DEFCONFIG ?= "" +# Add our template meta-data to the sources +FILESEXTRAPATHS_prepend := "${FILE_DIRNAME}/files:" +SRC_URI += "file://debian" + +# Variables and files that make our templates +# ------------------------------------------- + +TEMPLATE_FILES += " \ + debian/control.tmpl \ + debian/isar/build.tmpl \ + debian/isar/clean.tmpl \ + debian/isar/common.tmpl \ + debian/isar/install.tmpl \ + debian/isar/version.cfg.tmpl \ + debian/linux-image.postinst.tmpl \ + debian/linux-image.postrm.tmpl \ + debian/linux-image.preinst.tmpl \ + debian/linux-image.prerm.tmpl \ + debian/rules.tmpl \ +" + +TEMPLATE_VARS += " \ + HOST_ARCH \ + KBUILD_DEPENDS \ + KERNEL_ARCH \ + KERNEL_DEBIAN_DEPENDS \ + KERNEL_BUILD_DIR \ + KERNEL_DTB_DIR \ + KERNEL_FILE \ + KERNEL_HEADERS_DEBIAN_DEPENDS \ + KERNEL_HEADERS_DIR \ + KERNEL_LOCALVERSION \ + KERNEL_NAME_PROVIDED \ +" + +inherit dpkg +inherit template + +# Derive name of the kernel packages from the name of this recipe +KERNEL_NAME_PROVIDED ?= "${@ d.getVar('PN', True).partition('linux-')[2]}" + +# Make bitbake know we will be producing linux-image and linux-headers packages python() { kernel_name = d.getVar("KERNEL_NAME_PROVIDED", True) d.setVar('PROVIDES', 'linux-image-' + kernel_name + ' ' + \ 'linux-headers-' + kernel_name) } -inherit dpkg-base - -SRC_URI += "file://build-kernel.sh" - -KBUILD_DEPENDS ?= " \ - build-essential:native \ - libssl-dev \ - libelf-dev \ - bc \ - git \ - kmod \ - bison \ - flex \ - cpio \ - libncurses-dev" -KERNEL_DEBIAN_DEPENDS ?= "initramfs-tools | linux-initramfs-tool, kmod, linux-base (>= 4.3~)" -KERNEL_HEADERS_DEBIAN_DEPENDS ?= "libc6, libssl1.1" - -KERNEL_LIBC_DEV_DEPLOY ?= "0" - -do_install_builddeps() { - dpkg_do_mounts - E="${@ isar_export_proxies(d)}" - sudo -E chroot ${BUILDCHROOT_DIR} \ - apt-get update \ - -o Dir::Etc::SourceList="sources.list.d/isar-apt.list" \ - -o Dir::Etc::SourceParts="-" \ - -o APT::Get::List-Cleanup="0" - sudo -E chroot ${BUILDCHROOT_DIR} \ - apt-get install \ - -y -o Debug::pkgProblemResolver=yes \ - --no-install-recommends ${KBUILD_DEPENDS} - dpkg_undo_mounts +def get_kernel_arch(d): + distro_arch = d.getVar("DISTRO_ARCH") + if distro_arch == "amd64": + kernel_arch = "x86" + elif distro_arch == "arm64": + kernel_arch = "arm64" + elif distro_arch == "armhf": + kernel_arch = "arm" + elif distro_arch == "mipsel": + kernel_arch = "mips" + else: + kernel_arch = "" + return kernel_arch + +KERNEL_ARCH ??= "${@get_kernel_arch(d)}" + +def config_fragments(d): + fragments = [] + sources = d.getVar("SRC_URI").split() + for s in sources: + _, _, local, _, _, parm = bb.fetch.decodeurl(s) + apply = parm.get("apply") + if apply == "no": + continue + base, ext = os.path.splitext(os.path.basename(local)) + if ext and ext in (".cfg"): + fragments.append(local) + return fragments + +do_prepare_build_prepend() { + # copy meta-data over to source tree + rm -rf ${S}/debian + cp -r ${WORKDIR}/debian ${S}/ + + # remove templates from the source tree + find ${S}/debian -name *.tmpl | xargs rm -f + + # rename install/remove hooks to match user-specified name for our linux-image package + mv ${S}/debian/linux-image.postinst ${S}/debian/linux-image-${KERNEL_NAME_PROVIDED}.postinst + mv ${S}/debian/linux-image.postrm ${S}/debian/linux-image-${KERNEL_NAME_PROVIDED}.postrm + mv ${S}/debian/linux-image.preinst ${S}/debian/linux-image-${KERNEL_NAME_PROVIDED}.preinst + mv ${S}/debian/linux-image.prerm ${S}/debian/linux-image-${KERNEL_NAME_PROVIDED}.prerm + + # produce a changelog for our kernel build + deb_add_changelog } -addtask install_builddeps after do_prepare_build before do_dpkg_build -# apt and reprepro may not run in parallel, acquire the Isar lock -do_install_builddeps[lockfiles] += "${REPO_ISAR_DIR}/isar.lock" - -addtask devshell after do_install_builddeps +# build directory for our "full" kernel build +KERNEL_BUILD_DIR = "build-full" -dpkg_runbuild() { - chmod +x ${WORKDIR}/build-kernel.sh - KERNEL_CONFIG_TARGET="${KERNEL_DEFCONFIG}" +dpkg_configure_kernel() { + config_target="${KERNEL_DEFCONFIG}" + rm -rf ${S}/${KERNEL_BUILD_DIR} && mkdir -p ${S}/${KERNEL_BUILD_DIR} if [ -n "${KERNEL_DEFCONFIG}" ]; then if [ -e "${WORKDIR}/${KERNEL_DEFCONFIG}" ]; then - cp ${WORKDIR}/${KERNEL_DEFCONFIG} ${S}/.config - KERNEL_CONFIG_TARGET="olddefconfig" + cp ${WORKDIR}/${KERNEL_DEFCONFIG} ${S}/${KERNEL_BUILD_DIR}/.config + config_target="olddefconfig" fi else - KERNEL_CONFIG_TARGET="defconfig" + config_target="defconfig" fi - E="${@ isar_export_proxies(d)}" - - export PV=${PV} - export KERNEL_NAME=${KERNEL_NAME_PROVIDED} - - export KBUILD_DEPENDS="${KBUILD_DEPENDS}" - export KERNEL_CONFIG_TARGET - export KERNEL_DEBIAN_DEPENDS="${KERNEL_DEBIAN_DEPENDS}" - export KERNEL_FILE="${KERNEL_FILE}" - export KERNEL_HEADERS_DEBIAN_DEPENDS="${KERNEL_HEADERS_DEBIAN_DEPENDS}" + # copy config fragments over to the kernel tree + src_frags="${@ " ".join(config_fragments(d)) }" + out_frags="${@ " ".join(map(lambda frag: 'debian/fragments/' + frag, config_fragments(d))) }" + rm -rf ${S}/debian/fragments + if [ -n "${src_frags}" ]; then + mkdir -p ${S}/debian/fragments + (cd ${WORKDIR} && cp ${src_frags} ${S}/debian/fragments/) + fi - sudo -E chroot --userspec=$( id -u ):$( id -g ) ${BUILDCHROOT_DIR} ${PP}/build-kernel.sh ${PP}/${PPS} ${DISTRO_ARCH} + sudo -E chroot --userspec=$(id -u):$(id -g) ${BUILDCHROOT_DIR} sh -c " \ + export ARCH=${KERNEL_ARCH} && \ + cd ${PP}/${PPS} && \ + make O=${KERNEL_BUILD_DIR} ${config_target} && \ + ./scripts/kconfig/merge_config.sh \ + -O ${KERNEL_BUILD_DIR}/ \ + ${KERNEL_BUILD_DIR}/.config \ + ${out_frags} \ + debian/isar/version.cfg \ + " +} +dpkg_runbuild_prepend() { + profiles="${BASE_DISTRO}" if [ "${KERNEL_LIBC_DEV_DEPLOY}" != "1" ]; then - rm -f ${WORKDIR}/linux-libc-dev_${PV}*.deb + profiles="${profiles} nolibcdev" fi + export DEB_BUILD_PROFILES="${profiles}" + dpkg_configure_kernel } -- 2.16.4 ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 4/5] linux-custom: rewrite to no longer depend on the kernel's builddeb 2019-12-10 18:22 ` [PATCH v5 4/5] linux-custom: rewrite to no longer depend on the kernel's builddeb Jan Kiszka @ 2019-12-11 14:40 ` Jan Kiszka 2019-12-11 15:20 ` Gylstorff Quirin 1 sibling, 0 replies; 16+ messages in thread From: Jan Kiszka @ 2019-12-11 14:40 UTC (permalink / raw) To: isar-users, Cedric Hombourger On 10.12.19 19:22, [ext] Jan Kiszka wrote: > From: Cedric Hombourger <Cedric_Hombourger@mentor.com> > > Regain control over the packaging of the Linux kernel by providing our > own debian recipes (debian,{control,rules} files and friends) instead > of using the kernel's builddeb script. This will allow generation of > packages for "perf" (not included in this changeset) with per distro > scheme (Debian and Ubuntu have differences) and maintain compatibility > with upstream packages generated from different source packages but > dependent on a certain deployment scheme (e.g. linux-base for Debian) > > Signed-off-by: Cedric Hombourger <Cedric_Hombourger@mentor.com> > [Jan: continue to build kernel-headers for the host, add changelog entry] > Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> > --- ... > diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc > index 712f52b..bf1646a 100644 > --- a/meta/recipes-kernel/linux/linux-custom.inc > +++ b/meta/recipes-kernel/linux/linux-custom.inc > @@ -2,89 +2,183 @@ > # > # This software is a part of ISAR. > # Copyright (c) Siemens AG, 2018 > +# Copyright (c) Mentor Graphics, a Siemens business, 2019 > # > # SPDX-License-Identifier: MIT > > -FILESEXTRAPATHS_prepend := "${FILE_DIRNAME}/files:" > +# Settings that would typically be done from the custom kernel recipe > +# ------------------------------------------------------------------- > > +CHANGELOG_V = "${PV}+${PR}" > DESCRIPTION ?= "Custom kernel" > +MAINTAINER ?= "isar-users <isar-users@googlegroups.com>" > + > +KBUILD_DEPENDS ?= "build-essential:native, \ > + libelf-dev:native, \ > + libncurses-dev:native, \ > + libssl-dev:native, \ > + bc, \ > + bison, \ > + cpio, \ > + flex, \ > + git, \ > + kmod, \ > + libssl-dev," > + > +KERNEL_DEBIAN_DEPENDS ?= "initramfs-tools | linux-initramfs-tool, \ > + kmod, \ > + linux-base (>= 4.3~)," > + > +KERNEL_HEADERS_DEBIAN_DEPENDS ?= "libc6, \ > + libssl1.1," > + > +KERNEL_LIBC_DEV_DEPLOY ?= "0" > + > +# Settings that may be changed on a per distro, machine or layer basis > +# -------------------------------------------------------------------- > + > +KERNEL_LOCALVERSION ?= "-${KERNEL_NAME_PROVIDED}-${PR}" It turns out that this is deviating from the old versioning and can break downstream layers. Fixable downstream, but then it needs to be documented (RECIPE-API-CHANGELOG). However, do we want this new default? Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 4/5] linux-custom: rewrite to no longer depend on the kernel's builddeb 2019-12-10 18:22 ` [PATCH v5 4/5] linux-custom: rewrite to no longer depend on the kernel's builddeb Jan Kiszka 2019-12-11 14:40 ` Jan Kiszka @ 2019-12-11 15:20 ` Gylstorff Quirin 2019-12-11 15:43 ` Jan Kiszka 1 sibling, 1 reply; 16+ messages in thread From: Gylstorff Quirin @ 2019-12-11 15:20 UTC (permalink / raw) To: isar-users, Kiszka, Jan (CT RDA IOT SES-DE) On 12/10/19 7:22 PM, [ext] Jan Kiszka wrote: > From: Cedric Hombourger <Cedric_Hombourger@mentor.com> > > Regain control over the packaging of the Linux kernel by providing our > own debian recipes (debian,{control,rules} files and friends) instead > of using the kernel's builddeb script. This will allow generation of > packages for "perf" (not included in this changeset) with per distro > scheme (Debian and Ubuntu have differences) and maintain compatibility > with upstream packages generated from different source packages but > dependent on a certain deployment scheme (e.g. linux-base for Debian) > > Signed-off-by: Cedric Hombourger <Cedric_Hombourger@mentor.com> > [Jan: continue to build kernel-headers for the host, add changelog entry] > Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> > --- > RECIPE-API-CHANGELOG.md | 8 + > doc/custom_kernel.md | 83 ++++++++ > meta/recipes-kernel/linux/files/build-kernel.sh | 125 ------------ > meta/recipes-kernel/linux/files/debian/compat | 1 + > .../recipes-kernel/linux/files/debian/control.tmpl | 37 ++++ > .../linux/files/debian/isar/build.tmpl | 45 +++++ > .../linux/files/debian/isar/clean.tmpl | 21 +++ > .../linux/files/debian/isar/common.tmpl | 50 +++++ > .../linux/files/debian/isar/install.tmpl | 192 +++++++++++++++++++ > .../linux/files/debian/isar/version.cfg.tmpl | 2 + > .../linux/files/debian/linux-image.postinst.tmpl | 29 +++ > .../linux/files/debian/linux-image.postrm.tmpl | 35 ++++ > .../linux/files/debian/linux-image.preinst.tmpl | 25 +++ > .../linux/files/debian/linux-image.prerm.tmpl | 21 +++ > meta/recipes-kernel/linux/files/debian/rules.tmpl | 39 ++++ > meta/recipes-kernel/linux/linux-custom.inc | 210 +++++++++++++++------ > 16 files changed, 740 insertions(+), 183 deletions(-) > create mode 100644 doc/custom_kernel.md > delete mode 100644 meta/recipes-kernel/linux/files/build-kernel.sh > create mode 100644 meta/recipes-kernel/linux/files/debian/compat > create mode 100644 meta/recipes-kernel/linux/files/debian/control.tmpl > create mode 100644 meta/recipes-kernel/linux/files/debian/isar/build.tmpl > create mode 100644 meta/recipes-kernel/linux/files/debian/isar/clean.tmpl > create mode 100644 meta/recipes-kernel/linux/files/debian/isar/common.tmpl > create mode 100644 meta/recipes-kernel/linux/files/debian/isar/install.tmpl > create mode 100644 meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl > create mode 100644 meta/recipes-kernel/linux/files/debian/linux-image.postinst.tmpl > create mode 100644 meta/recipes-kernel/linux/files/debian/linux-image.postrm.tmpl > create mode 100644 meta/recipes-kernel/linux/files/debian/linux-image.preinst.tmpl > create mode 100644 meta/recipes-kernel/linux/files/debian/linux-image.prerm.tmpl > create mode 100755 meta/recipes-kernel/linux/files/debian/rules.tmpl > > diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md > index 508e3f5..86c8418 100644 > --- a/RECIPE-API-CHANGELOG.md > +++ b/RECIPE-API-CHANGELOG.md > @@ -193,6 +193,7 @@ files and patches using bbappend a lot easier. > For example: > ``` > FILESEXTRAPATHS_prepend := "$THISDIR/files:" > +``` > > ### multiconfig build targets were renamed > > @@ -209,3 +210,10 @@ The old syntax is no longer supported and will produce an error: > ``` > bitbake multiconfig:qemuarm-stretch:isar-image-base > ``` > + > +### Support for kernel config fragments > + > +Kernels built via linux-custom.inc will now get configuration fragments listed > +in SRC_URI automatically applied. Config fragment files need to end on .cfg. > +If such a file should not by applied, append `;apply=no` to the respective > +SRC_URI entry. > diff --git a/doc/custom_kernel.md b/doc/custom_kernel.md > new file mode 100644 > index 0000000..ffeaddc > --- /dev/null > +++ b/doc/custom_kernel.md > @@ -0,0 +1,83 @@ > +# Custom kernel recipe for Isar > + > +## Contents > + > + - [Summary](#summary) > + - [Features](#features) > + - [Future](#future) > + - [Examples](#examples) > + > +## Summary > + > +Isar provides a recipe to build custom kernels for Debian-based distributions. > +It uses templates to generate the debian meta-data (such as debian/control) and > +Debian's [BuildProfiles](https://wiki.debian.org/BuildProfileSpec) to handle > +some of the distro specific variations. It should be noted that Isar has moved > +away from using the kernel's builddeb script since it would not generate all > +the packages we need (and in particular perf). > + > +## Features > + > +The linux-custom recipe provides support for: > + > + 1. Sources to the custom Linux kernel may be specified via `SRC_URI` > + > + 2. Configure the kernel via an in-tree or an external `defconfig` via > + `KERNEL_DEFCONFIG` > + > + 3. Integrate kernel configuration tweaks via configuration fragments (`.cfg` > + files) > + > + 4. Patches to the linux kernel may be specified via `SRC_URI` > + > + 5. Ensure that the Isar recipe `PV` matches the kernel release identifier > + (`KERNEL_RELEASE`) > + > + 6. Produce a `linux-image` package that ships the kernel image and modules > + > + 7. Allow the name of the kernel image to be changed via `KERNEL_FILE` (defaults > + to `vmlinuz`) > + > + 8. Produce a `linux-headers` package which includes kernel headers and kbuild > + scripts/tools > + > + 9. The `linux-headers` package shall support native and cross compiles of > + out-of-tree kernel modules. However, when built in cross-compilation mode, > + it cannot be used on the target so far. > + > + 10. Produce a `linux-libc-dev` package to support user-land builds > + > + 11. Only build/ship the `linux-libc-dev` package if instructed to > + (`KERNEL_LIBC_DEV_DEPLOY` equals to `"1"`) > + > + 12. Support both native and cross compiles (`ISAR_CROSS_COMPILE`) > + > + 13. Support for the following kernel architectures: > + > + * arm > + * arm64 > + * mips > + * x86 > + > + 14. Support `devshell` (kernel configuration shall be applied) > + > +## Future > + > +In the future, the recipe may be extended to: > + > + 1. Package perf > + > + 2. Support inclusion/build of dts files listed in `SRC_URI` > + > + 3. Be compatible with Ubuntu > + > + 4. When cross-building, generate kernel-headers for both host and target > + > +## Examples > + > +The linux-custom recipe is currently used by the linux-mainline package and is > +used mainline recipe may be used for some basic testing. This recipe is being > +used by the following machines: > + > + * de0-nano-soc > + * qemumipsel > diff --git a/meta/recipes-kernel/linux/files/build-kernel.sh b/meta/recipes-kernel/linux/files/build-kernel.sh > deleted file mode 100644 > index 386e58b..0000000 > --- a/meta/recipes-kernel/linux/files/build-kernel.sh > +++ /dev/null > @@ -1,125 +0,0 @@ > -#!/bin/bash > -# > -# Custom kernel build > -# > -# This software is a part of ISAR. > -# Copyright (c) Siemens AG, 2018 > -# > -# SPDX-License-Identifier: MIT > - > -source /isar/common.sh > - > -host_arch=$(dpkg --print-architecture) > - > -if [ "$host_arch" != "$target_arch" ]; then > - case $target_arch in > - armhf) > - export ARCH=arm > - export CROSS_COMPILE="arm-linux-gnueabihf-" > - ;; > - arm64) > - export ARCH=arm64 > - export CROSS_COMPILE="aarch64-linux-gnu-" > - ;; > - mipsel) > - export ARCH=mips > - export CROSS_COMPILE="mipsel-linux-gnu-" > - ;; > - *) > - echo "error: unsupported architecture ($target_arch)" > - exit 1 > - ;; > - esac > -fi > - > -REPACK_DIR="$1/../repack" > -REPACK_LINUX_IMAGE_DIR="${REPACK_DIR}/linux-image" > -REPACK_LINUX_HEADERS_DIR="${REPACK_DIR}/linux-headers" > - > -make ${KERNEL_CONFIG_TARGET} || exit ${?} > - > -KV=$( make -s kernelrelease ) > -if [ "${KV}" != "${PV}" ]; then > - echo "ERROR: Recipe PV is \"${PV}\" but should be \"${KV}\"" 1>&2 > - echo "ERROR: Probably due to CONFIG_LOCALVERSION" 1>&2 > - exit 1 > -fi > - > -rm -f .version > -KBUILD_DEBARCH=$target_arch make -j $(($(nproc) * 2)) deb-pkg > - > -rm -rf "${REPACK_DIR}" > -mkdir -p "${REPACK_DIR}" > -mkdir -p "${REPACK_LINUX_IMAGE_DIR}" > -mkdir -p "${REPACK_LINUX_HEADERS_DIR}" > - > -cp -a debian "${REPACK_DIR}" > - > -# dpkg-gencontrol performs cross-incompatible checks on the > -# Architecture field; trick it to accept the control file > -sed -i "s/Architecture: .*/Architecture: any/" "${REPACK_DIR}/debian/control" > - > -cd .. > - > -dpkg-deb -R linux-image-${PV}_${PV}-1_*.deb "${REPACK_LINUX_IMAGE_DIR}" > -dpkg-deb -R linux-headers-${PV}_${PV}-1_*.deb "${REPACK_LINUX_HEADERS_DIR}" > - > -dpkg-gencontrol -crepack/debian/control \ > - -lrepack/debian/changelog \ > - -frepack/debian/files \ > - -plinux-image-${PV} \ > - -P"${REPACK_LINUX_IMAGE_DIR}" \ > - -DPackage="linux-image-${KERNEL_NAME}" \ > - -DSection=kernel \ > - -DPriority=required \ > - -DDepends="${KERNEL_DEBIAN_DEPENDS}" \ > - -DArchitecture=$target_arch > - > -# Add Debian-like link installation to postinst > -mkdir -p ${REPACK_LINUX_IMAGE_DIR}/lib/modules/${PV} > -touch "${REPACK_LINUX_IMAGE_DIR}/lib/modules/${PV}/.fresh-install" > -sed -i "${REPACK_LINUX_IMAGE_DIR}/DEBIAN/postinst" \ > - -e "/^set -e$/a\\ > -\\ > -if [ -f /lib/modules/${PV}/.fresh-install ]; then\\ > - change=install\\ > -else\\ > - change=upgrade\\ > -fi\\ > -linux-update-symlinks \$change ${PV} /boot/${KERNEL_FILE}-${PV}\\ > -rm -f /lib/modules/${PV}/.fresh-install" > - > -# Add Debian-like link removal to postrm > -sed -i "${REPACK_LINUX_IMAGE_DIR}/DEBIAN/postrm" \ > - -e "/^set -e$/a\\ > -\\ > -rm -f /lib/modules/${PV}/.fresh-install\\ > -\\ > -if [ \"\$1\" != upgrade ] && command -v linux-update-symlinks >/dev/null; then\\ > - linux-update-symlinks remove ${PV} /boot/${KERNEL_FILE}-${PV}\\ > -fi" > - > -# Make sure arm64 kernels are decompressed > -if [ "$target_arch" = "arm64" ]; then > - kernel_file="${REPACK_LINUX_IMAGE_DIR}/boot/${KERNEL_FILE}-${PV}" > - mv "${kernel_file}" "${kernel_file}.gz" > - gunzip "${kernel_file}.gz" > -fi > - > -dpkg-gencontrol -crepack/debian/control \ > - -lrepack/debian/changelog \ > - -frepack/debian/files \ > - -plinux-headers-${PV} \ > - -P"${REPACK_LINUX_HEADERS_DIR}" \ > - -Vkernel:debarch="${KERNEL_NAME}" \ > - -DPackage="linux-headers-${KERNEL_NAME}" \ > - -DSection=kernel \ > - -DDepends="${KERNEL_HEADERS_DEBIAN_DEPENDS}" \ > - -DArchitecture=$target_arch > - > -fakeroot dpkg-deb -b "${REPACK_LINUX_IMAGE_DIR}" \ > - linux-image-${KERNEL_NAME}_${PV}-1_${KERNEL_NAME}.deb > -rm -f linux-image-${PV}_${PV}-1_*.deb > -fakeroot dpkg-deb -b "${REPACK_LINUX_HEADERS_DIR}" \ > - linux-headers-${KERNEL_NAME}_${PV}-1_${KERNEL_NAME}.deb > -rm -f linux-headers-${PV}_${PV}-1_*.deb > diff --git a/meta/recipes-kernel/linux/files/debian/compat b/meta/recipes-kernel/linux/files/debian/compat > new file mode 100644 > index 0000000..ec63514 > --- /dev/null > +++ b/meta/recipes-kernel/linux/files/debian/compat > @@ -0,0 +1 @@ > +9 > diff --git a/meta/recipes-kernel/linux/files/debian/control.tmpl b/meta/recipes-kernel/linux/files/debian/control.tmpl > new file mode 100644 > index 0000000..7236732 > --- /dev/null > +++ b/meta/recipes-kernel/linux/files/debian/control.tmpl > @@ -0,0 +1,37 @@ > +Source: linux-${KERNEL_NAME_PROVIDED} > +Section: kernel > +Priority: optional > +Maintainer: ${MAINTAINER} > +Build-Depends: bc, kmod, cpio, ${KBUILD_DEPENDS} > +Homepage: http://www.kernel.org/ > + > +Package: linux-image-${KERNEL_NAME_PROVIDED} > +Architecture: any > +Depends: ${KERNEL_DEBIAN_DEPENDS} > +Description: ${KERNEL_NAME_PROVIDED} Linux kernel, version ${PV}-${KERNEL_LOCALVERSION} > + This package contains the Linux kernel, modules and corresponding other > + files, version: ${PV}-${KERNEL_LOCALVERSION}. > + > +Package: linux-headers-${KERNEL_NAME_PROVIDED} > +Architecture: any > +Depends: ${KERNEL_HEADERS_DEBIAN_DEPENDS}, ${perl:Depends}, ${shlib:Depends} > +Description: ${KERNEL_NAME_PROVIDED} Linux kernel headers for ${PV}-${KERNEL_LOCALVERSION} > + This package provides kernel header files for ${PV}-${KERNEL_LOCALVERSION} on ${DISTRO_ARCH} > + . > + This is useful for people who need to build external modules > + > +Package: linux-libc-dev > +Build-Profiles: <!nolibcdev> > +Section: devel > +Provides: linux-kernel-headers > +Architecture: any > +Description: Linux support headers for userspace development > + This package provides userspaces headers from the Linux kernel. These headers > + are used by the installed headers for GNU glibc and other system libraries. > + > +Package: linux-image-${KERNEL_NAME_PROVIDED}-dbg > +Section: debug > +Architecture: any > +Description: Linux kernel debugging symbols for ${PV}-${KERNEL_LOCALVERSION} > + This package will come in handy if you need to debug the kernel. It provides > + all the necessary debug symbols for the kernel and its modules. > diff --git a/meta/recipes-kernel/linux/files/debian/isar/build.tmpl b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl > new file mode 100644 > index 0000000..1775b19 > --- /dev/null > +++ b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl > @@ -0,0 +1,45 @@ > +#!/bin/bash > +# Copyright (c) Mentor Graphics, a Siemens business, 2019 > +# SPDX-License-Identifier: MIT > + > +# Load common stuff > +. ${S}/debian/isar/common || exit ${?} > + > +do_build() { > + > + # Print a few things that are of particular interest > + print_settings > + > + # Process existing kernel configuration to make sure it is complete > + # (use defaults for options that were not specified) > + ${MAKE} O=${KERNEL_BUILD_DIR} olddefconfig prepare || exit ${?} > + > + # Check if the recipe's PV makes sense > + KR=$(${MAKE} O=${KERNEL_BUILD_DIR} -s --no-print-directory kernelrelease) > + eval $(grep ^CONFIG_LOCALVERSION= ${KERNEL_BUILD_DIR}/${KCONF} || true) > + if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then > + echo "ERROR: Recipe version (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the kernelrelease (${KR})!" 1>&2 > + echo "ERROR: Make sure the kernel version in your NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 > + exit 1 > + fi we have some CI use case where we build the latest git release could we add something like this - if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then - echo "ERROR: Recipe version (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the kernelrelease (${KR})!" 1>&2 - echo "ERROR: Make sure the kernel version in your NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 - exit 1 + if [ "${PV}" =~ "latest" ]; then + if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then + echo "ERROR: Recipe version (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the kernelrelease (${KR})!" 1>&2 + echo "ERROR: Make sure the kernel version in your NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 + exit 1 + fi > + > + # Trace what we do here > + set -x > + > + # Build the Linux kernel > + ${MAKE} O=${KERNEL_BUILD_DIR} -j $(nproc) || exit ${?} > + > + # Stop tracing > + set +x > +} > + > +print_settings() { > + cat <<EOF > +# Build settings: > +# --------------- > +# ARCH=${ARCH} > +# CROSS_COMPILE=${CROSS_COMPILE} > +EOF > +} > + > +main build ${*} > diff --git a/meta/recipes-kernel/linux/files/debian/isar/clean.tmpl b/meta/recipes-kernel/linux/files/debian/isar/clean.tmpl > new file mode 100644 > index 0000000..f903987 > --- /dev/null > +++ b/meta/recipes-kernel/linux/files/debian/isar/clean.tmpl > @@ -0,0 +1,21 @@ > +#!/bin/bash > +# Copyright (c) Mentor Graphics, a Siemens business, 2019 > +# SPDX-License-Identifier: MIT > + > +# Load common stuff > +. ${S}/debian/isar/common || exit ${?} > + > +do_clean() { > + > + # Trace what we do here > + set -x > + > + rm -rf ${deb_img_dir} ${deb_dbg_dir} > + rm -rf ${deb_kern_hdrdir} > + rm -rf ${deb_libc_hdr_dir} > + > + # Stop tracing > + set +x > +} > + > +main clean ${*} > diff --git a/meta/recipes-kernel/linux/files/debian/isar/common.tmpl b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl > new file mode 100644 > index 0000000..44f67b3 > --- /dev/null > +++ b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl > @@ -0,0 +1,50 @@ > +#!/bin/bash > +# Copyright (c) Mentor Graphics, a Siemens business, 2019 > +# SPDX-License-Identifier: MIT > + > +# Isar settings > +ARCH=${KERNEL_ARCH} > +KERNEL_PKG_IMAGE=linux-image-${KERNEL_NAME_PROVIDED} > +KERNEL_PKG_KERN_HEADERS=linux-headers-${KERNEL_NAME_PROVIDED} > +KERNEL_PKG_LIBC_HEADERS=linux-libc-dev > + > +# Constants > +KCONF=.config > + > +# Target directories > +deb_top_dir=${S}/debian > +deb_img_dir=${deb_top_dir}/${KERNEL_PKG_IMAGE} > +deb_dbg_dir=${deb_img_dir}-dbg > +deb_dtb_dir=${deb_img_dir}/${KERNEL_DTB_DIR} > +deb_kern_hdr_dir=${deb_top_dir}/${KERNEL_PKG_KERN_HEADERS} > +deb_libc_hdr_dir=${deb_top_dir}/${KERNEL_PKG_LIBC_HEADERS} > + > +# Array of packages to be generated > +declare -A kern_pkgs > + > +main() { > + local target=${1} > + > + if [ ! -f ${S}/debian/isar/${target} ]; then > + echo "error: ${target} is not a supported build target!" >&2 > + return 1 > + fi > + > + # create do_<x> variables for each package to be generated > + for p in $(unset DEB_HOST_ARCH; dh_listpackages); do > + kern_pkgs["${p}"]="1" > + done > + > + # variables to be exported > + export ARCH > + > + # are we cross-compiling? > + BUILD_ARCH=$(dpkg-architecture -qDEB_BUILD_ARCH) > + if [ "${BUILD_ARCH}" = "${DISTRO_ARCH}" ]; then > + # no, make sure CROSS_COMPILE isn't set > + unset CROSS_COMPILE > + fi > + > + # call the actual target script > + do_${target} || return ${?} > +} > diff --git a/meta/recipes-kernel/linux/files/debian/isar/install.tmpl b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl > new file mode 100644 > index 0000000..67b7ce3 > --- /dev/null > +++ b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl > @@ -0,0 +1,192 @@ > +#!/bin/bash > +# Copyright (c) Mentor Graphics, a Siemens business, 2019 > +# SPDX-License-Identifier: MIT > + > +# Load common stuff > +. ${S}/debian/isar/common || exit ${?} > + > +# Stop on error > +set -e > + > +do_install() { > + > + # check if our kernel was configured > + if [ ! -f "${O}/.config" ]; then > + echo "error: kernel not configured!" >&2 > + return 1 > + fi > + > + # load its configuration > + . ${O}/.config > + > + kimage="$(${MAKE} O=${O} -s --no-print-directory image_name)" > + krel="$(${MAKE} O=${O} -s --no-print-directory kernelrelease)" > + case "${ARCH}" in > + mips|powerpc) kimage_path="boot/vmlinux-${krel}" ;; > + um) kimage_path="usr/bin/vmlinux-${krel}" ;; > + *) kimage_path="boot/vmlinuz-${krel}" ;; > + esac > + > + print_settings > + > + # Trace what we do here > + set -x > + > + install_image > + install_hooks > + install_dtbs > + install_kmods > + install_headers > + > + # Stop tracing > + set +x > +} > + > +print_settings() { > + cat <<EOF > +Install settings: > +----------------- > +deb_dtb_dir=${deb_dtb_dir} > +deb_hdr_dir=${deb_hdr_dir} > +kimage=${kimage} > +kimage_path=${kimage_path} > + > +EOF > +} > + > +install_image() { > + install -m 755 -d ${deb_img_dir}/$(dirname ${kimage_path}) > + cp ${O}/${kimage} ${deb_img_dir}/${kimage_path} > + > + # Make sure arm64 kernels are decompressed > + if [ "${ARCH}" = "arm64" ]; then > + mv ${deb_img_dir}/${kimage_path} ${deb_img_dir}/${kimage_path}.gz > + gunzip -f ${deb_img_dir}/${kimage_path}.gz > + fi > + > + install_image_debug > +} > + > +install_image_debug() { > + # Different tools want the image in different locations > + # perf > + mkdir -p ${deb_dbg_dir}/usr/lib/debug/lib/modules/${krel}/ > + cp ${O}/vmlinux ${deb_dbg_dir}/usr/lib/debug/lib/modules/${krel}/ > + # systemtap > + mkdir -p ${deb_dbg_dir}/usr/lib/debug/boot/ > + ln -s ../lib/modules/$version/vmlinux ${deb_dbg_dir}/usr/lib/debug/boot/vmlinux-${krel} > + # kdump-tools > + ln -s lib/modules/${krel}/vmlinux ${deb_dbg_dir}/usr/lib/debug/vmlinux-${krel} > +} > + > +install_hooks() { > + install -m 755 -d ${deb_img_dir}/etc/kernel/install.d > + install -m 755 -d ${deb_img_dir}/etc/kernel/postinst.d > + install -m 755 -d ${deb_img_dir}/etc/kernel/postrm.d > + install -m 755 -d ${deb_img_dir}/etc/kernel/prerm.d > + > + initrd="No" > + [ -z "${CONFIG_BLK_DEV_INITRD}" ] || initrd="Yes" > + > + for script in postinst postrm preinst prerm; do > + sed -i -e "s,INITRD=[A-Za-z0-9]*,INITRD=${initrd},g" ${S}/debian/linux-image*.${script} > + sed -i -e "s,version=.*,version=${krel},g" ${S}/debian/linux-image*.${script} > + done > +} > + > +install_dtbs() { > + [ -n "${CONFIG_OF}" ] || return 0 > + ${MAKE} O=${O} INSTALL_DTBS_PATH=${deb_dtb_dir} dtbs_install > +} > + > +install_kmods() { > + [ -n "${CONFIG_MODULES}" ] || return 0 > + ${MAKE} O=${O} INSTALL_MOD_PATH=${deb_img_dir} modules_install > + touch ${deb_img_dir}/lib/modules/${krel}/.fresh-install > + rm -fv ${deb_img_dir}/lib/modules/${krel}/build > + rm -fv ${deb_img_dir}/lib/modules/${krel}/source > + install_kmods_debug > +} > + > +kmods_sign() { > + [ -n "${CONFIG_MODULE_SIG_ALL}" ] || return 0 > + ${MAKE} O=${O} INSTALL_MOD_PATH=${deb_img_dir} modules_sign > +} > + > +install_kmods_debug() { > + [ -n "${CONFIG_DEBUG_INFO}" ] || return 0 > + > + kmod_inst_dir=${deb_img_dir}/lib/modules > + kmod_debug_dir=${deb_dbg_dir}/usr/lib/debug > + > + # copy kernels modules to usr/lib/debug > + mkdir -p ${kmod_debug_dir} > + tar -C ${kmod_inst_dir}/ -cO --exclude='modules.*' . | tar -C ${kmod_debug_dir}/ -xf - > + # strip everything but debug sections for modules in usr/lib/debug > + find ${kmod_debug_dir} -name *.ko -exec ${CROSS_COMPILE}objcopy --only-keep-debug {} \; > + # and strip debug sections from modules in lib/modules > + find ${kmod_inst_dir} -name *.ko -exec ${CROSS_COMPILE}objcopy --strip-debug {} \; > + > + # re-sign stripped kernel modules > + kmods_sign > +} > + > +headers_check() { > + ${MAKE} O=${O} headers_check > +} > + > +libc_headers() { > + mkdir -p ${deb_libc_hdr_dir} > + ${MAKE} O=${O} headers_install INSTALL_HDR_PATH=${deb_libc_hdr_dir}/usr > + host_arch=$(dpkg-architecture -a${DISTRO_ARCH} -qDEB_HOST_MULTIARCH) > + mkdir ${deb_libc_hdr_dir}/usr/include/${host_arch} > + mv ${deb_libc_hdr_dir}/usr/include/asm ${deb_libc_hdr_dir}/usr/include/${host_arch}/ > +} > + > +kernel_tools() { > + # remove object files > + find ${destdir}/scripts -type f -name '*.o' |xargs rm -f > +} > + > +kernel_headers() { > + destdir=${deb_kern_hdr_dir}/${KERNEL_HEADERS_DIR} > + src_hdr_files=$(mktemp) > + obj_hdr_files=$(mktemp) > + > + mkdir -p ${destdir} > + mkdir -p ${deb_kern_hdr_dir}/lib/modules/${krel} > + > + (cd ${S}; find . -name 'Makefile*' -o -name 'Kconfig*' -o -name '*.pl') >>${src_hdr_files} > + (cd ${S}; find arch/*/include include scripts -type f -o -type l) >>${src_hdr_files} > + (cd ${S}; find arch/${ARCH} -name module.lds -o -name Kbuild.platforms -o -name Platform) >>${src_hdr_files} > + (cd ${S}; find $(find arch/${ARCH} -name include -o -name scripts -type d) -type f) >>${src_hdr_files} > + > + (cd ${O}; find arch/${ARCH}/include Module.symvers include scripts -type f) >>${obj_hdr_files} > + if [ -n "${CONFIG_STACK_VALIDATION}" ]; then > + (cd ${O}; find tools/objtool -type f -executable) >>${obj_hdr_files} > + fi > + if [ -n "${CONFIG_GCC_PLUGINS}" ]; then > + (cd ${O}; find scripts/gcc-plugins -name *.so -o -name gcc-common.h) >>${obj_hdr_files} > + fi > + > + # deploy files that were matched above > + tar -C ${S} -cf - -T - <${src_hdr_files} | tar -C ${destdir} -xf - > + tar -C ${O} -cf - -T - <${obj_hdr_files} | tar -C ${destdir} -xf - > + > + # add the kernel config > + cp ${O}/${KCONF} ${destdir}/.config > + > + # handle kernel development tools > + kernel_tools > + > + # create symlinks > + ln -sf /${KERNEL_HEADERS_DIR} ${deb_kern_hdr_dir}/lib/modules/${krel}/build > +} > + > +install_headers() { > + headers_check > + [ -z ${kern_pkgs["linux-libc-headers"]} ] || libc_headers > + kernel_headers > +} > + > +main install ${*} > diff --git a/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl b/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl > new file mode 100644 > index 0000000..09fa364 > --- /dev/null > +++ b/meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl > @@ -0,0 +1,2 @@ > +CONFIG_LOCALVERSION="-${KERNEL_LOCALVERSION}" > +# CONFIG_LOCALVERSION_AUTO is not set > diff --git a/meta/recipes-kernel/linux/files/debian/linux-image.postinst.tmpl b/meta/recipes-kernel/linux/files/debian/linux-image.postinst.tmpl > new file mode 100644 > index 0000000..b373801 > --- /dev/null > +++ b/meta/recipes-kernel/linux/files/debian/linux-image.postinst.tmpl > @@ -0,0 +1,29 @@ > +#!/bin/sh > +# based on https://salsa.debian.org/kernel-team/linux/blob/master/debian/templates/image.postinst.in > + > +# Tell initramfs builder whether it's wanted > +export INITRD=Yes > + > +version=${PV}-${KERNEL_LOCALVERSION} > +image_path=/boot/${KERNEL_FILE}-${version} > + > +if [ "$1" != configure ]; then > + exit 0 > +fi > + > +depmod $version > + > +if [ -f /lib/modules/$version/.fresh-install ]; then > + change=install > +else > + change=upgrade > +fi > +linux-update-symlinks $change $version $image_path > +rm -f /lib/modules/$version/.fresh-install > + > +if [ -d /etc/kernel/postinst.d ]; then > + DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error --arg=$version \ > + --arg=$image_path /etc/kernel/postinst.d > +fi > + > +exit 0 > diff --git a/meta/recipes-kernel/linux/files/debian/linux-image.postrm.tmpl b/meta/recipes-kernel/linux/files/debian/linux-image.postrm.tmpl > new file mode 100644 > index 0000000..1b5dbbe > --- /dev/null > +++ b/meta/recipes-kernel/linux/files/debian/linux-image.postrm.tmpl > @@ -0,0 +1,35 @@ > +#!/bin/sh -e > +# based on https://salsa.debian.org/kernel-team/linux/blob/master/debian/templates/image.postrm.in > + > +# Tell initramfs builder whether it's wanted > +export INITRD=Yes > + > +version=${PV}-${KERNEL_LOCALVERSION} > +image_path=/boot/${KERNEL_FILE}-${version} > + > +rm -f /lib/modules/$version/.fresh-install > + > +if [ "$1" != upgrade ] && command -v linux-update-symlinks >/dev/null; then > + linux-update-symlinks remove $version $image_path > +fi > + > +if [ -d /etc/kernel/postrm.d ]; then > + DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error --arg=$version \ > + --arg=$image_path /etc/kernel/postrm.d > +fi > + > +if [ "$1" = purge ]; then > + for extra_file in modules.dep modules.isapnpmap modules.pcimap \ > + modules.usbmap modules.parportmap \ > + modules.generic_string modules.ieee1394map \ > + modules.ieee1394map modules.pnpbiosmap \ > + modules.alias modules.ccwmap modules.inputmap \ > + modules.symbols modules.ofmap \ > + modules.seriomap modules.\*.bin \ > + modules.softdep modules.devname; do > + eval rm -f /lib/modules/$version/$extra_file > + done > + rmdir /lib/modules/$version || true > +fi > + > +exit 0 > diff --git a/meta/recipes-kernel/linux/files/debian/linux-image.preinst.tmpl b/meta/recipes-kernel/linux/files/debian/linux-image.preinst.tmpl > new file mode 100644 > index 0000000..4f24019 > --- /dev/null > +++ b/meta/recipes-kernel/linux/files/debian/linux-image.preinst.tmpl > @@ -0,0 +1,25 @@ > +#!/bin/sh -e > +# based on https://salsa.debian.org/kernel-team/linux/blob/master/debian/templates/image.preinst.in > + > +# Tell initramfs builder whether it's wanted > +export INITRD=Yes > + > +version=${PV}-${KERNEL_LOCALVERSION} > +image_path=/boot/${KERNEL_FILE}-${version} > + > +if [ "$1" = abort-upgrade ]; then > + exit 0 > +fi > + > +if [ "$1" = install ]; then > + # Create a flag file for postinst > + mkdir -p /lib/modules/$version > + touch /lib/modules/$version/.fresh-install > +fi > + > +if [ -d /etc/kernel/preinst.d ]; then > + DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error --arg=$version \ > + --arg=$image_path /etc/kernel/preinst.d > +fi > + > +exit 0 > diff --git a/meta/recipes-kernel/linux/files/debian/linux-image.prerm.tmpl b/meta/recipes-kernel/linux/files/debian/linux-image.prerm.tmpl > new file mode 100644 > index 0000000..cd697c0 > --- /dev/null > +++ b/meta/recipes-kernel/linux/files/debian/linux-image.prerm.tmpl > @@ -0,0 +1,21 @@ > +#!/bin/sh -e > +# based on https://salsa.debian.org/kernel-team/linux/blob/master/debian/templates/image.prerm.in > + > +# Tell initramfs builder whether it's wanted > +export INITRD=Yes > + > +version=${PV}-${KERNEL_LOCALVERSION} > +image_path=/boot/${KERNEL_FILE}-${version} > + > +if [ "$1" != remove ]; then > + exit 0 > +fi > + > +linux-check-removal $version > + > +if [ -d /etc/kernel/prerm.d ]; then > + DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error --arg=$version \ > + --arg=$image_path /etc/kernel/prerm.d > +fi > + > +exit 0 > diff --git a/meta/recipes-kernel/linux/files/debian/rules.tmpl b/meta/recipes-kernel/linux/files/debian/rules.tmpl > new file mode 100755 > index 0000000..bea21f9 > --- /dev/null > +++ b/meta/recipes-kernel/linux/files/debian/rules.tmpl > @@ -0,0 +1,39 @@ > +#!/usr/bin/make -f > + > +CROSS_COMPILE:=$(DEB_HOST_GNU_TYPE)- > + > +O:=$(CURDIR)/${KERNEL_BUILD_DIR} > +S:=$(CURDIR) > +deb_top_dir:=$(S)/debian > + > +# Dynamic variables to be passed to Isar build scripts > +isar_env=$(strip \ > + export CROSS_COMPILE='$(CROSS_COMPILE)' && \ > + export DEB_BUILD_PROFILES='$(DEB_BUILD_PROFILES)' && \ > + export DEB_HOST_GNU_TYPE='$(DEB_HOST_GNU_TYPE)' && \ > + export MAKE='$(MAKE)' && \ > + export O='${O}' \ > + export S='${S}' \ > +) > + > +%: > + dh $(@) > + > +.PHONY: override_dh_auto_clean > +override_dh_auto_clean: > + $(isar_env) && bash $(deb_top_dir)/isar/clean > + > +.PHONY: override_dh_auto_build > +override_dh_auto_build: > + $(isar_env) && bash $(deb_top_dir)/isar/build > + > +override_dh_auto_install: > + $(isar_env) && bash $(deb_top_dir)/isar/install > + > +.PHONY: override_dh_auto_test > +override_dh_auto_test: > + true > + > +PHONY: override_dh_strip > +override_dh_strip: > + unset DEB_HOST_GNU_TYPE && dh_strip -Xvmlinux --no-automatic-dbgsym > diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc > index 712f52b..bf1646a 100644 > --- a/meta/recipes-kernel/linux/linux-custom.inc > +++ b/meta/recipes-kernel/linux/linux-custom.inc > @@ -2,89 +2,183 @@ > # > # This software is a part of ISAR. > # Copyright (c) Siemens AG, 2018 > +# Copyright (c) Mentor Graphics, a Siemens business, 2019 > # > # SPDX-License-Identifier: MIT > > -FILESEXTRAPATHS_prepend := "${FILE_DIRNAME}/files:" > +# Settings that would typically be done from the custom kernel recipe > +# ------------------------------------------------------------------- > > +CHANGELOG_V = "${PV}+${PR}" > DESCRIPTION ?= "Custom kernel" > +MAINTAINER ?= "isar-users <isar-users@googlegroups.com>" > + > +KBUILD_DEPENDS ?= "build-essential:native, \ > + libelf-dev:native, \ > + libncurses-dev:native, \ > + libssl-dev:native, \ > + bc, \ > + bison, \ > + cpio, \ > + flex, \ > + git, \ > + kmod, \ > + libssl-dev," > + > +KERNEL_DEBIAN_DEPENDS ?= "initramfs-tools | linux-initramfs-tool, \ > + kmod, \ > + linux-base (>= 4.3~)," > + > +KERNEL_HEADERS_DEBIAN_DEPENDS ?= "libc6, \ > + libssl1.1," > + > +KERNEL_LIBC_DEV_DEPLOY ?= "0" > + > +# Settings that may be changed on a per distro, machine or layer basis > +# -------------------------------------------------------------------- > + > +KERNEL_LOCALVERSION ?= "-${KERNEL_NAME_PROVIDED}-${PR}" > +KERNEL_DTB_DIR ?= "usr/lib/linux-image-${PV}-${KERNEL_LOCALVERSION}" > +KERNEL_HEADERS_DIR ?= "usr/src/linux-headers-${PV}-${KERNEL_LOCALVERSION}" > > -KERNEL_NAME_PROVIDED ?= "${@ d.getVar('PN', True).partition('linux-')[2]}" > KERNEL_DEFCONFIG ?= "" > > +# Add our template meta-data to the sources > +FILESEXTRAPATHS_prepend := "${FILE_DIRNAME}/files:" > +SRC_URI += "file://debian" > + > +# Variables and files that make our templates > +# ------------------------------------------- > + > +TEMPLATE_FILES += " \ > + debian/control.tmpl \ > + debian/isar/build.tmpl \ > + debian/isar/clean.tmpl \ > + debian/isar/common.tmpl \ > + debian/isar/install.tmpl \ > + debian/isar/version.cfg.tmpl \ > + debian/linux-image.postinst.tmpl \ > + debian/linux-image.postrm.tmpl \ > + debian/linux-image.preinst.tmpl \ > + debian/linux-image.prerm.tmpl \ > + debian/rules.tmpl \ > +" > + > +TEMPLATE_VARS += " \ > + HOST_ARCH \ > + KBUILD_DEPENDS \ > + KERNEL_ARCH \ > + KERNEL_DEBIAN_DEPENDS \ > + KERNEL_BUILD_DIR \ > + KERNEL_DTB_DIR \ > + KERNEL_FILE \ > + KERNEL_HEADERS_DEBIAN_DEPENDS \ > + KERNEL_HEADERS_DIR \ > + KERNEL_LOCALVERSION \ > + KERNEL_NAME_PROVIDED \ > +" > + > +inherit dpkg > +inherit template > + > +# Derive name of the kernel packages from the name of this recipe > +KERNEL_NAME_PROVIDED ?= "${@ d.getVar('PN', True).partition('linux-')[2]}" > + > +# Make bitbake know we will be producing linux-image and linux-headers packages > python() { > kernel_name = d.getVar("KERNEL_NAME_PROVIDED", True) > d.setVar('PROVIDES', 'linux-image-' + kernel_name + ' ' + \ > 'linux-headers-' + kernel_name) > } > > -inherit dpkg-base > - > -SRC_URI += "file://build-kernel.sh" > - > -KBUILD_DEPENDS ?= " \ > - build-essential:native \ > - libssl-dev \ > - libelf-dev \ > - bc \ > - git \ > - kmod \ > - bison \ > - flex \ > - cpio \ > - libncurses-dev" > -KERNEL_DEBIAN_DEPENDS ?= "initramfs-tools | linux-initramfs-tool, kmod, linux-base (>= 4.3~)" > -KERNEL_HEADERS_DEBIAN_DEPENDS ?= "libc6, libssl1.1" > - > -KERNEL_LIBC_DEV_DEPLOY ?= "0" > - > -do_install_builddeps() { > - dpkg_do_mounts > - E="${@ isar_export_proxies(d)}" > - sudo -E chroot ${BUILDCHROOT_DIR} \ > - apt-get update \ > - -o Dir::Etc::SourceList="sources.list.d/isar-apt.list" \ > - -o Dir::Etc::SourceParts="-" \ > - -o APT::Get::List-Cleanup="0" > - sudo -E chroot ${BUILDCHROOT_DIR} \ > - apt-get install \ > - -y -o Debug::pkgProblemResolver=yes \ > - --no-install-recommends ${KBUILD_DEPENDS} > - dpkg_undo_mounts > +def get_kernel_arch(d): > + distro_arch = d.getVar("DISTRO_ARCH") > + if distro_arch == "amd64": > + kernel_arch = "x86" > + elif distro_arch == "arm64": > + kernel_arch = "arm64" > + elif distro_arch == "armhf": > + kernel_arch = "arm" > + elif distro_arch == "mipsel": > + kernel_arch = "mips" > + else: > + kernel_arch = "" > + return kernel_arch > + > +KERNEL_ARCH ??= "${@get_kernel_arch(d)}" > + > +def config_fragments(d): > + fragments = [] > + sources = d.getVar("SRC_URI").split() > + for s in sources: > + _, _, local, _, _, parm = bb.fetch.decodeurl(s) > + apply = parm.get("apply") > + if apply == "no": > + continue > + base, ext = os.path.splitext(os.path.basename(local)) > + if ext and ext in (".cfg"): > + fragments.append(local) > + return fragments > + > +do_prepare_build_prepend() { > + # copy meta-data over to source tree > + rm -rf ${S}/debian > + cp -r ${WORKDIR}/debian ${S}/ > + > + # remove templates from the source tree > + find ${S}/debian -name *.tmpl | xargs rm -f > + > + # rename install/remove hooks to match user-specified name for our linux-image package > + mv ${S}/debian/linux-image.postinst ${S}/debian/linux-image-${KERNEL_NAME_PROVIDED}.postinst > + mv ${S}/debian/linux-image.postrm ${S}/debian/linux-image-${KERNEL_NAME_PROVIDED}.postrm > + mv ${S}/debian/linux-image.preinst ${S}/debian/linux-image-${KERNEL_NAME_PROVIDED}.preinst > + mv ${S}/debian/linux-image.prerm ${S}/debian/linux-image-${KERNEL_NAME_PROVIDED}.prerm > + > + # produce a changelog for our kernel build > + deb_add_changelog > } > > -addtask install_builddeps after do_prepare_build before do_dpkg_build > -# apt and reprepro may not run in parallel, acquire the Isar lock > -do_install_builddeps[lockfiles] += "${REPO_ISAR_DIR}/isar.lock" > - > -addtask devshell after do_install_builddeps > +# build directory for our "full" kernel build > +KERNEL_BUILD_DIR = "build-full" > > -dpkg_runbuild() { > - chmod +x ${WORKDIR}/build-kernel.sh > - KERNEL_CONFIG_TARGET="${KERNEL_DEFCONFIG}" > +dpkg_configure_kernel() { > + config_target="${KERNEL_DEFCONFIG}" > + rm -rf ${S}/${KERNEL_BUILD_DIR} && mkdir -p ${S}/${KERNEL_BUILD_DIR} > if [ -n "${KERNEL_DEFCONFIG}" ]; then > if [ -e "${WORKDIR}/${KERNEL_DEFCONFIG}" ]; then > - cp ${WORKDIR}/${KERNEL_DEFCONFIG} ${S}/.config > - KERNEL_CONFIG_TARGET="olddefconfig" > + cp ${WORKDIR}/${KERNEL_DEFCONFIG} ${S}/${KERNEL_BUILD_DIR}/.config > + config_target="olddefconfig" > fi > else > - KERNEL_CONFIG_TARGET="defconfig" > + config_target="defconfig" > fi > > - E="${@ isar_export_proxies(d)}" > - > - export PV=${PV} > - export KERNEL_NAME=${KERNEL_NAME_PROVIDED} > - > - export KBUILD_DEPENDS="${KBUILD_DEPENDS}" > - export KERNEL_CONFIG_TARGET > - export KERNEL_DEBIAN_DEPENDS="${KERNEL_DEBIAN_DEPENDS}" > - export KERNEL_FILE="${KERNEL_FILE}" > - export KERNEL_HEADERS_DEBIAN_DEPENDS="${KERNEL_HEADERS_DEBIAN_DEPENDS}" > + # copy config fragments over to the kernel tree > + src_frags="${@ " ".join(config_fragments(d)) }" > + out_frags="${@ " ".join(map(lambda frag: 'debian/fragments/' + frag, config_fragments(d))) }" > + rm -rf ${S}/debian/fragments > + if [ -n "${src_frags}" ]; then > + mkdir -p ${S}/debian/fragments > + (cd ${WORKDIR} && cp ${src_frags} ${S}/debian/fragments/) > + fi > > - sudo -E chroot --userspec=$( id -u ):$( id -g ) ${BUILDCHROOT_DIR} ${PP}/build-kernel.sh ${PP}/${PPS} ${DISTRO_ARCH} > + sudo -E chroot --userspec=$(id -u):$(id -g) ${BUILDCHROOT_DIR} sh -c " \ > + export ARCH=${KERNEL_ARCH} && \ > + cd ${PP}/${PPS} && \ > + make O=${KERNEL_BUILD_DIR} ${config_target} && \ > + ./scripts/kconfig/merge_config.sh \ > + -O ${KERNEL_BUILD_DIR}/ \ > + ${KERNEL_BUILD_DIR}/.config \ > + ${out_frags} \ > + debian/isar/version.cfg \ > + " > +} > > +dpkg_runbuild_prepend() { > + profiles="${BASE_DISTRO}" > if [ "${KERNEL_LIBC_DEV_DEPLOY}" != "1" ]; then > - rm -f ${WORKDIR}/linux-libc-dev_${PV}*.deb > + profiles="${profiles} nolibcdev" > fi > + export DEB_BUILD_PROFILES="${profiles}" > + dpkg_configure_kernel > } > Quirin ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 4/5] linux-custom: rewrite to no longer depend on the kernel's builddeb 2019-12-11 15:20 ` Gylstorff Quirin @ 2019-12-11 15:43 ` Jan Kiszka 2019-12-11 18:36 ` Jan Kiszka 0 siblings, 1 reply; 16+ messages in thread From: Jan Kiszka @ 2019-12-11 15:43 UTC (permalink / raw) To: Gylstorff Quirin, isar-users On 11.12.19 16:20, Gylstorff Quirin wrote: >> +do_build() { >> + >> + # Print a few things that are of particular interest >> + print_settings >> + >> + # Process existing kernel configuration to make sure it is complete >> + # (use defaults for options that were not specified) >> + ${MAKE} O=${KERNEL_BUILD_DIR} olddefconfig prepare || exit ${?} >> + >> + # Check if the recipe's PV makes sense >> + KR=$(${MAKE} O=${KERNEL_BUILD_DIR} -s --no-print-directory >> kernelrelease) >> + eval $(grep ^CONFIG_LOCALVERSION= ${KERNEL_BUILD_DIR}/${KCONF} || >> true) >> + if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then >> + echo "ERROR: Recipe version (${PV}-${KERNEL_LOCALVERSION}) >> does not seem to match the kernelrelease (${KR})!" 1>&2 >> + echo "ERROR: Make sure the kernel version in your NAME/PV/PR >> settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 >> + exit 1 > + fi > > we have some CI use case where we build the latest git release could we > add something like this > > - if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then > - echo "ERROR: Recipe version (${PV}-${KERNEL_LOCALVERSION}) does > not seem to match the kernelrelease (${KR})!" 1>&2 > - echo "ERROR: Make sure the kernel version in your NAME/PV/PR > settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 > - exit 1 > + if [ "${PV}" =~ "latest" ]; then I suspect you wanted to suggest != "latest". > + if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then > + echo "ERROR: Recipe version (${PV}-${KERNEL_LOCALVERSION}) > does not seem to match the kernelrelease (${KR})!" 1>&2 > + echo "ERROR: Make sure the kernel version in your > NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 > + exit 1 > + fi We need some relaxation path for the check, yes. Given the other versioning issue, I'm still trying to build a complete picture. Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 4/5] linux-custom: rewrite to no longer depend on the kernel's builddeb 2019-12-11 15:43 ` Jan Kiszka @ 2019-12-11 18:36 ` Jan Kiszka 2019-12-11 22:09 ` Henning Schild 0 siblings, 1 reply; 16+ messages in thread From: Jan Kiszka @ 2019-12-11 18:36 UTC (permalink / raw) To: Gylstorff Quirin, isar-users, Henning Schild, Cedric Hombourger On 11.12.19 16:43, [ext] Jan Kiszka wrote: > On 11.12.19 16:20, Gylstorff Quirin wrote: >>> +do_build() { >>> + >>> + # Print a few things that are of particular interest >>> + print_settings >>> + >>> + # Process existing kernel configuration to make sure it is complete >>> + # (use defaults for options that were not specified) >>> + ${MAKE} O=${KERNEL_BUILD_DIR} olddefconfig prepare || exit ${?} >>> + >>> + # Check if the recipe's PV makes sense >>> + KR=$(${MAKE} O=${KERNEL_BUILD_DIR} -s --no-print-directory >>> kernelrelease) >>> + eval $(grep ^CONFIG_LOCALVERSION= ${KERNEL_BUILD_DIR}/${KCONF} || >>> true) >>> + if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then >>> + echo "ERROR: Recipe version (${PV}-${KERNEL_LOCALVERSION}) >>> does not seem to match the kernelrelease (${KR})!" 1>&2 >>> + echo "ERROR: Make sure the kernel version in your NAME/PV/PR >>> settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 >>> + exit 1 > + fi >> >> we have some CI use case where we build the latest git release could we >> add something like this >> >> - if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then >> - echo "ERROR: Recipe version (${PV}-${KERNEL_LOCALVERSION}) does >> not seem to match the kernelrelease (${KR})!" 1>&2 >> - echo "ERROR: Make sure the kernel version in your NAME/PV/PR >> settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 >> - exit 1 >> + if [ "${PV}" =~ "latest" ]; then > > I suspect you wanted to suggest != "latest". > >> + if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then >> + echo "ERROR: Recipe version (${PV}-${KERNEL_LOCALVERSION}) >> does not seem to match the kernelrelease (${KR})!" 1>&2 >> + echo "ERROR: Make sure the kernel version in your >> NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 >> + exit 1 >> + fi > > We need some relaxation path for the check, yes. Given the other > versioning issue, I'm still trying to build a complete picture. Looking the Henning's commit that introduced the check, it reads to me like just addressing constraints of the old build approach. The new one has a way to set LOCALVERSION from the recipe. So, what we would rather need than this hard check is the following: - optional KERNEL_LOCALVERSION - pick-up of LOCALVERSION from the kernel config for the case it was defined via the config - KERNEL_LOCALVERSION ?= "" to avoid breaking existing users needlessly That approach would both enable CONFIG_LOCALVERSION usage via own configs as well as convenient management in recipes via KERNEL_LOCALVERSION. But it has a catch: We need the LOCALVERSION information already for the templating step while dpkg_configure_kernel is part of the build. So we may be left with these options: - check if CONFIG_LOCALVERSION == KERNEL_LOCALVERSION, which is true when KERNEL_LOCALVERSION is used but could be violated when the custom config provides a LOCALVERSION while KERNEL_LOCALVERSION is empty - always override CONFIG_LOCALVERSION with KERNEL_LOCALVERSION, as in this version of the patch - may cause surprises, though - try to pick up CONFIG_LOCALVERSION early, but only from a user- provided defconfig, not from fragments or templates - maybe too unintuitive Not so easy. Thoughts? Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 4/5] linux-custom: rewrite to no longer depend on the kernel's builddeb 2019-12-11 18:36 ` Jan Kiszka @ 2019-12-11 22:09 ` Henning Schild 2019-12-12 7:57 ` Gylstorff Quirin 0 siblings, 1 reply; 16+ messages in thread From: Henning Schild @ 2019-12-11 22:09 UTC (permalink / raw) To: Jan Kiszka; +Cc: Gylstorff Quirin, isar-users, Cedric Hombourger On Wed, 11 Dec 2019 19:36:05 +0100 Jan Kiszka <jan.kiszka@siemens.com> wrote: > On 11.12.19 16:43, [ext] Jan Kiszka wrote: > > On 11.12.19 16:20, Gylstorff Quirin wrote: > >>> +do_build() { > >>> + > >>> + # Print a few things that are of particular interest > >>> + print_settings > >>> + > >>> + # Process existing kernel configuration to make sure it is > >>> complete > >>> + # (use defaults for options that were not specified) > >>> + ${MAKE} O=${KERNEL_BUILD_DIR} olddefconfig prepare || exit > >>> ${?} + > >>> + # Check if the recipe's PV makes sense > >>> + KR=$(${MAKE} O=${KERNEL_BUILD_DIR} -s --no-print-directory > >>> kernelrelease) > >>> + eval $(grep ^CONFIG_LOCALVERSION= > >>> ${KERNEL_BUILD_DIR}/${KCONF} || true) > >>> + if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then > >>> + echo "ERROR: Recipe version > >>> (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the > >>> kernelrelease (${KR})!" 1>&2 > >>> + echo "ERROR: Make sure the kernel version in your > >>> NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 > >>> + exit 1 > + fi > >> > >> we have some CI use case where we build the latest git release > >> could we add something like this > >> > >> - if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then > >> - echo "ERROR: Recipe version > >> (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the > >> kernelrelease (${KR})!" 1>&2 > >> - echo "ERROR: Make sure the kernel version in your > >> NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 > >> - exit 1 > >> + if [ "${PV}" =~ "latest" ]; then > > > > I suspect you wanted to suggest != "latest". > > > >> + if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then > >> + echo "ERROR: Recipe version > >> (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the > >> kernelrelease (${KR})!" 1>&2 > >> + echo "ERROR: Make sure the kernel version in your > >> NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 > >> + exit 1 > >> + fi > > > > We need some relaxation path for the check, yes. Given the other > > versioning issue, I'm still trying to build a complete picture. > > Looking the Henning's commit that introduced the check, it reads to me > like just addressing constraints of the old build approach. The new > one has a way to set LOCALVERSION from the recipe. Yes, the check is just early catching a weird error that would have popped up later. That must have been either the build or the step copying the kernel binary to DEPLOY. If a new way of building can deal with it, the check can be dropped. > So, what we would rather need than this hard check is the following: > > - optional KERNEL_LOCALVERSION > - pick-up of LOCALVERSION from the kernel config for the case it was > defined via the config > - KERNEL_LOCALVERSION ?= "" to avoid breaking existing users > needlessly > > That approach would both enable CONFIG_LOCALVERSION usage via own > configs as well as convenient management in recipes via > KERNEL_LOCALVERSION. But it has a catch: We need the LOCALVERSION > information already for the templating step while > dpkg_configure_kernel is part of the build. > > So we may be left with these options: > > - check if CONFIG_LOCALVERSION == KERNEL_LOCALVERSION, which is true > when KERNEL_LOCALVERSION is used but could be violated when the > custom config provides a LOCALVERSION while KERNEL_LOCALVERSION is > empty > - always override CONFIG_LOCALVERSION with KERNEL_LOCALVERSION, as in > this version of the patch - may cause surprises, though > - try to pick up CONFIG_LOCALVERSION early, but only from a user- > provided defconfig, not from fragments or templates - maybe too > unintuitive > > Not so easy. Thoughts? I am not sure i fully get the suggestion. I think you suggest to have a bitbake variable control parts of the config ... that one localversion key in it. The user expectation would probably be that the PV will become _the_ version. So i would go for a sanity check for that, and a warning if not. After that we can discuss a magic that will turn something behind the first or last "-" in PV into CONFIG_LOCALVERSION and patch that into the config. So instead of a new variable, come up with a new recipe naming convention. And for people that really want to call the recipe "kernel.bb" they would get the default PV = "1.0" PR = "" PLOCALV = "" Would have to check if "PR" is the thing after the first "-" ... But maybe PR is what we are looking for ... Henning > Jan > ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 4/5] linux-custom: rewrite to no longer depend on the kernel's builddeb 2019-12-11 22:09 ` Henning Schild @ 2019-12-12 7:57 ` Gylstorff Quirin 2019-12-12 8:01 ` Jan Kiszka 0 siblings, 1 reply; 16+ messages in thread From: Gylstorff Quirin @ 2019-12-12 7:57 UTC (permalink / raw) To: Henning Schild, Jan Kiszka; +Cc: isar-users, Cedric Hombourger On 12/11/19 11:09 PM, Henning Schild wrote: > On Wed, 11 Dec 2019 19:36:05 +0100 > Jan Kiszka <jan.kiszka@siemens.com> wrote: > >> On 11.12.19 16:43, [ext] Jan Kiszka wrote: >>> On 11.12.19 16:20, Gylstorff Quirin wrote: >>>>> +do_build() { >>>>> + >>>>> + # Print a few things that are of particular interest >>>>> + print_settings >>>>> + >>>>> + # Process existing kernel configuration to make sure it is >>>>> complete >>>>> + # (use defaults for options that were not specified) >>>>> + ${MAKE} O=${KERNEL_BUILD_DIR} olddefconfig prepare || exit >>>>> ${?} + >>>>> + # Check if the recipe's PV makes sense >>>>> + KR=$(${MAKE} O=${KERNEL_BUILD_DIR} -s --no-print-directory >>>>> kernelrelease) >>>>> + eval $(grep ^CONFIG_LOCALVERSION= >>>>> ${KERNEL_BUILD_DIR}/${KCONF} || true) >>>>> + if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then >>>>> + echo "ERROR: Recipe version >>>>> (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the >>>>> kernelrelease (${KR})!" 1>&2 >>>>> + echo "ERROR: Make sure the kernel version in your >>>>> NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 >>>>> + exit 1 > + fi >>>> >>>> we have some CI use case where we build the latest git release >>>> could we add something like this >>>> >>>> - if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then >>>> - echo "ERROR: Recipe version >>>> (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the >>>> kernelrelease (${KR})!" 1>&2 >>>> - echo "ERROR: Make sure the kernel version in your >>>> NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 >>>> - exit 1 >>>> + if [ "${PV}" =~ "latest" ]; then >>> >>> I suspect you wanted to suggest != "latest". >>> >>>> + if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then >>>> + echo "ERROR: Recipe version >>>> (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the >>>> kernelrelease (${KR})!" 1>&2 >>>> + echo "ERROR: Make sure the kernel version in your >>>> NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 >>>> + exit 1 >>>> + fi >>> >>> We need some relaxation path for the check, yes. Given the other >>> versioning issue, I'm still trying to build a complete picture. >> >> Looking the Henning's commit that introduced the check, it reads to me >> like just addressing constraints of the old build approach. The new >> one has a way to set LOCALVERSION from the recipe. > > Yes, the check is just early catching a weird error that would have > popped up later. That must have been either the build or the step > copying the kernel binary to DEPLOY. > > If a new way of building can deal with it, the check can be dropped. > >> So, what we would rather need than this hard check is the following: >> >> - optional KERNEL_LOCALVERSION >> - pick-up of LOCALVERSION from the kernel config for the case it was >> defined via the config >> - KERNEL_LOCALVERSION ?= "" to avoid breaking existing users >> needlessly >> >> That approach would both enable CONFIG_LOCALVERSION usage via own >> configs as well as convenient management in recipes via >> KERNEL_LOCALVERSION. But it has a catch: We need the LOCALVERSION >> information already for the templating step while >> dpkg_configure_kernel is part of the build. >> >> So we may be left with these options: >> >> - check if CONFIG_LOCALVERSION == KERNEL_LOCALVERSION, which is true >> when KERNEL_LOCALVERSION is used but could be violated when the >> custom config provides a LOCALVERSION while KERNEL_LOCALVERSION is >> empty >> - always override CONFIG_LOCALVERSION with KERNEL_LOCALVERSION, as in >> this version of the patch - may cause surprises, though >> - try to pick up CONFIG_LOCALVERSION early, but only from a user- >> provided defconfig, not from fragments or templates - maybe too >> unintuitive >> >> Not so easy. Thoughts? > > I am not sure i fully get the suggestion. I think you suggest to have a > bitbake variable control parts of the config ... that one localversion > key in it. > > The user expectation would probably be that the PV will become _the_ > version. So i would go for a sanity check for that, and a warning if > not. After that we can discuss a magic that will turn something behind > the first or last "-" in PV into CONFIG_LOCALVERSION and patch that > into the config. You mean a warning or an error? The current version aborts the build, if the versions do not match. As mentioned before: If a mainline kernel is used PV == KERNEL_RELEASE is already not fulfilled. So we already have a two expectation the Debian user and the bitbake user. > > So instead of a new variable, come up with a new recipe naming > convention. And for people that really want to call the recipe > "kernel.bb" they would get the default > > PV = "1.0" > PR = "" > PLOCALV = "" > > Would have to check if "PR" is the thing after the first "-" ... But > maybe PR is what we are looking for ... PR is the revision of the recipe which comes after the first "-". Yocto uses its own variable "LINUX_VERSION_EXTENSION" which sets CONFIG_LOCALVERSION. > > Henning > >> Jan >> > Quirin ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 4/5] linux-custom: rewrite to no longer depend on the kernel's builddeb 2019-12-12 7:57 ` Gylstorff Quirin @ 2019-12-12 8:01 ` Jan Kiszka 2019-12-12 9:46 ` Gylstorff Quirin 0 siblings, 1 reply; 16+ messages in thread From: Jan Kiszka @ 2019-12-12 8:01 UTC (permalink / raw) To: Gylstorff Quirin, Henning Schild; +Cc: isar-users, Cedric Hombourger On 12.12.19 08:57, Gylstorff Quirin wrote: > > > On 12/11/19 11:09 PM, Henning Schild wrote: >> On Wed, 11 Dec 2019 19:36:05 +0100 >> Jan Kiszka <jan.kiszka@siemens.com> wrote: >> >>> On 11.12.19 16:43, [ext] Jan Kiszka wrote: >>>> On 11.12.19 16:20, Gylstorff Quirin wrote: >>>>>> +do_build() { >>>>>> + >>>>>> + # Print a few things that are of particular interest >>>>>> + print_settings >>>>>> + >>>>>> + # Process existing kernel configuration to make sure it is >>>>>> complete >>>>>> + # (use defaults for options that were not specified) >>>>>> + ${MAKE} O=${KERNEL_BUILD_DIR} olddefconfig prepare || exit >>>>>> ${?} + >>>>>> + # Check if the recipe's PV makes sense >>>>>> + KR=$(${MAKE} O=${KERNEL_BUILD_DIR} -s --no-print-directory >>>>>> kernelrelease) >>>>>> + eval $(grep ^CONFIG_LOCALVERSION= >>>>>> ${KERNEL_BUILD_DIR}/${KCONF} || true) >>>>>> + if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then >>>>>> + echo "ERROR: Recipe version >>>>>> (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the >>>>>> kernelrelease (${KR})!" 1>&2 >>>>>> + echo "ERROR: Make sure the kernel version in your >>>>>> NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 >>>>>> + exit 1 > + fi >>>>> >>>>> we have some CI use case where we build the latest git release >>>>> could we add something like this >>>>> >>>>> - if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then >>>>> - echo "ERROR: Recipe version >>>>> (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the >>>>> kernelrelease (${KR})!" 1>&2 >>>>> - echo "ERROR: Make sure the kernel version in your >>>>> NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 >>>>> - exit 1 >>>>> + if [ "${PV}" =~ "latest" ]; then >>>> >>>> I suspect you wanted to suggest != "latest". >>>> >>>>> + if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then >>>>> + echo "ERROR: Recipe version >>>>> (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the >>>>> kernelrelease (${KR})!" 1>&2 >>>>> + echo "ERROR: Make sure the kernel version in your >>>>> NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 >>>>> + exit 1 >>>>> + fi >>>> >>>> We need some relaxation path for the check, yes. Given the other >>>> versioning issue, I'm still trying to build a complete picture. >>> >>> Looking the Henning's commit that introduced the check, it reads to me >>> like just addressing constraints of the old build approach. The new >>> one has a way to set LOCALVERSION from the recipe. >> >> Yes, the check is just early catching a weird error that would have >> popped up later. That must have been either the build or the step >> copying the kernel binary to DEPLOY. >> >> If a new way of building can deal with it, the check can be dropped. >> >>> So, what we would rather need than this hard check is the following: >>> >>> - optional KERNEL_LOCALVERSION >>> - pick-up of LOCALVERSION from the kernel config for the case it was >>> defined via the config >>> - KERNEL_LOCALVERSION ?= "" to avoid breaking existing users >>> needlessly >>> >>> That approach would both enable CONFIG_LOCALVERSION usage via own >>> configs as well as convenient management in recipes via >>> KERNEL_LOCALVERSION. But it has a catch: We need the LOCALVERSION >>> information already for the templating step while >>> dpkg_configure_kernel is part of the build. >>> >>> So we may be left with these options: >>> >>> - check if CONFIG_LOCALVERSION == KERNEL_LOCALVERSION, which is true >>> when KERNEL_LOCALVERSION is used but could be violated when the >>> custom config provides a LOCALVERSION while KERNEL_LOCALVERSION is >>> empty >>> - always override CONFIG_LOCALVERSION with KERNEL_LOCALVERSION, as in >>> this version of the patch - may cause surprises, though >>> - try to pick up CONFIG_LOCALVERSION early, but only from a user- >>> provided defconfig, not from fragments or templates - maybe too >>> unintuitive >>> >>> Not so easy. Thoughts? >> >> I am not sure i fully get the suggestion. I think you suggest to have a >> bitbake variable control parts of the config ... that one localversion >> key in it. >> >> The user expectation would probably be that the PV will become _the_ >> version. So i would go for a sanity check for that, and a warning if >> not. After that we can discuss a magic that will turn something behind >> the first or last "-" in PV into CONFIG_LOCALVERSION and patch that >> into the config. > You mean a warning or an error? The current version aborts the build, if > the versions do not match. > > As mentioned before: If a mainline kernel is used PV == KERNEL_RELEASE > is already not fulfilled. So we already have a two expectation the > Debian user and the bitbake user. > >> >> So instead of a new variable, come up with a new recipe naming >> convention. And for people that really want to call the recipe >> "kernel.bb" they would get the default >> >> PV = "1.0" >> PR = "" >> PLOCALV = "" >> >> Would have to check if "PR" is the thing after the first "-" ... But >> maybe PR is what we are looking for ... > PR is the revision of the recipe which comes after the first "-". Yocto > uses its own variable "LINUX_VERSION_EXTENSION" which sets > CONFIG_LOCALVERSION. Then we should do s/KERNEL_LOCALVERSION/LINUX_VERSION_EXTENSION. Just leaves us with the other policy questions. Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 4/5] linux-custom: rewrite to no longer depend on the kernel's builddeb 2019-12-12 8:01 ` Jan Kiszka @ 2019-12-12 9:46 ` Gylstorff Quirin 2019-12-12 10:10 ` Gylstorff Quirin 0 siblings, 1 reply; 16+ messages in thread From: Gylstorff Quirin @ 2019-12-12 9:46 UTC (permalink / raw) To: Jan Kiszka, Henning Schild; +Cc: isar-users, Cedric Hombourger On 12/12/19 9:01 AM, Jan Kiszka wrote: > On 12.12.19 08:57, Gylstorff Quirin wrote: >> >> >> On 12/11/19 11:09 PM, Henning Schild wrote: >>> On Wed, 11 Dec 2019 19:36:05 +0100 >>> Jan Kiszka <jan.kiszka@siemens.com> wrote: >>> >>>> On 11.12.19 16:43, [ext] Jan Kiszka wrote: >>>>> On 11.12.19 16:20, Gylstorff Quirin wrote: >>>>>>> +do_build() { >>>>>>> + >>>>>>> + # Print a few things that are of particular interest >>>>>>> + print_settings >>>>>>> + >>>>>>> + # Process existing kernel configuration to make sure it is >>>>>>> complete >>>>>>> + # (use defaults for options that were not specified) >>>>>>> + ${MAKE} O=${KERNEL_BUILD_DIR} olddefconfig prepare || exit >>>>>>> ${?} + >>>>>>> + # Check if the recipe's PV makes sense >>>>>>> + KR=$(${MAKE} O=${KERNEL_BUILD_DIR} -s --no-print-directory >>>>>>> kernelrelease) >>>>>>> + eval $(grep ^CONFIG_LOCALVERSION= >>>>>>> ${KERNEL_BUILD_DIR}/${KCONF} || true) >>>>>>> + if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then >>>>>>> + echo "ERROR: Recipe version >>>>>>> (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the >>>>>>> kernelrelease (${KR})!" 1>&2 >>>>>>> + echo "ERROR: Make sure the kernel version in your >>>>>>> NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 >>>>>>> + exit 1 > + fi >>>>>> >>>>>> we have some CI use case where we build the latest git release >>>>>> could we add something like this >>>>>> >>>>>> - if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then >>>>>> - echo "ERROR: Recipe version >>>>>> (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the >>>>>> kernelrelease (${KR})!" 1>&2 >>>>>> - echo "ERROR: Make sure the kernel version in your >>>>>> NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 >>>>>> - exit 1 >>>>>> + if [ "${PV}" =~ "latest" ]; then >>>>> >>>>> I suspect you wanted to suggest != "latest". >>>>> >>>>>> + if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then >>>>>> + echo "ERROR: Recipe version >>>>>> (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the >>>>>> kernelrelease (${KR})!" 1>&2 >>>>>> + echo "ERROR: Make sure the kernel version in your >>>>>> NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 >>>>>> + exit 1 >>>>>> + fi >>>>> >>>>> We need some relaxation path for the check, yes. Given the other >>>>> versioning issue, I'm still trying to build a complete picture. >>>> >>>> Looking the Henning's commit that introduced the check, it reads to me >>>> like just addressing constraints of the old build approach. The new >>>> one has a way to set LOCALVERSION from the recipe. >>> >>> Yes, the check is just early catching a weird error that would have >>> popped up later. That must have been either the build or the step >>> copying the kernel binary to DEPLOY. >>> >>> If a new way of building can deal with it, the check can be dropped. >>> >>>> So, what we would rather need than this hard check is the following: >>>> >>>> - optional KERNEL_LOCALVERSION >>>> - pick-up of LOCALVERSION from the kernel config for the case it was >>>> defined via the config >>>> - KERNEL_LOCALVERSION ?= "" to avoid breaking existing users >>>> needlessly >>>> >>>> That approach would both enable CONFIG_LOCALVERSION usage via own >>>> configs as well as convenient management in recipes via >>>> KERNEL_LOCALVERSION. But it has a catch: We need the LOCALVERSION >>>> information already for the templating step while >>>> dpkg_configure_kernel is part of the build. >>>> >>>> So we may be left with these options: >>>> >>>> - check if CONFIG_LOCALVERSION == KERNEL_LOCALVERSION, which is true >>>> when KERNEL_LOCALVERSION is used but could be violated when the >>>> custom config provides a LOCALVERSION while KERNEL_LOCALVERSION is >>>> empty >>>> - always override CONFIG_LOCALVERSION with KERNEL_LOCALVERSION, as in >>>> this version of the patch - may cause surprises, though >>>> - try to pick up CONFIG_LOCALVERSION early, but only from a user- >>>> provided defconfig, not from fragments or templates - maybe too >>>> unintuitive >>>> >>>> Not so easy. Thoughts? >>> >>> I am not sure i fully get the suggestion. I think you suggest to have a >>> bitbake variable control parts of the config ... that one localversion >>> key in it. >>> >>> The user expectation would probably be that the PV will become _the_ >>> version. So i would go for a sanity check for that, and a warning if >>> not. After that we can discuss a magic that will turn something behind >>> the first or last "-" in PV into CONFIG_LOCALVERSION and patch that >>> into the config. >> You mean a warning or an error? The current version aborts the build, if >> the versions do not match. >> >> As mentioned before: If a mainline kernel is used PV == KERNEL_RELEASE >> is already not fulfilled. So we already have a two expectation the >> Debian user and the bitbake user. >> >>> >>> So instead of a new variable, come up with a new recipe naming >>> convention. And for people that really want to call the recipe >>> "kernel.bb" they would get the default >>> >>> PV = "1.0" >>> PR = "" >>> PLOCALV = "" >>> >>> Would have to check if "PR" is the thing after the first "-" ... But >>> maybe PR is what we are looking for ... >> PR is the revision of the recipe which comes after the first "-". Yocto >> uses its own variable "LINUX_VERSION_EXTENSION" which sets >> CONFIG_LOCALVERSION. > > Then we should do s/KERNEL_LOCALVERSION/LINUX_VERSION_EXTENSION. > > Just leaves us with the other policy questions. > > Jan > From my understanding after reading the patches the KERNEL_LOCALVERSION does not affect the build or installation of the Kernel artifacts as the mandatory control and changelog elements use only KERNEL_NAME_PROVIDED + CHANGELOG_V (PV+PR). So the only occurrence of the LOCALVERSION is in uname and the Package description. If this is the case then the check KERNEL_LOCALVERSION == CONFIG_LOCALVERSION and a warning should be enough. Did I miss something? Quirin ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 4/5] linux-custom: rewrite to no longer depend on the kernel's builddeb 2019-12-12 9:46 ` Gylstorff Quirin @ 2019-12-12 10:10 ` Gylstorff Quirin 0 siblings, 0 replies; 16+ messages in thread From: Gylstorff Quirin @ 2019-12-12 10:10 UTC (permalink / raw) To: isar-users On 12/12/19 10:46 AM, [ext] Gylstorff Quirin wrote: > > > On 12/12/19 9:01 AM, Jan Kiszka wrote: >> On 12.12.19 08:57, Gylstorff Quirin wrote: >>> >>> >>> On 12/11/19 11:09 PM, Henning Schild wrote: >>>> On Wed, 11 Dec 2019 19:36:05 +0100 >>>> Jan Kiszka <jan.kiszka@siemens.com> wrote: >>>> >>>>> On 11.12.19 16:43, [ext] Jan Kiszka wrote: >>>>>> On 11.12.19 16:20, Gylstorff Quirin wrote: >>>>>>>> +do_build() { >>>>>>>> + >>>>>>>> + # Print a few things that are of particular interest >>>>>>>> + print_settings >>>>>>>> + >>>>>>>> + # Process existing kernel configuration to make sure it is >>>>>>>> complete >>>>>>>> + # (use defaults for options that were not specified) >>>>>>>> + ${MAKE} O=${KERNEL_BUILD_DIR} olddefconfig prepare || exit >>>>>>>> ${?} + >>>>>>>> + # Check if the recipe's PV makes sense >>>>>>>> + KR=$(${MAKE} O=${KERNEL_BUILD_DIR} -s --no-print-directory >>>>>>>> kernelrelease) >>>>>>>> + eval $(grep ^CONFIG_LOCALVERSION= >>>>>>>> ${KERNEL_BUILD_DIR}/${KCONF} || true) >>>>>>>> + if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then >>>>>>>> + echo "ERROR: Recipe version >>>>>>>> (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the >>>>>>>> kernelrelease (${KR})!" 1>&2 >>>>>>>> + echo "ERROR: Make sure the kernel version in your >>>>>>>> NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 >>>>>>>> + exit 1 > + fi >>>>>>> >>>>>>> we have some CI use case where we build the latest git release >>>>>>> could we add something like this >>>>>>> >>>>>>> - if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then >>>>>>> - echo "ERROR: Recipe version >>>>>>> (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the >>>>>>> kernelrelease (${KR})!" 1>&2 >>>>>>> - echo "ERROR: Make sure the kernel version in your >>>>>>> NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 >>>>>>> - exit 1 >>>>>>> + if [ "${PV}" =~ "latest" ]; then >>>>>> >>>>>> I suspect you wanted to suggest != "latest". >>>>>>> + if [ "${PV}-${KERNEL_LOCALVERSION}" != "${KR}" ]; then >>>>>>> + echo "ERROR: Recipe version >>>>>>> (${PV}-${KERNEL_LOCALVERSION}) does not seem to match the >>>>>>> kernelrelease (${KR})!" 1>&2 >>>>>>> + echo "ERROR: Make sure the kernel version in your >>>>>>> NAME/PV/PR settings and/or CONFIG_LOCALVERSION are aligned" 1>&2 >>>>>>> + exit 1 >>>>>>> + fi >>>>>> >>>>>> We need some relaxation path for the check, yes. Given the other >>>>>> versioning issue, I'm still trying to build a complete picture. >>>>> >>>>> Looking the Henning's commit that introduced the check, it reads to me >>>>> like just addressing constraints of the old build approach. The new >>>>> one has a way to set LOCALVERSION from the recipe. >>>> >>>> Yes, the check is just early catching a weird error that would have >>>> popped up later. That must have been either the build or the step >>>> copying the kernel binary to DEPLOY. >>>> >>>> If a new way of building can deal with it, the check can be dropped. >>>> >>>>> So, what we would rather need than this hard check is the following: >>>>> >>>>> - optional KERNEL_LOCALVERSION >>>>> - pick-up of LOCALVERSION from the kernel config for the case it >>>>> was >>>>> defined via the config >>>>> - KERNEL_LOCALVERSION ?= "" to avoid breaking existing users >>>>> needlessly >>>>> >>>>> That approach would both enable CONFIG_LOCALVERSION usage via own >>>>> configs as well as convenient management in recipes via >>>>> KERNEL_LOCALVERSION. But it has a catch: We need the LOCALVERSION >>>>> information already for the templating step while >>>>> dpkg_configure_kernel is part of the build. >>>>> >>>>> So we may be left with these options: >>>>> >>>>> - check if CONFIG_LOCALVERSION == KERNEL_LOCALVERSION, which is >>>>> true >>>>> when KERNEL_LOCALVERSION is used but could be violated when the >>>>> custom config provides a LOCALVERSION while >>>>> KERNEL_LOCALVERSION is >>>>> empty >>>>> - always override CONFIG_LOCALVERSION with KERNEL_LOCALVERSION, >>>>> as in >>>>> this version of the patch - may cause surprises, though >>>> >>>>> - try to pick up CONFIG_LOCALVERSION early, but only from a user- >>>>> provided defconfig, not from fragments or templates - maybe too >>>>> unintuitive >>>>> >>>>> Not so easy. Thoughts? >>>> >>>> I am not sure i fully get the suggestion. I think you suggest to have a >>>> bitbake variable control parts of the config ... that one localversion >>>> key in it. >>>> >>>> The user expectation would probably be that the PV will become _the_ >>>> version. So i would go for a sanity check for that, and a warning if >>>> not. After that we can discuss a magic that will turn something behind >>>> the first or last "-" in PV into CONFIG_LOCALVERSION and patch that >>>> into the config. >>> You mean a warning or an error? The current version aborts the build, if >>> the versions do not match. >>> >>> As mentioned before: If a mainline kernel is used PV == KERNEL_RELEASE >>> is already not fulfilled. So we already have a two expectation the >>> Debian user and the bitbake user. >>> >>>> >>>> So instead of a new variable, come up with a new recipe naming >>>> convention. And for people that really want to call the recipe >>>> "kernel.bb" they would get the default >>>> >>>> PV = "1.0" >>>> PR = "" >>>> PLOCALV = "" >>>> >>>> Would have to check if "PR" is the thing after the first "-" ... But >>>> maybe PR is what we are looking for ... >>> PR is the revision of the recipe which comes after the first "-". Yocto >>> uses its own variable "LINUX_VERSION_EXTENSION" which sets >>> CONFIG_LOCALVERSION. >> >> Then we should do s/KERNEL_LOCALVERSION/LINUX_VERSION_EXTENSION. >> >> Just leaves us with the other policy questions. >> >> Jan >> > > From my understanding after reading the patches the KERNEL_LOCALVERSION > does not affect the build or installation of the Kernel artifacts as the > mandatory control and changelog elements use only KERNEL_NAME_PROVIDED + > CHANGELOG_V (PV+PR). So the only occurrence of the LOCALVERSION is in > uname and the Package description. > If this is the case then the check KERNEL_LOCALVERSION == > CONFIG_LOCALVERSION and a warning should be enough. > > Did I miss something? Yep I missed the (pre/post)inst/rm scripts. These are the only occurrence of the KERNEL_LOCALVERSION. This would require the abort of the build if some mismatch occurs. Quirin ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v5 5/5] linux-mainline: Test config fragments 2019-12-10 18:22 [PATCH v5 0/5] linux-custom recipe rework Jan Kiszka ` (3 preceding siblings ...) 2019-12-10 18:22 ` [PATCH v5 4/5] linux-custom: rewrite to no longer depend on the kernel's builddeb Jan Kiszka @ 2019-12-10 18:22 ` Jan Kiszka 2019-12-19 15:19 ` [PATCH v5 0/5] linux-custom recipe rework cedric_hombourger 5 siblings, 0 replies; 16+ messages in thread From: Jan Kiszka @ 2019-12-10 18:22 UTC (permalink / raw) To: isar-users From: Jan Kiszka <jan.kiszka@siemens.com> Covers both the case of successful application as well as suppressed one via "apply=no". Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> --- meta-isar/recipes-kernel/linux/files/no-root-nfs.cfg | 1 + meta-isar/recipes-kernel/linux/files/no-ubifs-fs.cfg | 1 + meta-isar/recipes-kernel/linux/linux-mainline_4.19.88.bb | 13 ++++++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 meta-isar/recipes-kernel/linux/files/no-root-nfs.cfg create mode 100644 meta-isar/recipes-kernel/linux/files/no-ubifs-fs.cfg diff --git a/meta-isar/recipes-kernel/linux/files/no-root-nfs.cfg b/meta-isar/recipes-kernel/linux/files/no-root-nfs.cfg new file mode 100644 index 0000000..97ec48c --- /dev/null +++ b/meta-isar/recipes-kernel/linux/files/no-root-nfs.cfg @@ -0,0 +1 @@ +# CONFIG_ROOT_NFS is not set diff --git a/meta-isar/recipes-kernel/linux/files/no-ubifs-fs.cfg b/meta-isar/recipes-kernel/linux/files/no-ubifs-fs.cfg new file mode 100644 index 0000000..72c1f7a --- /dev/null +++ b/meta-isar/recipes-kernel/linux/files/no-ubifs-fs.cfg @@ -0,0 +1 @@ +# CONFIG_UBIFS_FS is not set diff --git a/meta-isar/recipes-kernel/linux/linux-mainline_4.19.88.bb b/meta-isar/recipes-kernel/linux/linux-mainline_4.19.88.bb index 695eb39..759d123 100644 --- a/meta-isar/recipes-kernel/linux/linux-mainline_4.19.88.bb +++ b/meta-isar/recipes-kernel/linux/linux-mainline_4.19.88.bb @@ -11,7 +11,10 @@ ARCHIVE_VERSION = "${@ d.getVar('PV')[:-2] if d.getVar('PV').endswith('.0') else SRC_URI += " \ https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-${ARCHIVE_VERSION}.tar.xz \ - file://x86_64_defconfig" + file://x86_64_defconfig \ + file://no-ubifs-fs.cfg \ + file://no-root-nfs.cfg;apply=no" + SRC_URI[sha256sum] = "c1923b6bd166e6dd07be860c15f59e8273aaa8692bc2a1fce1d31b826b9b3fbe" SRC_URI_append_de0-nano-soc = " \ @@ -20,3 +23,11 @@ SRC_URI_append_de0-nano-soc = " \ S = "${WORKDIR}/linux-${ARCHIVE_VERSION}" KERNEL_DEFCONFIG_qemuamd64 = "x86_64_defconfig" + +# For testing purposes only +dpkg_configure_kernel_append() { + grep "# CONFIG_UBIFS_FS is not set" ${S}/${KERNEL_BUILD_DIR}/.config || \ + bbfatal "Self-check failed: CONFIG_UBIFS_FS still enabled" + grep "CONFIG_ROOT_NFS=y" ${S}/${KERNEL_BUILD_DIR}/.config || \ + bbfatal "Self-check failed: CONFIG_ROOT_NFS not enabled" +} -- 2.16.4 ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 0/5] linux-custom recipe rework 2019-12-10 18:22 [PATCH v5 0/5] linux-custom recipe rework Jan Kiszka ` (4 preceding siblings ...) 2019-12-10 18:22 ` [PATCH v5 5/5] linux-mainline: Test config fragments Jan Kiszka @ 2019-12-19 15:19 ` cedric_hombourger 5 siblings, 0 replies; 16+ messages in thread From: cedric_hombourger @ 2019-12-19 15:19 UTC (permalink / raw) To: isar-users [-- Attachment #1.1: Type: text/plain, Size: 3750 bytes --] On Tuesday, December 10, 2019 at 7:22:11 PM UTC+1, Jan Kiszka wrote: > > Adopting Cedric patches, removing the qemu-user trick for now, re-adding > test cases for the config fragments and bumping the kernel to 4.19.88. > > All looks good to me. Thanks Jan for all the help! Would be good to get this reviewed (and merged?) before the Xmas break CI tests look good so far. I tested a functionally identical version > against jailhouse-images earlier already. > > Jan > > > CC: Cedric Hombourger <Cedric_H...@mentor.com <javascript:>> > > Cedric Hombourger (4): > recipes-kernel/linux: make KERNEL_DEFCONFIG support in-tree defconfigs > linux-mainline: fix stripping of .0 from the kernel version > linux-mainline: update from 4.19.0 to 4.19.88 > linux-custom: rewrite to no longer depend on the kernel's builddeb > > Jan Kiszka (1): > linux-mainline: Test config fragments > > RECIPE-API-CHANGELOG.md | 8 + > doc/custom_kernel.md | 83 ++++++++ > .../recipes-kernel/linux/files/no-root-nfs.cfg | 1 + > .../recipes-kernel/linux/files/no-ubifs-fs.cfg | 1 + > .../recipes-kernel/linux/linux-mainline_4.19.0.bb | 22 --- > .../recipes-kernel/linux/linux-mainline_4.19.88.bb | 33 ++++ > meta/recipes-kernel/linux/files/build-kernel.sh | 129 ------------- > meta/recipes-kernel/linux/files/debian/compat | 1 + > .../recipes-kernel/linux/files/debian/control.tmpl | 37 ++++ > .../linux/files/debian/isar/build.tmpl | 45 +++++ > .../linux/files/debian/isar/clean.tmpl | 21 +++ > .../linux/files/debian/isar/common.tmpl | 50 +++++ > .../linux/files/debian/isar/install.tmpl | 192 > +++++++++++++++++++ > .../linux/files/debian/isar/version.cfg.tmpl | 2 + > .../linux/files/debian/linux-image.postinst.tmpl | 29 +++ > .../linux/files/debian/linux-image.postrm.tmpl | 35 ++++ > .../linux/files/debian/linux-image.preinst.tmpl | 25 +++ > .../linux/files/debian/linux-image.prerm.tmpl | 21 +++ > meta/recipes-kernel/linux/files/debian/rules.tmpl | 39 ++++ > meta/recipes-kernel/linux/linux-custom.inc | 209 > +++++++++++++++------ > 20 files changed, 778 insertions(+), 205 deletions(-) > create mode 100644 doc/custom_kernel.md > create mode 100644 meta-isar/recipes-kernel/linux/files/no-root-nfs.cfg > create mode 100644 meta-isar/recipes-kernel/linux/files/no-ubifs-fs.cfg > delete mode 100644 meta-isar/recipes-kernel/linux/ > linux-mainline_4.19.0.bb > create mode 100644 meta-isar/recipes-kernel/linux/ > linux-mainline_4.19.88.bb > delete mode 100644 meta/recipes-kernel/linux/files/build-kernel.sh > create mode 100644 meta/recipes-kernel/linux/files/debian/compat > create mode 100644 meta/recipes-kernel/linux/files/debian/control.tmpl > create mode 100644 meta/recipes-kernel/linux/files/debian/isar/build.tmpl > create mode 100644 meta/recipes-kernel/linux/files/debian/isar/clean.tmpl > create mode 100644 > meta/recipes-kernel/linux/files/debian/isar/common.tmpl > create mode 100644 > meta/recipes-kernel/linux/files/debian/isar/install.tmpl > create mode 100644 > meta/recipes-kernel/linux/files/debian/isar/version.cfg.tmpl > create mode 100644 > meta/recipes-kernel/linux/files/debian/linux-image.postinst.tmpl > create mode 100644 > meta/recipes-kernel/linux/files/debian/linux-image.postrm.tmpl > create mode 100644 > meta/recipes-kernel/linux/files/debian/linux-image.preinst.tmpl > create mode 100644 > meta/recipes-kernel/linux/files/debian/linux-image.prerm.tmpl > create mode 100755 meta/recipes-kernel/linux/files/debian/rules.tmpl > > -- > 2.16.4 > > [-- Attachment #1.2: Type: text/html, Size: 6515 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2019-12-19 15:19 UTC | newest] Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-12-10 18:22 [PATCH v5 0/5] linux-custom recipe rework Jan Kiszka 2019-12-10 18:22 ` [PATCH v5 1/5] recipes-kernel/linux: make KERNEL_DEFCONFIG support in-tree defconfigs Jan Kiszka 2019-12-10 18:22 ` [PATCH v5 2/5] linux-mainline: fix stripping of .0 from the kernel version Jan Kiszka 2019-12-10 18:22 ` [PATCH v5 3/5] linux-mainline: update from 4.19.0 to 4.19.88 Jan Kiszka 2019-12-10 18:22 ` [PATCH v5 4/5] linux-custom: rewrite to no longer depend on the kernel's builddeb Jan Kiszka 2019-12-11 14:40 ` Jan Kiszka 2019-12-11 15:20 ` Gylstorff Quirin 2019-12-11 15:43 ` Jan Kiszka 2019-12-11 18:36 ` Jan Kiszka 2019-12-11 22:09 ` Henning Schild 2019-12-12 7:57 ` Gylstorff Quirin 2019-12-12 8:01 ` Jan Kiszka 2019-12-12 9:46 ` Gylstorff Quirin 2019-12-12 10:10 ` Gylstorff Quirin 2019-12-10 18:22 ` [PATCH v5 5/5] linux-mainline: Test config fragments Jan Kiszka 2019-12-19 15:19 ` [PATCH v5 0/5] linux-custom recipe rework cedric_hombourger
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox