From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6520199916203016192 X-Received: by 10.28.128.79 with SMTP id b76mr393480wmd.30.1518198855199; Fri, 09 Feb 2018 09:54:15 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 10.28.199.10 with SMTP id x10ls1726326wmf.9.gmail; Fri, 09 Feb 2018 09:54:14 -0800 (PST) X-Google-Smtp-Source: AH8x227sZdi6vZ+TjssyxKHwE0+epPm4c21t0n5R76/7pTP/3BFIQpSJzZP5LcQjjHehDVKxBzVD X-Received: by 10.28.69.76 with SMTP id s73mr368874wma.15.1518198854553; Fri, 09 Feb 2018 09:54:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518198854; cv=none; d=google.com; s=arc-20160816; b=LvsJByIh+YCp6vprn+pFNP1Zi5DjH62bx/PbWhFZkpVevrIDXadslMa/exkNrOnaYp hZx0ijnXEoXWpB7rT1Hz6pN9r4PNNKK+KTq8BQkQDvKCEcdiNyiNjzqxY+QkjLTajeh8 /wxlQ2wr1QbDIpyU7RWBA4JIF6X+sO0Q6ZbNqLR/lo534ewwFzT8yKrFXYJt2TLetyNa yBgDhEMJbXpj9zDOE3xIyiJjIRVO3yS5nrOn3nMOxVrEv+mVyb8PsNJgkLyxu0r/ldh0 7zx0avUAGsyQK+6ppiPco/0J+4/9M5ZVbdEAQO2ehqoMryyLohiulCBtepDl4G8msP1L rWxg== 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:cc:to:subject :arc-authentication-results; bh=QP9yIqh0FX93MXNkxgPxi8iKbELpc7GUUUXvHZm6lWc=; b=mBOY0lzp2ZKXJ/ebdq4VHhzUrw6gLCvCe+Lm0WUGoQECXYFc616bmlXRtvcqz9PTRH lda6LaGnnTAYY5Q/4UIBYlHNPxDpSf4QtJcdaxpwP9Dm5TMvqGNTWsP+jLPDIvV6Nmbn NKs7+XRr4fgHJbNb3FP560WaXCuU5EN/GIZgkmXOctXI8EHXgQABwvf5+vqtZBocvyco vR/8P9+zfiJD9a0yDDiIfo6Jrwy5X3oVL9X/dBKIn2+WKSKIQQbyHpXFbi/tetlVUl9Z eZnNCw/AqLu1LJnNNbNlN8YEM2h/mhSX9FqzcQFNy4YoLaV4nKr2bmA/IRCuow7cDFsd bJ1g== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Return-Path: Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id d8si130325wmf.1.2018.02.09.09.54.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Feb 2018 09:54:14 -0800 (PST) Received-SPF: pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.14 as permitted sender) client-ip=192.35.17.14; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id w19HsEDt019686 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 9 Feb 2018 18:54:14 +0100 Received: from [139.25.68.37] (md1q0hnc.ad001.siemens.net [139.25.68.37] (may be forged)) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w19HsDCH030466; Fri, 9 Feb 2018 18:54:13 +0100 Subject: Re: [PATCH v2 5/8] Provide include file for easy custom kernel builds To: Henning Schild Cc: isar-users References: <8ee0db162e27f31b64bc17eaf00d24f7b488806e.1518110579.git.jan.kiszka@siemens.com> <20180209183039.537f17d6@mmd1pvb1c.ad001.siemens.net> From: Jan Kiszka Message-ID: Date: Fri, 9 Feb 2018 18:54:12 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 In-Reply-To: <20180209183039.537f17d6@mmd1pvb1c.ad001.siemens.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: Z/9JpSKHIZSL On 2018-02-09 18:30, Henning Schild wrote: > Am Thu, 8 Feb 2018 18:22:56 +0100 > schrieb "[ext] Jan Kiszka" : > >> From: Jan Kiszka >> >> With this include file, it becomes almost trivial to replace the >> distro kernel with a custom build. You just need to include >> linux-custom.inc, specify the source URI, define via S where the >> source is unpacked to and provide a defconfig. To switch to a custom >> kernel recipe, PREFERRED_PROVIDER_virtual/kernel has to be adjusted >> in local.conf or the distro conf. >> >> The approach works internally by first running "make deb-pkg" on the >> kernel and the repackages the output to make the binary linux-image >> and linux-header debs act as replacement of their distro packages. >> This results in a suboptimal technical implementation which may >> eventually be replaced by an isar-implemented deb-pkg build process. >> However, this is not expected to affect the user-visible interface of >> this include file. >> >> Signed-off-by: Jan Kiszka >> --- >> meta/recipes-kernel/linux/linux-custom.inc | 98 >> ++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) >> create mode 100644 meta/recipes-kernel/linux/linux-custom.inc >> >> diff --git a/meta/recipes-kernel/linux/linux-custom.inc >> b/meta/recipes-kernel/linux/linux-custom.inc new file mode 100644 >> index 0000000..feb96a1 >> --- /dev/null >> +++ b/meta/recipes-kernel/linux/linux-custom.inc >> @@ -0,0 +1,98 @@ >> +# Custom kernel recipe include >> +# >> +# This software is a part of ISAR. >> +# Copyright (c) Siemens AG, 2018 >> +# >> +# SPDX-License-Identifier: MIT >> + >> +DESCRIPTION ?= "Custom kernel" >> +PROVIDES = "virtual/kernel" >> + >> +inherit dpkg-base >> + >> +KERNEL_DEBIAN_DEPENDS = "initramfs-tools | linux-initramfs-tool, >> kmod, linux-base (>= 4.3~)" +KERNEL_HEADERS_DEBIAN_DEPENDS = "libc6, >> libssl1.1, gcc" +KBUILD_DEPENDS = "libssl-dev libelf-dev bc" > > These guys and the repacking are here because someone wrote a > build-script that does not allow customization, how about not repeating > that mistake and using "?=". As this is an include, you can already easily adjust after including. Granted, defining those as default assignment would permit project-wide overrides in local.conf & Co. OK, will send v3. Jan >> +REPACK_DIR = "${PP}/repack" >> +REPACK_LINUX_IMAGE_DIR = "${REPACK_DIR}/linux-image" >> +REPACK_LINUX_HEADERS_DIR = "${REPACK_DIR}/linux-headers" >> + >> +dpkg_runbuild() { >> + E="${@ bb.utils.export_proxies(d)}" >> + sudo -E chroot ${BUILDCHROOT_DIR} sh -c ' >> + set -e >> + >> + apt-get install -y -o Debug::pkgProblemResolver=yes \ >> + --no-install-recommends ${KBUILD_DEPENDS} >> + >> + cd ${PP}/${S} >> + cp ../defconfig .config >> + make olddefconfig >> + >> + make -j ${@bb.utils.cpu_count() * 2} deb-pkg >> + >> + rm -rf ${REPACK_DIR} >> + mkdir -p ${REPACK_DIR} >> + mkdir -p ${REPACK_LINUX_IMAGE_DIR} >> + mkdir -p ${REPACK_LINUX_HEADERS_DIR} >> + >> + cd ${PP} >> + tar xzf linux-${PV}_${PV}-1.debian.tar.gz -C >> ${REPACK_DIR} >> + dpkg-deb -R >> linux-image-${PV}_${PV}-1_${KERNEL_ARCH}.deb \ >> + ${REPACK_LINUX_IMAGE_DIR} >> + dpkg-deb -R >> linux-headers-${PV}_${PV}-1_${KERNEL_ARCH}.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_ARCH}" \ >> + -DSection=kernel \ >> + -DPriority=required \ >> + -DProvides="${PN}" \ >> + -DDepends="${KERNEL_DEBIAN_DEPENDS}" >> + >> + # Add Debian-like link installation to postinst >> + 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/vmlinuz-${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/vmlinuz-${PV}\\ >> +fi" >> + >> + dpkg-gencontrol -crepack/debian/control \ >> + -lrepack/debian/changelog \ >> + -frepack/debian/files \ >> + -plinux-headers-${PV} \ >> + -P${REPACK_LINUX_HEADERS_DIR} \ >> + -Vkernel:debarch="${KERNEL_ARCH}" \ >> + -DPackage="linux-headers-${KERNEL_ARCH}" \ >> + -DSection=kernel \ >> + -DDepends="${KERNEL_HEADERS_DEBIAN_DEPENDS}" >> + >> + dpkg-deb -b ${REPACK_LINUX_IMAGE_DIR} \ >> + >> linux-image-${KERNEL_ARCH}_${PV}-1_${KERNEL_ARCH}.deb >> + rm -f linux-image-${PV}_${PV}-1_${KERNEL_ARCH}.deb >> + dpkg-deb -b ${REPACK_LINUX_HEADERS_DIR} \ >> + >> linux-headers-${KERNEL_ARCH}_${PV}-1_${KERNEL_ARCH}.deb >> + rm -f linux-headers-${PV}_${PV}-1_${KERNEL_ARCH}.deb >> + ' >> +} > -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux