From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6520199916203016192 X-Received: by 10.223.184.131 with SMTP id i3mr1241335wrf.29.1518461784965; Mon, 12 Feb 2018 10:56:24 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 10.28.227.65 with SMTP id a62ls1186474wmh.3.canary-gmail; Mon, 12 Feb 2018 10:56:24 -0800 (PST) X-Google-Smtp-Source: AH8x227nhoyZHs/TRfAUe8cQWDew3D7HSibUUPTaUfTfn/sJday8K53oNa+DcwgJlt0RoVI6Sc5b X-Received: by 10.28.4.216 with SMTP id 207mr591779wme.13.1518461784476; Mon, 12 Feb 2018 10:56:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518461784; cv=none; d=google.com; s=arc-20160816; b=SfP5l1SxgVZRbDX3SaLhOKle8bB4Q/AFt1okJ8S5DK5k86ycMDLl/dhZjSaNxsspMd NHedPvXsMkZn8L9tn2YhHeRTVZA13sQFkbSetObHtOEuZ4U9KCP8flPU/hujlRNKBIZP +x0Q1+UpLZqv5mwqLsKb0FLwUMI7pcg0D/lmtNP671wjljV2DpBRPlQUQL1BWZsFnAFu zfPwUyGSQD4MhU2w7aeaXtMD4P/AaBTuC/mcqs3Df6qOgMZlsAjxQz/vRxams79m1JcL O83GP/05oSU9POEkQewxWpfz2vB0D3GAKww36W2G9vW4jrj7TmNilmRrwywPqFwLZUTR vaKA== 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 :arc-authentication-results; bh=JpxY1KaNof+A0ogQtpof/qdh5lyEbBSE4LSNyrr9SJ8=; b=UdKeOIniMP721CUhZn5QDKpqll0kb7LVrFLX8YCU7lqzOdKrPw0ZOhFWLObS8NuYvn v6O3/SbJsCRBjZz/GoG+0e3tqz+KOOeoWxUpx0LkrCf8e/inFosRJhCY5Mge6VjXmBzU xn/RQEd1uRh0Bac3Ugd+XSazCLhIsGDmwXMHiKi9UepJjhexuPgNNEJg4QtKhHLHwogZ b/NOu/5Q436mKUWTPvNysJnrE5jIouNAOp5XnOS9X+uGLfz4hUMGP4CSnkILFvax+Je+ s5gaRIVQCPocY/xjMAobnBF62LK7we8X0cYTMbyM2gutazTKs4dVFmoEeDEsdb7Pajn3 eU2Q== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: best guess record for domain of asmirnov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=asmirnov@ilbers.de Return-Path: Received: from aqmola.ilbers.de (aqmola.ilbers.de. [85.214.62.211]) by gmr-mx.google.com with ESMTPS id 200si392412wml.2.2018.02.12.10.56.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Feb 2018 10:56:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of asmirnov@ilbers.de designates 85.214.62.211 as permitted sender) client-ip=85.214.62.211; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of asmirnov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=asmirnov@ilbers.de Received: from [10.0.2.15] ([188.227.110.165]) (authenticated bits=0) by aqmola.ilbers.de (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id w1CIuL0p002698 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Mon, 12 Feb 2018 19:56:23 +0100 Subject: Re: [PATCH v4 5/8] Provide class for easy custom kernel builds To: Jan Kiszka , isar-users References: <10f71292d5c06de6909594c891f2478334106135.1518362719.git.jan.kiszka@siemens.com> From: Alexander Smirnov Message-ID: Date: Mon, 12 Feb 2018 21:56:16 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <10f71292d5c06de6909594c891f2478334106135.1518362719.git.jan.kiszka@siemens.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: uKhJ+NZc6jBk On 02/11/2018 06:25 PM, Jan Kiszka wrote: > From: Jan Kiszka > > With this class, it becomes almost trivial to replace the distro kernel > with a custom build. You just need to inherit linux-kernel, 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 class. > > Signed-off-by: Jan Kiszka > --- > meta/classes/linux-kernel.bbclass | 98 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 98 insertions(+) > create mode 100644 meta/classes/linux-kernel.bbclass > > diff --git a/meta/classes/linux-kernel.bbclass b/meta/classes/linux-kernel.bbclass > new file mode 100644 > index 0000000..5f4df3f > --- /dev/null > +++ b/meta/classes/linux-kernel.bbclass > @@ -0,0 +1,98 @@ > +# Custom kernel build > +# > +# 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 > + ' > +} > What is the benefit of having this script in the class? I see that we have separate files for: - buildchroot - kernel modules Why this chroot script should be a part of bitbake class? This makes debugging much more complicated, because I have no possibility to run this script manually from buildchroot (like I could do with build.sh) Also formatting style looks nasty here. Alex