diff mbox series

kernel-yocto: fix merge_config.sh flag set when KBUILD_DEFCONFIG is used

Message ID 20250126124335.1530274-1-sst@poczta.fm
State New
Headers show
Series kernel-yocto: fix merge_config.sh flag set when KBUILD_DEFCONFIG is used | expand

Commit Message

Slawomir Stepien Jan. 26, 2025, 12:43 p.m. UTC
Based on the documentation of KCONFIG_MODE[1], when we use "in-tree"
defconfig (the KBUILD_DEFCONFIG is set), then the alldefconfig mode
should be used with merge_config.sh.

This commit fixes the logic behind setting the flag by checking if the
provided defconfig file exists in the linux source tree.

[1] https://docs.yoctoproject.org/ref-manual/variables.html#term-KCONFIG_MODE

Signed-off-by: Slawomir Stepien <sst@poczta.fm>
---
 meta/classes-recipe/kernel-yocto.bbclass | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/kernel-yocto.bbclass b/meta/classes-recipe/kernel-yocto.bbclass
index c45abf6ddc..ffda41ffc9 100644
--- a/meta/classes-recipe/kernel-yocto.bbclass
+++ b/meta/classes-recipe/kernel-yocto.bbclass
@@ -113,6 +113,14 @@  def get_dirs_with_fragments(d):
 
     return " ".join(extrafiles)
 
+kbuild_defconfig_exists() {
+	if [ -f "${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG}" ]; then
+		return 0
+	fi
+
+	return 1
+}
+
 do_kernel_metadata() {
 	set +e
 
@@ -155,7 +163,7 @@  do_kernel_metadata() {
 	# precendence.
 	#
 	if [ -n "${KBUILD_DEFCONFIG}" ]; then
-		if [ -f "${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG}" ]; then
+		if $(kbuild_defconfig_exists); then
 			if [ -f "${UNPACKDIR}/defconfig" ]; then
 				# If the two defconfig's are different, warn that we overwrote the
 				# one already placed in UNPACKDIR
@@ -478,8 +486,12 @@  do_kernel_configme() {
 			config_flags=""
 			;;
 		*)
-			if [ -f ${UNPACKDIR}/defconfig ]; then
-				config_flags="-n"
+			if $(kbuild_defconfig_exists); then
+				config_flags=""
+			else
+				if [ -f ${UNPACKDIR}/defconfig ]; then
+					config_flags="-n"
+				fi
 			fi
 			;;
 	esac