diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-10-21 21:05:30 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-12-21 12:37:53 +0000 |
| commit | 86893e4ea5896199a6f02f8475f4f17aa1124c37 (patch) | |
| tree | 8991c2825bdf69b41c8b30ff00db68663566209e | |
| parent | 1ff64a7e848dcdd540e1c60acec1d0ad80a642bb (diff) | |
| download | poky-86893e4ea5896199a6f02f8475f4f17aa1124c37.tar.gz | |
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>
| -rw-r--r-- | meta/classes/kernel-yocto.bbclass | 2 | ||||
| -rw-r--r-- | meta/classes/kernel.bbclass | 91 | ||||
| -rw-r--r-- | meta/classes/kernelsrc.bbclass | 7 | ||||
| -rw-r--r-- | meta/classes/linux-kernel-base.bbclass | 13 | ||||
| -rw-r--r-- | meta/recipes-kernel/perf/perf.bb | 12 |
5 files changed, 27 insertions, 98 deletions
diff --git a/meta/classes/kernel-yocto.bbclass b/meta/classes/kernel-yocto.bbclass index c3e24943bb..45bdc9670a 100644 --- a/meta/classes/kernel-yocto.bbclass +++ b/meta/classes/kernel-yocto.bbclass | |||
| @@ -1,5 +1,3 @@ | |||
| 1 | S = "${WORKDIR}/linux" | ||
| 2 | |||
| 3 | # remove tasks that modify the source tree in case externalsrc is inherited | 1 | # remove tasks that modify the source tree in case externalsrc is inherited |
| 4 | SRCTREECOVEREDTASKS += "do_kernel_link_vmlinux do_kernel_configme do_validate_branches do_kernel_configcheck do_kernel_checkout do_patch" | 2 | SRCTREECOVEREDTASKS += "do_kernel_link_vmlinux do_kernel_configme do_validate_branches do_kernel_configcheck do_kernel_checkout do_patch" |
| 5 | 3 | ||
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass index 70ed95bbe0..bca34f4698 100644 --- a/meta/classes/kernel.bbclass +++ b/meta/classes/kernel.bbclass | |||
| @@ -3,6 +3,8 @@ inherit linux-kernel-base kernel-module-split | |||
| 3 | PROVIDES += "virtual/kernel" | 3 | PROVIDES += "virtual/kernel" |
| 4 | DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native depmodwrapper-cross bc-native" | 4 | DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native depmodwrapper-cross bc-native" |
| 5 | 5 | ||
| 6 | S = "${STAGING_DIR_TARGET}/${KERNEL_SRC_PATH}" | ||
| 7 | |||
| 6 | # we include gcc above, we dont need virtual/libc | 8 | # we include gcc above, we dont need virtual/libc |
| 7 | INHIBIT_DEFAULT_DEPS = "1" | 9 | INHIBIT_DEFAULT_DEPS = "1" |
| 8 | 10 | ||
| @@ -55,7 +57,7 @@ KERNEL_IMAGEDEST = "boot" | |||
| 55 | # | 57 | # |
| 56 | export CMDLINE_CONSOLE = "console=${@d.getVar("KERNEL_CONSOLE",1) or "ttyS0"}" | 58 | export CMDLINE_CONSOLE = "console=${@d.getVar("KERNEL_CONSOLE",1) or "ttyS0"}" |
| 57 | 59 | ||
| 58 | KERNEL_VERSION = "${@get_kernelversion('${B}')}" | 60 | KERNEL_VERSION = "${@get_kernelversion_headers('${B}')}" |
| 59 | 61 | ||
| 60 | KERNEL_LOCALVERSION ?= "" | 62 | KERNEL_LOCALVERSION ?= "" |
| 61 | 63 | ||
| @@ -221,93 +223,6 @@ kernel_do_install() { | |||
| 221 | # | 223 | # |
| 222 | 224 | ||
| 223 | echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion | 225 | echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion |
| 224 | |||
| 225 | # | ||
| 226 | # Store kernel image name to allow use during image generation | ||
| 227 | # | ||
| 228 | |||
| 229 | echo "${KERNEL_IMAGE_BASE_NAME}" >$kerneldir/kernel-image-name | ||
| 230 | |||
| 231 | # | ||
| 232 | # Copy the entire source tree. In case an external build directory is | ||
| 233 | # used, copy the build directory over first, then copy over the source | ||
| 234 | # dir. This ensures the original Makefiles are used and not the | ||
| 235 | # redirecting Makefiles in the build directory. | ||
| 236 | # | ||
| 237 | 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 | ||
| 238 | cp .config $kerneldir | ||
| 239 | if [ "${S}" != "${B}" ]; then | ||
| 240 | pwd="$PWD" | ||
| 241 | cd "${S}" | ||
| 242 | find . -depth -not -path "./Documentation*" -not -path "./.*" -print0 | cpio --null -pdlu $kerneldir | ||
| 243 | cd "$pwd" | ||
| 244 | fi | ||
| 245 | |||
| 246 | # Test to ensure that the output file and image type are not actually | ||
| 247 | # the same file. If hardlinking is used, they will be the same, and there's | ||
| 248 | # no need to install. | ||
| 249 | ! [ ${KERNEL_OUTPUT} -ef $kerneldir/${KERNEL_IMAGETYPE} ] && install -m 0644 ${KERNEL_OUTPUT} $kerneldir/${KERNEL_IMAGETYPE} | ||
| 250 | install -m 0644 System.map $kerneldir/System.map-${KERNEL_VERSION} | ||
| 251 | |||
| 252 | # Dummy Makefile so the clean below works | ||
| 253 | mkdir $kerneldir/Documentation | ||
| 254 | touch $kerneldir/Documentation/Makefile | ||
| 255 | |||
| 256 | # | ||
| 257 | # Clean and remove files not needed for building modules. | ||
| 258 | # Some distributions go through a lot more trouble to strip out | ||
| 259 | # unecessary headers, for now, we just prune the obvious bits. | ||
| 260 | # | ||
| 261 | # We don't want to leave host-arch binaries in /sysroots, so | ||
| 262 | # we clean the scripts dir while leaving the generated config | ||
| 263 | # and include files. | ||
| 264 | # | ||
| 265 | oe_runmake -C $kerneldir CC="${KERNEL_CC}" LD="${KERNEL_LD}" clean _mrproper_scripts | ||
| 266 | |||
| 267 | # hide directories that shouldn't have their .c, s and S files deleted | ||
| 268 | for d in tools scripts lib; do | ||
| 269 | mv $kerneldir/$d $kerneldir/.$d | ||
| 270 | done | ||
| 271 | |||
| 272 | # delete .c, .s and .S files, unless we hid a directory as .<dir>. This technique is | ||
| 273 | # much faster than find -prune and -exec | ||
| 274 | find $kerneldir -not -path '*/\.*' -type f -name "*.[csS]" -delete | ||
| 275 | |||
| 276 | # put the hidden dirs back | ||
| 277 | for d in tools scripts lib; do | ||
| 278 | mv $kerneldir/.$d $kerneldir/$d | ||
| 279 | done | ||
| 280 | |||
| 281 | # As of Linux kernel version 3.0.1, the clean target removes | ||
| 282 | # arch/powerpc/lib/crtsavres.o which is present in | ||
| 283 | # KBUILD_LDFLAGS_MODULE, making it required to build external modules. | ||
| 284 | if [ ${ARCH} = "powerpc" ]; then | ||
| 285 | cp -l arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o | ||
| 286 | fi | ||
| 287 | |||
| 288 | # Necessary for building modules like compat-wireless. | ||
| 289 | if [ -f include/generated/bounds.h ]; then | ||
| 290 | cp -l include/generated/bounds.h $kerneldir/include/generated/bounds.h | ||
| 291 | fi | ||
| 292 | if [ -d arch/${ARCH}/include/generated ]; then | ||
| 293 | mkdir -p $kerneldir/arch/${ARCH}/include/generated/ | ||
| 294 | cp -flR arch/${ARCH}/include/generated/* $kerneldir/arch/${ARCH}/include/generated/ | ||
| 295 | fi | ||
| 296 | |||
| 297 | # Remove the following binaries which cause strip or arch QA errors | ||
| 298 | # during do_package for cross-compiled platforms | ||
| 299 | bin_files="arch/powerpc/boot/addnote arch/powerpc/boot/hack-coff \ | ||
| 300 | arch/powerpc/boot/mktree scripts/kconfig/zconf.tab.o \ | ||
| 301 | scripts/kconfig/conf.o scripts/kconfig/kxgettext.o" | ||
| 302 | for entry in $bin_files; do | ||
| 303 | rm -f $kerneldir/$entry | ||
| 304 | done | ||
| 305 | |||
| 306 | # kernels <2.6.30 don't have $kerneldir/tools directory so we check if it exists before calling sed | ||
| 307 | if [ -f $kerneldir/tools/perf/Makefile ]; then | ||
| 308 | # Fix SLANG_INC for slang.h | ||
| 309 | sed -i 's#-I/usr/include/slang#-I=/usr/include/slang#g' $kerneldir/tools/perf/Makefile | ||
| 310 | fi | ||
| 311 | } | 226 | } |
| 312 | do_install[prefuncs] += "package_get_auto_pr" | 227 | do_install[prefuncs] += "package_get_auto_pr" |
| 313 | 228 | ||
diff --git a/meta/classes/kernelsrc.bbclass b/meta/classes/kernelsrc.bbclass new file mode 100644 index 0000000000..11f04e9612 --- /dev/null +++ b/meta/classes/kernelsrc.bbclass | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | S = "${STAGING_KERNEL_DIR}" | ||
| 2 | do_unpack[depends] += "virtual/kernel:do_patch" | ||
| 3 | do_package[depends] += "virtual/kernel:do_populate_sysroot" | ||
| 4 | KERNEL_VERSION = "${@get_kernelversion_file("${S}")}" | ||
| 5 | |||
| 6 | inherit linux-kernel-base | ||
| 7 | |||
diff --git a/meta/classes/linux-kernel-base.bbclass b/meta/classes/linux-kernel-base.bbclass index 4f2b0a4a98..89ce71605c 100644 --- a/meta/classes/linux-kernel-base.bbclass +++ b/meta/classes/linux-kernel-base.bbclass | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | # parse kernel ABI version out of <linux/version.h> | 1 | # parse kernel ABI version out of <linux/version.h> |
| 2 | def get_kernelversion(p): | 2 | def get_kernelversion_headers(p): |
| 3 | import re | 3 | import re |
| 4 | 4 | ||
| 5 | fn = p + '/include/linux/utsrelease.h' | 5 | fn = p + '/include/linux/utsrelease.h' |
| @@ -9,7 +9,6 @@ def get_kernelversion(p): | |||
| 9 | if not os.path.isfile(fn): | 9 | if not os.path.isfile(fn): |
| 10 | fn = p + '/include/linux/version.h' | 10 | fn = p + '/include/linux/version.h' |
| 11 | 11 | ||
| 12 | import re | ||
| 13 | try: | 12 | try: |
| 14 | f = open(fn, 'r') | 13 | f = open(fn, 'r') |
| 15 | except IOError: | 14 | except IOError: |
| @@ -24,6 +23,16 @@ def get_kernelversion(p): | |||
| 24 | return m.group(1) | 23 | return m.group(1) |
| 25 | return None | 24 | return None |
| 26 | 25 | ||
| 26 | |||
| 27 | def get_kernelversion_file(p): | ||
| 28 | fn = p + '/kernel-abiversion' | ||
| 29 | |||
| 30 | try: | ||
| 31 | with open(fn, 'r') as f: | ||
| 32 | return f.readlines()[0].strip() | ||
| 33 | except IOError: | ||
| 34 | return None | ||
| 35 | |||
| 27 | def linux_module_packages(s, d): | 36 | def linux_module_packages(s, d): |
| 28 | suffix = "" | 37 | suffix = "" |
| 29 | return " ".join(map(lambda s: "kernel-module-%s%s" % (s.lower().replace('_', '-').replace('@', '+'), suffix), s.split())) | 38 | return " ".join(map(lambda s: "kernel-module-%s%s" % (s.lower().replace('_', '-').replace('@', '+'), suffix), s.split())) |
diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/perf.bb index 3771cdb3e9..d375e246ce 100644 --- a/meta/recipes-kernel/perf/perf.bb +++ b/meta/recipes-kernel/perf/perf.bb | |||
| @@ -22,7 +22,7 @@ TUI_DEPENDS = "${@perf_feature_enabled('perf-tui', 'libnewt slang', '',d)}" | |||
| 22 | SCRIPTING_DEPENDS = "${@perf_feature_enabled('perf-scripting', 'perl python', '',d)}" | 22 | SCRIPTING_DEPENDS = "${@perf_feature_enabled('perf-scripting', 'perl python', '',d)}" |
| 23 | LIBUNWIND_DEPENDS = "${@perf_feature_enabled('perf-libunwind', 'libunwind', '',d)}" | 23 | LIBUNWIND_DEPENDS = "${@perf_feature_enabled('perf-libunwind', 'libunwind', '',d)}" |
| 24 | 24 | ||
| 25 | DEPENDS = "virtual/kernel \ | 25 | DEPENDS = " \ |
| 26 | virtual/${MLPREFIX}libc \ | 26 | virtual/${MLPREFIX}libc \ |
| 27 | ${MLPREFIX}elfutils \ | 27 | ${MLPREFIX}elfutils \ |
| 28 | ${MLPREFIX}binutils \ | 28 | ${MLPREFIX}binutils \ |
| @@ -32,6 +32,8 @@ DEPENDS = "virtual/kernel \ | |||
| 32 | bison flex \ | 32 | bison flex \ |
| 33 | " | 33 | " |
| 34 | 34 | ||
| 35 | do_configure[depends] += "virtual/kernel:do_patch" | ||
| 36 | |||
| 35 | PROVIDES = "virtual/perf" | 37 | PROVIDES = "virtual/perf" |
| 36 | 38 | ||
| 37 | inherit linux-kernel-base kernel-arch pythonnative | 39 | inherit linux-kernel-base kernel-arch pythonnative |
| @@ -46,7 +48,7 @@ export HOST_SYS | |||
| 46 | #kernel 3.1+ supports WERROR to disable warnings as errors | 48 | #kernel 3.1+ supports WERROR to disable warnings as errors |
| 47 | export WERROR = "0" | 49 | export WERROR = "0" |
| 48 | 50 | ||
| 49 | do_populate_lic[depends] += "virtual/kernel:do_populate_sysroot" | 51 | do_populate_lic[depends] += "virtual/kernel:do_patch" |
| 50 | 52 | ||
| 51 | # needed for building the tools/perf Perl binding | 53 | # needed for building the tools/perf Perl binding |
| 52 | inherit perlnative cpan-base | 54 | inherit perlnative cpan-base |
| @@ -56,9 +58,7 @@ export PERL_INC = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)} | |||
| 56 | export PERL_LIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}" | 58 | export PERL_LIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}" |
| 57 | export PERL_ARCHLIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}" | 59 | export PERL_ARCHLIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}" |
| 58 | 60 | ||
| 59 | S = "${STAGING_KERNEL_DIR}" | 61 | inherit kernelsrc |
| 60 | # The source should be ready after the do_unpack | ||
| 61 | do_unpack[depends] += "virtual/kernel:do_populate_sysroot" | ||
| 62 | 62 | ||
| 63 | B = "${WORKDIR}/${BPN}-${PV}" | 63 | B = "${WORKDIR}/${BPN}-${PV}" |
| 64 | 64 | ||
| @@ -157,7 +157,7 @@ do_configure_prepend () { | |||
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | python do_package_prepend() { | 159 | python do_package_prepend() { |
| 160 | bb.data.setVar('PKGV', get_kernelversion('${S}').split("-")[0], d) | 160 | d.setVar('PKGV', d.getVar("KERNEL_VERSION", True).split("-")[0]) |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | PACKAGE_ARCH = "${MACHINE_ARCH}" | 163 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
