kernel-devsrc: add new recipe and add into inf image 12/3112/1
authorJackie Huang <jackie.huang@windriver.com>
Thu, 2 Apr 2020 07:15:59 +0000 (15:15 +0800)
committerJackie Huang <jackie.huang@windriver.com>
Thu, 2 Apr 2020 09:17:08 +0000 (17:17 +0800)
The original recipe is copied from oe-core, which is only
capable of running "make scripts" and compiling kernel
modules against the running kernel on target.

We need the support to rebuild the kernel as well, so
do the following changes:
- Extend the ability of the recipe so it can rebuild kernel
- Add the one in oe-core into bbmask
- Add required kernel packages into packagegroup-oran

Issue-ID: INF-21
Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
Change-Id: I2a6d6a87f5956d3f5d8da8150407df107dd42b17

meta-oran/conf/distro/oran-inf.conf
meta-oran/recipes-base/packagegroups/packagegroup-oran.bb
meta-oran/recipes-kernel/linux/kernel-devsrc.bb [new file with mode: 0644]

index 6cc1f28..2582109 100644 (file)
@@ -51,3 +51,7 @@ IMAGE_FSTYPES += "tar.bz2 wic.qcow2"
 
 # Use the default splash
 SYSLINUX_SPLASH = ""
+
+# The recipe in oe-core is only capable of running "make scripts" and compiling
+# kernel modules, so add it into bbmask and use the one in meta-oran
+BBMASK += "/oe-core/meta/recipes-kernel/linux/kernel-devsrc.bb"
index 6c9d672..175dfcd 100644 (file)
@@ -26,6 +26,7 @@ PROVIDES = "${PACKAGES}"
 PACKAGES += " \
     ${PN}-base \
     ${PN}-docker \
+    ${PN}-kernel \
     ${PN}-k8s \
     ${PN}-vm \
     ${PN}-trace-tools \
@@ -36,6 +37,7 @@ PACKAGES += " \
 RDEPENDS_${PN} = "\
     ${PN}-base \
     ${PN}-docker \
+    ${PN}-kernel \
     ${PN}-k8s \
     ${PN}-vm \
     ${PN}-trace-tools \
@@ -56,6 +58,13 @@ RDEPENDS_${PN}-docker = "\
     docker-registry \
 "
 
+RDEPENDS_${PN}-kernel = "\
+    kernel-base \
+    kernel-dev \
+    kernel-devsrc \
+    kernel-modules \
+    kernel-vmlinux \
+"
 RDEPENDS_${PN}-k8s = "\
     cni \
     flannel \
diff --git a/meta-oran/recipes-kernel/linux/kernel-devsrc.bb b/meta-oran/recipes-kernel/linux/kernel-devsrc.bb
new file mode 100644 (file)
index 0000000..0e1a43b
--- /dev/null
@@ -0,0 +1,89 @@
+SUMMARY = "Linux kernel Development Source"
+DESCRIPTION = "Development source linux kernel. When built, this recipe packages the \
+source of the preferred virtual/kernel provider and makes it available for full kernel \
+development or external module builds"
+
+SECTION = "kernel"
+
+LICENSE = "GPLv2"
+
+inherit linux-kernel-base
+
+# Whilst not a module, this ensures we don't get multilib extended (which would make no sense)
+inherit module-base
+
+# We need the kernel to be staged (unpacked, patched and configured) before
+# we can grab the source and make the source package. We also need the bits from
+# ${B} not to change while we install, so virtual/kernel must finish do_compile.
+do_install[depends] += "virtual/kernel:do_shared_workdir"
+# Need the source, not just the output of populate_sysroot
+do_install[depends] += "virtual/kernel:do_install"
+
+# There's nothing to do here, except install the source where we can package it
+do_fetch[noexec] = "1"
+do_unpack[noexec] = "1"
+do_patch[noexec] = "1"
+do_configure[noexec] = "1"
+do_compile[noexec] = "1"
+do_populate_sysroot[noexec] = "1"
+
+S = "${STAGING_KERNEL_DIR}"
+B = "${STAGING_KERNEL_BUILDDIR}"
+
+KERNEL_VERSION = "${@get_kernelversion_headers('${S}')}"
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+do_install() {
+        kerneldir=${D}${KERNEL_SRC_PATH}
+        install -d $kerneldir
+
+        #
+        # Copy the staging dir source (and module build support) into the devsrc structure.
+        # We can keep this copy simple and take everything, since a we'll clean up any build
+        # artifacts afterwards, and the extra i/o is not significant
+        #
+        cd ${B}
+        find . -type d -name '.git*' -prune -o -path '.debug' -prune -o -type f -print0 | cpio --null -pdlu $kerneldir
+        cd ${S}
+        find . -type d -name '.git*' -prune -o -type d -name '.kernel-meta' -prune -o -type f -print0 | cpio --null -pdlu $kerneldir
+
+        # Explicitly set KBUILD_OUTPUT to ensure that the image directory is cleaned and not
+        # The main build artifacts. We clean the directory to avoid QA errors on mismatched
+        # architecture (since scripts and helpers are native format).
+        KBUILD_OUTPUT="$kerneldir"
+        oe_runmake -C $kerneldir CC="${KERNEL_CC}" LD="${KERNEL_LD}" clean _mrproper_scripts
+
+        # make clean generates an absolute path symlink called "source"
+        # in $kerneldir points to $kerneldir, which doesn't make any
+        # sense, so remove it.
+        if [ -L $kerneldir/source ]; then
+            bbnote "Removing $kerneldir/source symlink"
+            rm -f $kerneldir/source
+        fi
+
+        # As of Linux kernel version 3.0.1, the clean target removes
+        # arch/powerpc/lib/crtsavres.o which is present in
+        # KBUILD_LDFLAGS_MODULE, making it required to build external modules.
+        if [ ${ARCH} = "powerpc" ]; then
+                mkdir -p $kerneldir/arch/powerpc/lib/
+                cp ${B}/arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o
+        fi
+
+        # Remove fixdep/objtool as they won't be target binaries
+        for i in fixdep objtool; do
+                if [ -e $kerneldir/tools/objtool/$i ]; then
+                        rm -rf $kerneldir/tools/objtool/$i
+                fi
+        done
+
+        chown -R root:root ${D}
+}
+# Ensure we don't race against "make scripts" during cpio
+do_install[lockfiles] = "${TMPDIR}/kernel-scripts.lock"
+
+PACKAGES = "kernel-devsrc"
+FILES_${PN} = "${KERNEL_SRC_PATH}"
+RDEPENDS_${PN} = "bc"
+
+INSANE_SKIP_${PN} = "arch"