generic-poky/meta/classes/kernel-yocto.bbclass

203 lines
6.2 KiB
Plaintext
Raw Normal View History

yocto-kernel: factor common routes, update to 2.6.37 and branch renaming In order to extend and create more kernel recipes based on the supported yocto kernel common routines need to be placed in re-usable blocks. To accomplish this meta/recipes-kernel/linux/linux-yocto_git.bb is broken into three parts: - meta/classes/kernel-yocto.bbclass: contains common routines for checking out and configuring a yocto kernel git repository. This should be inherited by recipes that need this functionality. - meta/recipes-kernel/linux/linux-yocto.inc: Contains the machine mappings, compatibility, build directives and common task definitions for a yocto kernel based recipe. This inherits kernel-yocto, and is the typical point of entry for other recipes. - meta/recipes-kernel/linux/linuux-tools.inc: tasks and function definitions for kernel recipes that want to build/export perf It also updates the linux-yocto recipe to default to 2.6.37. As part of the update to 2.6.37 the branch naming and conventions have been modified to show inheritance, and be more generic. For example: master meta yocto/base yocto/standard/arm_versatile_926ejs yocto/standard/base yocto/standard/beagleboard yocto/standard/common_pc/atom-pc yocto/standard/common_pc/base yocto/standard/common_pc_64 yocto/standard/fsl-mpc8315e-rdb yocto/standard/intel_atom_z530 yocto/standard/intel_core_qm57_pch yocto/standard/mti_malta32_be yocto/standard/preempt_rt/base yocto/standard/preempt_rt/common_pc yocto/standard/preempt_rt/common_pc_64 yocto/standard/preempt_rt/intel_atom_z530 yocto/standard/preempt_rt/intel_core_qm57_pch yocto/standard/qemu_ppc32 yocto/standard/routerstationpro In this structure: master: tracks the mainline kernel meta: meta information for the BSPs and kernel features yocto/base: baseline kernel branch yocto/standard/base: 'standard' kernel, contains features and configs for all BSPs yocto/standard/<machine>: represents a BSP with specific features or configurations The tools, tree and libc-headers have all been updated to deal with this new structure. Also in addition to dealing with the new structure, they continue to work with the existing tree and will adapt at runtime to the differences. The linux-yocto-stable_git.bb recipe continues to build the 2.6.34 based tree,and linux-yocto_git.bb builds 2.6.37. As boards are enabled for the new kernel they will move from -stable to the development kernel. As of now, only the emulated targets have moved to 2.6.37-rcX Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
2010-11-18 21:09:02 +00:00
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}
fi
# simply ensures that a branch of the right name has been created
createme ${ARCH} ${kbranch} ${defconfig}
if [ $? -ne 0 ]; then
echo "ERROR. Could not create ${kbranch}"
exit 1
fi
# updates or generates the target description
if [ -n "${KERNEL_FEATURES}" ]; then
addon_features="--features ${KERNEL_FEATURES}"
fi
updateme ${addon_features} ${ARCH} ${WORKDIR}
if [ $? -ne 0 ]; then
echo "ERROR. Could not update ${kbranch}"
exit 1
fi
# executes and modifies the source tree as required
patchme ${kbranch}
if [ $? -ne 0 ]; then
echo "ERROR. Could not modify ${kbranch}"
exit 1
fi
}
do_kernel_checkout() {
if [ -d ${WORKDIR}/.git/refs/remotes/origin ]; then
echo "Fixing up git directory for ${LINUX_KERNEL_TYPE}/${KMACHINE}"
rm -rf ${S}
mkdir ${S}
mv ${WORKDIR}/.git ${S}
if [ -e ${S}/.git/packed-refs ]; then
cd ${S}
rm -f .git/refs/remotes/origin/HEAD
IFS='
';
for r in `git show-ref | grep remotes`; do
ref=`echo $r | cut -d' ' -f1`;
b=`echo $r | cut -d' ' -f2 | sed 's%refs/remotes/origin/%%'`;
dir=`dirname $b`
mkdir -p .git/refs/heads/$dir
echo $ref > .git/refs/heads/$b
done
cd ..
else
cp -r ${S}/.git/refs/remotes/origin/* ${S}/.git/refs/heads
rmdir ${S}/.git/refs/remotes/origin
fi
fi
cd ${S}
# checkout and clobber and unimportant files
git checkout -f ${KBRANCH}
}
do_kernel_checkout[dirs] = "${S}"
addtask kernel_checkout before do_patch after do_unpack
do_kernel_configme() {
echo "[INFO] doing kernel configme"
cd ${S}
configme --reconfig
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}
}
# 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
# are reset to the correct commit.
do_validate_branches() {
cd ${S}
branch_head=`git show-ref -s --heads ${KBRANCH}`
meta_head=`git show-ref -s --heads ${KMETA}`
target_branch_head="${SRCREV_machine}"
target_meta_head="${SRCREV_meta}"
# nothing to do if bootstrapping
if [ -n "${BOOTSTRAP}" ]; 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
echo "ERROR ${target_branch_head} is not a valid commit ID."
echo "The kernel source tree may be out of sync"
exit 1
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
echo "ERROR ${target_meta_head} is not a valid commit ID"
echo "The kernel source tree may be out of sync"
exit 1
fi
fi
fi
# restore the branch for builds
git checkout -f ${KBRANCH}
}
# Many scripts want to look in arch/$arch/boot for the bootable
# image. This poses a problem for vmlinux based booting. This
# task arranges to have vmlinux appear in the normalized directory
# location.
do_kernel_link_vmlinux() {
if [ ! -d "${B}/arch/${ARCH}/boot" ]; then
mkdir ${B}/arch/${ARCH}/boot
fi
cd ${B}/arch/${ARCH}/boot
ln -sf ../../../vmlinux
}