From aaf2b59a0bd69c1cfea6d2fc0df30ab49e16e031 Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Fri, 13 Mar 2020 10:41:36 +0100 Subject: toradex-kernel-config: add bbclass It contains a helper function kernel_configure_variable that could be called in do_configure_append task to assign a value to a config variable in ${B}/.config. Change toradex-kernel-localversion.bbclass to use this function. Signed-off-by: Ming Liu --- classes/toradex-kernel-config.bbclass | 17 +++++++++++++++++ classes/toradex-kernel-localversion.bbclass | 10 +++++----- 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 classes/toradex-kernel-config.bbclass diff --git a/classes/toradex-kernel-config.bbclass b/classes/toradex-kernel-config.bbclass new file mode 100644 index 0000000..8c3ad71 --- /dev/null +++ b/classes/toradex-kernel-config.bbclass @@ -0,0 +1,17 @@ +# Assign a config variable in ${B}/.config. +# Should be called in do_configure_append only. +# +# $1 - config variable to be set +# $2 - value [n/y/value] +# +kernel_configure_variable() { + # Remove the original config, to avoid reassigning it. + sed -i -e "/CONFIG_$1[ =]/d" ${B}/.config + + # Assign the config value + if [ "$2" = "n" ]; then + echo "# CONFIG_$1 is not set" >> ${B}/.config + else + echo "CONFIG_$1=$2" >> ${B}/.config + fi +} diff --git a/classes/toradex-kernel-localversion.bbclass b/classes/toradex-kernel-localversion.bbclass index f23ee58..e2ec3a0 100644 --- a/classes/toradex-kernel-localversion.bbclass +++ b/classes/toradex-kernel-localversion.bbclass @@ -10,15 +10,15 @@ # Copyright 2014, 2015 (C) O.S. Systems Software LTDA. # Copyright 2019 (C) Toradex AG +inherit toradex-kernel-config + TDX_VERSION ??= "0" SCMVERSION ??= "y" LOCALVERSION ?= "-${TDX_VERSION}" kernel_do_configure_append() { - sed -i -e /CONFIG_LOCALVERSION/d ${B}/.config - echo "CONFIG_LOCALVERSION=\"${LOCALVERSION}\"" >> ${B}/.config + kernel_configure_variable LOCALVERSION "\"${LOCALVERSION}\"" - sed -i -e /CONFIG_LOCALVERSION_AUTO/d ${B}/.config if [ "${SCMVERSION}" = "y" ]; then # Add GIT revision to the local version # SRCREV_machine is used in kernel recipes using kernel-yocto.bbclass, @@ -40,8 +40,8 @@ kernel_do_configure_append() { head=`git --git-dir=${S}/.git rev-parse --verify --short HEAD 2> /dev/null` fi printf "+git.%s" $head > ${S}/.scmversion - echo "CONFIG_LOCALVERSION_AUTO=y" >> ${B}/.config + kernel_configure_variable LOCALVERSION_AUTO y else - echo "# CONFIG_LOCALVERSION_AUTO is not set" >> ${B}/.config + kernel_configure_variable LOCALVERSION_AUTO n fi } -- cgit v1.2.3