From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6520199916203016192 X-Received: by 10.25.211.79 with SMTP id k76mr160629lfg.1.1518197477938; Fri, 09 Feb 2018 09:31:17 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 10.25.67.66 with SMTP id m2ls829018lfj.1.gmail; Fri, 09 Feb 2018 09:31:13 -0800 (PST) X-Google-Smtp-Source: AH8x224GMUHMXfj8FHmghwALkTyIP9uSkswdl9FokQeiEbt/AcXKL2yGokdra7OiuLItwHNAdYTR X-Received: by 10.25.72.198 with SMTP id v189mr293561lfa.14.1518197473265; Fri, 09 Feb 2018 09:31:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518197473; cv=none; d=google.com; s=arc-20160816; b=yraTmEAUxFcLFA60s0iUmc9WenXf3iJcI7quUknYbLBozwfsjhCGYneA5zbtoTMCE/ ORat9jP8Q+kHIj9YKlkOryBCdEuWu+XXLzyc8pfJlpMfQKDTcddb4TAB69WR60qibbNY 7OZ57D5qJn84EpXSadTCNZaVZXsicThmzlPz033BjfvwkBOgXX+uAHDFE2ULW9DLhAWB S88lmwFyI5Xy4D9XFNMkde4TRFaB+ZMMUgGZ5wmXjz774M4x9Vz9KRec43jRTgRWRSNf 6oMign7yoavdMsJp5XSPvykE9CRDwuQ8aoUiMB6L7fFbly70hWRebLfaQZqyfTLhkiB8 kFRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:arc-authentication-results; bh=DrwXN9O5FC7YPmW1dayPenMEW3lgh+VBhs4uscbPGqs=; b=kHQwGtxJoyHxkneJXAStYLhnnK75FMNw5+nVGUwEM9vaj4N/+nAZtkFbXG1ntQp+W5 P7KUgabkapcoYRIMmmLHUFBaxlUjr1HAuUryn/BX2y8/uWKjnH3xQWA1w+Epax9vwnog 0DBGGYxe+aeRXxt5daOv1peEBlMut29j33vCf30Kks48Tg0UyORNC4TvdGrlmKpuBOli HhUcT5btAFyZmRW2MBiSrEBWr4FVMF6Ml5C1u98wFa/KGBzplzZgJubgtzgn6nGwfXEK gRvfj6S6KvEgUrKs9jOC37Kp/0qc1cenAqK3tBtAnZag7BVHn4iXB3ejqybiBYaWgrvT EzMQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=henning.schild@siemens.com Return-Path: Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id u10si159255lju.0.2018.02.09.09.31.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Feb 2018 09:31:13 -0800 (PST) Received-SPF: pass (google.com: domain of henning.schild@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 henning.schild@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=henning.schild@siemens.com Received: from mail2.siemens.de (mail2.siemens.de [139.25.208.11]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id w19HVCLG030041 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 9 Feb 2018 18:31:12 +0100 Received: from mmd1pvb1c.ad001.siemens.net (md1pvb1c.ad001.siemens.net [139.25.68.40] (may be forged)) by mail2.siemens.de (8.15.2/8.15.2) with ESMTP id w19HVCcv011422; Fri, 9 Feb 2018 18:31:12 +0100 Date: Fri, 9 Feb 2018 18:31:11 +0100 From: Henning Schild To: Jan Kiszka Cc: isar-users Subject: Re: [PATCH v2 5/8] Provide include file for easy custom kernel builds Message-ID: <20180209183111.0be19f58@mmd1pvb1c.ad001.siemens.net> In-Reply-To: <18624984-a30e-a59b-54d5-d782766ce61c@siemens.com> References: <8ee0db162e27f31b64bc17eaf00d24f7b488806e.1518110579.git.jan.kiszka@siemens.com> <20180209175955.6ff52d19@mmd1pvb1c.ad001.siemens.net> <18624984-a30e-a59b-54d5-d782766ce61c@siemens.com> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TUID: QPk80zjqtXmr Am Fri, 9 Feb 2018 18:24:18 +0100 schrieb Jan Kiszka : > On 2018-02-09 17:59, Henning Schild wrote: > > This is where the (nasty) magic happens ;). I would suggest pulling > > the shell script out like dpkg.bbclass is calling its build.sh, > > that should make it more readable. > > Hmm, not sure. I would have to export lots of variables for that.... Yes, i see. Henning > > > > On which kernel versions have you actually tested this? I just built > > the jailhouse example and saw it was 4.14. Will that work on 4.4 or > > even before? > > See patch 6: tested down to 4.4 so far. > > Jan > > > > > Henning > > > > 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" + > >> +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 > >> + ' > >> +} > > >