From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6755821036247187456 X-Received: by 2002:a2e:8804:: with SMTP id x4mr793549ljh.2.1573198901914; Thu, 07 Nov 2019 23:41:41 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6512:15b:: with SMTP id m27ls1554694lfo.1.gmail; Thu, 07 Nov 2019 23:41:41 -0800 (PST) X-Google-Smtp-Source: APXvYqz54cNTtbfFiMx7Uj154nUrGjOccpLUT87w355xSP9EjZ7dOMiILAGRjaGcDuojf3XtN53t X-Received: by 2002:ac2:4c86:: with SMTP id d6mr5532200lfl.106.1573198901163; Thu, 07 Nov 2019 23:41:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573198901; cv=none; d=google.com; s=arc-20160816; b=LlKPtfS2G7GvdSVMe0wDI00GAddNB0MNulztFBhLcRCYnacKis8geIDi09vrLNzAX4 iQFZt1431lFSAL7dbS9DAPlxbZkrmLEcQj0zSqJ9btwCXdvOmorltpl0EwJG4ns6+8DN HyZu0VUfxHET+8q54PKXDOUDj5Re3HQM+Ge81OsFj47rRA+PGBsZ/SbaCw+LJczcdfiK uimzP4poKl+vItEziGdcNMrodFGkN1GQZzRGuo2QAtFk/sVJF+MJNorYRahhN0QcY5H9 nu7+OYTwQabDh5+P34wNr2zUCWsS1QTZUzjGqZINhvX15Tz2b70fE3M2NpuIayPloulp GJmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject; bh=3+av+QLf8VBbhDZaGc5dkMGuX+jb3JKA6bGXXyLhLBs=; b=0qKPCrZy9J1SXe1L+6n0mpRgJ6TC84xPLNCJraZeqPHGu8dAwDQaAXS0smqgHisnWq aq4NvCrF3F0gpLY1OgKvtRiXiYFxPYkah+VMjwC44PlCO2V8ucFIsc2mQq7uxBAP4PqJ RoE3knmwDM6fIbiGVozKvRS1nbkzXRH+3OyfOymuYKuuPLbSBs2Z7ZpVFB9VQ/xuCNNk j0/5bQEbZsYZRAIrAYN94ZdxwKJ+/lyi9ZobnZB5mYW9LlfEcGMFd8zKEvHZk12rs0Kv r+AHRmiVvmPxgXoxg9BrFIKqAnhwTVY6S9/F8k+K1ESDqYbYhaZMliAbZ7L54bU6itTq Q9/Q== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id z18si401799lfh.1.2019.11.07.23.41.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Nov 2019 23:41:41 -0800 (PST) Received-SPF: pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.2 as permitted sender) client-ip=192.35.17.2; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id xA87feo9025800 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 Nov 2019 08:41:40 +0100 Received: from [167.87.14.235] ([167.87.14.235]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id xA87fdlj012598; Fri, 8 Nov 2019 08:41:39 +0100 Subject: Re: [PATCH L-C v3 7/7] linux-custom: rewrite to no longer depend on the kernel's builddeb To: Cedric Hombourger , isar-users@googlegroups.com References: <1573118604-909-1-git-send-email-Cedric_Hombourger@mentor.com> <1573196839-1143-1-git-send-email-Cedric_Hombourger@mentor.com> <1573196839-1143-8-git-send-email-Cedric_Hombourger@mentor.com> <817df519-9d7b-5ec7-5fd6-55f37efee0a9@mentor.com> From: Jan Kiszka Message-ID: Date: Fri, 8 Nov 2019 08:41:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <817df519-9d7b-5ec7-5fd6-55f37efee0a9@mentor.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-TUID: uY/FpMpbdEuh On 08.11.19 08:36, Cedric Hombourger wrote: > > On 11/8/19 8:19 AM, Jan Kiszka wrote: >> On 08.11.19 08:07, 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                          |  80 +++++++ >>>   .../linux/files/build-kernel.sh               | 128 ----------- >>>   meta/recipes-kernel/linux/files/debian/compat |   1 + >>>   .../linux/files/debian/control.tmpl           |  37 ++++ >>>   .../linux/files/debian/isar/build.tmpl        |  45 ++++ >>>   .../linux/files/debian/isar/clean.tmpl        |  21 ++ >>>   .../linux/files/debian/isar/common.tmpl       |  50 +++++ >>>   .../linux/files/debian/isar/install.tmpl      | 206 ++++++++++++++++++ >>>   .../files/debian/linux-image.postinst.tmpl    |  29 +++ >>>   .../files/debian/linux-image.postrm.tmpl      |  35 +++ >>>   .../files/debian/linux-image.preinst.tmpl     |  25 +++ >>>   .../linux/files/debian/linux-image.prerm.tmpl |  21 ++ >>>   .../linux/files/debian/rules.tmpl             |  39 ++++ >>>   meta/recipes-kernel/linux/linux-custom.inc    | 180 ++++++++++----- >>>   14 files changed, 712 insertions(+), 185 deletions(-) >>>   create mode 100644 doc/custom_kernel.md >>>   delete mode 100644 meta/recipes-kernel/linux/files/build-kernel.sh >>>   create mode 100644 meta/recipes-kernel/linux/files/debian/compat >>>   create mode 100644 meta/recipes-kernel/linux/files/debian/control.tmpl >>>   create mode 100644 >>> meta/recipes-kernel/linux/files/debian/isar/build.tmpl >>>   create mode 100644 >>> meta/recipes-kernel/linux/files/debian/isar/clean.tmpl >>>   create mode 100644 >>> meta/recipes-kernel/linux/files/debian/isar/common.tmpl >>>   create mode 100644 >>> meta/recipes-kernel/linux/files/debian/isar/install.tmpl >>>   create mode 100644 >>> meta/recipes-kernel/linux/files/debian/linux-image.postinst.tmpl >>>   create mode 100644 >>> meta/recipes-kernel/linux/files/debian/linux-image.postrm.tmpl >>>   create mode 100644 >>> meta/recipes-kernel/linux/files/debian/linux-image.preinst.tmpl >>>   create mode 100644 >>> meta/recipes-kernel/linux/files/debian/linux-image.prerm.tmpl >>>   create mode 100755 meta/recipes-kernel/linux/files/debian/rules.tmpl >>> >>> diff --git a/doc/custom_kernel.md b/doc/custom_kernel.md >>> new file mode 100644 >>> index 0000000..31319d4 >>> --- /dev/null >>> +++ b/doc/custom_kernel.md >>> @@ -0,0 +1,80 @@ >>> +# Custom kernel recipe for Isar >>> + >>> +## Contents >>> + >>> + - [Summary](#summary) >>> + - [Features](#features) >>> + - [Future](#future) >>> + - [Examples](#examples) >>> + >>> +## Summary >>> + >>> +Isar provides a recipe to build custom kernels for Debian-based >>> distributions. >>> +It uses templates to generate the debian meta-data (such as >>> debian/control) and >>> +Debian's [BuildProfiles](https://wiki.debian.org/BuildProfileSpec) >>> to handle >>> +some of the distro specific variations. It should be noted that Isar >>> has moved >>> +away from using the kernel's builddeb script since it would not >>> generate all >>> +the packages we need (and in particular perf). >>> + >>> +## Features >>> + >>> +The linux-custom recipe provides support for: >>> + >>> + 1. Sources to the custom Linux kernel may be specified via `SRC_URI` >>> + >>> + 2. Configure the kernel via an in-tree or an external `defconfig` via >>> +    `KERNEL_DEFCONFIG` >>> + >>> + 3. Integrate kernel configuration tweaks via configuration >>> fragments (`.cfg` >>> +    files) >>> + >>> + 4. Patches to the linux kernel may be specified via `SRC_URI` >>> + >>> + 5. Ensure that the Isar recipe `PV` matches the kernel release >>> identifier >>> +    (`KERNEL_RELEASE`) >>> + >>> + 6. Produce a `linux-image` package that ships the kernel image and >>> modules >>> + >>> + 7. Allow the name of the kernel image to be changed via >>> `KERNEL_FILE` (defaults >>> +    to `vmlinuz`) >>> + >>> + 8. Produce a `linux-headers` package which includes kernel headers >>> and kbuild >>> +    scripts/tools >>> + >>> + 9. The `linux-headers` package shall support native and cross >>> compiles of >>> +    out-of-tree kernel modules >>> + >>> + 10. Produce a `linux-libc-dev` package to support user-land builds >>> + >>> + 11. Only build/ship the `linux-libc-dev` package if instructed to >>> +     (`KERNEL_LIBC_DEV_DEPLOY` equals to `"1"`) >>> + >>> + 12. Support both native and cross compiles (`ISAR_CROSS_COMPILE`) >>> + >>> + 13. Support for the following kernel architectures: >>> + >>> +   * arm >>> +   * arm64 >>> +   * mips >>> +   * x86 >>> + >>> + 14. Support `devshell` (kernel configuration shall be applied) >>> + >>> +## Future >>> + >>> +In the future, the recipe may be extended to: >>> + >>> + 1. Package perf >>> + >>> + 2. Support inclusion/build of dts files listed in `SRC_URI` >>> + >>> + 3. Be compatible with Ubuntu >>> + >>> +## Examples >>> + >>> +The linux-custom recipe is currently used by the linux-mainline >>> package and is >>> +used mainline recipe may be used for some basic testing. This recipe >>> is being >>> +used by the following machines: >>> + >>> + * de0-nano-soc >>> + * qemumipsel >>> diff --git a/meta/recipes-kernel/linux/files/build-kernel.sh >>> b/meta/recipes-kernel/linux/files/build-kernel.sh >>> deleted file mode 100644 >>> index 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..d55096b >>> --- /dev/null >>> +++ b/meta/recipes-kernel/linux/files/debian/control.tmpl >>> @@ -0,0 +1,37 @@ >>> +Source: linux-${KERNEL_NAME_PROVIDED} >>> +Section: kernel >>> +Priority: optional >>> +Maintainer: ${MAINTAINER} >>> +Build-Depends: bc, kmod, cpio, ${KBUILD_DEPENDS} >>> +Homepage: http://www.kernel.org/ >>> + >>> +Package: linux-image-${KERNEL_NAME_PROVIDED} >>> +Architecture: any >>> +Depends: ${KERNEL_DEBIAN_DEPENDS} >>> +Description: ${KERNEL_NAME_PROVIDED} Linux kernel, version ${PV} >>> + 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 >>> +Build-Profiles: >>> +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/isar/build.tmpl >>> b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl >>> new file mode 100644 >>> index 0000000..4ea18d5 >>> --- /dev/null >>> +++ b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl >>> @@ -0,0 +1,45 @@ >>> +#!/bin/bash >>> +# Copyright (c) Mentor Graphics, a Siemens business, 2019 >>> +# SPDX-License-Identifier: MIT >>> + >>> +# Load common stuff >>> +. ${S}/debian/isar/common || exit ${?} >>> + >>> +do_build() { >>> + >>> +    # Print a few things that are of particular interest >>> +    print_settings >>> + >>> +    # Process existing kernel configuration to make sure it is complete >>> +    # (use defaults for options that were not specified) >>> +    ${MAKE} O=${KERNEL_BUILD_DIR} olddefconfig prepare || exit ${?} >>> + >>> +    # Check if the recipe's PV makes sense >>> +    KR=$(${MAKE} O=${KERNEL_BUILD_DIR} -s --no-print-directory >>> kernelrelease) >>> +    eval $(grep ^CONFIG_LOCALVERSION= ${KERNEL_BUILD_DIR}/${KCONF} >>> || true) >>> +    if [ "${PV}" != "${KR}" -a "${PV}${CONFIG_LOCALVERSION}" != >>> "${KR}" ]; then >>> +        echo "ERROR: Recipe PV (${PV}) does not seem to match the >>> kernelrelease (${KR})!" 1>&2 >>> +        echo "ERROR: Make sure the kernel version in your PV setting >>> and/or CONFIG_LOCALVERSION are aligned" 1>&2 >>> +        exit 1 >>> +    fi >>> + >>> +    # Trace what we do here >>> +    set -x >>> + >>> +    # Build the Linux kernel >>> +    ${MAKE} O=${KERNEL_BUILD_DIR} -j $(nproc) || exit ${?} >>> + >>> +    # Stop tracing >>> +    set +x >>> +} >>> + >>> +print_settings() { >>> +    cat <>> +# Build settings: >>> +# --------------- >>> +# ARCH=${ARCH} >>> +# CROSS_COMPILE=${CROSS_COMPILE} >>> +EOF >>> +} >>> + >>> +main build ${*} >>> diff --git a/meta/recipes-kernel/linux/files/debian/isar/clean.tmpl >>> b/meta/recipes-kernel/linux/files/debian/isar/clean.tmpl >>> new file mode 100644 >>> index 0000000..f903987 >>> --- /dev/null >>> +++ b/meta/recipes-kernel/linux/files/debian/isar/clean.tmpl >>> @@ -0,0 +1,21 @@ >>> +#!/bin/bash >>> +# Copyright (c) Mentor Graphics, a Siemens business, 2019 >>> +# SPDX-License-Identifier: MIT >>> + >>> +# Load common stuff >>> +. ${S}/debian/isar/common || exit ${?} >>> + >>> +do_clean() { >>> + >>> +    # Trace what we do here >>> +    set -x >>> + >>> +    rm -rf ${deb_img_dir} ${deb_dbg_dir} >>> +    rm -rf ${deb_kern_hdrdir} >>> +    rm -rf ${deb_libc_hdr_dir} >>> + >>> +    # Stop tracing >>> +    set +x >>> +} >>> + >>> +main clean ${*} >>> diff --git a/meta/recipes-kernel/linux/files/debian/isar/common.tmpl >>> b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl >>> new file mode 100644 >>> index 0000000..44f67b3 >>> --- /dev/null >>> +++ b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl >>> @@ -0,0 +1,50 @@ >>> +#!/bin/bash >>> +# Copyright (c) Mentor Graphics, a Siemens business, 2019 >>> +# SPDX-License-Identifier: MIT >>> + >>> +# Isar settings >>> +ARCH=${KERNEL_ARCH} >>> +KERNEL_PKG_IMAGE=linux-image-${KERNEL_NAME_PROVIDED} >>> +KERNEL_PKG_KERN_HEADERS=linux-headers-${KERNEL_NAME_PROVIDED} >>> +KERNEL_PKG_LIBC_HEADERS=linux-libc-dev >>> + >>> +# Constants >>> +KCONF=.config >>> + >>> +# Target directories >>> +deb_top_dir=${S}/debian >>> +deb_img_dir=${deb_top_dir}/${KERNEL_PKG_IMAGE} >>> +deb_dbg_dir=${deb_img_dir}-dbg >>> +deb_dtb_dir=${deb_img_dir}/${KERNEL_DTB_DIR} >>> +deb_kern_hdr_dir=${deb_top_dir}/${KERNEL_PKG_KERN_HEADERS} >>> +deb_libc_hdr_dir=${deb_top_dir}/${KERNEL_PKG_LIBC_HEADERS} >>> + >>> +# Array of packages to be generated >>> +declare -A kern_pkgs >>> + >>> +main() { >>> +    local target=${1} >>> + >>> +    if [ ! -f ${S}/debian/isar/${target} ]; then >>> +        echo "error: ${target} is not a supported build target!" >&2 >>> +        return 1 >>> +    fi >>> + >>> +    # create do_ variables for each package to be generated >>> +    for p in $(unset DEB_HOST_ARCH; dh_listpackages); do >>> +        kern_pkgs["${p}"]="1" >>> +    done >>> + >>> +    # variables to be exported >>> +    export ARCH >>> + >>> +    # are we cross-compiling? >>> +    BUILD_ARCH=$(dpkg-architecture -qDEB_BUILD_ARCH) >>> +    if [ "${BUILD_ARCH}" = "${DISTRO_ARCH}" ]; then >>> +        # no, make sure CROSS_COMPILE isn't set >>> +        unset CROSS_COMPILE >>> +    fi >>> + >>> +    # call the actual target script >>> +    do_${target} || return ${?} >>> +} >>> diff --git a/meta/recipes-kernel/linux/files/debian/isar/install.tmpl >>> b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl >>> new file mode 100644 >>> index 0000000..8ccda68 >>> --- /dev/null >>> +++ b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl >>> @@ -0,0 +1,206 @@ >>> +#!/bin/bash >>> +# Copyright (c) Mentor Graphics, a Siemens business, 2019 >>> +# SPDX-License-Identifier: MIT >>> + >>> +# Load common stuff >>> +. ${S}/debian/isar/common || exit ${?} >>> + >>> +# Stop on error >>> +set -e >>> + >>> +do_install() { >>> + >>> +    # check if our kernel was configured >>> +    if [ ! -f "${O}/.config" ]; then >>> +        echo "error: kernel not configured!" >&2 >>> +        return 1 >>> +    fi >>> + >>> +    # load its configuration >>> +    . ${O}/.config >>> + >>> +    kimage="$(${MAKE} O=${O} -s --no-print-directory image_name)" >>> +    krel="$(${MAKE} O=${O} -s --no-print-directory kernelrelease)" >>> +    case "${ARCH}" in >>> +        mips|powerpc) kimage_path="boot/vmlinux-${krel}"    ;; >>> +                  um) kimage_path="usr/bin/vmlinux-${krel}" ;; >>> +                   *) kimage_path="boot/vmlinuz-${krel}"    ;; >>> +    esac >>> + >>> +    print_settings >>> + >>> +    # Trace what we do here >>> +    set -x >>> + >>> +    install_image >>> +    install_hooks >>> +    install_dtbs >>> +    install_kmods >>> +    install_headers >>> + >>> +    # Stop tracing >>> +    set +x >>> +} >>> + >>> +print_settings() { >>> +    cat <>> +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/${krel}/ >>> +    cp ${O}/vmlinux ${deb_dbg_dir}/usr/lib/debug/lib/modules/${krel}/ >>> +    # systemtap >>> +    mkdir -p ${deb_dbg_dir}/usr/lib/debug/boot/ >>> +    ln -s ../lib/modules/$version/vmlinux >>> ${deb_dbg_dir}/usr/lib/debug/boot/vmlinux-${krel} >>> +    # kdump-tools >>> +    ln -s lib/modules/${krel}/vmlinux >>> ${deb_dbg_dir}/usr/lib/debug/vmlinux-${krel} >>> +} >>> + >>> +install_hooks() { >>> +    install -m 755 -d ${deb_img_dir}/etc/kernel/install.d >>> +    install -m 755 -d ${deb_img_dir}/etc/kernel/postinst.d >>> +    install -m 755 -d ${deb_img_dir}/etc/kernel/postrm.d >>> +    install -m 755 -d ${deb_img_dir}/etc/kernel/prerm.d >>> + >>> +    initrd="No" >>> +    [ -z "${CONFIG_BLK_DEV_INITRD}" ] || initrd="Yes" >>> + >>> +    for script in postinst postrm preinst prerm; do >>> +        sed -i -e "s,INITRD=[A-Za-z0-9]*,INITRD=${initrd},g" >>> ${S}/debian/linux-image*.${script} >>> +        sed -i -e "s,version=.*,version=${krel},g" >>> ${S}/debian/linux-image*.${script} >>> +    done >>> +} >>> + >>> +install_dtbs() { >>> +    [ -n "${CONFIG_OF}" ] || return 0 >>> +    ${MAKE} O=${O} INSTALL_DTBS_PATH=${deb_dtb_dir} dtbs_install >>> +} >>> + >>> +install_kmods() { >>> +    [ -n "${CONFIG_MODULES}" ] || return 0 >>> +    ${MAKE} O=${O} INSTALL_MOD_PATH=${deb_img_dir} modules_install >>> +    touch ${deb_img_dir}/lib/modules/${krel}/.fresh-install >>> +    rm -fv ${deb_img_dir}/lib/modules/${krel}/build >>> +    rm -fv ${deb_img_dir}/lib/modules/${krel}/source >>> +    install_kmods_debug >>> +} >>> + >>> +kmods_sign() { >>> +    [ -n "${CONFIG_MODULE_SIG_ALL}" ] || return 0 >>> +    ${MAKE} O=${O} INSTALL_MOD_PATH=${deb_img_dir} modules_sign >>> +} >>> + >>> +install_kmods_debug() { >>> +    [ -n "${CONFIG_DEBUG_INFO}" ] || return 0 >>> + >>> +    kmod_inst_dir=${deb_img_dir}/lib/modules >>> +    kmod_debug_dir=${deb_dbg_dir}/usr/lib/debug >>> + >>> +    # copy kernels modules to usr/lib/debug >>> +    mkdir -p ${kmod_debug_dir} >>> +    tar -C ${kmod_inst_dir}/ -cO --exclude='modules.*' . | tar -C >>> ${kmod_debug_dir}/ -xf - >>> +    # strip everything but debug sections for modules in usr/lib/debug >>> +    find ${kmod_debug_dir} -name *.ko -exec ${CROSS_COMPILE}objcopy >>> --only-keep-debug {} \; >>> +    # and strip debug sections from modules in lib/modules >>> +    find ${kmod_inst_dir} -name *.ko -exec ${CROSS_COMPILE}objcopy >>> --strip-debug {} \; >>> + >>> +    # re-sign stripped kernel modules >>> +    kmods_sign >>> +} >>> + >>> +headers_check() { >>> +    ${MAKE} O=${O} headers_check >>> +} >>> + >>> +libc_headers() { >>> +    mkdir -p ${deb_libc_hdr_dir} >>> +    ${MAKE} O=${O} headers_install >>> INSTALL_HDR_PATH=${deb_libc_hdr_dir}/usr >>> +    host_arch=$(dpkg-architecture -a${DISTRO_ARCH} >>> -qDEB_HOST_MULTIARCH) >>> +    mkdir ${deb_libc_hdr_dir}/usr/include/${host_arch} >>> +    mv ${deb_libc_hdr_dir}/usr/include/asm >>> ${deb_libc_hdr_dir}/usr/include/${host_arch}/ >>> +} >>> + >>> +# 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/${krel} >>> + >>> +    (cd ${S}; find . -name 'Makefile*' -o -name 'Kconfig*' -o -name >>> '*.pl') >>${src_hdr_files} >>> +    (cd ${S}; find arch/*/include include scripts -type f -o -type >>> l) >>${src_hdr_files} >>> +    (cd ${S}; find arch/${ARCH} -name module.lds -o -name >>> Kbuild.platforms -o -name Platform) >>${src_hdr_files} >>> +    (cd ${S}; find $(find arch/${ARCH} -name include -o -name >>> scripts -type d) -type f) >>${src_hdr_files} >>> + >>> +    (cd ${O}; find arch/${ARCH}/include Module.symvers include >>> scripts -type f) >>${obj_hdr_files} >>> +    if [ -n "${CONFIG_STACK_VALIDATION}" ]; then >>> +        (cd ${O}; find tools/objtool -type f -executable) >>> >>${obj_hdr_files} >>> +    fi >>> +    if [ -n "${CONFIG_GCC_PLUGINS}" ]; then >>> +        (cd ${O}; find scripts/gcc-plugins -name *.so -o -name >>> gcc-common.h) >>${obj_hdr_files} >>> +    fi >>> + >>> +    # deploy files that were matched above >>> +    tar -C ${S} -cf - -T - <${src_hdr_files} | tar -C ${destdir} -xf - >>> +    tar -C ${O} -cf - -T - <${obj_hdr_files} | tar -C ${destdir} -xf - >>> + >>> +    # add the kernel config >>> +    cp ${O}/${KCONF} ${destdir}/.config >>> + >>> +    # handle kernel development tools >>> +    kernel_tools >>> + >>> +    # create symlinks >>> +    ln -sf /${KERNEL_HEADERS_DIR} >>> ${deb_kern_hdr_dir}/lib/modules/${krel}/build >>> +} >>> + >>> +install_headers() { >>> +    headers_check >>> +    [ -z ${kern_pkgs["linux-libc-headers"]} ] || libc_headers >>> +    kernel_headers >>> +} >>> + >>> +main install ${*} >>> diff --git >>> a/meta/recipes-kernel/linux/files/debian/linux-image.postinst.tmpl >>> b/meta/recipes-kernel/linux/files/debian/linux-image.postinst.tmpl >>> new file mode 100644 >>> index 0000000..8e8636a >>> --- /dev/null >>> +++ b/meta/recipes-kernel/linux/files/debian/linux-image.postinst.tmpl >>> @@ -0,0 +1,29 @@ >>> +#!/bin/sh >>> +# based on >>> https://salsa.debian.org/kernel-team/linux/blob/master/debian/templates/image.postinst.in >>> >>> + >>> +# Tell initramfs builder whether it's wanted >>> +export INITRD=Yes >>> + >>> +version=${PV} >>> +image_path=/boot/${KERNEL_FILE}-${version} >>> + >>> +if [ "$1" != configure ]; then >>> +    exit 0 >>> +fi >>> + >>> +depmod $version >>> + >>> +if [ -f /lib/modules/$version/.fresh-install ]; then >>> +    change=install >>> +else >>> +    change=upgrade >>> +fi >>> +linux-update-symlinks $change $version $image_path >>> +rm -f /lib/modules/$version/.fresh-install >>> + >>> +if [ -d /etc/kernel/postinst.d ]; then >>> +    DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error >>> --arg=$version \ >>> +          --arg=$image_path /etc/kernel/postinst.d >>> +fi >>> + >>> +exit 0 >>> diff --git >>> a/meta/recipes-kernel/linux/files/debian/linux-image.postrm.tmpl >>> b/meta/recipes-kernel/linux/files/debian/linux-image.postrm.tmpl >>> new file mode 100644 >>> index 0000000..4d8a7d9 >>> --- /dev/null >>> +++ b/meta/recipes-kernel/linux/files/debian/linux-image.postrm.tmpl >>> @@ -0,0 +1,35 @@ >>> +#!/bin/sh -e >>> +# based on >>> https://salsa.debian.org/kernel-team/linux/blob/master/debian/templates/image.postrm.in >>> >>> + >>> +# Tell initramfs builder whether it's wanted >>> +export INITRD=Yes >>> + >>> +version=${PV} >>> +image_path=/boot/${KERNEL_FILE}-${version} >>> + >>> +rm -f /lib/modules/$version/.fresh-install >>> + >>> +if [ "$1" != upgrade ] && command -v linux-update-symlinks >>> >/dev/null; then >>> +    linux-update-symlinks remove $version $image_path >>> +fi >>> + >>> +if [ -d /etc/kernel/postrm.d ]; then >>> +    DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error >>> --arg=$version \ >>> +          --arg=$image_path /etc/kernel/postrm.d >>> +fi >>> + >>> +if [ "$1" = purge ]; then >>> +    for extra_file in modules.dep modules.isapnpmap modules.pcimap \ >>> +                      modules.usbmap modules.parportmap \ >>> +                      modules.generic_string modules.ieee1394map \ >>> +                      modules.ieee1394map modules.pnpbiosmap \ >>> +                      modules.alias modules.ccwmap modules.inputmap \ >>> +                      modules.symbols modules.ofmap \ >>> +                      modules.seriomap modules.\*.bin \ >>> +              modules.softdep modules.devname; do >>> +    eval rm -f /lib/modules/$version/$extra_file >>> +    done >>> +    rmdir /lib/modules/$version || true >>> +fi >>> + >>> +exit 0 >>> diff --git >>> a/meta/recipes-kernel/linux/files/debian/linux-image.preinst.tmpl >>> b/meta/recipes-kernel/linux/files/debian/linux-image.preinst.tmpl >>> new file mode 100644 >>> index 0000000..7465197 >>> --- /dev/null >>> +++ b/meta/recipes-kernel/linux/files/debian/linux-image.preinst.tmpl >>> @@ -0,0 +1,25 @@ >>> +#!/bin/sh -e >>> +# based on >>> https://salsa.debian.org/kernel-team/linux/blob/master/debian/templates/image.preinst.in >>> >>> + >>> +# Tell initramfs builder whether it's wanted >>> +export INITRD=Yes >>> + >>> +version=${PV} >>> +image_path=/boot/${KERNEL_FILE}-${version} >>> + >>> +if [ "$1" = abort-upgrade ]; then >>> +    exit 0 >>> +fi >>> + >>> +if [ "$1" = install ]; then >>> +    # Create a flag file for postinst >>> +    mkdir -p /lib/modules/$version >>> +    touch /lib/modules/$version/.fresh-install >>> +fi >>> + >>> +if [ -d /etc/kernel/preinst.d ]; then >>> +    DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error >>> --arg=$version \ >>> +          --arg=$image_path /etc/kernel/preinst.d >>> +fi >>> + >>> +exit 0 >>> diff --git >>> a/meta/recipes-kernel/linux/files/debian/linux-image.prerm.tmpl >>> b/meta/recipes-kernel/linux/files/debian/linux-image.prerm.tmpl >>> new file mode 100644 >>> index 0000000..1992b32 >>> --- /dev/null >>> +++ b/meta/recipes-kernel/linux/files/debian/linux-image.prerm.tmpl >>> @@ -0,0 +1,21 @@ >>> +#!/bin/sh -e >>> +# based on >>> https://salsa.debian.org/kernel-team/linux/blob/master/debian/templates/image.prerm.in >>> >>> + >>> +# Tell initramfs builder whether it's wanted >>> +export INITRD=Yes >>> + >>> +version=${PV} >>> +image_path=/boot/${KERNEL_FILE}-${version} >>> + >>> +if [ "$1" != remove ]; then >>> +    exit 0 >>> +fi >>> + >>> +linux-check-removal $version >>> + >>> +if [ -d /etc/kernel/prerm.d ]; then >>> +    DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error >>> --arg=$version \ >>> +          --arg=$image_path /etc/kernel/prerm.d >>> +fi >>> + >>> +exit 0 >>> diff --git a/meta/recipes-kernel/linux/files/debian/rules.tmpl >>> b/meta/recipes-kernel/linux/files/debian/rules.tmpl >>> new file mode 100755 >>> index 0000000..c024768 >>> --- /dev/null >>> +++ b/meta/recipes-kernel/linux/files/debian/rules.tmpl >>> @@ -0,0 +1,39 @@ >>> +#!/usr/bin/make -f >>> + >>> +CROSS_COMPILE:=$(DEB_HOST_GNU_TYPE)- >>> + >>> +O:=$(CURDIR)/${KERNEL_BUILD_DIR} >>> +S:=$(CURDIR) >>> +deb_top_dir:=$(S)/debian >>> + >>> +# Dynamic variables to be passed to Isar build scripts >>> +isar_env=$(strip \ >>> +    export CROSS_COMPILE='$(CROSS_COMPILE)' && \ >>> +    export DEB_BUILD_PROFILES='$(DEB_BUILD_PROFILES)' && \ >>> +    export DEB_HOST_GNU_TYPE='$(DEB_HOST_GNU_TYPE)' && \ >>> +    export MAKE='$(MAKE)' && \ >>> +    export O='${O}' \ >>> +    export S='${S}' \ >>> +) >>> + >>> +%: >>> +    dh $(@) >>> + >>> +.PHONY: override_dh_auto_clean >>> +override_dh_auto_clean: >>> +    $(isar_env) && bash $(deb_top_dir)/isar/clean >>> + >>> +.PHONY: override_dh_auto_build >>> +override_dh_auto_build: >>> +    $(isar_env) && bash $(deb_top_dir)/isar/build >>> + >>> +override_dh_auto_install: >>> +    $(isar_env) && bash $(deb_top_dir)/isar/install >>> + >>> +.PHONY: override_dh_auto_test >>> +override_dh_auto_test: >>> +    true >>> + >>> +PHONY: override_dh_strip >>> +override_dh_strip: >>> +    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..ecf0e66 100644 >>> --- a/meta/recipes-kernel/linux/linux-custom.inc >>> +++ b/meta/recipes-kernel/linux/linux-custom.inc >>> @@ -2,22 +2,107 @@ >>>   # >>>   # 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}" >> >> Here is the bug that breaks U-boot setups here: Must be >> linux-image-${PV} in order to stay compatible with Debian. >> >> Did you compare some content of the new packages against that of the >> original package build? >> > Yes but I had not anticipated this one as being an issue (so thanks for > pointing that out). I have limited hardware available here (mostly > Siemens IPCs or non supported boards such as Xilinx ref boards). will > check if I can get remote access to some of the boards supported by > Isar. I have made the change locally and started a build. I hope I can > check it out on the de0-nano-soc board that we have in meta-isar There are plenty of fully enabled test cases of Isar publicly available, all being affected in some way: - https://github.com/siemens/jailhouse-images (recommended test case for a broad coverages of cases) - https://gitlab.denx.de/Xenomai/xenomai-images - https://gitlab.com/cip-project/cip-core/isar-cip-core In addition, our isar-siemens should be broken for the de0-nano-soc, and I think that board is also in Isar upstream, and your lab. Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux