kernel: Rearrange for 1.8

In 1.8 we want to streamline the kernel build process. Basically we
currently have multiple copies of the kernel source floating around
and the copying/compression/decompression is painful.

Lets assume we have a kernel source per machine since in most cases
this is true (and we have a sysroot per machine anyway). Basically,
instead of extracting a source into WORKDIR, then copying to a sysroot,
we now set S to point straight at STAGING_DIR_KERNEL.

Anything using kernel source can then just point at it and use:

do_configure[depends] += "virtual/kernel:do_patch"

to depend on the kernel source being present. Note this is different
behaviour to DEPENDS += "virtual/kernel" which equates to
do_configure[depends] += "virtual/kernel:do_populate_sysroot".

Once we do this, we no longer need the copy operation in
do_populate_sysroot, in fact there is nothing to do there (yay).

The remaining part of the challenge is to kill off the horrible
do_install. This patch splits it off to a different class, the idea here
is to have a separate recipe which depends on the virtual/kernel:do_patch
and just installs and packages the source needed to build modules on
target into a specific package.

Right now this code is proof of concept. It builds kernels and kernel
modules. perf blows up in do_package with issues on finding the kernel
version which can probably be fixed by adding back the right bit of do_install,
and adding a dependency of do_package[depends] += "virtual/kernel:do_install"
to perf. The whole thing needs a good write up, the corner cases testing
and probably a good dose of cleanup to the remaining code.

(From OE-Core rev: 3b3f7e785e27990ba21bc7cd97289c826a9a95d1)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2014-10-21 21:05:30 +00:00
parent 1ff64a7e84
commit 86893e4ea5
5 changed files with 27 additions and 98 deletions

View File

@@ -3,6 +3,8 @@ inherit linux-kernel-base kernel-module-split
PROVIDES += "virtual/kernel"
DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native depmodwrapper-cross bc-native"
S = "${STAGING_DIR_TARGET}/${KERNEL_SRC_PATH}"
# we include gcc above, we dont need virtual/libc
INHIBIT_DEFAULT_DEPS = "1"
@@ -55,7 +57,7 @@ KERNEL_IMAGEDEST = "boot"
#
export CMDLINE_CONSOLE = "console=${@d.getVar("KERNEL_CONSOLE",1) or "ttyS0"}"
KERNEL_VERSION = "${@get_kernelversion('${B}')}"
KERNEL_VERSION = "${@get_kernelversion_headers('${B}')}"
KERNEL_LOCALVERSION ?= ""
@@ -221,93 +223,6 @@ kernel_do_install() {
#
echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
#
# Store kernel image name to allow use during image generation
#
echo "${KERNEL_IMAGE_BASE_NAME}" >$kerneldir/kernel-image-name
#
# Copy the entire source tree. In case an external build directory is
# used, copy the build directory over first, then copy over the source
# dir. This ensures the original Makefiles are used and not the
# redirecting Makefiles in the build directory.
#
find . -depth -not -name "*.cmd" -not -name "*.o" -not -name "*.so.dbg" -not -name "*.so" -not -path "./Documentation*" -not -path "./source*" -not -path "./.*" -print0 | cpio --null -pdlu $kerneldir
cp .config $kerneldir
if [ "${S}" != "${B}" ]; then
pwd="$PWD"
cd "${S}"
find . -depth -not -path "./Documentation*" -not -path "./.*" -print0 | cpio --null -pdlu $kerneldir
cd "$pwd"
fi
# Test to ensure that the output file and image type are not actually
# the same file. If hardlinking is used, they will be the same, and there's
# no need to install.
! [ ${KERNEL_OUTPUT} -ef $kerneldir/${KERNEL_IMAGETYPE} ] && install -m 0644 ${KERNEL_OUTPUT} $kerneldir/${KERNEL_IMAGETYPE}
install -m 0644 System.map $kerneldir/System.map-${KERNEL_VERSION}
# Dummy Makefile so the clean below works
mkdir $kerneldir/Documentation
touch $kerneldir/Documentation/Makefile
#
# Clean and remove files not needed for building modules.
# Some distributions go through a lot more trouble to strip out
# unecessary headers, for now, we just prune the obvious bits.
#
# We don't want to leave host-arch binaries in /sysroots, so
# we clean the scripts dir while leaving the generated config
# and include files.
#
oe_runmake -C $kerneldir CC="${KERNEL_CC}" LD="${KERNEL_LD}" clean _mrproper_scripts
# hide directories that shouldn't have their .c, s and S files deleted
for d in tools scripts lib; do
mv $kerneldir/$d $kerneldir/.$d
done
# delete .c, .s and .S files, unless we hid a directory as .<dir>. This technique is
# much faster than find -prune and -exec
find $kerneldir -not -path '*/\.*' -type f -name "*.[csS]" -delete
# put the hidden dirs back
for d in tools scripts lib; do
mv $kerneldir/.$d $kerneldir/$d
done
# 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
cp -l arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o
fi
# Necessary for building modules like compat-wireless.
if [ -f include/generated/bounds.h ]; then
cp -l include/generated/bounds.h $kerneldir/include/generated/bounds.h
fi
if [ -d arch/${ARCH}/include/generated ]; then
mkdir -p $kerneldir/arch/${ARCH}/include/generated/
cp -flR arch/${ARCH}/include/generated/* $kerneldir/arch/${ARCH}/include/generated/
fi
# Remove the following binaries which cause strip or arch QA errors
# during do_package for cross-compiled platforms
bin_files="arch/powerpc/boot/addnote arch/powerpc/boot/hack-coff \
arch/powerpc/boot/mktree scripts/kconfig/zconf.tab.o \
scripts/kconfig/conf.o scripts/kconfig/kxgettext.o"
for entry in $bin_files; do
rm -f $kerneldir/$entry
done
# kernels <2.6.30 don't have $kerneldir/tools directory so we check if it exists before calling sed
if [ -f $kerneldir/tools/perf/Makefile ]; then
# Fix SLANG_INC for slang.h
sed -i 's#-I/usr/include/slang#-I=/usr/include/slang#g' $kerneldir/tools/perf/Makefile
fi
}
do_install[prefuncs] += "package_get_auto_pr"