From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6755821036247187456 Date: Tue, 5 Nov 2019 12:16:38 -0800 (PST) From: chombourger@gmail.com To: isar-users Message-Id: <6736dd6f-1a6f-4367-8fed-bdacc63ec2de@googlegroups.com> In-Reply-To: <8b757aec-9994-683d-8ac4-1c83718373ce@siemens.com> References: <1572962145-318-1-git-send-email-Cedric_Hombourger@mentor.com> <1572962258-367-1-git-send-email-Cedric_Hombourger@mentor.com> <1572962258-367-3-git-send-email-Cedric_Hombourger@mentor.com> <8b757aec-9994-683d-8ac4-1c83718373ce@siemens.com> Subject: Re: [PATCH 7/7] linux-custom: rewrite to no longer depend on the kernel's builddeb MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_1081_711889408.1572984998648" X-Google-Token: EKaxh-4FqyUVriG6QMY0 X-Google-IP: 77.130.253.234 X-TUID: DjXB5OaOrkW+ ------=_Part_1081_711889408.1572984998648 Content-Type: multipart/alternative; boundary="----=_Part_1082_119568546.1572984998652" ------=_Part_1082_119568546.1572984998652 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On Tuesday, November 5, 2019 at 4:26:33 PM UTC+1, Jan Kiszka wrote: > > On 05.11.19 14:57, Cedric Hombourger wrote: > > 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 > > > --- > > doc/custom_kernel.md | 181 ++++++++++++++++ > > .../linux/files/build-kernel.sh | 128 ------------ > > meta/recipes-kernel/linux/files/debian/compat | 1 + > > .../linux/files/debian/control.tmpl | 36 ++++ > > meta/recipes-kernel/linux/files/debian/files | 5 + > > .../linux/files/debian/isar/build.tmpl | 36 ++++ > > .../linux/files/debian/isar/clean.tmpl | 20 ++ > > .../linux/files/debian/isar/common.tmpl | 60 ++++++ > > .../linux/files/debian/isar/install.tmpl | 197 ++++++++++++++++++ > > .../files/debian/linux-image.postinst.tmpl | 22 ++ > > .../files/debian/linux-image.postrm.tmpl | 18 ++ > > .../linux/files/debian/rules.tmpl | 39 ++++ > > meta/recipes-kernel/linux/linux-custom.inc | 172 ++++++++++----- > > 13 files changed, 732 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/files > > 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/linux-image.postinst.tmpl > > create mode 100644 > meta/recipes-kernel/linux/files/debian/linux-image.postrm.tmpl > > create mode 100755 meta/recipes-kernel/linux/files/debian/rules.tmpl > > > > diff --git a/doc/custom_kernel.md b/doc/custom_kernel.md > > new file mode 100644 > > index 0000000..5ab2599 > > --- /dev/null > > +++ b/doc/custom_kernel.md > > @@ -0,0 +1,181 @@ > > +# Custom kernel recipe for Isar > > + > > +## Contents > > + > > + - [Summary](#summary) > > + - [Proposal owners](#proposal-owners) > > + - [Current status](#current-status) > > + - [Detailed description](#detailed-description) > > + - [Benefit to Isar](#benefit-to-isar) > > + - [How can I help?](#how-can-i-help) > > + - [Scope](#scope) > > + - [How to test](#how-to-test) > > + - [Dependencies](#dependencies) > > + - [Documentation](#documentation) > > + - [Questions and answers](#questions-and-answers) > > + > > +## Summary > > + > > +Isar currently uses the Linux kernel's builddeb script to generate > linux-image, > > +linux-headers and linux-libc-dev packages for your custom kernel > sources. The > > +main benefit of this approach was that the low level details of how to > package > > +the Linux kernel image, modules and headers were left in the kernel. > There are > > +however some drawbacks: Isar had to repack generated packages to > introduce some > > +of the changes it needs such as suffixing the kernel packages with the > name of > > +the custom kernel (e.g. with "mainline" for the "linux-mainline" > recipe), lack > > +of automatic dependencies (the builddeb script from the kernel does not > use > > +debhelper), it was difficult to add packages especially distribution > specific > > +packages (maintain version specific patch in Isar vs being able to > upstream > > +distribution specific changes upstream), etc. This change is about > being less > > +dependent on the kernel packaging scripts (which aren't used by major > distros > > +anyway) and regain control on how we want or need the Linux kernel > packaged. > > + > > +## Proposal owners > > + > > + * name: [Cedric Hombourger](https://github.com/chombourger) > > + > > +## Current status > > + > > +### Tests > > + > > +The following were recently checked: > > + > > + * Custom kernels in meta-isar build without (known) failures > > + * initrd image gets generated when the kernel is added to the rootfs > > + * `ISAR_CROSS_COMPILE` is supported > > + * `KERNEL_FILE` is honored > > + * `KERNEL_DEFCONFIG` may either be a file (specified via `SRC_URI`) or > a > > + kernel-provided defconfig > > + * Config fragments get merged with the user-specified kernel > configuration > > + * Path to installed DTBs may be configured (new) > > + * Configuration and build from a `devshell` > > + * Support for the `KERNEL_LIBC_DEV_DEPLOY` directive > > + > > +while the following needs work: > > + > > + * Check if custom-kernel builds are reproducible > > + > > +### Remaining work items > > + > > + * Check if there is a better way to cross compile kernel "scripts" > such as > > + `fixdep` or `modpost` than manually compiling them (they are > compiled for > > + the build machine (amd64) and not for the target (e.g. armhf) even > though > > + we are cross-compiling - yet the linux-headers package should be > shipping > > + "scripts" for the target machine) > > + > > +## Detailed description > > + > > +### Requirements > > + > > +#### Current > > + > > +Isar has had a `linux-custom` recipe for a long time and counts many > users. It is therefore > > +paramount to maintain features that it has today with no or little > changes to the APIs. The > > +following requirements were identified and will be maintained: > > + > > + 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` > > Reference to KERNEL_DEFCONFIG is missing. > > > + > > + 3. Support 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 > > One package to serve them all? Is that the use case for patch 6? IOW, we > are now building linux-headers for the target, not the host OS anymore? > What's the slowdown compare to cross-linux-headers? > > The current policy is that, when cross-building, our -dev packagages > (which is what linux-headers falls under) will work natively with the > buildchroot. The future path is clearly generating fitting packages for > both host and target. Or is there anything in the linux-headers that > prevents providing both? > > > + > > + 10. Produce a `linux-libc-dev` package to support user-land builds > > This should be opt-in only: No need to build it when we don't ship it. > Just add the related fragement to debian/control when > KERNEL_LIBC_DEV_DEPLOY is set. > > > + > > + 11. Only 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) > > + > > +#### New requirements (proposed) > > + > > +This proposal includes the following new requirements: > > + > > + 1. Support creation of additional packages > > + > > + 2. Allow per-distro packaging tweaks > > + > > +### Approach > > + > > +The new implementation will have the `builddeb` code ported from the > Linux kernel included to the > > +Isar environment. It will be refactor to support pre and post hooks. > Hooks may be used by external > > +layers to extend the kernel packaging instructions provided by "stock" > Isar or by Isar itself to > > +implement distro-specific packages or tweaks. > > + > > +Hooks need the ability to add `build` and `install` steps which can be > achieved by having the main > > +`build` and `install` steps call pre and post scripts. This will > however solve only one side of the > > +problem: new packages should be declared in the `debian/control` file. > The packaging process > > +(initiated by `debian/rules`) will use a baseline `control` file when > started and a mechanism will > > +be provided for hooks to append `control` blocks as they are processed. > > Is this a section addressing users or reviewers? The latter audience is > better addressed via the commit log. > > > + > > +### Future work > > + > > +In the event where this proposal is accepted, here are a few future > projects that are being > > +considered: > > + > > + 1. Package `perf` as Debian does > > + > > + 2. Add `ubuntu` as an Isar supported target distro and validate > `linux-custom` recipe > > + > > +## Benefit to Isar > > + > > + * Control the kernel build and packaging process > > + > > + * No longer need to repack packages > > + > > + * Provide hooks for custom kernel recipes to add build/install > directives > > Careful with hooks! They tend to pile up mess. Where exactly do you want > them? What for? > > > + > > +## How can I help? > > + > > + * Check if you are able to build your own linux-custom recipes with > this change > > + * Check if packages generated by this recipe are compatible with your > Debian-based distro > > + * Review and provide comments on this changeset > > + * Create templates for distro-specific packages (e.g. perf) > > + > > +## Scope > > + > > + * Proposal owners: proposal owners are to communicate the idea to > isar-users and make sure > > + that all of their requirements are met (to the extent they are > already supported with the > > + current solution) or may be met in the future. > > + > > + * Other developers: port your out-of-tree linux-custom recipes to this > new solution and > > + report issues. > > + > > +## How to test? > > + > > +The linux-mainline recipe may be used for some basic testing. This > recipe is being used by the > > +following machines: > > + > > + * de0-nano-soc > > + * qemumipsel > > + > > +## Dependencies > > + > > + * None > > + > > +## Documentation > > + > > + * Document user-visible variables added by this proposal > > + > > +## Questions and answers > > + > > + * None > > 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 f56e96c..0000000 > > --- a/meta/recipes-kernel/linux/files/build-kernel.sh > > +++ /dev/null > > @@ -1,128 +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 ${?} > > -if [ -n "${KERNEL_FRAGMENTS}" ]; then > > - scripts/kconfig/merge_config.sh -m .config ${KERNEL_FRAGMENTS} > > -fi > > - > > -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..1295466 > > --- /dev/null > > +++ b/meta/recipes-kernel/linux/files/debian/control.tmpl > > @@ -0,0 +1,36 @@ > > +Source: linux-${KERNEL_NAME_PROVIDED} > > +Section: kernel > > +Priority: optional > > +Maintainer: ${MAINTAINER} > > +Build-Depends: bc, kmod, cpio, ${KBUILD_DEPENDS} > > +Homepage: http://www.kernel.org/ > > Standard-Version? > > > + > > +Package: linux-image-${KERNEL_NAME_PROVIDED} > > +Architecture: any > > +Depends: ${KERNEL_DEBIAN_DEPENDS} > > +Description: ${KERNEL_NAME_PROVIDED} Linux kernel, version ${PV} > > + This package contains the Linux kernel, modules and corresponding > other > > + files, version: ${PV}. > > + > > +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} > > + This package provides kernel header files for ${PV} on ${DISTRO_ARCH} > > + . > > + This is useful for people who need to build external modules > > + > > +Package: linux-libc-dev > > See above, should not be here by default. > > > +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} > > + 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/files > b/meta/recipes-kernel/linux/files/debian/files > > new file mode 100644 > > index 0000000..a8ace32 > > --- /dev/null > > +++ b/meta/recipes-kernel/linux/files/debian/files > > @@ -0,0 +1,5 @@ > > +linux-headers_4.19.80-1_mipsel.deb kernel optional > > +linux-image-dbg_4.19.80-1_mipsel.deb debug optional > > +linux-image_4.19.80-1_mipsel.deb kernel optional > > +linux-libc-dev_4.19.80-1_mipsel.deb devel optional > > +linux_4.19.80-1_mipsel.buildinfo kernel optional > > Looks like an accidentally added file. > > > 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..ce79d56 > > --- /dev/null > > +++ b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl > > @@ -0,0 +1,36 @@ > > +#!/bin/sh > > +# 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 > > + > > + # Trace what we do here > > + set -x > > + > > + # Process existing kernel configuration to make sure it is complete > > + # (use defaults for options that were not specified) > > + ${MAKE} O=${KERNEL_BUILD_DIR} olddefconfig || exit ${?} > > + > > + # Build the Linux kernel > > + ${MAKE} O=${KERNEL_BUILD_DIR} -j $(nproc) || exit ${?} > > + > > + # Stop tracing > > + set +x > > +} > > + > > +print_settings() { > > + cat < > +# 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..2aa3742 > > --- /dev/null > > +++ b/meta/recipes-kernel/linux/files/debian/isar/clean.tmpl > > @@ -0,0 +1,20 @@ > > +#!/bin/sh > > +# 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} ${deb_libc_hdr_dir} > > I suppose we rather (or also?) want "make clean" here for the build > artifacts. Just make sure to save/restore the debian folder across that > step. > > > + > > + # 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..b392b46 > > --- /dev/null > > +++ b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl > > @@ -0,0 +1,60 @@ > > +#!/bin/sh > > +# 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} > > + > > +main() { > > + target=${1} > > + > > + if [ ! -f ${S}/debian/isar/${target} ]; then > > + echo "error: ${target} is not a supported build target!" >&2 > > + return 1 > > + fi > > + > > + # check for scripts to be sourced > > + for f in ${S}/debian/isar/defaults.d/${target}/*; do > > + [ -f ${f} ] || continue > > + . ${f} || return ${?} > > + 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 > > + > > + # check for pre-target scripts > > + for f in ${S}/debian/isar/pre.d/${target}/*; do > > + [ -f ${f} ] || continue > > + sh ${f} || return ${?} > > + done > > + > > + # call the actual target script > > + do_${target} || return ${?} > > + > > + # check for post-target scripts > > + for f in ${S}/debian/isar/post.d/${target}/*; do > > + [ -f ${f} ] || continue > > + sh ${f} || return ${?} > > + done > > +} > > 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..2055669 > > --- /dev/null > > +++ b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl > > @@ -0,0 +1,197 @@ > > +#!/bin/sh > > +# Copyright (c) Mentor Graphics, a Siemens business, 2019 > > +# SPDX-License-Identifier: MIT > > + > > +# Load common stuff > > +. ${S}/debian/isar/common || exit ${?} > > + > > +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)" > > + case "${ARCH}" in > > + mips|powerpc) kimage_path="boot/vmlinux-${PV}" ;; > > + um) kimage_path="usr/bin/vmlinux-${PV}" ;; > > + *) kimage_path="boot/vmlinuz-${PV}" ;; > > + esac > > + > > + print_settings > > + > > + # Stop on error > > + set -e > > + > > + # Trace what we do here > > + set -x > > + > > + install_image > > + install_hooks > > + install_dtbs > > + install_kmods > > + install_headers > > + > > + # Stop tracing > > + set +x > > +} > > + > > +print_settings() { > > + cat < > +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} > > + 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/${PV}/ > > + cp vmlinux ${deb_dbg_dir}/usr/lib/debug/lib/modules/${PV}/ > > + # systemtap > > + mkdir -p ${deb_dbg_dir}/usr/lib/debug/boot/ > > + ln -s ../lib/modules/$version/vmlinux > ${deb_dbg_dir}/usr/lib/debug/boot/vmlinux-${PV} > > + # kdump-tools > > + ln -s lib/modules/${PV}/vmlinux > ${deb_dbg_dir}/usr/lib/debug/vmlinux-${PV} > > +} > > + > > +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 > > +} > > + > > +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/${PV}/.fresh-install > > + rm -fv ${deb_img_dir}/lib/modules/${PV}/build > > + rm -fv ${deb_img_dir}/lib/modules/${PV}/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}/ > > +} > > + > > +# the kernel does not seem to provide a way to cross-compile its tools, > we however > > +# have qemu-user-static binaries in our buildchroot. Create a new build > tree for the > > +# scripts and override HOSTCC to force a cross-compile > > +kernel_tools_build() { > > + odir="${S}/build-scripts" > > + mflags="HOSTCC=${CROSS_COMPILE}gcc O=${odir} NOSTDINC_FLAGS=" > > + rm -rf ${odir} && mkdir -p ${odir} && cp > ${S}/${KERNEL_BUILD_DIR}/.config ${odir} > > + (unset LD_PRELOAD; cd ${odir} && make -C ${S} ${mflags} > olddefconfig scripts) > > + (cd ${odir}; find scripts -type f -executable -exec file {} \;|grep > ELF|cut -d: -f1) >${src_hdr_files} > > + tar -C ${odir} -cf - -T - <${src_hdr_files} | tar -C ${destdir} -xf > - > > +} > > + > > +kernel_tools() { > > + # remove object files > > + find ${destdir}/scripts -type f -name '*.o' |xargs rm -f > > + > > + # we're all done if we aren't cross-compiling > > + [ -n "${CROSS_COMPILE}" ] || return 0 > > + > > + # remove ELF executables from the linux-headers package > > + find ${destdir}/scripts -type f -exec file {} \;|grep ELF|cut -d: > -f1|xargs rm -fv > > + > > + # cross-compile kernel tools to be shipped with linux-headers > > + kernel_tools_build > > +} > > + > > +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/${PV} > > + > > + (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/${PV}/build > > +} > > + > > +install_headers() { > > + headers_check > > + libc_headers > > + kernel_headers > > +} > > + > > +main install ${*} > > 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..fd89121 > > --- /dev/null > > +++ b/meta/recipes-kernel/linux/files/debian/linux-image.postinst.tmpl > > @@ -0,0 +1,22 @@ > > +#!/bin/sh > > + > > +set -e > > +set -x > > + > > +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 > > + > > +# Pass maintainer script parameters to hook scripts > > +export DEB_MAINT_PARAMS="$*" > > + > > +# Tell initramfs builder whether it's wanted > > +export INITRD=Yes > > I've noticed while hacking my version that this should follow > CONFIG_BLK_DEV_INITRD. > > > + > > +test -d /etc/kernel/postinst.d && run-parts --arg="${PV}" > --arg="/boot/${KERNEL_FILE}-${PV}" /etc/kernel/postinst.d > > +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..9d88218 > > --- /dev/null > > +++ b/meta/recipes-kernel/linux/files/debian/linux-image.postrm.tmpl > > @@ -0,0 +1,18 @@ > > +#!/bin/sh > > + > > +set -e > > + > > +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 > > + > > +# Pass maintainer script parameters to hook scripts > > +export DEB_MAINT_PARAMS="$*" > > + > > +# Tell initramfs builder whether it's wanted > > +export INITRD=Yes > > + > > +test -d /etc/kernel/postrm.d && run-parts --arg="${PV}" > --arg="/boot/${KERNEL_FILE}-${PV}" /etc/kernel/postrm.d > > +exit 0 > > diff --git a/meta/recipes-kernel/linux/files/debian/rules.tmpl > b/meta/recipes-kernel/linux/files/debian/rules.tmpl > > There is quite some duplication between postinst and postrm already. > Moreover, I think you are missing preinst and prerm. I think all four > should probably be generated from one template. > Ok I have checked upstream scripts and it seems that they all differ see https://salsa.debian.org/kernel-team/linux/tree/master/debian/templates I would recommend we just copy over their scripts but use our templating system instead of theirs (use ${var} instead of @var@) > > > new file mode 100755 > > index 0000000..93c8a5b > > --- /dev/null > > +++ b/meta/recipes-kernel/linux/files/debian/rules.tmpl > > @@ -0,0 +1,39 @@ > > +#!/usr/bin/make -f > > + > > +export CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)- > > + > > +O:=$(CURDIR)/${KERNEL_BUILD_DIR} > > +S:=$(CURDIR) > > +deb_top_dir:=$(S)/debian > > + > > +DH_VERBOSE=1 > > + > > +# Dynamic variables to be passed to Isar build scripts > > +isar_env=$(strip \ > > + export CROSS_COMPILE='$(CROSS_COMPILE)' && \ > > + export MAKE='$(MAKE)' && \ > > + export O='${O}' \ > > + export S='${S}' \ > > +) > > + > > +%: > > + dh $(@) > > + > > +.PHONY: override_dh_auto_clean > > +override_dh_auto_clean: > > + $(isar_env) && sh $(deb_top_dir)/isar/clean > > + > > +.PHONY: override_dh_auto_build > > +override_dh_auto_build: > > + $(isar_env) && sh $(deb_top_dir)/isar/build > > + > > +override_dh_auto_install: > > + $(isar_env) && sh $(deb_top_dir)/isar/install > > + > > +.PHONY: override_dh_auto_test > > +override_dh_auto_test: > > + true > > + > > +PHONY: override_dh_strip > > +override_dh_strip: > > + 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 ca91f64..36086be 100644 > > --- a/meta/recipes-kernel/linux/linux-custom.inc > > +++ b/meta/recipes-kernel/linux/linux-custom.inc > > @@ -2,22 +2,104 @@ > > # > > # 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 > > +# ------------------------------------------------------------------- > > > > DESCRIPTION ?= "Custom kernel" > > +MAINTAINER ?= "isar-users >" > > + > > +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_DTB_DIR ?= "usr/lib/linux-${KERNEL_NAME_PROVIDED}-${PV}" > > +KERNEL_HEADERS_DIR ?= "usr/src/linux-headers-${PV}" > > > > -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/linux-image.postinst.tmpl \ > > + debian/linux-image.postrm.tmpl \ > > + debian/rules.tmpl \ > > +" > > + > > +TEMPLATE_VARS += " \ > > + KBUILD_DEPENDS \ > > + KERNEL_ARCH \ > > + KERNEL_DEBIAN_DEPENDS \ > > + KERNEL_BUILD_DIR \ > > + KERNEL_DTB_DIR \ > > + KERNEL_FILE \ > > + KERNEL_HEADERS_DEBIAN_DEPENDS \ > > + KERNEL_HEADERS_DIR \ > > + 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) > > } > > > > +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() > > @@ -31,57 +113,35 @@ def config_fragments(d): > > fragments.append(local) > > return fragments > > > > -inherit dpkg-base > > - > > -SRC_URI += "file://build-kernel.sh" > > +do_prepare_build_prepend() { > > + # copy meta-data over to source tree > > + rm -rf ${S}/debian > > + cp -r ${WORKDIR}/debian ${S}/ > > > > -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" > > + # remove templates from the source tree > > + find ${S}/debian -name *.tmpl | xargs rm -f > > > > -KERNEL_LIBC_DEV_DEPLOY ?= "0" > > + # 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 > > > > -do_install_builddeps() { > > - dpkg_do_mounts > > - E="${@ bb.utils.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 > > + # 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 > > > > # copy config fragments over to the kernel tree > > @@ -92,21 +152,23 @@ dpkg_runbuild() { > > mkdir -p ${S}/debian/fragments > > (cd ${WORKDIR} && cp ${src_frags} > ${S}/debian/fragments/) > > fi > > - export KERNEL_FRAGMENTS="${out_frags}" > > > > - E="${@ bb.utils.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}" > > + 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} > \ > > + " > > +} > > > > - sudo -E chroot --userspec=$( id -u ):$( id -g ) > ${BUILDCHROOT_DIR} ${PP}/build-kernel.sh ${PP}/${PPS} ${DISTRO_ARCH} > > +dpkg_runbuild_prepend() { > > + dpkg_configure_kernel > > +} > > > > +dpkg_runbuild_append() { > > if [ "${KERNEL_LIBC_DEV_DEPLOY}" != "1" ]; then > > rm -f ${WORKDIR}/linux-libc-dev_${PV}*.deb > > fi > > > > Valuable step forward! I still need to check some more details against > my unfinished prototype, but it seems it generally a superset of it. > > Jan > > -- > Siemens AG, Corporate Technology, CT RDA IOT SES-DE > Corporate Competence Center Embedded Linux > ------=_Part_1082_119568546.1572984998652 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Tuesday, November 5, 2019 at 4:26:33 PM UTC+1, = Jan Kiszka wrote:
On 05.11.19 1= 4:57, Cedric Hombourger wrote:
> Regain control over the packaging of the Linux kernel by providing= our
> own debian recipes (debian,{control,rules} files and friends) inst= ead
> of using the kernel's builddeb script. This will allow generat= ion of
> packages for "perf" (not included in this changeset) wit= h per distro
> scheme (Debian and Ubuntu have differences) and maintain compatibi= lity
> with upstream packages generated from different source packages bu= t
> dependent on a certain deployment scheme (e.g. linux-base for Debi= an)
>=20
> Signed-off-by: Cedric Hombourger <Cedric_H...@mentor.com>
> ---
> =C2=A0doc/custom_kernel.md =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 181 ++++++++++++++++
> =C2=A0.../linux/files/build-kernel.sh =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 128 ------------
> =C2=A0meta/recipes-kernel/linux/files/debian/compat | =C2=A0 = 1 +
> =C2=A0.../linux/files/debian/control.tmpl =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 | =C2=A036 ++++
> =C2=A0meta/recipes-kernel/linux/files/debian/files =C2=A0| = =C2=A0 5 +
> =C2=A0.../linux/files/debian/isar/build.tmpl =C2=A0 =C2=A0 = =C2=A0 =C2=A0| =C2=A036 ++++
> =C2=A0.../linux/files/debian/isar/clean.tmpl =C2=A0 =C2=A0 = =C2=A0 =C2=A0| =C2=A020 ++
> =C2=A0.../linux/files/debian/isar/common.tmpl =C2=A0 =C2=A0 = =C2=A0 | =C2=A060 ++++++
> =C2=A0.../linux/files/debian/isar/install.tmpl =C2=A0 =C2=A0 = =C2=A0| 197 ++++++++++++++++++
> =C2=A0.../files/debian/linux-image.postinst.tmpl =C2=A0 =C2= =A0| =C2=A022 ++
> =C2=A0.../files/debian/linux-image.postrm.tmpl =C2=A0 =C2=A0 = =C2=A0| =C2=A018 ++
> =C2=A0.../linux/files/debian/rules.tmpl =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 | =C2=A039 ++++
> =C2=A0meta/recipes-kernel/linux/linux-custom.inc =C2=A0 =C2= =A0| 172 ++++++++++-----
> =C2=A013 files changed, 732 insertions(+), 183 deletions(-)
> =C2=A0create mode 100644 doc/custom_kernel.md
> =C2=A0delete mode 100644 meta/recipes-kernel/linux/files/buil= d-kernel.sh
> =C2=A0create mode 100644 meta/recipes-kernel/linux/files/debi= an/compat
> =C2=A0create mode 100644 meta/recipes-kernel/linux/files/debi= an/control.tmpl
> =C2=A0create mode 100644 meta/recipes-kernel/linux/files/debi= an/files
> =C2=A0create mode 100644 meta/recipes-kernel/linux/files/debi= an/isar/build.tmpl
> =C2=A0create mode 100644 meta/recipes-kernel/linux/files/debi= an/isar/clean.tmpl
> =C2=A0create mode 100644 meta/recipes-kernel/linux/files/debi= an/isar/common.tmpl
> =C2=A0create mode 100644 meta/recipes-kernel/linux/files/debi= an/isar/install.tmpl
> =C2=A0create mode 100644 meta/recipes-kernel/linux/files/debi= an/linux-image.postinst.tmpl
> =C2=A0create mode 100644 meta/recipes-kernel/linux/files/debi= an/linux-image.postrm.tmpl
> =C2=A0create mode 100755 meta/recipes-kernel/linux/files/debi= an/rules.tmpl
>=20
> diff --git a/doc/custom_kernel.md b/doc/custom_kernel.md
> new file mode 100644
> index 0000000..5ab2599
> --- /dev/null
> +++ b/doc/custom_kernel.md
> @@ -0,0 +1,181 @@
> +# Custom kernel recipe for Isar
> +
> +## Contents
> +
> + - [Summary](#summary)
> + - [Proposal owners](#proposal-owners)
> + - [Current status](#current-status)
> + - [Detailed description](#detailed-description)
> + - [Benefit to Isar](#benefit-to-isar)
> + - [How can I help?](#how-can-i-help)
> + - [Scope](#scope)
> + - [How to test](#how-to-test)
> + - [Dependencies](#dependencies)
> + - [Documentation](#documentation)
> + - [Questions and answers](#questions-and-answers)
> +
> +## Summary
> +
> +Isar currently uses the Linux kernel's builddeb script to gen= erate linux-image,
> +linux-headers and linux-libc-dev packages for your custom kernel = sources. The
> +main benefit of this approach was that the low level details of h= ow to package
> +the Linux kernel image, modules and headers were left in the kern= el. There are
> +however some drawbacks: Isar had to repack generated packages to = introduce some
> +of the changes it needs such as suffixing the kernel packages wit= h the name of
> +the custom kernel (e.g. with "mainline" for the "l= inux-mainline" recipe), lack
> +of automatic dependencies (the builddeb script from the kernel do= es not use
> +debhelper), it was difficult to add packages especially distribut= ion specific
> +packages (maintain version specific patch in Isar vs being able t= o upstream
> +distribution specific changes upstream), etc. This change is abou= t being less
> +dependent on the kernel packaging scripts (which aren't used = by major distros
> +anyway) and regain control on how we want or need the Linux kerne= l packaged.
> +
> +## Proposal owners
> +
> + * name: [Cedric Hombourger](https://github.com/chombo= urger)
> +
> +## Current status
> +
> +### Tests
> +
> +The following were recently checked:
> +
> + * Custom kernels in meta-isar build without (known) failures
> + * initrd image gets generated when the kernel is added to the ro= otfs
> + * `ISAR_CROSS_COMPILE` is supported
> + * `KERNEL_FILE` is honored
> + * `KERNEL_DEFCONFIG` may either be a file (specified via `SRC_UR= I`) or a
> + =C2=A0 kernel-provided defconfig
> + * Config fragments get merged with the user-specified kernel con= figuration
> + * Path to installed DTBs may be configured (new)
> + * Configuration and build from a `devshell`
> + * Support for the `KERNEL_LIBC_DEV_DEPLOY` directive
> +
> +while the following needs work:
> +
> + * Check if custom-kernel builds are reproducible
> +
> +### Remaining work items
> +
> + * Check if there is a better way to cross compile kernel "s= cripts" such as
> + =C2=A0 `fixdep` or `modpost` than manually compiling them (they = are compiled for
> + =C2=A0 the build machine (amd64) and not for the target (e.g. ar= mhf) even though
> + =C2=A0 we are cross-compiling - yet the linux-headers package sh= ould be shipping
> + =C2=A0 "scripts" for the target machine)
> +
> +## Detailed description
> +
> +### Requirements
> +
> +#### Current
> +
> +Isar has had a `linux-custom` recipe for a long time and counts m= any users. It is therefore
> +paramount to maintain features that it has today with no or littl= e changes to the APIs. The
> +following requirements were identified and will be maintained:
> +
> + 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= `

Reference to KERNEL_DEFCONFIG is missing.

> +
> + 3. Support kernel configuration tweaks via configuration fragmen= ts (`.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 i= dentifier (`KERNEL_RELEASE`)
> +
> + 6. Produce a `linux-image` package that ships the kernel image a= nd 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 heade= rs and kbuild scripts/tools
> +
> + 9. The `linux-headers` package shall support native and cross co= mpiles of out-of-tree kernel modules

One package to serve them all? Is that the use case for patch 6? IOW, w= e
are now building linux-headers for the target, not the host OS anymore?
What's the slowdown compare to cross-linux-headers?

The current policy is that, when cross-building, our -dev packagages
(which is what linux-headers falls under) will work natively with the
buildchroot. The future path is clearly generating fitting packages for
both host and target. Or is there anything in the linux-headers that
prevents providing both?

> +
> + 10. Produce a `linux-libc-dev` package to support user-land buil= ds

This should be opt-in only: No need to build it when we don't ship = it.
Just add the related fragement to debian/control when
KERNEL_LIBC_DEV_DEPLOY is set.

> +
> + 11. Only ship the `linux-libc-dev` package if instructed to (`KE= RNEL_LIBC_DEV_DEPLOY` equals to `"1"`)
> +
> + 12. Support both native and cross compiles (`ISAR_CROSS_COMPILE`= )
> +
> + 13. Support for the following kernel architectures:
> +
> + =C2=A0 * arm
> + =C2=A0 * arm64
> + =C2=A0 * mips
> + =C2=A0 * x86
> +
> + 14. Support `devshell` (kernel configuration shall be applied)
> +
> +#### New requirements (proposed)
> +
> +This proposal includes the following new requirements:
> +
> + 1. Support creation of additional packages
> +
> + 2. Allow per-distro packaging tweaks
> +
> +### Approach
> +
> +The new implementation will have the `builddeb` code ported from = the Linux kernel included to the
> +Isar environment. It will be refactor to support pre and post hoo= ks. Hooks may be used by external
> +layers to extend the kernel packaging instructions provided by &q= uot;stock" Isar or by Isar itself to
> +implement distro-specific packages or tweaks.
> +
> +Hooks need the ability to add `build` and `install` steps which c= an be achieved by having the main
> +`build` and `install` steps call pre and post scripts. This will = however solve only one side of the
> +problem: new packages should be declared in the `debian/control` = file. The packaging process
> +(initiated by `debian/rules`) will use a baseline `control` file = when started and a mechanism will
> +be provided for hooks to append `control` blocks as they are proc= essed.

Is this a section addressing users or reviewers? The latter audience is
better addressed via the commit log.

> +
> +### Future work
> +
> +In the event where this proposal is accepted, here are a few futu= re projects that are being
> +considered:
> +
> + 1. Package `perf` as Debian does
> +
> + 2. Add `ubuntu` as an Isar supported target distro and validate = `linux-custom` recipe
> +=20
> +## Benefit to Isar
> +
> + * Control the kernel build and packaging process
> +
> + * No longer need to repack packages
> +
> + * Provide hooks for custom kernel recipes to add build/install d= irectives

Careful with hooks! They tend to pile up mess. Where exactly do you wan= t
them? What for?

> +
> +## How can I help?
> +
> + * Check if you are able to build your own linux-custom recipes w= ith this change
> + * Check if packages generated by this recipe are compatible with= your Debian-based distro
> + * Review and provide comments on this changeset
> + * Create templates for distro-specific packages (e.g. perf)
> +
> +## Scope
> +
> + * Proposal owners: proposal owners are to communicate the idea t= o isar-users and make sure
> + =C2=A0 that all of their requirements are met (to the extent the= y are already supported with the
> + =C2=A0 current solution) or may be met in the future.
> +
> + * Other developers: port your out-of-tree linux-custom recipes t= o this new solution and
> + =C2=A0 report issues.
> +
> +## How to test?
> +
> +The linux-mainline recipe may be used for some basic testing. Thi= s recipe is being used by the
> +following machines:
> +
> + * de0-nano-soc
> + * qemumipsel
> +
> +## Dependencies
> +
> + * None
> +
> +## Documentation
> +
> + * Document user-visible variables added by this proposal
> +
> +## Questions and answers
> +
> + * None
> 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 f56e96c..0000000
> --- a/meta/recipes-kernel/linux/files/build-kernel.sh
> +++ /dev/null
> @@ -1,128 +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=3D$(dpkg --print-architecture)
> -
> -if [ "$host_arch" !=3D "$target_arch" ]; then
> - =C2=A0 =C2=A0case $target_arch in
> - =C2=A0 =C2=A0armhf)
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0export ARCH=3Darm
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0export CROSS_COMPILE=3D"arm-linu= x-gnueabihf-"
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0;;
> - =C2=A0 =C2=A0arm64)
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0export ARCH=3Darm64
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0export CROSS_COMPILE=3D"aarch64-= linux-gnu-"
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0;;
> - =C2=A0 =C2=A0mipsel)
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0export ARCH=3Dmips
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0export CROSS_COMPILE=3D"mipsel-l= inux-gnu-"
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0;;
> - =C2=A0 =C2=A0*)
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0echo "error: unsupported archite= cture ($target_arch)"
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0exit 1
> - =C2=A0 =C2=A0 =C2=A0 =C2=A0;;
> - =C2=A0 =C2=A0esac
> -fi
> -
> -REPACK_DIR=3D"$1/../repack"
> -REPACK_LINUX_IMAGE_DIR=3D"${REPACK_DIR}/linux-image&quo= t;
> -REPACK_LINUX_HEADERS_DIR=3D"${REPACK_DIR}/linux-headers= "
> -
> -make ${KERNEL_CONFIG_TARGET} || exit ${?}
> -if [ -n "${KERNEL_FRAGMENTS}" ]; then
> - =C2=A0 =C2=A0scripts/kconfig/merge_config.sh -m .config ${K= ERNEL_FRAGMENTS}
> -fi
> -
> -KV=3D$( make -s kernelrelease )
> -if [ "${KV}" !=3D "${PV}" ]; then
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0echo "ERROR:= Recipe PV is \"${PV}\" but should be \"${KV}\"" 1= >&2
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0echo "ERROR:= Probably due to CONFIG_LOCALVERSION" 1>&2
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0exit 1
> -fi
> -
> -rm -f .version
> -KBUILD_DEBARCH=3D$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_L= INUX_IMAGE_DIR}"
> -dpkg-deb -R linux-headers-${PV}_${PV}-1_*.deb "${REPACK= _LINUX_HEADERS_DIR}"
> -
> -dpkg-gencontrol -crepack/debian/control \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-lrepack/debian/<= wbr>changelog \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-frepack/debian/f= iles \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-plinux-image-${P= V} \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-P"${REPACK_= LINUX_IMAGE_DIR}" \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-DPackage=3D"= ;linux-image-${KERNEL_NAME}" \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-DSection=3Dkerne= l \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-DPriority=3Drequ= ired \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-DDepends=3D"= ;${KERNEL_DEBIAN_DEPENDS}" \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-DArchitecture=3D= $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}/.fre= sh-install"
> -sed -i "${REPACK_LINUX_IMAGE_DIR}/DEBIAN/postinst"= \
> - =C2=A0 =C2=A0-e "/^set -e$/a\\
> -\\
> -if [ -f /lib/modules/${PV}/.fresh-install ]; then\\
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0change=3Dinstall\= \
> -else\\
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0change=3Dupgrade\= \
> -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" \
> - =C2=A0 =C2=A0-e "/^set -e$/a\\
> -\\
> -rm -f /lib/modules/${PV}/.fresh-install\\
> -\\
> -if [ \"\$1\" !=3D upgrade ] && command -v linux= -update-symlinks >/dev/null; then\\
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0linux-update-syml= inks remove ${PV} =C2=A0/boot/${KERNEL_FILE}-${PV}\\
> -fi"
> -
> -# Make sure arm64 kernels are decompressed
> -if [ "$target_arch" =3D "arm64" ]; then
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0kernel_file=3D&qu= ot;${REPACK_LINUX_IMAGE_DIR}/boot/${KERNEL_FILE}-${PV}"
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0mv "${kernel= _file}" "${kernel_file}.gz"
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0gunzip "${ke= rnel_file}.gz"
> -fi
> -
> -dpkg-gencontrol -crepack/debian/control \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-lrepack/debian/<= wbr>changelog \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-frepack/debian/f= iles \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-plinux-headers-$= {PV} \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-P"${REPACK_= LINUX_HEADERS_DIR}" \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-Vkernel:debarch= =3D"${KERNEL_NAME}" \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-DPackage=3D"= ;linux-headers-${KERNEL_NAME}" \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-DSection=3Dkerne= l \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-DDepends=3D"= ;${KERNEL_HEADERS_DEBIAN_DEPENDS}" \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0-DArchitecture=3D= $target_arch
> -
> -fakeroot dpkg-deb -b "${REPACK_LINUX_IMAGE_DIR}" \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0linux-image-${KER= NEL_NAME}_${PV}-1_${KERNEL_NAME}.deb
> -rm -f linux-image-${PV}_${PV}-1_*.deb
> -fakeroot dpkg-deb -b "${REPACK_LINUX_HEADERS_DIR}" \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0linux-headers-${<= wbr>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.t= mpl b/meta/recipes-kernel/linux/files/debian/control.tmpl
> new file mode 100644
> index 0000000..1295466
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/files/debian/control.tmpl
> @@ -0,0 +1,36 @@
> +Source: linux-${KERNEL_NAME_PROVIDED}
> +Section: kernel
> +Priority: optional
> +Maintainer: ${MAINTAINER}
> +Build-Depends: bc, kmod, cpio, ${KBUILD_DEPENDS}
> +Homepage: = http://www.kernel.org/

Standard-Version?

> +
> +Package: linux-image-${KERNEL_NAME_PROVIDED}
> +Architecture: any
> +Depends: ${KERNEL_DEBIAN_DEPENDS}
> +Description: ${KERNEL_NAME_PROVIDED} Linux kernel, version ${PV}
> + This package contains the Linux kernel, modules and correspondin= g other
> + files, version: ${PV}.
> +
> +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 ${P= V}
> + This package provides kernel header files for ${PV} on ${DISTRO_= ARCH}
> + .
> + This is useful for people who need to build external modules
> +
> +Package: linux-libc-dev

See above, should not be here by default.

> +Section: devel
> +Provides: linux-kernel-headers
> +Architecture: any
> +Description: Linux support headers for userspace development
> + This package provides userspaces headers from the Linux kernel. = =C2=A0These 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}
> + 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/files b/m= eta/recipes-kernel/linux/files/debian/files
> new file mode 100644
> index 0000000..a8ace32
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/files/debian/files
> @@ -0,0 +1,5 @@
> +linux-headers_4.19.80-1_mipsel.deb kernel optional
> +linux-image-dbg_4.19.80-1_mipsel.deb debug optional
> +linux-image_4.19.80-1_mipsel.deb kernel optional
> +linux-libc-dev_4.19.80-1_mipsel.deb devel optional
> +linux_4.19.80-1_mipsel.buildinfo kernel optional

Looks like an accidentally added file.

> diff --git a/meta/recipes-kernel/linux/files/debian/isar/buil= d.tmpl b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl
> new file mode 100644
> index 0000000..ce79d56
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl
> @@ -0,0 +1,36 @@
> +#!/bin/sh
> +# Copyright (c) Mentor Graphics, a Siemens business, 2019
> +# SPDX-License-Identifier: MIT
> +
> +# Load common stuff
> +. ${S}/debian/isar/common || exit ${?}
> +
> +do_build() {
> +
> + =C2=A0 =C2=A0# Print a few things that are of particular interes= t
> + =C2=A0 =C2=A0print_settings
> +
> + =C2=A0 =C2=A0# Trace what we do here
> + =C2=A0 =C2=A0set -x
> +
> + =C2=A0 =C2=A0# Process existing kernel configuration to make sur= e it is complete
> + =C2=A0 =C2=A0# (use defaults for options that were not specified= )
> + =C2=A0 =C2=A0${MAKE} O=3D${KERNEL_BUILD_DIR} olddefconfig || exi= t ${?}
> +
> + =C2=A0 =C2=A0# Build the Linux kernel
> + =C2=A0 =C2=A0${MAKE} O=3D${KERNEL_BUILD_DIR} -j $(nproc) || exit= ${?}
> +
> + =C2=A0 =C2=A0# Stop tracing
> + =C2=A0 =C2=A0set +x
> +}
> +
> +print_settings() {
> + =C2=A0 =C2=A0cat <<EOF
> +# Build settings:
> +# ---------------
> +# ARCH=3D${ARCH}
> +# CROSS_COMPILE=3D${CROSS_COMPILE}
> +EOF
> +}
> +
> +main build ${*}
> diff --git a/meta/recipes-kernel/linux/files/debian/isar/clea= n.tmpl b/meta/recipes-kernel/linux/files/debian/isar/clean.tmpl
> new file mode 100644
> index 0000000..2aa3742
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/files/debian/isar/clean.tmpl
> @@ -0,0 +1,20 @@
> +#!/bin/sh
> +# Copyright (c) Mentor Graphics, a Siemens business, 2019
> +# SPDX-License-Identifier: MIT
> +
> +# Load common stuff
> +. ${S}/debian/isar/common || exit ${?}
> +
> +do_clean() {
> +
> + =C2=A0 =C2=A0# Trace what we do here
> + =C2=A0 =C2=A0set -x
> +
> + =C2=A0 =C2=A0rm -rf ${deb_img_dir} ${deb_dbg_dir}
> + =C2=A0 =C2=A0rm -rf ${deb_kern_hdrdir} ${deb_libc_hdr_dir}

I suppose we rather (or also?) want "make clean" here for the= build
artifacts. Just make sure to save/restore the debian folder across that
step.

> +
> + =C2=A0 =C2=A0# Stop tracing
> + =C2=A0 =C2=A0set +x
> +}
> +
> +main clean ${*}
> diff --git a/meta/recipes-kernel/linux/files/debian/isar/comm= on.tmpl b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl
> new file mode 100644
> index 0000000..b392b46
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl
> @@ -0,0 +1,60 @@
> +#!/bin/sh
> +# Copyright (c) Mentor Graphics, a Siemens business, 2019
> +# SPDX-License-Identifier: MIT
> +
> +# Isar settings
> +ARCH=3D${KERNEL_ARCH}
> +KERNEL_PKG_IMAGE=3Dlinux-image-${KERNEL_NAME_PROVIDED}
> +KERNEL_PKG_KERN_HEADERS=3Dlinux-headers-${KERNEL_NAME_P= ROVIDED}
> +KERNEL_PKG_LIBC_HEADERS=3Dlinux-libc-dev
> +
> +# Constants
> +KCONF=3D.config
> +
> +# Target directories
> +deb_top_dir=3D${S}/debian
> +deb_img_dir=3D${deb_top_dir}/${KERNEL_PKG_IMAGE}
> +deb_dbg_dir=3D${deb_img_dir}-dbg
> +deb_dtb_dir=3D${deb_img_dir}/${KERNEL_DTB_DIR}
> +deb_kern_hdr_dir=3D${deb_top_dir}/${KERNEL_PKG_KERN_HEA= DERS}
> +deb_libc_hdr_dir=3D${deb_top_dir}/${KERNEL_PKG_LIBC_HEA= DERS}
> +
> +main() {
> + =C2=A0 =C2=A0target=3D${1}
> +
> + =C2=A0 =C2=A0if [ ! -f ${S}/debian/isar/${target} ]; then
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0echo "error: ${target} is not a = supported build target!" >&2
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0return 1
> + =C2=A0 =C2=A0fi
> +
> + =C2=A0 =C2=A0# check for scripts to be sourced
> + =C2=A0 =C2=A0for f in ${S}/debian/isar/defaults.d/${target}= /*; do
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0[ -f ${f} ] || continue
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0. ${f} || return ${?}
> + =C2=A0 =C2=A0done
> +
> + =C2=A0 =C2=A0# variables to be exported
> + =C2=A0 =C2=A0export ARCH
> +
> + =C2=A0 =C2=A0# are we cross-compiling?
> + =C2=A0 =C2=A0BUILD_ARCH=3D$(dpkg-architecture -qDEB_BUILD_A= RCH)
> + =C2=A0 =C2=A0if [ "${BUILD_ARCH}" =3D "${DISTRO_A= RCH}" ]; then
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0# no, make sure CROSS_COMPILE isn'= ;t set
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0unset CROSS_COMPILE
> + =C2=A0 =C2=A0fi
> +
> + =C2=A0 =C2=A0# check for pre-target scripts
> + =C2=A0 =C2=A0for f in ${S}/debian/isar/pre.d/${target}/*; d= o
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0[ -f ${f} ] || continue
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0sh ${f} || return ${?}
> + =C2=A0 =C2=A0done
> +
> + =C2=A0 =C2=A0# call the actual target script
> + =C2=A0 =C2=A0do_${target} || return ${?}
> +
> + =C2=A0 =C2=A0# check for post-target scripts
> + =C2=A0 =C2=A0for f in ${S}/debian/isar/post.d/${target}/*; = do
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0[ -f ${f} ] || continue
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0sh ${f} || return ${?}
> + =C2=A0 =C2=A0done
> +}
> diff --git a/meta/recipes-kernel/linux/files/debian/isar/inst= all.tmpl b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl
> new file mode 100644
> index 0000000..2055669
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/files/debian/isar/install.tmp= l
> @@ -0,0 +1,197 @@
> +#!/bin/sh
> +# Copyright (c) Mentor Graphics, a Siemens business, 2019
> +# SPDX-License-Identifier: MIT
> +
> +# Load common stuff
> +. ${S}/debian/isar/common || exit ${?}
> +
> +do_install() {
> +
> + =C2=A0 =C2=A0# check if our kernel was configured
> + =C2=A0 =C2=A0if [ ! -f "${O}/.config" ]; then
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0echo "error: kernel not configur= ed!" >&2
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0return 1
> + =C2=A0 =C2=A0fi
> +
> + =C2=A0 =C2=A0# load its configuration
> + =C2=A0 =C2=A0. ${O}/.config
> +
> + =C2=A0 =C2=A0kimage=3D"$(${MAKE} O=3D${O} -s --no-print-dir= ectory image_name)"
> + =C2=A0 =C2=A0case "${ARCH}" in
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0mips|powerpc) kimage_path=3D"boo= t/vmlinux-${PV}" =C2=A0 =C2=A0;;
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0um= ) kimage_path=3D"usr/bin/vmlinux-${PV}" ;;
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *= ) kimage_path=3D"boot/vmlinuz-${PV}" =C2=A0 =C2=A0;;
> + =C2=A0 =C2=A0esac
> +
> + =C2=A0 =C2=A0print_settings
> +
> + =C2=A0 =C2=A0# Stop on error
> + =C2=A0 =C2=A0set -e
> +
> + =C2=A0 =C2=A0# Trace what we do here
> + =C2=A0 =C2=A0set -x
> +
> + =C2=A0 =C2=A0install_image
> + =C2=A0 =C2=A0install_hooks
> + =C2=A0 =C2=A0install_dtbs
> + =C2=A0 =C2=A0install_kmods
> + =C2=A0 =C2=A0install_headers
> +
> + =C2=A0 =C2=A0# Stop tracing
> + =C2=A0 =C2=A0set +x
> +}
> +
> +print_settings() {
> + =C2=A0 =C2=A0cat <<EOF
> +Install settings:
> +-----------------
> +deb_dtb_dir=3D${deb_dtb_dir}
> +deb_hdr_dir=3D${deb_hdr_dir}
> +kimage=3D${kimage}
> +kimage_path=3D${kimage_path}
> +
> +EOF
> +}
> +
> +install_image() {
> + =C2=A0 =C2=A0install -m 755 -d ${deb_img_dir}/$(dirname ${kimage= _path})
> + =C2=A0 =C2=A0cp ${O}/${kimage} ${deb_img_dir}/${kimage_path}
> + =C2=A0 =C2=A0install_image_debug
> +}
> +
> +install_image_debug() {
> + =C2=A0 =C2=A0# Different tools want the image in different locat= ions
> + =C2=A0 =C2=A0# perf
> + =C2=A0 =C2=A0mkdir -p ${deb_dbg_dir}/usr/lib/debug/lib/modu= les/${PV}/
> + =C2=A0 =C2=A0cp vmlinux ${deb_dbg_dir}/usr/lib/debug/lib/mo= dules/${PV}/
> + =C2=A0 =C2=A0# systemtap
> + =C2=A0 =C2=A0mkdir -p ${deb_dbg_dir}/usr/lib/debug/boot/
> + =C2=A0 =C2=A0ln -s ../lib/modules/$version/vmlinux ${deb_db= g_dir}/usr/lib/debug/boot/vmlinux-${PV}
> + =C2=A0 =C2=A0# kdump-tools
> + =C2=A0 =C2=A0ln -s lib/modules/${PV}/vmlinux ${deb_dbg_dir}/usr/= lib/debug/vmlinux-${PV}
> +}
> +
> +install_hooks() {
> + =C2=A0 =C2=A0install -m 755 -d ${deb_img_dir}/etc/kernel/in= stall.d
> + =C2=A0 =C2=A0install -m 755 -d ${deb_img_dir}/etc/kernel/po= stinst.d
> + =C2=A0 =C2=A0install -m 755 -d ${deb_img_dir}/etc/kernel/po= strm.d
> + =C2=A0 =C2=A0install -m 755 -d ${deb_img_dir}/etc/kernel/pr= erm.d
> +}
> +
> +install_dtbs() {
> + =C2=A0 =C2=A0[ -n "${CONFIG_OF}" ] || return 0
> + =C2=A0 =C2=A0${MAKE} O=3D${O} INSTALL_DTBS_PATH=3D${deb_dtb_dir} dtbs_install
> +}
> +
> +install_kmods() {
> + =C2=A0 =C2=A0[ -n "${CONFIG_MODULES}" ] || return 0
> + =C2=A0 =C2=A0${MAKE} O=3D${O} INSTALL_MOD_PATH=3D${deb_img_= dir} modules_install
> + =C2=A0 =C2=A0touch ${deb_img_dir}/lib/modules/${PV}/.fresh-= install
> + =C2=A0 =C2=A0rm -fv ${deb_img_dir}/lib/modules/${PV}/build
> + =C2=A0 =C2=A0rm -fv ${deb_img_dir}/lib/modules/${PV}/source
> + =C2=A0 =C2=A0install_kmods_debug
> +}
> +
> +kmods_sign() {
> + =C2=A0 =C2=A0[ -n "${CONFIG_MODULE_SIG_ALL}" ] || retu= rn 0
> + =C2=A0 =C2=A0${MAKE} O=3D${O} INSTALL_MOD_PATH=3D${deb_img_= dir} modules_sign
> +}
> +
> +install_kmods_debug() {
> + =C2=A0 =C2=A0[ -n "${CONFIG_DEBUG_INFO}" ] || return 0
> +
> + =C2=A0 =C2=A0kmod_inst_dir=3D${deb_img_dir}/lib/modules
> + =C2=A0 =C2=A0kmod_debug_dir=3D${deb_dbg_dir}/usr/lib/debug
> +
> + =C2=A0 =C2=A0# copy kernels modules to usr/lib/debug
> + =C2=A0 =C2=A0mkdir -p ${kmod_debug_dir}
> + =C2=A0 =C2=A0tar -C ${kmod_inst_dir}/ -cO --exclude=3D'modul= es.*' . | tar -C ${kmod_debug_dir}/ -xf -
> + =C2=A0 =C2=A0# strip everything but debug sections for modules i= n usr/lib/debug
> + =C2=A0 =C2=A0find ${kmod_debug_dir} -name *.ko -exec ${CROSS_COM= PILE}objcopy --only-keep-debug {} \;
> + =C2=A0 =C2=A0# and strip debug sections from modules in lib/modu= les
> + =C2=A0 =C2=A0find ${kmod_inst_dir} -name *.ko -exec ${CROSS_COMP= ILE}objcopy --strip-debug {} \;
> +
> + =C2=A0 =C2=A0# re-sign stripped kernel modules
> + =C2=A0 =C2=A0kmods_sign
> +}
> +
> +headers_check() {
> + =C2=A0 =C2=A0${MAKE} O=3D${O} headers_check
> +}
> +
> +libc_headers() {
> + =C2=A0 =C2=A0mkdir -p ${deb_libc_hdr_dir}
> + =C2=A0 =C2=A0${MAKE} O=3D${O} headers_install INSTALL_HDR_PATH= =3D${deb_libc_hdr_dir}/usr
> + =C2=A0 =C2=A0host_arch=3D$(dpkg-architecture -a${DISTRO_ARCH} -q= DEB_HOST_MULTIARCH)
> + =C2=A0 =C2=A0mkdir ${deb_libc_hdr_dir}/usr/include/${host_a= rch}
> + =C2=A0 =C2=A0mv ${deb_libc_hdr_dir}/usr/include/asm ${deb_l= ibc_hdr_dir}/usr/include/${host_arch}/
> +}
> +
> +# the kernel does not seem to provide a way to cross-compile its = tools, we however
> +# have qemu-user-static binaries in our buildchroot. Create a new= build tree for the
> +# scripts and override HOSTCC to force a cross-compile
> +kernel_tools_build() {
> + =C2=A0 =C2=A0odir=3D"${S}/build-scripts"
> + =C2=A0 =C2=A0mflags=3D"HOSTCC=3D${CROSS_COMPILE}gcc O= =3D${odir} NOSTDINC_FLAGS=3D"
> + =C2=A0 =C2=A0rm -rf ${odir} && mkdir -p ${odir} &&am= p; cp ${S}/${KERNEL_BUILD_DIR}/.config ${odir}
> + =C2=A0 =C2=A0(unset LD_PRELOAD; cd ${odir} && make -C ${= S} ${mflags} olddefconfig scripts)
> + =C2=A0 =C2=A0(cd ${odir}; find scripts -type f -executable -exec= file {} \;|grep ELF|cut -d: -f1) >${src_hdr_files}
> + =C2=A0 =C2=A0tar -C ${odir} -cf - -T - <${src_hdr_files} | ta= r -C ${destdir} -xf -
> +}
> +
> +kernel_tools() {
> + =C2=A0 =C2=A0# remove object files
> + =C2=A0 =C2=A0find ${destdir}/scripts -type f -name '*.o'= |xargs rm -f
> +
> + =C2=A0 =C2=A0# we're all done if we aren't cross-compili= ng
> + =C2=A0 =C2=A0[ -n "${CROSS_COMPILE}" ] || return 0
> +
> + =C2=A0 =C2=A0# remove ELF executables from the linux-headers pac= kage
> + =C2=A0 =C2=A0find ${destdir}/scripts -type f -exec file {} \;|gr= ep ELF|cut -d: -f1|xargs rm -fv
> +
> + =C2=A0 =C2=A0# cross-compile kernel tools to be shipped with lin= ux-headers
> + =C2=A0 =C2=A0kernel_tools_build
> +}
> +
> +kernel_headers() {
> + =C2=A0 =C2=A0destdir=3D${deb_kern_hdr_dir}/${KERNEL_HEADERS= _DIR}
> + =C2=A0 =C2=A0src_hdr_files=3D$(mktemp)
> + =C2=A0 =C2=A0obj_hdr_files=3D$(mktemp)
> +
> + =C2=A0 =C2=A0mkdir -p ${destdir}
> + =C2=A0 =C2=A0mkdir -p ${deb_kern_hdr_dir}/lib/modules/${PV}
> +
> + =C2=A0 =C2=A0(cd ${S}; find . -name 'Makefile*' -o -name= 'Kconfig*' -o -name '*.pl') >>${src_hdr_files}
> + =C2=A0 =C2=A0(cd ${S}; find arch/*/include include scripts -type= f -o -type l) >>${src_hdr_files}
> + =C2=A0 =C2=A0(cd ${S}; find arch/${ARCH} -name module.lds -o -na= me Kbuild.platforms -o -name Platform) >>${src_hdr_files}
> + =C2=A0 =C2=A0(cd ${S}; find $(find arch/${ARCH} -name include -o= -name scripts -type d) -type f) >>${src_hdr_files}
> +
> + =C2=A0 =C2=A0(cd ${O}; find arch/${ARCH}/include Module.symvers = include scripts -type f) >>${obj_hdr_files}
> + =C2=A0 =C2=A0if [ -n "${CONFIG_STACK_VALIDATION}" ]; t= hen
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0(cd ${O}; find tools/objtool -type f = -executable) >>${obj_hdr_files}
> + =C2=A0 =C2=A0fi
> + =C2=A0 =C2=A0if [ -n "${CONFIG_GCC_PLUGINS}" ]; then
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0(cd ${O}; find scripts/gcc-plugins -n= ame *.so -o -name gcc-common.h) >>${obj_hdr_files}
> + =C2=A0 =C2=A0fi
> +
> + =C2=A0 =C2=A0# deploy files that were matched above
> + =C2=A0 =C2=A0tar -C ${S} -cf - -T - <${src_hdr_files} | tar -= C ${destdir} -xf -
> + =C2=A0 =C2=A0tar -C ${O} -cf - -T - <${obj_hdr_files} | tar -= C ${destdir} -xf -
> +
> + =C2=A0 =C2=A0# add the kernel config
> + =C2=A0 =C2=A0cp ${O}/${KCONF} ${destdir}/.config
> +
> + =C2=A0 =C2=A0# handle kernel development tools
> + =C2=A0 =C2=A0kernel_tools
> +
> + =C2=A0 =C2=A0# create symlinks
> + =C2=A0 =C2=A0ln -sf /${KERNEL_HEADERS_DIR} ${deb_kern_hdr_dir}/l= ib/modules/${PV}/build
> +}
> +
> +install_headers() {
> + =C2=A0 =C2=A0headers_check
> + =C2=A0 =C2=A0libc_headers
> + =C2=A0 =C2=A0kernel_headers
> +}
> +
> +main install ${*}
> diff --git a/meta/recipes-kernel/linux/files/debian/linux-ima= ge.postinst.tmpl b/meta/recipes-kernel/linux/files/debian/linux-i= mage.postinst.tmpl
> new file mode 100644
> index 0000000..fd89121
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/files/debian/linux-image.postinst.tmpl
> @@ -0,0 +1,22 @@
> +#!/bin/sh
> +
> +set -e
> +set -x
> +
> +if [ -f /lib/modules/${PV}/.fresh-install ]; then
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0change=3Dinstall
> +else
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0change=3Dupgrade
> +fi
> +
> +linux-update-symlinks $change ${PV} /boot/${KERNEL_FILE}-${PV}
> +rm -f /lib/modules/${PV}/.fresh-install
> +
> +# Pass maintainer script parameters to hook scripts
> +export DEB_MAINT_PARAMS=3D"$*"
> +
> +# Tell initramfs builder whether it's wanted
> +export INITRD=3DYes

I've noticed while hacking my version that this should follow
CONFIG_BLK_DEV_INITRD.

> +
> +test -d /etc/kernel/postinst.d && run-parts --arg=3D"= ;${PV}" --arg=3D"/boot/${KERNEL_FILE}-${PV}" /etc/kerne= l/postinst.d
> +exit 0
> diff --git a/meta/recipes-kernel/linux/files/debian/linux-ima= ge.postrm.tmpl b/meta/recipes-kernel/linux/files/debian/linux-ima= ge.postrm.tmpl
> new file mode 100644
> index 0000000..9d88218
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/files/debian/linux-image.postrm.tmpl
> @@ -0,0 +1,18 @@
> +#!/bin/sh
> + =C2=A0
> +set -e
> +
> +rm -f /lib/modules/${PV}/.fresh-install
> +
> +if [ "$1" !=3D upgrade ] && command -v linux-up= date-symlinks >/dev/null; then
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0linux-update-syml= inks remove ${PV} /boot/${KERNEL_FILE}-${PV}
> +fi
> +
> +# Pass maintainer script parameters to hook scripts
> +export DEB_MAINT_PARAMS=3D"$*"
> +
> +# Tell initramfs builder whether it's wanted
> +export INITRD=3DYes
> +
> +test -d /etc/kernel/postrm.d && run-parts --arg=3D"$= {PV}" --arg=3D"/boot/${KERNEL_FILE}-${PV}" /etc/kernel/= postrm.d
> +exit 0
> diff --git a/meta/recipes-kernel/linux/files/debian/rules.tmp= l b/meta/recipes-kernel/linux/files/debian/rules.tmpl

There is quite some duplication between postinst and postrm already.
Moreover, I think you are missing preinst and prerm. I think all four
should probably be generated from one template.

Ok I have checked upstream scripts and= it seems that they all differ

<= /div>
I would recommend we just copy over their scripts but use our tem= plating system instead of theirs
(use ${var} instead of @var@)
=C2=A0

> new file mode 100755
> index 0000000..93c8a5b
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/files/debian/rules.tmpl
> @@ -0,0 +1,39 @@
> +#!/usr/bin/make -f
> +
> +export CROSS_COMPILE=3D$(DEB_HOST_GNU_TYPE)-
> +
> +O:=3D$(CURDIR)/${KERNEL_BUILD_DIR}
> +S:=3D$(CURDIR)
> +deb_top_dir:=3D$(S)/debian
> +
> +DH_VERBOSE=3D1
> +
> +# Dynamic variables to be passed to Isar build scripts
> +isar_env=3D$(strip \
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0export CROSS_COMP= ILE=3D'$(CROSS_COMPILE)' && \
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0export MAKE=3D= 9;$(MAKE)' && \
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0export O=3D'$= {O}' \
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0export S=3D'$= {S}' \
> +)
> +
> +%:
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0dh $(@)
> +
> +.PHONY: override_dh_auto_clean
> +override_dh_auto_clean:
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0$(isar_env) &= & sh $(deb_top_dir)/isar/clean
> +
> +.PHONY: override_dh_auto_build
> +override_dh_auto_build:
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0$(isar_env) &= & sh $(deb_top_dir)/isar/build
> +
> +override_dh_auto_install:
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0$(isar_env) &= & sh $(deb_top_dir)/isar/install
> +
> +.PHONY: override_dh_auto_test
> +override_dh_auto_test:
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0true
> +
> +PHONY: override_dh_strip
> +override_dh_strip:
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0dh_strip -Xvmlinu= x --no-automatic-dbgsym
> diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/met= a/recipes-kernel/linux/linux-custom.inc
> index ca91f64..36086be 100644
> --- a/meta/recipes-kernel/linux/linux-custom.inc
> +++ b/meta/recipes-kernel/linux/linux-custom.inc
> @@ -2,22 +2,104 @@
> =C2=A0#
> =C2=A0# This software is a part of ISAR.
> =C2=A0# Copyright (c) Siemens AG, 2018
> +# Copyright (c) Mentor Graphics, a Siemens business, 2019
> =C2=A0#
> =C2=A0# SPDX-License-Identifier: MIT
> =C2=A0
> -FILESEXTRAPATHS_prepend :=3D "${FILE_DIRNAME}/files:"
> +# Settings that would typically be done from the custom kernel re= cipe
> +# ----------------------------------------------------------= ---------
> =C2=A0
> =C2=A0DESCRIPTION ?=3D "Custom kernel"
> +MAINTAINER ?=3D "isar-users <isar-...@googlegroups.com>= "
> +
> +KBUILD_DEPENDS ?=3D "build-essential:native, \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 l= ibelf-dev:native, \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 l= ibncurses-dev:native, \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 l= ibssl-dev:native, \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 b= c, \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 b= ison, \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 c= pio, \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f= lex, \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 g= it, \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 k= mod, \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 l= ibssl-dev,"
> +
> +KERNEL_DEBIAN_DEPENDS ?=3D "initramfs-tools | linux-initramf= s-tool, \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0kmod, \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0linux-base (>=3D 4.3~),"
> +
> +KERNEL_HEADERS_DEBIAN_DEPENDS ?=3D "libc6, \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0libssl1.1,"
> +
> +KERNEL_LIBC_DEV_DEPLOY ?=3D "0"
> +
> +# Settings that may be changed on a per distro, machine or layer = basis
> +# ----------------------------------------------------------= ----------
> +
> +KERNEL_DTB_DIR ?=3D "usr/lib/linux-${KERNEL_NAME_PROVID= ED}-${PV}"
> +KERNEL_HEADERS_DIR ?=3D "usr/src/linux-headers-${PV}"
> =C2=A0
> -KERNEL_NAME_PROVIDED ?=3D "${@ d.getVar('PN', True).= partition('linux-')[2]}"
> =C2=A0KERNEL_DEFCONFIG ?=3D ""
> =C2=A0
> +# Add our template meta-data to the sources
> +FILESEXTRAPATHS_prepend :=3D "${FILE_DIRNAME}/files:"
> +SRC_URI +=3D "file://debian"
> +
> +# Variables and files that make our templates
> +# -------------------------------------------
> +
> +TEMPLATE_FILES +=3D " =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0\
> + =C2=A0 =C2=A0debian/control.tmpl =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0\
> + =C2=A0 =C2=A0debian/isar/build.tmpl =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 \
> + =C2=A0 =C2=A0debian/isar/clean.tmpl =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 \
> + =C2=A0 =C2=A0debian/isar/common.tmpl =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0\
> + =C2=A0 =C2=A0debian/isar/install.tmpl =C2=A0 =C2=A0 =C2=A0 =C2= =A0 \
> + =C2=A0 =C2=A0debian/linux-image.postinst.tmpl \
> + =C2=A0 =C2=A0debian/linux-image.postrm.tmpl =C2=A0 \
> + =C2=A0 =C2=A0debian/rules.tmpl =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0\
> +"
> +
> +TEMPLATE_VARS +=3D " =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0\
> + =C2=A0 =C2=A0KBUILD_DEPENDS =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0\
> + =C2=A0 =C2=A0KERNEL_ARCH =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 \
> + =C2=A0 =C2=A0KERNEL_DEBIAN_DEPENDS =C2=A0 =C2=A0 =C2=A0 =C2=A0 \
> + =C2=A0 =C2=A0KERNEL_BUILD_DIR =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0\
> + =C2=A0 =C2=A0KERNEL_DTB_DIR =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0\
> + =C2=A0 =C2=A0KERNEL_FILE =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 \
> + =C2=A0 =C2=A0KERNEL_HEADERS_DEBIAN_DEPENDS \
> + =C2=A0 =C2=A0KERNEL_HEADERS_DIR =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0\
> + =C2=A0 =C2=A0KERNEL_NAME_PROVIDED =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0\
> +"
> +
> +inherit dpkg
> +inherit template
> +
> +# Derive name of the kernel packages from the name of this recipe
> +KERNEL_NAME_PROVIDED ?=3D "${@ d.getVar('PN', True).= partition('linux-')[2]}"
> +
> +# Make bitbake know we will be producing linux-image and linux-he= aders packages
> =C2=A0python() {
> =C2=A0 =C2=A0 =C2=A0kernel_name =3D d.getVar("KERNEL_NAME_PROVIDED", True)
> =C2=A0 =C2=A0 =C2=A0d.setVar('PROVIDES', 'linux-image-= ' + kernel_name + ' ' + \
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 'linux-headers-' + kernel_name)
> =C2=A0}
> =C2=A0
> +def get_kernel_arch(d):
> + =C2=A0 =C2=A0distro_arch =3D d.getVar("DISTRO_ARCH")
> + =C2=A0 =C2=A0if distro_arch =3D=3D "amd64":
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0kernel_arch =3D "x86"
> + =C2=A0 =C2=A0elif distro_arch =3D=3D "arm64":
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0kernel_arch =3D "arm64"
> + =C2=A0 =C2=A0elif distro_arch =3D=3D "armhf":
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0kernel_arch =3D "arm"
> + =C2=A0 =C2=A0elif distro_arch =3D=3D "mipsel":
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0kernel_arch =3D "mips"
> + =C2=A0 =C2=A0else:
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0kernel_arch =3D ""
> + =C2=A0 =C2=A0return kernel_arch
> +
> +KERNEL_ARCH ??=3D "${@get_kernel_arch(d)}"
> +
> =C2=A0def config_fragments(d):
> =C2=A0 =C2=A0 =C2=A0fragments =3D []
> =C2=A0 =C2=A0 =C2=A0sources =3D d.getVar("SRC_URI").spli= t()
> @@ -31,57 +113,35 @@ def config_fragments(d):
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fragments.append(l= ocal)
> =C2=A0 =C2=A0 =C2=A0return fragments
> =C2=A0
> -inherit dpkg-base
> -
> -SRC_URI +=3D "file://build-kernel.sh"
> +do_prepare_build_prepend() {
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0# copy meta-data = over to source tree
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0rm -rf ${S}/debia= n
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0cp -r ${WORKDIR}/= debian ${S}/
> =C2=A0
> -KBUILD_DEPENDS ?=3D " \
> - =C2=A0 =C2=A0build-essential:native \
> - =C2=A0 =C2=A0libssl-dev \
> - =C2=A0 =C2=A0libelf-dev \
> - =C2=A0 =C2=A0bc \
> - =C2=A0 =C2=A0git \
> - =C2=A0 =C2=A0kmod \
> - =C2=A0 =C2=A0bison \
> - =C2=A0 =C2=A0flex \
> - =C2=A0 =C2=A0cpio \
> - =C2=A0 =C2=A0libncurses-dev"
> -KERNEL_DEBIAN_DEPENDS ?=3D "initramfs-tools | linux-initramf= s-tool, kmod, linux-base (>=3D 4.3~)"
> -KERNEL_HEADERS_DEBIAN_DEPENDS ?=3D "libc6, libssl1.1"
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0# remove template= s from the source tree
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0find ${S}/debian = -name *.tmpl | xargs rm -f
> =C2=A0
> -KERNEL_LIBC_DEV_DEPLOY ?=3D "0"
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0# rename install/= remove hooks to match user-specified name for our linux-image package
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0mv ${S}/debian/li= nux-image.postinst ${S}/debian/linux-image-${KERNEL_NAME_PROVIDED= }.postinst
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0mv ${S}/debian/li= nux-image.postrm ${S}/debian/linux-image-${KERNEL_NAME_PROVIDED}.postr= m
> =C2=A0
> -do_install_builddeps() {
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0dpkg_do_mounts
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0E=3D"${@ bb.= utils.export_proxies(d)}"
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0sudo -E chroot ${= BUILDCHROOT_DIR} \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0apt-get update \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0-o Dir::Etc::SourceList=3D"sources.list.d/isar-apt.list&quo= t; \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0-o Dir::Etc::SourceParts=3D"-" \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0-o APT::Get::List-Cleanup=3D"0"
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0sudo -E chroot ${= BUILDCHROOT_DIR} \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0apt-get install \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0-y -o Debug::pkgProblemResolver=3Dyes \
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0--no-install-recommends ${KBUILD_DEPENDS}
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0dpkg_undo_mounts
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0# produce a chang= elog for our kernel build
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0deb_add_changelog
> =C2=A0}
> =C2=A0
> -addtask install_builddeps after do_prepare_build before do_dpkg_b= uild
> -# apt and reprepro may not run in parallel, acquire the Isar lock
> -do_install_builddeps[lockfiles] +=3D "${REPO_ISAR_DIR}/= isar.lock"
> -
> -addtask devshell after do_install_builddeps
> +# build directory for our "full" kernel build
> +KERNEL_BUILD_DIR =3D "build-full"
> =C2=A0
> -dpkg_runbuild() {
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0chmod +x ${WORKDI= R}/build-kernel.sh
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0KERNEL_CONFIG_TAR= GET=3D"${KERNEL_DEFCONFIG}"
> +dpkg_configure_kernel() {
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0config_target=3D&= quot;${KERNEL_DEFCONFIG}"
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0rm -rf ${S}/${KER= NEL_BUILD_DIR} && mkdir -p ${S}/${KERNEL_BUILD_DIR}
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if [ -n &quo= t;${KERNEL_DEFCONFIG}" ]; then
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if [ -e "${WORKDIR}/${KERNEL_= DEFCONFIG}" ]; then
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0cp ${WORKDIR}/${KERNEL_DEFCONFIG} ${S}/.config
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0KERNEL_CONFIG_TARGET=3D"olddefconfig"
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0cp ${WORKDIR}/${KERNEL_DEFCONFIG} ${S}/${KERNEL_BUILD_DIR}/.conf= ig
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0config_target=3D"olddefconfig"
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0fi
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0KERNEL_CONFIG_TARGET=3D"defconfi= g"
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0config_target=3D"defconfig"
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0fi
> =C2=A0
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0# copy confi= g fragments over to the kernel tree
> @@ -92,21 +152,23 @@ dpkg_runbuild() {
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0mkdir -p ${S}/debian/fragments
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(cd ${WORKDIR} && cp ${src_frag= s} ${S}/debian/fragments/)
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0fi
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0export KERNEL_FRA= GMENTS=3D"${out_frags}"
> =C2=A0
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0E=3D"${@ bb.= utils.export_proxies(d)}"
> -
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0export PV=3D${PV}
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0export KERNEL_NAM= E=3D${KERNEL_NAME_PROVIDED}
> -
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0export KBUILD_DEP= ENDS=3D"${KBUILD_DEPENDS}"
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0export KERNEL_CON= FIG_TARGET
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0export KERNEL_DEB= IAN_DEPENDS=3D"${KERNEL_DEBIAN_DEPENDS}"
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0export KERNEL_FIL= E=3D"${KERNEL_FILE}"
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0export KERNEL_HEA= DERS_DEBIAN_DEPENDS=3D"${KERNEL_HEADERS_DEBIAN_DEPENDS}"= ;
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0sudo -E chroot --= userspec=3D$(id -u):$(id -g) ${BUILDCHROOT_DIR} sh -c " \
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0export ARCH=3D${KERNEL_ARCH} && = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0cd ${PP}/${PPS} && =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0make O=3D${KERNEL_BUILD_DIR} ${config_targ= et} && =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0./scripts/kconfig/merge_config.sh =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0\
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0-O ${KERNEL_BUILD_DIR}/ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0${KERNEL_BUILD_DIR}/.config =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0${out_frags} =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0"
> +}
> =C2=A0
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0sudo -E chroot --= userspec=3D$( id -u ):$( id -g ) ${BUILDCHROOT_DIR} ${PP}/build-kernel.sh $= {PP}/${PPS} ${DISTRO_ARCH}
> +dpkg_runbuild_prepend() {
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0dpkg_configure_ke= rnel
> +}
> =C2=A0
> +dpkg_runbuild_append() {
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if [ "$= {KERNEL_LIBC_DEV_DEPLOY}" !=3D "1" ]; then
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0rm -f ${WORKDIR}/linux-libc-dev_${= PV}*.deb
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0fi
>=20

Valuable step forward! I still need to check some more details against
my unfinished prototype, but it seems it generally a superset of it.

Jan

--=20
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
------=_Part_1082_119568546.1572984998652-- ------=_Part_1081_711889408.1572984998648--