From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6520199916203016192 X-Received: by 10.25.150.9 with SMTP id y9mr613008lfd.7.1518362722700; Sun, 11 Feb 2018 07:25:22 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 10.25.193.87 with SMTP id r84ls5800lff.9.gmail; Sun, 11 Feb 2018 07:25:22 -0800 (PST) X-Google-Smtp-Source: AH8x225/neRtUmHXopri8G90R5XZ4nZ5waWpRp070Thc+oC8q73xK/tCad/Y9WqILjE9mM2FqjtO X-Received: by 10.25.170.82 with SMTP id t79mr625835lfe.36.1518362722052; Sun, 11 Feb 2018 07:25:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518362722; cv=none; d=google.com; s=arc-20160816; b=c1pm2FXZhiDIh80wRVYrI+smNS/fFtc9ubS8WSEyrUcC+eHBNwg5LS4nEG8sP1qz/Y ENT2GnkOm/HvDMm7IUsSxVbSHYbNA3PRyXBC5uNXN5cVlbD9t3pBZ/pmKgiEmi0h1RaL mn9B1+ukgffnw9XYioBhVU0c1bfqnq5KNfFIF3hDqjtmPT+EJDZSHejAK9JdDwQtrT2Z brMwuK0rf0U09jqvgOihN7DmYY2rBX7Dd6H0LClpFmNlWUsRTc1UbuB4+hnDnBX1pa6T 6jj+abApyPfjGy4Mt2B+Tw8OQVGK9+4Jqn+B7Kshy2w1rZrLFWwRm8pOHRIPdLKsYtvK z7FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:references:in-reply-to:message-id:date :subject:to:from:arc-authentication-results; bh=SDAh27TOGYWibEcZIe0VB2IdRPE+5/gcMETKXhrIuK8=; b=MTCCXKIL5fxgg0xgN2lXaZLNlciKFeVspq04uo3isPlX0j4/ZeA7+HhjdfTjPhrZ+F wz8j1V8MTNMcOh5rIhkEltLqNR7vMkUUnL352HzOi4rLa2DsRZ0zJFCLUg1LQZWDOHgF sk8i9S8bmpY3vdIEX8FutWwbrVxvaBAfH9LN+qt0THri1BPHEXGTqu+pVIdijmp0CWEL /xZtM8f9PcOZpX+j3MEGjspSJqw4UT5c1HdkQnCWiaTE84QmppEfIzV+XO0flUmyfYFR 32gfVHCAAT58vNUfM5wD3KP5ToUl9zE05KCCkco+Yo8LovkauXDqkm8MH+DKgXtdRvRF X+Lg== 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 Return-Path: Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id 25si389665ljt.1.2018.02.11.07.25.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Feb 2018 07:25:22 -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 Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id w1BFPLM2010634 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 11 Feb 2018 16:25:21 +0100 Received: from md1f2u6c.ww002.siemens.net ([167.87.32.7]) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id w1BFPKhD024517 for ; Sun, 11 Feb 2018 16:25:21 +0100 From: Jan Kiszka To: isar-users Subject: [PATCH v4 5/8] Provide class for easy custom kernel builds Date: Sun, 11 Feb 2018 16:25:16 +0100 Message-Id: <10f71292d5c06de6909594c891f2478334106135.1518362719.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: References: In-Reply-To: References: X-TUID: +EU281Yx0ybd 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 + ' +} -- 2.13.6