summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMing Liu <ming.liu@toradex.com>2020-03-13 10:41:36 +0100
committerMing Liu <ming.liu@toradex.com>2020-03-14 21:10:56 +0100
commit2d38b92941737400dc5b6279548b85483d3026c4 (patch)
tree00d26b5913cabc49bde70e1e80356130219ca9ed
parentcac029d529426d031c5542fb1918b4341dcb160d (diff)
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 <ming.liu@toradex.com> (cherry picked from commit aaf2b59a0bd69c1cfea6d2fc0df30ab49e16e031)
-rw-r--r--classes/toradex-kernel-config.bbclass17
-rw-r--r--classes/toradex-kernel-localversion.bbclass10
2 files changed, 22 insertions, 5 deletions
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
}