diff options
Diffstat (limited to 'meta/classes/kernel-yocto.bbclass')
-rw-r--r-- | meta/classes/kernel-yocto.bbclass | 112 |
1 files changed, 39 insertions, 73 deletions
diff --git a/meta/classes/kernel-yocto.bbclass b/meta/classes/kernel-yocto.bbclass index 8e820122ec..15802fabdf 100644 --- a/meta/classes/kernel-yocto.bbclass +++ b/meta/classes/kernel-yocto.bbclass @@ -1,60 +1,15 @@ S = "${WORKDIR}/linux" -# Determine which branch to fetch and build. Not all branches are in the -# upstream repo (but will be locally created after the fetchers run) so -# a fallback branch needs to be chosen. -# -# The default machine 'UNDEFINED'. If the machine is not set to a specific -# branch in this recipe or in a recipe extension, then we fallback to a -# branch that is always present 'standard'. This sets the KBRANCH variable -# and is used in the SRC_URI. The machine is then set back to ${MACHINE}, -# since futher processing will use that to create local branches -python __anonymous () { - import bb, re - - version = bb.data.getVar("LINUX_VERSION", d, 1) - # 2.6.34 signifies the old-style tree, so we need some temporary - # conditional processing based on the kernel version. - if version == "2.6.34": - bb.data.setVar("KBRANCH", "${KMACHINE}-${LINUX_KERNEL_TYPE}", d) - bb.data.setVar("KMETA", "wrs_meta", d) - mach = bb.data.getVar("KMACHINE", d, 1) - if mach == "UNDEFINED": - bb.data.setVar("KBRANCH", "standard", d) - bb.data.setVar("KMACHINE", "${MACHINE}", d) - # track the global configuration on a bootstrapped BSP - bb.data.setVar("SRCREV_machine", "${SRCREV_meta}", d) - bb.data.setVar("BOOTSTRAP", "t", d) - else: - # The branch for a build is: - # yocto/<kernel type>/${KMACHINE} or - # yocto/<kernel type>/${KMACHINE}/base - bb.data.setVar("KBRANCH", bb.data.expand("yocto/${LINUX_KERNEL_TYPE}/${KMACHINE}",d), d) - bb.data.setVar("KMETA", "meta", d) - - mach = bb.data.getVar("KMACHINE", d, 1) - # drop the "/base" if it was on the KMACHINE - kmachine = mach.replace('/base','') - # and then write KMACHINE back - bb.data.setVar('KMACHINE_' + bb.data.expand("${MACHINE}",d), kmachine, d) - - if mach == "UNDEFINED": - bb.data.setVar("KBRANCH", "yocto/standard/base", d) - bb.data.setVar('KMACHINE_' + bb.data.expand("${MACHINE}",d), bb.data.expand("${MACHINE}",d), d) - bb.data.setVar("SRCREV_machine", "standard", d) - bb.data.setVar("BOOTSTRAP", "t", d) -} - do_patch() { cd ${S} if [ -f ${WORKDIR}/defconfig ]; then defconfig=${WORKDIR}/defconfig fi - if [ -n "${BOOTSTRAP}" ]; then - kbranch="yocto/${LINUX_KERNEL_TYPE}/${KMACHINE}" - else - kbranch=${KBRANCH} + kbranch=${KBRANCH} + if [ -n "${YOCTO_KERNEL_EXTERNAL_BRANCH}" ]; then + # switch from a generic to a specific branch + kbranch=${YOCTO_KERNEL_EXTERNAL_BRANCH} fi # simply ensures that a branch of the right name has been created @@ -68,7 +23,7 @@ do_patch() { if [ -n "${KERNEL_FEATURES}" ]; then addon_features="--features ${KERNEL_FEATURES}" fi - updateme ${addon_features} ${ARCH} ${WORKDIR} + updateme ${addon_features} ${ARCH} ${MACHINE} ${WORKDIR} if [ $? -ne 0 ]; then echo "ERROR. Could not update ${kbranch}" exit 1 @@ -83,11 +38,11 @@ do_patch() { } do_kernel_checkout() { - if [ -d ${WORKDIR}/.git/refs/remotes/origin ]; then + if [ -d ${WORKDIR}/git/.git/refs/remotes/origin ]; then echo "Fixing up git directory for ${LINUX_KERNEL_TYPE}/${KMACHINE}" rm -rf ${S} mkdir ${S} - mv ${WORKDIR}/.git ${S} + mv ${WORKDIR}/git/.git ${S} if [ -e ${S}/.git/packed-refs ]; then cd ${S} @@ -119,23 +74,34 @@ addtask kernel_checkout before do_patch after do_unpack do_kernel_configme() { echo "[INFO] doing kernel configme" + kbranch=${KBRANCH} + if [ -n "${YOCTO_KERNEL_EXTERNAL_BRANCH}" ]; then + # switch from a generic to a specific branch + kbranch=${YOCTO_KERNEL_EXTERNAL_BRANCH} + fi + cd ${S} - configme --reconfig + configme --reconfig --output ${B} ${kbranch} ${MACHINE} if [ $? -ne 0 ]; then echo "ERROR. Could not configure ${KMACHINE}-${LINUX_KERNEL_TYPE}" exit 1 fi - + echo "# Global settings from linux recipe" >> ${B}/.config echo "CONFIG_LOCALVERSION="\"${LINUX_VERSION_EXTENSION}\" >> ${B}/.config } -do_kernel_configcheck() { - echo "[INFO] validating kernel configuration" - cd ${B}/.. - kconf_check ${B}/.config ${B} ${S} ${B} ${LINUX_VERSION} ${KMACHINE}-${LINUX_KERNEL_TYPE} -} +python do_kernel_configcheck() { + import bb, re, string, sys, commands + bb.plain("NOTE: validating kernel configuration") + + pathprefix = "export PATH=%s; " % bb.data.getVar('PATH', d, True) + cmd = bb.data.expand("cd ${B}/..; kconf_check -${LINUX_KERNEL_TYPE}-config-${LINUX_VERSION} ${B} ${S} ${B} ${KBRANCH}",d ) + ret, result = commands.getstatusoutput("%s%s" % (pathprefix, cmd)) + + bb.plain( "%s" % result ) +} # Ensure that the branches (BSP and meta) are on the locatios specified by # their SRCREV values. If they are NOT on the right commits, the branches @@ -148,37 +114,37 @@ do_validate_branches() { target_meta_head="${SRCREV_meta}" # nothing to do if bootstrapping - if [ -n "${BOOTSTRAP}" ]; then + if [ -n "${YOCTO_KERNEL_EXTERNAL_BRANCH}" ]; then return fi current=`git branch |grep \*|sed 's/^\* //'` if [ -n "$target_branch_head" ] && [ "$branch_head" != "$target_branch_head" ]; then if [ -n "${KERNEL_REVISION_CHECKING}" ]; then - git show ${target_branch_head} > /dev/null 2>&1 - if [ $? -eq 0 ]; then - echo "Forcing branch $current to ${target_branch_head}" - git branch -m $current $current-orig - git checkout -b $current ${target_branch_head} - else + ref=`git show ${target_meta_head} 2>&1 | head -n1 || true` + if [ "$ref" = "fatal: bad object ${target_meta_head}" ]; then echo "ERROR ${target_branch_head} is not a valid commit ID." echo "The kernel source tree may be out of sync" exit 1 - fi + else + echo "Forcing branch $current to ${target_branch_head}" + git branch -m $current $current-orig + git checkout -b $current ${target_branch_head} + fi fi fi if [ "$meta_head" != "$target_meta_head" ]; then if [ -n "${KERNEL_REVISION_CHECKING}" ]; then - git show ${target_meta_head} > /dev/null 2>&1 - if [ $? -eq 0 ]; then - echo "Forcing branch meta to ${target_meta_head}" - git branch -m ${KMETA} ${KMETA}-orig - git checkout -b ${KMETA} ${target_meta_head} - else + ref=`git show ${target_meta_head} 2>&1 | head -n1 || true` + if [ "$ref" = "fatal: bad object ${target_meta_head}" ]; then echo "ERROR ${target_meta_head} is not a valid commit ID" echo "The kernel source tree may be out of sync" exit 1 + else + echo "Forcing branch meta to ${target_meta_head}" + git branch -m ${KMETA} ${KMETA}-orig + git checkout -b ${KMETA} ${target_meta_head} fi fi fi |