Merge branch 'org.openembedded.dev' of git://git.openembedded.org/openembedded into...
[vuplus_openembedded] / classes / kernel.bbclass
index 2a335af..1323228 100644 (file)
@@ -29,6 +29,7 @@ inherit kernel-arch
 
 PACKAGES_DYNAMIC += "kernel-module-*"
 PACKAGES_DYNAMIC += "kernel-image-*"
+PACKAGES_DYNAMIC += "kernel-firmware-*"
 
 export OS = "${TARGET_OS}"
 export CROSS_COMPILE = "${TARGET_PREFIX}"
@@ -63,6 +64,10 @@ export CMDLINE_CONSOLE = "console=${@bb.data.getVar("KERNEL_CONSOLE",d,1) or "tt
 KERNEL_VERSION = "${@get_kernelversion('${S}')}"
 KERNEL_MAJOR_VERSION = "${@get_kernelmajorversion('${KERNEL_VERSION}')}"
 
+# A machine.conf or local.conf can increase MACHINE_KERNEL_PR to force
+# rebuilds for kernel and external modules
+PR = "${MACHINE_KERNEL_PR}"
+
 KERNEL_LOCALVERSION ?= ""
 
 # kernels are generally machine specific
@@ -73,9 +78,6 @@ UBOOT_ENTRYPOINT ?= "20008000"
 UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}"
 
 kernel_do_compile() {
-       if [ ! -z "${INITRAMFS_IMAGE}" ]; then
-               cp "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.cpio.gz" initramfs.cpio.gz
-       fi
        unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
        oe_runmake include/linux/version.h CC="${KERNEL_CC}" LD="${KERNEL_LD}"
        if [ "${KERNEL_MAJOR_VERSION}" != "2.6" ]; then
@@ -90,12 +92,17 @@ kernel_do_compile() {
 }
 kernel_do_compile[depends] = "${INITRAMFS_TASK}"
 
-
 kernel_do_stage() {
        ASMDIR=`readlink include/asm`
 
        mkdir -p ${STAGING_KERNEL_DIR}/include/$ASMDIR
        cp -fR include/$ASMDIR/* ${STAGING_KERNEL_DIR}/include/$ASMDIR/
+       # Kernel 2.6.27 moved headers from includes/asm-${ARCH} to arch/${ARCH}/include/asm     
+       if [ -e arch/${ARCH}/include/asm/ ] ; then 
+               cp -fR arch/${ARCH}/include/asm/* ${STAGING_KERNEL_DIR}/include/$ASMDIR/
+               install -d ${STAGING_KERNEL_DIR}/arch/${ARCH}/include
+               cp -fR arch/${ARCH}/* ${STAGING_KERNEL_DIR}/arch/${ARCH}/       
+       fi
        rm -f $ASMDIR ${STAGING_KERNEL_DIR}/include/asm
        ln -sf $ASMDIR ${STAGING_KERNEL_DIR}/include/asm
 
@@ -111,7 +118,7 @@ kernel_do_stage() {
        mkdir -p ${STAGING_KERNEL_DIR}/include/pcmcia
        cp -fR include/pcmcia/* ${STAGING_KERNEL_DIR}/include/pcmcia/
 
-       for entry in drivers/crypto include/media include/acpi include/sound include/video; do
+       for entry in drivers/crypto drivers/media include/media include/acpi include/sound include/video include/scsi include/trace; do
                if [ -d $entry ]; then
                        mkdir -p ${STAGING_KERNEL_DIR}/$entry
                        cp -fR $entry/* ${STAGING_KERNEL_DIR}/$entry/
@@ -182,7 +189,10 @@ kernel_do_install() {
 }
 
 kernel_do_configure() {
-        yes '' | oe_runmake oldconfig
+       yes '' | oe_runmake oldconfig
+       if [ ! -z "${INITRAMFS_IMAGE}" ]; then
+               cp "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.cpio.gz" initramfs.cpio.gz
+       fi 
 }
 
 do_menuconfig() {
@@ -233,6 +243,9 @@ ALLOW_EMPTY_kernel-image = "1"
 DEPENDS_kernel-module-dtl1-cs = "bluez-dtl1-workaround"
 RDEPENDS_kernel-module-dtl1-cs = "bluez-dtl1-workaround"
 
+# renamed modules
+RPROVIDES_kernel-module-aes-generic = "kernel-module-aes"
+
 pkg_postinst_kernel-image () {
 if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
        mkdir -p $D/lib/modules/${KERNEL_VERSION}
@@ -284,13 +297,16 @@ module_conf_rfcomm = "alias bt-proto-3 rfcomm"
 
 python populate_packages_prepend () {
        def extract_modinfo(file):
-               import os, re
-               tmpfile = os.tmpnam()
+               import tempfile, os, re
+               tempfile.tempdir = bb.data.getVar("WORKDIR", d, 1)
+               tf = tempfile.mkstemp()
+               tmpfile = tf[1]
                cmd = "PATH=\"%s\" %sobjcopy -j .modinfo -O binary %s %s" % (bb.data.getVar("PATH", d, 1), bb.data.getVar("HOST_PREFIX", d, 1) or "", file, tmpfile)
                os.system(cmd)
                f = open(tmpfile)
                l = f.read().split("\000")
                f.close()
+               os.close(tf[0])
                os.unlink(tmpfile)
                exp = re.compile("([^=]+)=(.*)")
                vals = {}
@@ -425,6 +441,9 @@ python populate_packages_prepend () {
 
        postinst = bb.data.getVar('pkg_postinst_modules', d, 1)
        postrm = bb.data.getVar('pkg_postrm_modules', d, 1)
+       
+       do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.bin$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
+       do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.fw$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
        do_split_packages(d, root='/lib/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='update-modules kernel-%s' % bb.data.getVar("KERNEL_VERSION", d, 1))
 
        import re, os