From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7163980406052618240 X-Received: by 2002:a2e:54f:0:b0:26f:a90a:fd82 with SMTP id 76-20020a2e054f000000b0026fa90afd82mr143894ljf.248.1668144881030; Thu, 10 Nov 2022 21:34:41 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6512:36c7:b0:4a2:3951:eac8 with SMTP id e7-20020a05651236c700b004a23951eac8ls11714lfs.0.-pod-prod-gmail; Thu, 10 Nov 2022 21:34:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf5D7BQI+g+HIsPbRjjkG6wxs49mMam4YoscC0H1CWfU6fHbHQ9YXNsd/sbrdcZ636Ssx642 X-Received: by 2002:ac2:5ec3:0:b0:4aa:f1f2:ad77 with SMTP id d3-20020ac25ec3000000b004aaf1f2ad77mr225426lfq.171.1668144879370; Thu, 10 Nov 2022 21:34:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668144879; cv=none; d=google.com; s=arc-20160816; b=0ArZcCcEY+VW1DWvJ/EepS1YlQYs9hoWrzu+oqUAKsbekwsKeBk62YClOtgCLDYd+p t1uD2Zn5LDDatURs7wHKxrvZuWNzL8YcM/RHA5uwd4549oucmYatZ2W3BKhSNC1wEaAl 6927xkKER7TQtE7h9EQwZBVDn9hCNwJU5ymY8F09HczJWcvjFB3zmEk2D6S31NAUQfZF 4clXWbG+ppiGKSTY/glRYJLfrQ5U9eqs0JWXjPhr1A/71hjK3nh7lqJcu7BBlAZqjcqa Awgr5Cs+dVXJNbWgqYF5Zyl5YbJH48X8IxKEKqdW41KrfuHw9rJ7LRj/QXTcIHH6MU7h 2bvw== 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:date:subject:cc:to:from; bh=rrM+dO1ii4J8mkjxQSB6h43fcJr+/BkvPoEaFhR4O8A=; b=Q4l0fVjxNBXjko31ku9PR5WaZtoeTYpwTFsUZ41vrYZQJEdfqH3/G0olHlbk7NbbRH Gf84FpJL5yctdPtEHiA8tXfvRLOaOLYj805cfd0absIVboFroD2cqN+wHGWUAsz34PfB 9ttnIV/6U2VXfK7Is/3mFiWSusBrSkzAvtApp4YWqI+AeQ64HFWpGBDw99Psr3fVegbX K8CsaJUsqXBjvw/5U/HJbL98hzAgn7r5vpiKipnzp+2mRbLr3mmokqzqdFqBMbzYCxMX 471318A6h9+jbNfVwAy478JI7oveHoTYzeir7SQMvk4P2MpcVHokm6WzpZca9qQ1GHrS oi2g== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=ubely@ilbers.de Return-Path: Received: from shymkent.ilbers.de (shymkent.ilbers.de. [85.214.156.166]) by gmr-mx.google.com with ESMTPS id o4-20020a05651205c400b004a225e3ed13si33212lfo.13.2022.11.10.21.34.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Nov 2022 21:34:39 -0800 (PST) Received-SPF: pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) client-ip=85.214.156.166; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=ubely@ilbers.de Received: from hp.localnet (host-80-81-17-52.static.customer.m-online.net [80.81.17.52]) (authenticated bits=0) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPSA id 2AB5Ya4q007434 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Nov 2022 06:34:37 +0100 From: Uladzimir Bely To: "isar-users@googlegroups.com" Cc: "Koch, Stefan" Subject: Re: [PATCH 2/3] linux-custom: Split up binaries from kernel headers to kbuild packages Date: Fri, 11 Nov 2022 08:34:33 +0300 Message-ID: <4749412.OV4Wx5bFTl@hp> In-Reply-To: <20221109103238.1520091-3-stefan-koch@siemens.com> References: <20221109103238.1520091-1-stefan-koch@siemens.com> <20221109103238.1520091-3-stefan-koch@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-TUID: 4ILQmLlB3fFX In mail from =D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BD=D0=BE=D1=8F=D0=B1=D1= =80=D1=8F 2022 =D0=B3. 13:32:48 +03 user Koch, Stefan wrote: > When using a cross build this patch does introduce > host and target specific kernel kbuild packages that > ship the "scripts" and "tools" binaries. > The kernel headers fulfill this using symlinks to point > to the "scripts" and "tools" of the respective kernel kbuild package. >=20 > Known from doc/custom_kernel.inc: > - The kernel headers package has not supported both native > and cross compilation of kernel modules when itself was cross built > - Future roadmap: Generate kernel headers package for both host > and target when using a cross build >=20 > Known from debian kernel packages structure: > - Generate a kernel headers package without binaries > - Create specific kernel kbuild packages that > ship the "scripts" and "tools" binaries > - Using symlinks to point to the "scripts" > and "tools" binaries >=20 > Signed-off-by: Stefan Koch > --- > .../linux/files/debian/control.tmpl | 18 ++- > .../linux/files/debian/isar/build.tmpl | 9 +- > .../linux/files/debian/isar/common.tmpl | 7 +- > .../linux/files/debian/isar/install.tmpl | 64 +++++++++-- > .../linux/files/debian/rules.tmpl | 5 +- > meta/recipes-kernel/linux/linux-custom.inc | 104 ++++++++++++++++-- > 6 files changed, 178 insertions(+), 29 deletions(-) >=20 > diff --git a/meta/recipes-kernel/linux/files/debian/control.tmpl > b/meta/recipes-kernel/linux/files/debian/control.tmpl index > dd0b624..adac4ef 100644 > --- a/meta/recipes-kernel/linux/files/debian/control.tmpl > +++ b/meta/recipes-kernel/linux/files/debian/control.tmpl > @@ -26,7 +26,7 @@ Section: devel > Provides: linux-kernel-headers > Architecture: any > Description: Linux support headers for userspace development > - This package provides userspaces headers from the Linux kernel. These > headers + This package provides userspaces headers from the Linux kernel. > These headers are used by the installed headers for GNU glibc and other > system libraries. >=20 > Package: linux-image-${KERNEL_NAME_PROVIDED}-dbg > @@ -35,3 +35,19 @@ Architecture: any > Description: Linux kernel debugging symbols for @KR@ > This package will come in handy if you need to debug the kernel. It > provides all the necessary debug symbols for the kernel and its modules. > + > +Package: linux-kbuild-${KERNEL_NAME_PROVIDED} > +Architecture: any > +Depends: ${KERNEL_HEADERS_DEBIAN_DEPENDS}, ${perl:Depends}, > ${shlib:Depends} +Description: ${KERNEL_NAME_PROVIDED} Linux kbuild scrip= ts > and tools for @KR@ + This package provides kernel kbuild scripts and tools > for @KR@ > + This is useful for people who need to build external modules > + > +Package: linux-kbuild-${KERNEL_NAME_PROVIDED}-cross > +Architecture: ${CONTROL_TARGET_ARCH} Is this architecture correct? Below, it's set to target_arch =3D distro_arc= h for=20 cross-compile case. I looked into `linux-kbuild-mainline-cross_5.4.203+r0_armhf.deb` and there = are=20 some binaries inside, "ELF 64-bit LSB pie executable, x86-64", so it looks = for=20 me that the package is supposed to be installed on host machine and to have= =20 the host architecture instead. > +Depends: ${KERNEL_HEADERS_DEBIAN_DEPENDS}, ${perl:Depends}, > ${shlib:Depends} +Description: ${KERNEL_NAME_PROVIDED} Linux kbuild scrip= ts > and tools for @KR@ + This package provides kernel kbuild scripts and tools > + as ${HOST_ARCH} cross binaries for @KR@ > + This is useful for those who need to cross build > + external modules using ISAR's sbuild-chroot-host > diff --git a/meta/recipes-kernel/linux/files/debian/isar/build.tmpl > b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl index > 94cfbe0..7e2daad 100644 > --- a/meta/recipes-kernel/linux/files/debian/isar/build.tmpl > +++ b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl > @@ -13,16 +13,19 @@ do_build() { > # Trace what we do here > set -x >=20 > + # Set correct build directory for kernel or kbuild (kernel scripts a= nd > tools) cases + build_dir=3D${KERNEL_BUILD_DIR} > + > # Process existing kernel configuration to make sure it is complete > # (use defaults for options that were not specified) > - ${MAKE} O=3D${KERNEL_BUILD_DIR} olddefconfig prepare > + ${MAKE} O=3D${build_dir} olddefconfig prepare >=20 > # Transfer effective kernel version into control file and scripts > - KR=3D$(${MAKE} O=3D${KERNEL_BUILD_DIR} -s --no-print-directory > kernelrelease) + KR=3D$(${MAKE} O=3D${build_dir} -s --no-print-directo= ry > kernelrelease) sed -i "s/@KR@/${KR}/g" ${S}/debian/control > ${S}/debian/linux-image-${KERNEL_NAME_PROVIDED}.* >=20 > # Build the Linux kernel > - ${MAKE} O=3D${KERNEL_BUILD_DIR} ${PARALLEL_MAKE} KCFLAGS=3D"${KCFLAG= S}" > + ${MAKE} O=3D${build_dir} ${PARALLEL_MAKE} KCFLAGS=3D"${KCFLAGS}" >=20 > # Stop tracing > set +x > diff --git a/meta/recipes-kernel/linux/files/debian/isar/common.tmpl > b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl index > 52ebebb..55d6123 100644 > --- a/meta/recipes-kernel/linux/files/debian/isar/common.tmpl > +++ b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl > @@ -5,10 +5,14 @@ > set -e >=20 > # Isar settings > -ARCH=3D${KERNEL_ARCH} > KERNEL_PKG_IMAGE=3Dlinux-image-${KERNEL_NAME_PROVIDED} > KERNEL_PKG_KERN_HEADERS=3Dlinux-headers-${KERNEL_NAME_PROVIDED} > KERNEL_PKG_LIBC_HEADERS=3Dlinux-libc-dev > +KERNEL_PKG_KERN_KBUILD=3Dlinux-kbuild-${KERNEL_NAME_PROVIDED} > + > +if [ -z "${ARCH}" ]; then > + ARCH=3D${KERNEL_ARCH} > +fi >=20 > # Constants > KCONF=3D.config > @@ -19,6 +23,7 @@ deb_img_dir=3D${deb_top_dir}/${KERNEL_PKG_IMAGE} > deb_dbg_dir=3D${deb_img_dir}-dbg > deb_kern_hdr_dir=3D${deb_top_dir}/${KERNEL_PKG_KERN_HEADERS} > deb_libc_hdr_dir=3D${deb_top_dir}/${KERNEL_PKG_LIBC_HEADERS} > +deb_kern_kbuild_dir=3D${deb_top_dir}/${KERNEL_PKG_KERN_KBUILD} >=20 > # Array of packages to be generated > declare -A kern_pkgs > diff --git a/meta/recipes-kernel/linux/files/debian/isar/install.tmpl > b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl index > 0a8645d..890a996 100644 > --- a/meta/recipes-kernel/linux/files/debian/isar/install.tmpl > +++ b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl > @@ -33,6 +33,7 @@ do_install() { > # Trace what we do here > set -x >=20 > + # Run the install steps > install_image > if [ "${ARCH}" !=3D "um" ]; then > install_config > @@ -43,6 +44,19 @@ do_install() { > install_kmods > install_headers >=20 > + if [ -d "$(dirname ${O})/build-full-kbuild-target" ]; then > + # Install cross kernel scripts and tools > + install_kbuild ${deb_kern_kbuild_dir}-cross build-full > + > + # Cleanup and install kernel scripts and tools for target arch > + rm -rf ${deb_kern_kbuild_dir} > + install_kbuild ${deb_kern_kbuild_dir} build-full-kbuild-target > + else > + # Cleanup and install kernel scripts and tools > + rm -rf ${deb_kern_kbuild_dir} > + install_kbuild ${deb_kern_kbuild_dir} build-full > + fi > + > # Stop tracing > set +x > } > @@ -168,21 +182,15 @@ kernel_headers() { > mkdir -p ${destdir} > mkdir -p ${deb_kern_hdr_dir}/lib/modules/${krel} >=20 > - (cd ${S}; find . -name 'Makefile*' -o -name 'Kconfig*' -o -name '*.p= l') > >>${src_hdr_files} - (cd ${S}; find arch/*/include include scripts -ty= pe > f -o -type l) >>${src_hdr_files} + (cd ${S}; find . -not -path > './scripts/*' -a -not -path './tools/*' -a \( -name 'Makefile*' -o -name > 'Kconfig*' -o -name '*.pl' \)) >>${src_hdr_files} + (cd ${S}; find > arch/*/include include -type f -o -type l) >>${src_hdr_files} (cd ${S}; > find arch/${ARCH} -name module.lds -o -name Kbuild.platforms -o -name > Platform) >>${src_hdr_files} (cd ${S}; find $(find arch/${ARCH} -name > include -o -name scripts -type d) -type f) >>${src_hdr_files} >=20 > if [ -n "${CONFIG_MODULES}" ]; then > echo Module.symvers >> ${obj_hdr_files} > fi > - (cd ${O}; find arch/${ARCH}/include include scripts -type f) > >>${obj_hdr_files} - if [ -n "${CONFIG_STACK_VALIDATION}" ]; then > - (cd ${O}; find tools/objtool -type f -executable) > >>${obj_hdr_files} - fi > - if [ -n "${CONFIG_GCC_PLUGINS}" ]; then > - (cd ${O}; find scripts/gcc-plugins -name *.so -o -name > gcc-common.h) >>${obj_hdr_files} - fi > + (cd ${O}; find arch/${ARCH}/include include -type f) >>${obj_hdr_fil= es} >=20 > # deploy files that were matched above > tar -C ${S} -cf - -T - <${src_hdr_files} | tar -C ${destdir} -xf - > @@ -191,8 +199,11 @@ kernel_headers() { > # add the kernel config > cp ${O}/${KCONF} ${destdir}/.config >=20 > - # handle kernel development tools > - kernel_tools > + # add symlink to scripts and tools directories > + ln -sf ../../lib/linux-kbuild-${krel}/scripts ${destdir}/scripts > + if [ -n "${CONFIG_STACK_VALIDATION}" ]; then > + ln -sf ../../lib/linux-kbuild-${krel}/tools ${destdir}/tools > + fi >=20 > # create symlinks > ln -sf /${kernel_headers_dir} > ${deb_kern_hdr_dir}/lib/modules/${krel}/build @@ -206,4 +217,35 @@ > install_headers() { > kernel_headers > } >=20 > +install_kbuild() { > + kernel_kbuild_dir=3Dusr/lib/linux-kbuild-${krel} > + destdir=3D${1}/${kernel_kbuild_dir} > + src_kbuild_files=3D$(mktemp) > + obj_kbuild_files=3D$(mktemp) > + > + if [ -n "${2}" ]; then > + O=3D$(dirname ${O})/${2} > + fi > + > + mkdir -p ${destdir} > + > + (cd ${S}; find . -path './scripts/*' -a -path './tools/*' -a \( -name > 'Makefile*' -o -name 'Kconfig*' -o -name '*.pl' \)) >>${src_kbuild_files}= + > (cd ${S}; find scripts -type f -o -type l) >>${src_kbuild_files} + > + (cd ${O}; find scripts -type f) >>${obj_kbuild_files} > + if [ -n "${CONFIG_STACK_VALIDATION}" ]; then > + (cd ${O}; find tools/objtool -type f -executable) > >>${obj_kbuild_files} + fi > + if [ -n "${CONFIG_GCC_PLUGINS}" ]; then > + (cd ${O}; find scripts/gcc-plugins -name *.so -o -name > gcc-common.h) >>${obj_kbuild_files} + fi > + > + # deploy files that were matched above > + tar -C ${S} -cf - -T - <${src_kbuild_files} | tar -C ${destdir} -xf - > + tar -C ${O} -cf - -T - <${obj_kbuild_files} | tar -C ${destdir} -xf - > + > + # handle kernel development tools > + kernel_tools > +} > + > main install ${*} > diff --git a/meta/recipes-kernel/linux/files/debian/rules.tmpl > b/meta/recipes-kernel/linux/files/debian/rules.tmpl index 8063c49..e131288 > 100755 > --- a/meta/recipes-kernel/linux/files/debian/rules.tmpl > +++ b/meta/recipes-kernel/linux/files/debian/rules.tmpl > @@ -36,4 +36,7 @@ override_dh_auto_test: > true >=20 > override_dh_strip: > - unset DEB_HOST_GNU_TYPE && dh_strip -Xvmlinu --no-automatic-dbgsym > + dh_strip -Xvmlinu -Xlinux-kbuild-${KERNEL_NAME_PROVIDED}-cross > --no-automatic-dbgsym + > +override_dh_shlibdeps: > + dh_shlibdeps -Xlinux-kbuild-${KERNEL_NAME_PROVIDED} > diff --git a/meta/recipes-kernel/linux/linux-custom.inc > b/meta/recipes-kernel/linux/linux-custom.inc index 96f0afc..0f8ba50 100644 > --- a/meta/recipes-kernel/linux/linux-custom.inc > +++ b/meta/recipes-kernel/linux/linux-custom.inc > @@ -74,12 +74,14 @@ TEMPLATE_VARS +=3D " \ > KERNEL_ARCH \ > KERNEL_DEBIAN_DEPENDS \ > KERNEL_BUILD_DIR \ > + KERNEL_KBUILD_DIR \ > KERNEL_FILE \ > KERNEL_HEADERS_DEBIAN_DEPENDS \ > LINUX_VERSION_EXTENSION \ > KERNEL_NAME_PROVIDED \ > KERNEL_CONFIG_FRAGMENTS \ > KCFLAGS \ > + CONTROL_TARGET_ARCH \ > " >=20 > inherit dpkg > @@ -91,30 +93,54 @@ KCFLAGS ?=3D "-fdebug-prefix-map=3D${CURDIR}=3D." > # Derive name of the kernel packages from the name of this recipe > KERNEL_NAME_PROVIDED ?=3D "${@ d.getVar('PN', True).partition('linux-')[= 2]}" >=20 > -# Make bitbake know we will be producing linux-image and linux-headers > packages python() { > kernel_name =3D d.getVar("KERNEL_NAME_PROVIDED", True) > - d.setVar('PROVIDES', 'linux-image-' + kernel_name + ' ' + \ > - 'linux-headers-' + kernel_name) > + distro_arch =3D d.getVar("DISTRO_ARCH", True) > + host_arch =3D d.getVar("HOST_ARCH", True) > + target_arch =3D "" > + kbuild_depends =3D "linux-kbuild-" + kernel_name > + > + # For different distro and host archs > + # - Set target arch (empty string disables package build) > + # - Add dependency for sbuild-chroot-target > + # to allow building arch specific kbuild scripts and tools > + # - Set correct name of kbuild package dependency > + if distro_arch !=3D host_arch: > + d.appendVar("SCHROOT_DEP", " sbuild-chroot-target:do_build") > + if d.getVar("ISAR_CROSS_COMPILE", True) =3D=3D "1": > + target_arch =3D distro_arch > + kbuild_depends =3D kbuild_depends + "-cross | " + kbuild_dep= ends > + > + # Set CONTROL_TARGET_ARCH > + d.setVar("CONTROL_TARGET_ARCH", target_arch) > + > + # Make bitbake know we will be producing > + # linux-image and linux-headers packages > + d.setVar("PROVIDES", "linux-image-" + kernel_name + " " + \ > + "linux-headers-" + kernel_name) > + > + # Set dependency for kbuild package > + d.appendVar("KERNEL_HEADERS_DEBIAN_DEPENDS", kbuild_depends) > } >=20 > -def get_kernel_arch(d): > - distro_arch =3D d.getVar("DISTRO_ARCH") > - if distro_arch in ["amd64", "i386"]: > +def get_kernel_arch(d, arch=3D"DISTRO_ARCH"): > + arch =3D d.getVar(arch) > + if arch in ["amd64", "i386"]: > kernel_arch =3D "x86" > - elif distro_arch =3D=3D "arm64": > + elif arch =3D=3D "arm64": > kernel_arch =3D "arm64" > - elif distro_arch =3D=3D "armhf": > + elif arch =3D=3D "armhf": > kernel_arch =3D "arm" > - elif distro_arch =3D=3D "mipsel": > + elif arch =3D=3D "mipsel": > kernel_arch =3D "mips" > - elif distro_arch =3D=3D "riscv64": > + elif arch =3D=3D "riscv64": > kernel_arch =3D "riscv" > else: > kernel_arch =3D "" > return kernel_arch >=20 > KERNEL_ARCH ??=3D "${@get_kernel_arch(d)}" > +KERNEL_HOST_ARCH ??=3D "${@get_kernel_arch(d, 'HOST_ARCH')}" >=20 > def config_fragments(d): > fragments =3D [] > @@ -157,6 +183,7 @@ do_prepare_build_prepend() { >=20 > # build directory for our "full" kernel build > KERNEL_BUILD_DIR =3D "build-full" > +KERNEL_KBUILD_DIR =3D "${KERNEL_BUILD_DIR}-kbuild" >=20 > def get_kernel_config_target(d): > kernel_defconfig =3D d.getVar('KERNEL_DEFCONFIG', True) > @@ -187,15 +214,19 @@ def get_kernel_config_fragments(d): > KERNEL_CONFIG_FRAGMENTS =3D "${@get_kernel_config_fragments(d)}" >=20 > dpkg_configure_kernel() { > + build_dir=3D"${KERNEL_BUILD_DIR}" > + if [ -n "${1}" ]; then > + build_dir=3D"${1}" > + fi > grep -q "KERNEL_CONFIG_TARGET=3D" ${S}/debian/isar/configure || > cat << EOF | sed -i '/^do_configure() {/ r /dev/stdin' > ${S}/debian/isar/configure > KERNEL_CONFIG_TARGET=3D"${@get_kernel_config_target(d)}" > EOF >=20 > - rm -rf ${S}/${KERNEL_BUILD_DIR} && mkdir -p ${S}/$ {KERNEL_BUILD_DIR} > + rm -rf ${S}/${build_dir} && mkdir -p ${S}/${build_dir} > if [ -n "${KERNEL_DEFCONFIG}" ]; then > if [ -e "${WORKDIR}/${KERNEL_DEFCONFIG}" ]; then > - cp ${WORKDIR}/${KERNEL_DEFCONFIG} ${S}/$ {KERNEL_BUILD_DIR}/.config > + cp ${WORKDIR}/${KERNEL_DEFCONFIG} ${S}/$ {build_dir}/.config > fi > fi >=20 > @@ -210,4 +241,53 @@ EOF >=20 > dpkg_runbuild_prepend() { > dpkg_configure_kernel > + > + if [ "${ISAR_CROSS_COMPILE}" =3D "1" ] && [ "${HOST_ARCH}" !=3D > "${DISTRO_ARCH}" ]; then + # Create temporarily kernel=20 schroot-target > configuration > + schroot_create_configs ${SCHROOT_TARGET_DIR} > + > + # Begin kernel schroot-target session > + schroot_session=3D$(schroot -b -c ${SBUILD_CHROOT}) > + > + # Install build deps for schroot session > + schroot -u root -r -c $schroot_session -- sh -c " \ > + cd ${PP}/${PPS}; \ > + mk-build-deps -i -r --host-arch $ {DISTRO_ARCH} -t \"apt-get -y > --no-install-recommends --allow-downgrades -o > Debug::pkgProblemResolver=3Dyes\" debian/control; \ + " > + > + # Create kernel configuration for kbuild > + dpkg_configure_kernel ${KERNEL_KBUILD_DIR}-target > + KERNEL_CONFIG_TARGET=3D"${@get_kernel_config_target(d)}" > + > + schroot -r -c $schroot_session -- sh -c " \ > + cd ${PP}/${PPS}; \ > + ARCH=3D${KERNEL_ARCH} make O=3D$ {KERNEL_KBUILD_DIR}-target > ${KERNEL_CONFIG_TARGET}; \ + " > + > + cd ${S} > + ARCH=3D${KERNEL_ARCH} ./scripts/kconfig/merge_config.sh -m=20 =2DO > ${KERNEL_KBUILD_DIR}-target/ ${KERNEL_KBUILD_DIR}-target/.config > ${KERNEL_CONFIG_FRAGMENTS} + cd - > + > + # Build kernel scripts and tools for target arch in a non- cross > way + # Cross building kernel scripts and tools would not provide > them in target architecture + schroot -r -c=20 $schroot_session -- sh -c " \ > + cd ${PP}/${PPS}; \ > + ARCH=3D${KERNEL_ARCH} make O=3D$ {KERNEL_KBUILD_DIR}-target olddefconfig; \ > + ARCH=3D${KERNEL_ARCH} make O=3D$ {KERNEL_KBUILD_DIR}-target ${PARALLEL_MAKE} > scripts; \ + if [ -d "tools/objtool" ]; then \ > + echo ARCH=3D${KERNEL_ARCH} make O=3D$ {KERNEL_KBUILD_DIR}-target > ${PARALLEL_MAKE} tools/objtool; \ + ARCH=3D$ {KERNEL_ARCH} make > O=3D${KERNEL_KBUILD_DIR}-target ${PARALLEL_MAKE} tools/objtool; \ + =09 fi; \ > + if grep -q "CONFIG_MODULES=3Dy" $ {KERNEL_KBUILD_DIR}-target/.config; then > \ + echo ARCH=3D${KERNEL_ARCH} make O=3D$ {KERNEL_KBUILD_DIR}-target > ${PARALLEL_MAKE} modules_prepare; \ + =09 ARCH=3D${KERNEL_ARCH} make > O=3D${KERNEL_KBUILD_DIR}-target ${PARALLEL_MAKE} modules_prepare; \ + =09 fi; \ > + " > + > + # End kernel schroot-target session > + schroot -e -c $schroot_session > + > + # Restore kernel schroot-host configuration > + schroot_create_configs > + fi > }