<div dir="ltr">Sorry, but this breaks on ARM:<br><br>ERROR: kernel-devsrc-1.0-r0 do_install: Function failed: do_install (log file is located at /home/pokybuild/yocto-autobuilder/yocto-worker/nightly-arm/build/build/tmp/work/qemuarm-poky-linux-gnueabi/kernel-devsrc/1.0-r0/temp/log.do_install.25822)<br>ERROR: Logfile of failure stored in: /home/pokybuild/yocto-autobuilder/yocto-worker/nightly-arm/build/build/tmp/work/qemuarm-poky-linux-gnueabi/kernel-devsrc/1.0-r0/temp/log.do_install.25822<br>Log data follows:<br>| DEBUG: Executing shell function do_install<br>| cp: with --parents, the destination must be a directory<br>| Try &#39;cp --help&#39; for more information.<br>| WARNING: /home/pokybuild/yocto-autobuilder/yocto-worker/nightly-arm/build/build/tmp/work/qemuarm-poky-linux-gnueabi/kernel-devsrc/1.0-r0/temp/run.do_install.25822:1 exit 1 from &#39;rm -rf $kerneldir/build/include&#39;<br>| ERROR: Function failed: do_install (log file is located at /home/pokybuild/yocto-autobuilder/yocto-worker/nightly-arm/build/build/tmp/work/qemuarm-poky-linux-gnueabi/kernel-devsrc/1.0-r0/temp/log.do_install.25822)<div><br></div><div>Ross</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 28 February 2018 at 02:06, Bruce Ashfield <span dir="ltr">&lt;<a href="mailto:bruce.ashfield@windriver.com" target="_blank">bruce.ashfield@windriver.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The existing kernel-devsrc package starts with a full copy of the kernel<br>
source and then starts to strip out elements that are not required.<br>
<br>
This results in extra time (I/O) and extra space being taken up in the<br>
final package. The main purpose of the kernel-devsrc package has been to<br>
build modules against the running kernel, not to include a full copy of<br>
the source code for re-building the kernel. The end result was a<br>
600M kernel-devsrc package.<br>
<br>
This restructuring of the package uses an approach similar to other<br>
distros, where the kernel-devsrc package is for building against the<br>
running kernel and uses a curated set of copied infrastructure, versus<br>
a mass copy of the entire kernel.<br>
<br>
The differences in this approach versus other is largely due to the<br>
architecture support and the split build/source directory of the<br>
kernel.<br>
<br>
The result is a kernel-devsrc package of about 10M, which is capable<br>
of running &quot;make scripts&quot; and compiling kernel modules against the<br>
running kernel.<br>
<br>
Along with the changes to the copying of the infrascture, we also<br>
have the following changes:<br>
<br>
 - a better/more explicit listing of dependencies for on-target<br>
   builds of &quot;make scripts&quot; or &quot;make modules_prepare&quot;<br>
<br>
 - The kernel source is installed into /lib/modules/&lt;version&gt;/build<br>
   and a symlink created from /usr/src/kernel to the new location.<br>
   This aligns with the standard location for module support<br>
   code<br>
<br>
 - There is also a symlink from /lib/modules/&lt;version&gt;/source -&gt; build<br>
   to reserve a spot for a new package that is simply the kernel<br>
   source. That package is not part of this update.<br>
