kernel-yocto: streamline patch, configuration and audit phases

We've been running with a set of kern-tools that were designed to work
with build systems that knew nothing about git, trees, commits, etc.

As such, there's been a set of shims/wrappers in place to work with
within bitbake/oe-core. These were the *me scripts: createme, updateme,
patchme and configme.

With this commit, we strip that legacy code and use the tools directly.
This means less complexity, fewer corner cases .. and no surprises
when the tools are arunning. As another benefit, the tools consume
much less time during a typical build and have no noticeable impact
on the overall build time.

Existing .scc files, features, and processing are not impacted as
these tools are compatible with existing feature descriptions and
kerne configuration fragments.

The audit of kernel configuration fragments is now detached
from the linux-yocto build structure and process. This means that
they can eventually be tweaked to offer kernel audit to any type of
kernel build and configuration process.

Additionally, the kernel symbol audit phase can now resolve symbol
dependencies and offer guidance when a symbol is missing:

   WARNING: linux-yocto-4.4.15+gitAUTOINC+b030d96c7b_f5e2c49d58-r0 do_kernel_configcheck: [kernel config]: specified values did not make it into the kernel's final configuration:

   ---------- CONFIG_BT_6LOWPAN -----------------
   Config: CONFIG_BT_6LOWPAN
   From: /home/bruce/poky/build/tmp/work-shared/qemux86-64/kernel-source/.kernel-meta/configs/standard/features/bluetooth/bluetooth.cfg
   Requested value:  CONFIG_BT_6LOWPAN=y
   Actual value:

   Config 'BT_6LOWPAN' has the following conditionals:
     BT_LE && 6LOWPAN (value: "n")
   Dependency values are:
     BT_LE [y] 6LOWPAN [n]

(From OE-Core rev: 0f698dfd1c8bbc0d53ae7977e26685a7a3df52a3)

Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Bruce Ashfield 2016-08-15 14:26:59 -04:00 committed by Richard Purdie
parent 028e133171
commit 5ef0620b18
2 changed files with 55 additions and 92 deletions

View File

