From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6520199916203016192 X-Received: by 10.28.173.203 with SMTP id w194mr80003wme.24.1518515631062; Tue, 13 Feb 2018 01:53:51 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 10.28.31.200 with SMTP id f191ls1524062wmf.5.canary-gmail; Tue, 13 Feb 2018 01:53:50 -0800 (PST) X-Google-Smtp-Source: AH8x2264FThTRjqe1yYr5DKdIXMxR5sX/5+CIgAXQzNhQxULz+lARibLfulZBaehXniUUvThyjFb X-Received: by 10.28.129.195 with SMTP id c186mr83927wmd.10.1518515630567; Tue, 13 Feb 2018 01:53:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518515630; cv=none; d=google.com; s=arc-20160816; b=arUzDzYPhIW5r4lck3ZbBII5MBEIp5IukJ8zN5CK19E0JvKle9pfOIJyFecxRywk0N B4c4OAjA4V5+3e+db81od+TDoznc5yZpm3BtYcAwyheKISzmhcwjP2TRnWb78Oo8tNBL KFd8Vpx23j3MkmI30kjkbgsYx1uz5ys6b3ArJ72+lpo9Ta4VM75A6n4uC/Wpxrl07oR3 DWT/WjzjgWd5UxQ33BZdxKt2el/EKtr/IQRYSuNiapfGGUrSVQvoHCSVeQHGuvSUjgro P1nfJCWoYEceeC2IMwUnlpaPsWyeMTl1GcRgNuG3jRfSvy1lXlmHNzD/7c+VYaEleh4X BGeQ== 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=7mvh2X39E+qIK/0s4hNOC52gIWSYSZbgFNEhvxZqW7s=; b=0R3McPBxrgzeObWh8xQqbT9r9mGA2Vy5BFgq7Ef/ULDghg4uRUbZfhTcqcrAg2IIyl uMyU9rzuKJP+j17hLotQWg5kaxu/ySaj6pf1y05PIb+nceyftlrheAVykJAr4oh4LprK syqq3xI0y5H7e4eGfcPmprE/NSloDidbRvpH3XMP07Vyh8ydiZ7jV2uLuvwlemKe+qIw r9Sh3xVY8k383aXs5+05SFZYBvfrIVB5wIIuJEcGIE3GbJiUdo2Xec51bhmwXC7lkxWW /LsQPuCEDIjABmilDn+MyLG9NbmJvPP36iO+7orb9oSwUzP6XJcjfSDuuOa7UnYVREbR ByBg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=henning.schild@siemens.com Return-Path: Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id f192si383181wmg.1.2018.02.13.01.53.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Feb 2018 01:53:50 -0800 (PST) Received-SPF: pass (google.com: domain of henning.schild@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 henning.schild@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=henning.schild@siemens.com Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id w1D9ro62013517 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Feb 2018 10:53:50 +0100 Received: from mmd1pvb1c.ad001.siemens.net (md1pvb1c.ad001.siemens.net [139.25.68.40] (may be forged)) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w1D9roWP023533; Tue, 13 Feb 2018 10:53:50 +0100 Date: Tue, 13 Feb 2018 10:53:49 +0100 From: Henning Schild To: "[ext] Jan Kiszka" Cc: Alexander Smirnov , isar-users Subject: Re: [PATCH v4 5/8] Provide class for easy custom kernel builds Message-ID: <20180213105349.05baf3a0@mmd1pvb1c.ad001.siemens.net> In-Reply-To: <5771c955-dec7-8347-123d-d4b3f08e751a@siemens.com> References: <10f71292d5c06de6909594c891f2478334106135.1518362719.git.jan.kiszka@siemens.com> <5771c955-dec7-8347-123d-d4b3f08e751a@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=UTF-8 Content-Transfer-Encoding: quoted-printable X-TUID: YWLtZsj88YOH Am Tue, 13 Feb 2018 08:03:12 +0100 schrieb "[ext] Jan Kiszka" : > On 2018-02-12 19:56, Alexander Smirnov wrote: > > On 02/11/2018 06:25 PM, Jan Kiszka wrote: =20 > >> 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 > >> --- > >> =C2=A0 meta/classes/linux-kernel.bbclass | 98 > >> +++++++++++++++++++++++++++++++++++++++ > >> =C2=A0 1 file changed, 98 insertions(+) > >> =C2=A0 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 ?=3D "Custom kernel" > >> +PROVIDES =3D "virtual/kernel" > >> + > >> +inherit dpkg-base > >> + > >> +KERNEL_DEBIAN_DEPENDS ?=3D "initramfs-tools | linux-initramfs-tool, > >> kmod, linux-base (>=3D 4.3~)" > >> +KERNEL_HEADERS_DEBIAN_DEPENDS ?=3D "libc6, libssl1.1, gcc" > >> +KBUILD_DEPENDS ?=3D "libssl-dev libelf-dev bc" > >> + > >> +REPACK_DIR =3D "${PP}/repack" > >> +REPACK_LINUX_IMAGE_DIR =3D "${REPACK_DIR}/linux-image" > >> +REPACK_LINUX_HEADERS_DIR =3D "${REPACK_DIR}/linux-headers" > >> + > >> +dpkg_runbuild() { > >> +=C2=A0=C2=A0=C2=A0 E=3D"${@ bb.utils.export_proxies(d)}" > >> +=C2=A0=C2=A0=C2=A0 sudo -E chroot ${BUILDCHROOT_DIR} sh -c ' > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 set -e > >> + > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 apt-get install -y -o Debu= g::pkgProblemResolver=3Dyes \ > >> +=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 cd ${PP}/${S} > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cp ../defconfig .config > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 make olddefconfig > >> + > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 make -j ${@bb.utils.cpu_co= unt() * 2} deb-pkg > >> + > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rm -rf ${REPACK_DIR} > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mkdir -p ${REPACK_DIR} > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mkdir -p ${REPACK_LINUX_IM= AGE_DIR} > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mkdir -p ${REPACK_LINUX_HE= ADERS_DIR} > >> + > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cd ${PP} > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tar xzf linux-${PV}_${PV}-= 1.debian.tar.gz -C ${REPACK_DIR} > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dpkg-deb -R linux-image-${= PV}_${PV}-1_${KERNEL_ARCH}.deb \ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ${= REPACK_LINUX_IMAGE_DIR} > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dpkg-deb -R > >> linux-headers-${PV}_${PV}-1_${KERNEL_ARCH}.deb \ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ${= REPACK_LINUX_HEADERS_DIR} > >> + > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dpkg-gencontrol -crepack/d= ebian/control \ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -l= repack/debian/changelog \ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -f= repack/debian/files \ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -p= linux-image-${PV} \ > >> +=C2=A0=C2=A0=C2=A0=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=C2=A0=C2=A0=C2=A0 -D= Package=3D"linux-image-${KERNEL_ARCH}" \ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -D= Section=3Dkernel \ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -D= Priority=3Drequired \ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -D= Provides=3D"${PN}" \ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -D= Depends=3D"${KERNEL_DEBIAN_DEPENDS}" > >> + > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Add Debian-like link ins= tallation to postinst > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 touch > >> ${REPACK_LINUX_IMAGE_DIR}/lib/modules/${PV}/.fresh-install > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sed -i ${REPACK_LINUX_IMAG= E_DIR}/DEBIAN/postinst \ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -e= "/^set -e$/a\\ > >> +\\ > >> +if [ -f /lib/modules/${PV}/.fresh-install ]; then\\ > >> +=C2=A0=C2=A0=C2=A0 change=3Dinstall\\ > >> +else\\ > >> +=C2=A0=C2=A0=C2=A0 change=3Dupgrade\\ > >> +fi\\ > >> +linux-update-symlinks \$change ${PV} /boot/vmlinuz-${PV}\\ > >> +rm -f /lib/modules/${PV}/.fresh-install" > >> + > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Add Debian-like link rem= oval to postrm > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sed -i ${REPACK_LINUX_IMAG= E_DIR}/DEBIAN/postrm \ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -e= "/^set -e$/a\\ > >> +\\ > >> +rm -f /lib/modules/${PV}/.fresh-install\\ > >> +\\ > >> +if [ \"\$1\" !=3D upgrade ] && command -v linux-update-symlinks =20 > >> >/dev/null; then\\ =20 > >> +=C2=A0=C2=A0=C2=A0 linux-update-symlinks remove ${PV}=C2=A0 /boot/vml= inuz-${PV}\\ > >> +fi" > >> + > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dpkg-gencontrol -crepack/d= ebian/control \ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -l= repack/debian/changelog \ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -f= repack/debian/files \ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -p= linux-headers-${PV} \ > >> +=C2=A0=C2=A0=C2=A0=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=C2=A0=C2=A0=C2=A0 -V= kernel:debarch=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 -D= Package=3D"linux-headers-${KERNEL_ARCH}" \ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -D= Section=3Dkernel \ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -D= Depends=3D"${KERNEL_HEADERS_DEBIAN_DEPENDS}" > >> + > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dpkg-deb -b ${REPACK_LINUX= _IMAGE_DIR} \ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 li= nux-image-${KERNEL_ARCH}_${PV}-1_${KERNEL_ARCH}.deb > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rm -f linux-image-${PV}_${= PV}-1_${KERNEL_ARCH}.deb > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dpkg-deb -b ${REPACK_LINUX= _HEADERS_DIR} \ > >> + > >> linux-headers-${KERNEL_ARCH}_${PV}-1_${KERNEL_ARCH}.deb > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rm -f linux-headers-${PV}_= ${PV}-1_${KERNEL_ARCH}.deb > >> +=C2=A0=C2=A0=C2=A0 ' > >> +} > >> =20 > >=20 > > What is the benefit of having this script in the class? I see that > > we have separate files for: > >=20 > > =C2=A0- buildchroot > > =C2=A0- kernel modules > >=20 > > 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) =20 >=20 > I played with it, and it "just" took 6 exports to set up the interface > to script-based build. That will likely not be convenient for > debugging as well (and I never had to call things manually that way, > I got all information from logs), but I can keep that pattern. Will > also mean: back to an include, rather than using a class (no big > issue). You could write all these exports into a file that the scripts sources. Given that file exists, one could run manually and the recipe would not contain all that logic. > >=20 > > Also formatting style looks nasty here. =20 >=20 > That's not going to change unless you suggest some alternative for the > sed-based code injection into postinst/postrm. Can that code be appended with echo >> ? The patching looks pretty unconditional already. Henning =20 > Jan >=20