<br>
[YOCTO #12535]<br>
<br>
Signed-off-by: Bruce Ashfield &lt;<a href="mailto:bruce.ashfield@windriver.com">bruce.ashfield@windriver.com</a>&gt;<br>
---<br>
 meta/recipes-kernel/linux/<a href="http://kernel-devsrc.bb" rel="noreferrer" target="_blank">kern<wbr>el-devsrc.bb</a> | 178 ++++++++++++++++++++++-------<br>
 1 file changed, 138 insertions(+), 40 deletions(-)<br>
<br>
diff --git a/meta/recipes-kernel/linux/<a href="http://kernel-devsrc.bb" rel="noreferrer" target="_blank">ke<wbr>rnel-devsrc.bb</a> b/meta/recipes-kernel/linux/<a href="http://kernel-devsrc.bb" rel="noreferrer" target="_blank">ke<wbr>rnel-devsrc.bb</a><br>
index c1b5b7786d7c..f55b115e0936 100644<br>
--- a/meta/recipes-kernel/linux/<a href="http://kernel-devsrc.bb" rel="noreferrer" target="_blank">ke<wbr>rnel-devsrc.bb</a><br>
+++ b/meta/recipes-kernel/linux/<a href="http://kernel-devsrc.bb" rel="noreferrer" target="_blank">ke<wbr>rnel-devsrc.bb</a><br>
@@ -30,50 +30,148 @@ do_populate_sysroot[noexec] = &quot;1&quot;<br>
 S = &quot;${STAGING_KERNEL_DIR}&quot;<br>
 B = &quot;${STAGING_KERNEL_BUILDDIR}&quot;<br>
<br>
-KERNEL_VERSION = &quot;${@get_kernelversion_headers(<wbr>&#39;${S}&#39;)}&quot;<br>
-<br>
 PACKAGE_ARCH = &quot;${MACHINE_ARCH}&quot;<br>
<br>
+KERNEL_BUILD_ROOT=&quot;/lib/<wbr>modules/&quot;<br>
+<br>
 do_install() {<br>
-        kerneldir=${D}${KERNEL_SRC_<wbr>PATH}<br>
-        install -d $kerneldir<br>
-<br>
-        #<br>
-        # Copy the staging dir source (and module build support) into the devsrc structure.<br>
-        # We can keep this copy simple and take everything, since a we&#39;ll clean up any build<br>
-        # artifacts afterwards, and the extra i/o is not significant<br>
-        #<br>
-        cd ${B}<br>
-        find . -type d -name &#39;.git*&#39; -prune -o -path &#39;.debug&#39; -prune -o -type f -print0 | cpio --null -pdlu $kerneldir<br>
-        cd ${S}<br>
-       find . -type d -name &#39;.git*&#39; -prune -o -type d -name &#39;.kernel-meta&#39; -prune -o -type f -print0 | cpio --null -pdlu $kerneldir<br>
-<br>
-        # Explicitly set KBUILD_OUTPUT to ensure that the image directory is cleaned and not<br>
-        # The main build artifacts. We clean the directory to avoid QA errors on mismatched<br>
-        # architecture (since scripts and helpers are native format).<br>
-        KBUILD_OUTPUT=&quot;$kerneldir&quot;<br>
-        oe_runmake -C $kerneldir CC=&quot;${KERNEL_CC}&quot; LD=&quot;${KERNEL_LD}&quot; clean _mrproper_scripts<br>
-        # make clean generates an absolute path symlink called &quot;source&quot;<br>
-        # in $kerneldir points to $kerneldir, which doesn&#39;t make any<br>
-        # sense, so remove it.<br>
-        if [ -L $kerneldir/source ]; then<br>
-            bbnote &quot;Removing $kerneldir/source symlink&quot;<br>
-            rm -f $kerneldir/source<br>
-        fi<br>
-<br>
-        # As of Linux kernel version 3.0.1, the clean target removes<br>
-        # arch/powerpc/lib/crtsavres.o which is present in<br>
-        # KBUILD_LDFLAGS_MODULE, making it required to build external modules.<br>
-        if [ ${ARCH} = &quot;powerpc&quot; ]; then<br>
-                mkdir -p $kerneldir/arch/powerpc/lib/<br>
-                cp ${B}/arch/powerpc/lib/<wbr>crtsavres.o $kerneldir/arch/powerpc/lib/<wbr>crtsavres.o<br>
-        fi<br>
-<br>
-        chown -R root:root ${D}<br>
+    kerneldir=${D}${KERNEL_BUILD_<wbr>ROOT}${KERNEL_VERSION}<br>
+    install -d $kerneldir<br>
+<br>
+    # create the directory structure<br>
+    rm -f $kerneldir/build<br>
+    rm -f $kerneldir/source<br>
+    mkdir -p $kerneldir/build<br>
+<br>
+    # for compatibility with some older variants of this package, we<br>
+    # create  a /usr/src/kernel symlink to /lib/modules/&lt;version&gt;/source<br>
+    mkdir -p ${D}/usr/src<br>
+    (<br>
+       cd ${D}/usr/src<br>
+       ln -s ${KERNEL_BUILD_ROOT}${KERNEL_<wbr>VERSION}/source kernel<br>
+    )<br>
+<br>
+    # for on target purposes, we unify build and source<br>
+    (<br>
+       cd $kerneldir<br>
+       ln -s build source<br>
+    )<br>
+<br>
+    # first copy everything<br>
+    (<br>
+       cd ${S}<br>
+       cp --parents $(find  -type f -name &quot;Makefile*&quot; -o -name &quot;Kconfig*&quot;) $kerneldir/build<br>
+    )<br>
+<br>
+    # then drop all but the needed Makefiles/Kconfig files<br>
+    rm -rf $kerneldir/build/Documentation<br>
+    rm -rf $kerneldir/build/scripts<br>
+    rm -rf $kerneldir/build/include<br>
+<br>
+    # now copy in parts from the build that we&#39;ll need later<br>
+    (<br>
+       cd ${B}<br>
+<br>
+       cp Module.symvers $kerneldir/build<br>
+       cp System.map* $kerneldir/build<br>
+       if [ -s Module.markers ]; then<br>
+           cp Module.markers $kerneldir/build<br>
+       fi<br>
+<br>
+       cp .config $kerneldir/build<br>
+<br>
+       # TODO: this scripts copy will likely blow up QA, so for now, we<br>
+       #       require a more complex &#39;make scripts&#39; to restore these, versus<br>
+       #       copying them here. Left as a reference to indicate that we<br>
+       #       know the scripts must be dealt with.<br>
+       # cp -a scripts $kerneldir/build<br>
+<br>
+       if [ -f tools/objtool/objtool ]; then<br>
+           cp -a tools/objtool/objtool $kerneldir/build/tools/<wbr>objtool/<br>
+       fi<br>
+       if [ -d arch/${ARCH}/scripts ]; then<br>
+           cp -a arch/${ARCH}/scripts $kerneldir/build/arch/${ARCH}<br>
+       fi<br>
+       if [ -f arch/${ARCH}/*lds ]; then<br>
+           cp -a arch/${ARCH}/*lds $kerneldir/build/arch/${ARCH}<br>
+       fi<br>
+<br>
+       rm -f $kerneldir/build/scripts/*.o<br>
+       rm -f $kerneldir/build/scripts/*/*.o<br>
+<br>
+       if [ &quot;${ARCH}&quot; = &quot;powerpc&quot; ]; then<br>
+           cp -a --parents arch/powerpc/lib/crtsavres.[<wbr>So] $kerneldir/build/<br>
+       fi<br>
+<br>
+       cp -a include $kerneldir/build/include<br>
+    )<br>
+<br>
+    # now grab the chunks from the source tree that we need<br>
+    (<br>
+       cd ${S}<br>
+<br>
+       cp -a scripts $kerneldir/build<br>
+       if [ &quot;${ARCH}&quot; = &quot;arm64&quot; ]; then<br>
+           # arch/arm64/include/asm/xen references arch/arm<br>
+           cp -a --parents arch/arm/include/asm/xen $kerneldir/build/<br>
+           # arch/arm64/include/asm/<wbr>opcodes.h references arch/arm<br>
+           cp -a --parents arch/arm/include/asm/opcodes.h $kerneldir/build/<br>
+       fi<br>
+<br>
+       # include the machine specific headers for ARM variants, if available.<br>
+       if [ &quot;${ARCH}&quot; = &quot;arm&quot; ]; then<br>
+           cp -a --parents arch/${ARCH}/mach-*/include $kerneldir/build/<br>
+<br>
+           # include a few files for &#39;make prepare&#39;<br>
+           cp -a --parents arch/arm/tools/gen-mach-types $RPM_BUILD_ROOT/lib/modules/$<wbr>KernelVer/build/<br>
+           cp -a --parents arch/arm/tools/mach-types $RPM_BUILD_ROOT/lib/modules/$<wbr>KernelVer/build/<br>
+       fi<br>
+<br>
+       if [ -d arch/${ARCH}/include ]; then<br>
+           cp -a --parents arch/${ARCH}/include $kerneldir/build/<br>
+       fi<br>
+<br>
+       cp -a include $kerneldir/build<br>
+<br>
+       if [ &quot;${ARCH}&quot; = &quot;x86&quot; ]; then<br>
+           # files for &#39;make prepare&#39; to succeed with kernel-devel<br>
+           cp -a --parents arch/x86/entry/syscalls/<wbr>syscall_32.tbl $kerneldir/build/<br>
+           cp -a --parents arch/x86/entry/syscalls/<wbr>syscalltbl.sh $kerneldir/build/<br>
+           cp -a --parents arch/x86/entry/syscalls/<wbr>syscallhdr.sh $kerneldir/build/<br>
+           cp -a --parents arch/x86/entry/syscalls/<wbr>syscall_64.tbl $kerneldir/build/<br>
+           cp -a --parents arch/x86/tools/relocs_32.c $kerneldir/build/<br>
+           cp -a --parents arch/x86/tools/relocs_64.c $kerneldir/build/<br>
+           cp -a --parents arch/x86/tools/relocs.c $kerneldir/build/<br>
+           cp -a --parents arch/x86/tools/relocs_common.c $kerneldir/build/<br>
+           cp -a --parents arch/x86/tools/relocs.h $kerneldir/build/<br>
+           cp -a --parents tools/include/tools/le_<wbr>byteshift.h $kerneldir/build/<br>
+           cp -a --parents tools/include/tools/be_<wbr>byteshift.h $kerneldir/build/<br>
+           cp -a --parents arch/x86/purgatory/purgatory.c $kerneldir/build/<br>
+           cp -a --parents arch/x86/purgatory/sha256.h $kerneldir/build/<br>
+           cp -a --parents arch/x86/purgatory/sha256.c $kerneldir/build/<br>
+           cp -a --parents arch/x86/purgatory/stack.S $kerneldir/build/<br>
+           cp -a --parents arch/x86/purgatory/string.c $kerneldir/build/<br>
+           cp -a --parents arch/x86/purgatory/setup-x86_<wbr>64.S $kerneldir/build/<br>
+           cp -a --parents arch/x86/purgatory/entry64.S $kerneldir/build/<br>
+           cp -a --parents arch/x86/boot/string.h $kerneldir/build/<br>
+           cp -a --parents arch/x86/boot/string.c $kerneldir/build/<br>
+           cp -a --parents arch/x86/boot/ctype.h $kerneldir/build/<br>
+       fi<br>
+    )<br>
+<br>
+    # Make sure the Makefile and version.h have a matching timestamp so that<br>
+    # external modules can be built<br>
+    touch -r $kerneldir/build/Makefile $kerneldir/build/include/<wbr>generated/uapi/linux/version.h<br>
+<br>
+    # Copy .config to include/config/auto.conf so &quot;make prepare&quot; is unnecessary.<br>
+    cp $kerneldir/build/.config $kerneldir/build/include/<wbr>config/auto.conf<br>
+<br>
+    chown -R root:root ${D}<br>
 }<br>
+<br>
 # Ensure we don&#39;t race against &quot;make scripts&quot; during cpio<br>
 do_install[lockfiles] = &quot;${TMPDIR}/kernel-scripts.<wbr>lock&quot;<br>
<br>
-PACKAGES = &quot;kernel-devsrc&quot;<br>
-FILES_${PN} = &quot;${KERNEL_SRC_PATH}&quot;<br>
-RDEPENDS_${PN} = &quot;bc&quot;<br>
+FILES_${PN} = &quot;${KERNEL_BUILD_ROOT} ${KERNEL_SRC_PATH}&quot;<br>
+FILES_${PN}-dbg += &quot;${KERNEL_BUILD_ROOT}*/build/<wbr>scripts/*/.debug/*&quot;<br>
+RDEPENDS_${PN} = &quot;bc glibc-utils&quot;<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.0<br>
<br>
</font></span></blockquote></div><br></div>