@ -119,77 +119,42 @@ do_kernel_metadata() {
patches="${@" ".join(find_patches(d))}" patches="${@" ".join(find_patches(d))}"
feat_dirs="${@" ".join(find_kernel_feature_dirs(d))}" feat_dirs="${@" ".join(find_kernel_feature_dirs(d))}"
# add any explicitly referenced features onto the end of the feature
# list that is passed to the kernel build scripts.
if [ -n "${KERNEL_FEATURES}" ]; then
for feat in ${KERNEL_FEATURES}; do
addon_features="$addon_features --feature $feat"
done
fi
# check for feature directories/repos/branches that were part of the # check for feature directories/repos/branches that were part of the
# SRC_URI. If they were supplied, we convert them into include directives # SRC_URI. If they were supplied, we convert them into include directives
# for the update part of the process # for the update part of the process
if [ -n "${feat_dirs}" ]; then for f in ${feat_dirs}; do
for f in ${feat_dirs}; do
if [ -d "${WORKDIR}/$f/meta" ]; then if [ -d "${WORKDIR}/$f/meta" ]; then
includes="$includes -I${WORKDIR}/$f/meta" includes="$includes -I${WORKDIR}/$f/meta"
elif [ -d "${WORKDIR}/$f" ]; then elif [ -d "${WORKDIR}/$f" ]; then
includes="$includes -I${WORKDIR}/$f" includes="$includes -I${WORKDIR}/$f"
fi fi
done done
fi for s in ${sccs}; do
sdir=$(dirname $s)
includes="$includes -I${sdir}"
done
# updates or generates the target description # expand kernel features into their full path equivalents
updateme ${updateme_flags} -DKDESC=${KMACHINE}:${LINUX_KERNEL_TYPE} \ bsp_definition=$(spp ${includes} --find -DKMACHINE=${KMACHINE} -DKTYPE=${LINUX_KERNEL_TYPE})
${includes} ${addon_features} ${ARCH} ${KMACHINE} ${sccs} ${patches} meta_dir=$(kgit --meta)
if [ $? -ne 0 ]; then
bbfatal_log "Could not update ${machine_branch}" # run1: pull all the configuration fragments, no matter where they come from
fi scc --force -o ${S}/${meta_dir}:cfg,meta ${includes} ${bsp_definition} ${sccs} ${patches} ${KERNEL_FEATURES}
# run2: only generate patches for elements that have been passed on the SRC_URI
scc --force -o ${S}/${meta_dir}:patch --cmds patch ${includes} ${sccs} ${patches} ${KERNEL_FEATURES}
} }
do_patch() { do_patch() {
cd ${S} cd ${S}
# executes and modifies the source tree as required meta_dir=$(kgit --meta)
patchme ${KMACHINE} (cd ${meta_dir}; ln -sf patch.queue series)
if [ $? -ne 0 ]; then if [ -f "${meta_dir}/series" ]; then
bberror "Could not apply patches for ${KMACHINE}." kgit-s2q --gen -v --patches .kernel-meta/
bbfatal_log "Patch failures can be resolved in the linux source directory ${S})" if [ $? -ne 0 ]; then
fi bberror "Could not apply patches for ${KMACHINE}."
bbfatal_log "Patch failures can be resolved in the linux source directory ${S})"
# check to see if the specified SRCREV is reachable from the final branch.
# if it wasn't something wrong has happened, and we should error.
machine_srcrev="${SRCREV_machine}"
if [ -z "${machine_srcrev}" ]; then
# fallback to SRCREV if a non machine_meta tree is being built
machine_srcrev="${SRCREV}"
# if SRCREV cannot be reached something is wrong.
if [ -z "${machine_srcrev}" ]; then
bbfatal "Neither SRCREV_machine or SRCREV was specified!"
fi
fi
if [ -n "${KMETA_AUDIT}" ]; then
current_branch=`git rev-parse --abbrev-ref HEAD`
machine_branch="${@ get_machine_branch(d, "${KBRANCH}" )}"
if [ "${current_branch}" != "${machine_branch}" ]; then
bbwarn "After meta data application, the kernel tree branch is ${current_branch}."
bbwarn "The SRC_URI specified branch ${machine_branch}."
bbwarn ""
bbwarn "The branch will be forced to ${machine_branch}, but this means the board meta data"
bbwarn "(.scc files) do not match the SRC_URI specification."
bbwarn ""
bbwarn "The meta data and branch ${machine_branch} should be inspected to ensure the proper"
bbwarn "kernel is being built."
git checkout -f ${machine_branch}
fi
fi
if [ "${machine_srcrev}" != "AUTOINC" ]; then
if ! [ "$(git rev-parse --verify ${machine_srcrev}~0)" = "$(git merge-base ${machine_srcrev} HEAD)" ]; then
bberror "SRCREV ${machine_srcrev} was specified, but is not reachable"
bbfatal "Check the BSP description for incorrect branch selection, or other errors."
fi fi
fi fi
} }
@ -258,26 +223,37 @@ do_kernel_metadata[depends] = "kern-tools-native:do_populate_sysroot"
do_kernel_configme[dirs] += "${S} ${B}" do_kernel_configme[dirs] += "${S} ${B}"
do_kernel_configme() { do_kernel_configme() {
bbnote "kernel configme" set +e
export KMETA=${KMETA}
if [ -n "${KCONFIG_MODE}" ]; then # translate the kconfig_mode into something that merge_config.sh
configmeflags=${KCONFIG_MODE} # understands
else case ${KCONFIG_MODE} in
# If a defconfig was passed, use =n as the baseline, which is achieved allnoconfig)
# via --allnoconfig config_flags="-n"
;;
alldefconfig)
config_flags=""
;;
*)
if [ -f ${WORKDIR}/defconfig ]; then if [ -f ${WORKDIR}/defconfig ]; then
configmeflags="--allnoconfig" config_flags="-n"
fi fi
fi ;;
esac
cd ${S} cd ${S}
PATH=${PATH}:${S}/scripts/util
configme ${configmeflags} --reconfig --output ${B} ${LINUX_KERNEL_TYPE} ${KMACHINE} meta_dir=$(kgit --meta)
configs="$(scc --configs -o ${meta_dir})"
if [ -z "${configs}" ]; then
bbfatal_log "Could not find configuration queue (${meta_dir}/config.queue)"
fi
ARCH=${ARCH} merge_config.sh -O ${B} ${config_flags} ${configs} > ${meta_dir}/cfg/merge_config_build.log 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
bbfatal_log "Could not configure ${KMACHINE}-${LINUX_KERNEL_TYPE}" bbfatal_log "Could not configure ${KMACHINE}-${LINUX_KERNEL_TYPE}"
fi fi
echo "# Global settings from linux recipe" >> ${B}/.config echo "# Global settings from linux recipe" >> ${B}/.config
echo "CONFIG_LOCALVERSION="\"${LINUX_VERSION_EXTENSION}\" >> ${B}/.config echo "CONFIG_LOCALVERSION="\"${LINUX_VERSION_EXTENSION}\" >> ${B}/.config
} }
@ -295,36 +271,23 @@ python do_kernel_configcheck() {
kmeta = "." + kmeta kmeta = "." + kmeta
pathprefix = "export PATH=%s:%s; " % (d.getVar('PATH', True), "${S}/scripts/util/") pathprefix = "export PATH=%s:%s; " % (d.getVar('PATH', True), "${S}/scripts/util/")
cmd = d.expand("cd ${S}; kconf_check -config %s/meta-series ${S} ${B}" % kmeta)
cmd = d.expand("scc --configs -o ${S}/.kernel-meta")
ret, configs = oe.utils.getstatusoutput("%s%s" % (pathprefix, cmd))
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)) ret, result = oe.utils.getstatusoutput("%s%s" % (pathprefix, cmd))
config_check_visibility = int(d.getVar( "KCONF_AUDIT_LEVEL", True ) or 0) 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) bsp_check_visibility = int(d.getVar( "KCONF_BSP_AUDIT_LEVEL", True ) or 0)
# if config check visibility is non-zero, report dropped configuration values # if config check visibility is non-zero, report dropped configuration values
mismatch_file = "${S}/" + kmeta + "/" + "mismatch.cfg" mismatch_file = d.expand("${S}/%s/cfg/mismatch.txt" % kmeta)
if os.path.exists(mismatch_file): if os.path.exists(mismatch_file):
if config_check_visibility: if config_check_visibility:
with open (mismatch_file, "r") as myfile: with open (mismatch_file, "r") as myfile:
results = myfile.read() results = myfile.read()
bb.warn( "[kernel config]: specified values did not make it into the kernel's final configuration:\n\n%s" % results) bb.warn( "[kernel config]: specified values did not make it into the kernel's final configuration:\n\n%s" % results)
# if config check visibility is level 2 or higher, report non-hardware options
nonhw_file = "${S}/" + kmeta + "/" + "nonhw_report.cfg"
if os.path.exists(nonhw_file):
if config_check_visibility > 1:
with open (nonhw_file, "r") as myfile:
results = myfile.read()
bb.warn( "[kernel config]: BSP specified non-hw configuration:\n\n%s" % results)
bsp_desc = "${S}/" + kmeta + "/" + "top_tgt"
if os.path.exists(bsp_desc) and bsp_check_visibility > 1:
with open (bsp_desc, "r") as myfile:
bsp_tgt = myfile.read()
m = re.match("^(.*)scratch.obj(.*)$", bsp_tgt)
if not m is None:
bb.warn( "[kernel]: An auto generated BSP description was used, this normally indicates a misconfiguration.\n" +
"Check that your machine (%s) has an associated kernel description." % "${MACHINE}" )
} }
# Ensure that the branches (BSP and meta) are on the locations specified by # Ensure that the branches (BSP and meta) are on the locations specified by

View File

@ -1,10 +1,10 @@
SUMMARY = "Tools for managing Yocto Project style branched kernels" SUMMARY = "Tools for managing Yocto Project style branched kernels"
LICENSE = "GPLv2" LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://git/tools/kgit;beginline=5;endline=9;md5=d8d1d729a70cd5f52972f8884b80743d" LIC_FILES_CHKSUM = "file://git/tools/kgit;beginline=5;endline=9;md5=a6c2fa8aef1bda400e2828845ba0d06c"
DEPENDS = "git-native" DEPENDS = "git-native"
SRCREV = "a6a6f6e1e738d2ecd26b675e9bec867105703416" SRCREV = "4b5de9011b31ff92ba2b6e052ab818b09affd905"
PR = "r12" PR = "r12"
PV = "0.2+git${SRCPV}" PV = "0.2+git${SRCPV}"