summaryrefslogtreecommitdiffstats
path: root/meta/classes/kernel-yocto.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/kernel-yocto.bbclass')
-rw-r--r--meta/classes/kernel-yocto.bbclass144
1 files changed, 125 insertions, 19 deletions
diff --git a/meta/classes/kernel-yocto.bbclass b/meta/classes/kernel-yocto.bbclass
index 53659f2f37..ed9bcfa57c 100644
--- a/meta/classes/kernel-yocto.bbclass
+++ b/meta/classes/kernel-yocto.bbclass
@@ -1,14 +1,25 @@
# remove tasks that modify the source tree in case externalsrc is inherited
SRCTREECOVEREDTASKS += "do_kernel_configme do_validate_branches do_kernel_configcheck do_kernel_checkout do_fetch do_unpack do_patch"
+PATCH_GIT_USER_EMAIL ?= "kernel-yocto@oe"
+PATCH_GIT_USER_NAME ?= "OpenEmbedded"
# returns local (absolute) path names for all valid patches in the
# src_uri
-def find_patches(d):
+def find_patches(d,subdir):
patches = src_patches(d)
patch_list=[]
for p in patches:
- _, _, local, _, _, _ = bb.fetch.decodeurl(p)
- patch_list.append(local)
+ _, _, local, _, _, parm = bb.fetch.decodeurl(p)
+ # if patchdir has been passed, we won't be able to apply it so skip
+ # the patch for now, and special processing happens later
+ patchdir = ''
+ if "patchdir" in parm:
+ patchdir = parm["patchdir"]
+ if subdir:
+ if subdir == patchdir:
+ patch_list.append(local)
+ else:
+ patch_list.append(local)
return patch_list
@@ -105,26 +116,51 @@ do_kernel_metadata() {
cmp "${WORKDIR}/defconfig" "${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG}"
if [ $? -ne 0 ]; then
bbwarn "defconfig detected in WORKDIR. ${KBUILD_DEFCONFIG} skipped"
+ else
+ cp -f ${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG} ${WORKDIR}/defconfig
fi
else
cp -f ${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG} ${WORKDIR}/defconfig
- sccs="${WORKDIR}/defconfig"
fi
+ sccs="${WORKDIR}/defconfig"
else
- bbfatal "A KBUILD_DECONFIG '${KBUILD_DEFCONFIG}' was specified, but not present in the source tree"
+ bbfatal "A KBUILD_DEFCONFIG '${KBUILD_DEFCONFIG}' was specified, but not present in the source tree"
fi
fi
- sccs="$sccs ${@" ".join(find_sccs(d))}"
- patches="${@" ".join(find_patches(d))}"
+ # was anyone trying to patch the kernel meta data ?, we need to do
+ # this here, since the scc commands migrate the .cfg fragments to the
+ # kernel source tree, where they'll be used later.
+ check_git_config
+ patches="${@" ".join(find_patches(d,'kernel-meta'))}"
+ for p in $patches; do
+ (
+ cd ${WORKDIR}/kernel-meta
+ git am -s $p
+ )
+ done
+
+ sccs_from_src_uri="${@" ".join(find_sccs(d))}"
+ patches="${@" ".join(find_patches(d,''))}"
feat_dirs="${@" ".join(find_kernel_feature_dirs(d))}"
+ # a quick check to make sure we don't have duplicate defconfigs
+ # If there's a defconfig in the SRC_URI, did we also have one from
+ # the KBUILD_DEFCONFIG processing above ?
+ if [ -n "$sccs" ]; then
+ # we did have a defconfig from above. remove any that might be in the src_uri
+ sccs_from_src_uri=$(echo $sccs_from_src_uri | awk '{ if ($0!="defconfig") { print $0 } }' RS=' ')
+ fi
+ sccs="$sccs $sccs_from_src_uri"
+
# check for feature directories/repos/branches that were part of the
# SRC_URI. If they were supplied, we convert them into include directives
# for the update part of the process
for f in ${feat_dirs}; do
if [ -d "${WORKDIR}/$f/meta" ]; then
includes="$includes -I${WORKDIR}/$f/kernel-meta"
+ elif [ -d "${WORKDIR}/../oe-local-files/$f" ]; then
+ includes="$includes -I${WORKDIR}/../oe-local-files/$f"
elif [ -d "${WORKDIR}/$f" ]; then
includes="$includes -I${WORKDIR}/$f"
fi
@@ -141,24 +177,39 @@ do_kernel_metadata() {
# expand kernel features into their full path equivalents
bsp_definition=$(spp ${includes} --find -DKMACHINE=${KMACHINE} -DKTYPE=${LINUX_KERNEL_TYPE})
+ if [ -z "$bsp_definition" ]; then
+ echo "$sccs" | grep -q defconfig
+ if [ $? -ne 0 ]; then
+ bbfatal_log "Could not locate BSP definition for ${KMACHINE}/${LINUX_KERNEL_TYPE} and no defconfig was provided"
+ fi
+ fi
meta_dir=$(kgit --meta)
# run1: pull all the configuration fragments, no matter where they come from
elements="`echo -n ${bsp_definition} ${sccs} ${patches} ${KERNEL_FEATURES}`"
if [ -n "${elements}" ]; then
- scc --force -o ${S}/${meta_dir}:cfg,meta ${includes} ${bsp_definition} ${sccs} ${patches} ${KERNEL_FEATURES}
+ echo "${bsp_definition}" > ${S}/${meta_dir}/bsp_definition
+ scc --force -o ${S}/${meta_dir}:cfg,merge,meta ${includes} ${bsp_definition} ${sccs} ${patches} ${KERNEL_FEATURES}
+ if [ $? -ne 0 ]; then
+ bbfatal_log "Could not generate configuration queue for ${KMACHINE}."
+ fi
fi
# run2: only generate patches for elements that have been passed on the SRC_URI
elements="`echo -n ${sccs} ${patches} ${KERNEL_FEATURES}`"
if [ -n "${elements}" ]; then
scc --force -o ${S}/${meta_dir}:patch --cmds patch ${includes} ${sccs} ${patches} ${KERNEL_FEATURES}
+ if [ $? -ne 0 ]; then
+ bbfatal_log "Could not generate configuration queue for ${KMACHINE}."
+ fi
fi
}
do_patch() {
+ set +e
cd ${S}
+ check_git_config
meta_dir=$(kgit --meta)
(cd ${meta_dir}; ln -sf patch.queue series)
if [ -f "${meta_dir}/series" ]; then
@@ -168,6 +219,19 @@ do_patch() {
bbfatal_log "Patch failures can be resolved in the linux source directory ${S})"
fi
fi
+
+ if [ -f "${meta_dir}/merge.queue" ]; then
+ # we need to merge all these branches
+ for b in $(cat ${meta_dir}/merge.queue); do
+ git show-ref --verify --quiet refs/heads/${b}
+ if [ $? -eq 0 ]; then
+ bbnote "Merging branch ${b}"
+ git merge -q --no-ff -m "Merge branch ${b}" ${b}
+ else
+ bbfatal "branch ${b} does not exist, cannot merge"
+ fi
+ done
+ fi
}
do_kernel_checkout() {
@@ -206,6 +270,7 @@ do_kernel_checkout() {
fi
rm -f .gitignore
git init
+ check_git_config
git add .
git commit -q -m "baseline commit: creating repo for ${PN}-${PV}"
git clean -d -f
@@ -231,7 +296,11 @@ do_kernel_checkout[dirs] = "${S}"
addtask kernel_checkout before do_kernel_metadata after do_unpack
addtask kernel_metadata after do_validate_branches do_unpack before do_patch
do_kernel_metadata[depends] = "kern-tools-native:do_populate_sysroot"
+do_validate_branches[depends] = "kern-tools-native:do_populate_sysroot"
+do_kernel_configme[depends] += "virtual/${TARGET_PREFIX}binutils:do_populate_sysroot"
+do_kernel_configme[depends] += "virtual/${TARGET_PREFIX}gcc:do_populate_sysroot"
+do_kernel_configme[depends] += "bc-native:do_populate_sysroot bison-native:do_populate_sysroot"
do_kernel_configme[dirs] += "${S} ${B}"
do_kernel_configme() {
set +e
@@ -256,11 +325,12 @@ do_kernel_configme() {
meta_dir=$(kgit --meta)
configs="$(scc --configs -o ${meta_dir})"
- if [ -z "${configs}" ]; then
+ if [ $? -ne 0 ]; then
+ bberror "${configs}"
bbfatal_log "Could not find configuration queue (${meta_dir}/config.queue)"
fi
- CFLAGS="${CFLAGS} ${TOOLCHAIN_OPTIONS}" ARCH=${ARCH} merge_config.sh -O ${B} ${config_flags} ${configs} > ${meta_dir}/cfg/merge_config_build.log 2>&1
+ CFLAGS="${CFLAGS} ${TOOLCHAIN_OPTIONS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}" CC="${KERNEL_CC}" ARCH=${ARCH} merge_config.sh -O ${B} ${config_flags} ${configs} > ${meta_dir}/cfg/merge_config_build.log 2>&1
if [ $? -ne 0 ]; then
bbfatal_log "Could not configure ${KMACHINE}-${LINUX_KERNEL_TYPE}"
fi
@@ -272,25 +342,36 @@ do_kernel_configme() {
addtask kernel_configme before do_configure after do_patch
python do_kernel_configcheck() {
- import re, string, sys
+ import re, string, sys, subprocess
# if KMETA isn't set globally by a recipe using this routine, we need to
# set the default to 'meta'. Otherwise, kconf_check is not passed a valid
# meta-series for processing
- kmeta = d.getVar( "KMETA", True ) or "meta"
+ kmeta = d.getVar("KMETA") or "meta"
if not os.path.exists(kmeta):
kmeta = "." + kmeta
- pathprefix = "export PATH=%s:%s; " % (d.getVar('PATH', True), "${S}/scripts/util/")
+ s = d.getVar('S')
+
+ env = os.environ.copy()
+ env['PATH'] = "%s:%s%s" % (d.getVar('PATH'), s, "/scripts/util/")
- cmd = d.expand("scc --configs -o ${S}/.kernel-meta")
- ret, configs = oe.utils.getstatusoutput("%s%s" % (pathprefix, cmd))
+ try:
+ configs = subprocess.check_output(['scc', '--configs', '-o', s + '/.kernel-meta'], env=env).decode('utf-8')
+ except subprocess.CalledProcessError as e:
+ bb.fatal( "Cannot gather config fragments for audit: %s" % e.output.decode("utf-8") )
- cmd = d.expand("cd ${S}; kconf_check --report -o ${S}/%s/cfg/ ${B}/.config ${S} %s" % (kmeta,configs))
- ret, result = oe.utils.getstatusoutput("%s%s" % (pathprefix, cmd))
+ try:
+ subprocess.check_call(['kconf_check', '--report', '-o',
+ '%s/%s/cfg' % (s, kmeta), d.getVar('B') + '/.config', s, configs], cwd=s, env=env)
+ except subprocess.CalledProcessError:
+ # The configuration gathering can return different exit codes, but
+ # we interpret them based on the KCONF_AUDIT_LEVEL variable, so we catch
+ # everything here, and let the run continue.
+ pass
- config_check_visibility = int(d.getVar( "KCONF_AUDIT_LEVEL", True ) or 0)
- bsp_check_visibility = int(d.getVar( "KCONF_BSP_AUDIT_LEVEL", True ) or 0)
+ config_check_visibility = int(d.getVar("KCONF_AUDIT_LEVEL") or 0)
+ bsp_check_visibility = int(d.getVar("KCONF_BSP_AUDIT_LEVEL") or 0)
# if config check visibility is non-zero, report dropped configuration values
mismatch_file = d.expand("${S}/%s/cfg/mismatch.txt" % kmeta)
@@ -299,6 +380,27 @@ python do_kernel_configcheck() {
with open (mismatch_file, "r") as myfile:
results = myfile.read()
bb.warn( "[kernel config]: specified values did not make it into the kernel's final configuration:\n\n%s" % results)
+
+ if bsp_check_visibility:
+ invalid_file = d.expand("${S}/%s/cfg/invalid.cfg" % kmeta)
+ if os.path.exists(invalid_file) and os.stat(invalid_file).st_size > 0:
+ with open (invalid_file, "r") as myfile:
+ results = myfile.read()
+ bb.warn( "[kernel config]: This BSP sets config options that are not offered anywhere within this kernel:\n\n%s" % results)
+ errors_file = d.expand("${S}/%s/cfg/fragment_errors.txt" % kmeta)
+ if os.path.exists(errors_file) and os.stat(errors_file).st_size > 0:
+ with open (errors_file, "r") as myfile:
+ results = myfile.read()
+ bb.warn( "[kernel config]: This BSP contains fragments with errors:\n\n%s" % results)
+
+ # if the audit level is greater than two, we report if a fragment has overriden
+ # a value from a base fragment. This is really only used for new kernel introduction
+ if bsp_check_visibility > 2:
+ redefinition_file = d.expand("${S}/%s/cfg/redefinition.txt" % kmeta)
+ if os.path.exists(redefinition_file) and os.stat(redefinition_file).st_size > 0:
+ with open (redefinition_file, "r") as myfile:
+ results = myfile.read()
+ bb.warn( "[kernel config]: This BSP has configuration options defined in more than one config, with differing values:\n\n%s" % results)
}
# Ensure that the branches (BSP and meta) are on the locations specified by
@@ -341,6 +443,10 @@ do_validate_branches() {
current_branch=`git rev-parse --abbrev-ref HEAD`
git branch "$current_branch-orig"
git reset --hard ${force_srcrev}
+ # We've checked out HEAD, make sure we cleanup kgit-s2q fence post check
+ # so the patches are applied as expected otherwise no patching
+ # would be done in some corner cases.
+ kgit-s2q --clean
fi
fi
}