[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250116143140.2640563-1-maciej.wieczor-retman@intel.com>
Date: Thu, 16 Jan 2025 15:31:40 +0100
From: Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com>
To: Masahiro Yamada <masahiroy@...nel.org>
Cc: artem.bityutskiy@...el.com,
maciej.wieczor-retman@...el.com,
linux-kbuild@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] scripts: kconfig: merge_config: Add upgrade mode option
The -y option in merge_config.sh is used to not demote options that are
enabled - if something is set as builtin it won't move to be a module in
the output .config.
There is however no mode that would simply take the most enabled option
out of both files and put it in the output .config.
Add an upgrade mode specified by passing -u parameter. It works similar
to -y but when the new value is "not set" it will use the old value.
Reuse the BUILTIN_FLAG since usage is similar and rename it to OMIT_FLAG
since it's not used for builtin option only anymore.
Change the if else order so upgrade is checked first and builtin is
checked second since upgrade is a wider version of builtin.
I tested the patch on two working configs from two very different kernel
builds and it compiled and booted without problems.
Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com>
---
scripts/kconfig/merge_config.sh | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh
index 0b7952471c18..da794ac08b3e 100755
--- a/scripts/kconfig/merge_config.sh
+++ b/scripts/kconfig/merge_config.sh
@@ -30,6 +30,7 @@ usage() {
echo " -O dir to put generated output files. Consider setting \$KCONFIG_CONFIG instead."
echo " -s strict mode. Fail if the fragment redefines any value."
echo " -Q disable warning messages for overridden options."
+ echo " -u make builtin have precedence over modules and modules over not set"
echo
echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_ environment variable."
}
@@ -38,6 +39,7 @@ RUNMAKE=true
ALLTARGET=alldefconfig
WARNREDUN=false
BUILTIN=false
+UPGRADE=false
OUTPUT=.
STRICT=false
CONFIG_PREFIX=${CONFIG_-CONFIG_}
@@ -69,6 +71,11 @@ while true; do
shift
continue
;;
+ "-u")
+ UPGRADE=true
+ shift
+ continue
+ ;;
"-O")
if [ -d $2 ];then
OUTPUT=$(echo $2 | sed 's/\/*$//')
@@ -143,13 +150,23 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
grep -q -w $CFG $TMP_FILE || continue
PREV_VAL=$(grep -w $CFG $TMP_FILE)
NEW_VAL=$(grep -w $CFG $MERGE_FILE)
- BUILTIN_FLAG=false
- if [ "$BUILTIN" = "true" ] && [ "${NEW_VAL#CONFIG_*=}" = "m" ] && [ "${PREV_VAL#CONFIG_*=}" = "y" ]; then
+ OMIT_FLAG=false
+
+ if { [ "$UPGRADE" = "true" ] && \
+ { { [ "${NEW_VAL#CONFIG_*=}" = "m" ] && [ "${PREV_VAL#CONFIG_*=}" = "y" ]; } ||
+ { [ "${NEW_VAL#CONFIG_*=}" != "m" ] && [ "${NEW_VAL#CONFIG_*=}" != "y" ] &&
+ { [ "${PREV_VAL#CONFIG_*=}" = "y" ] || [ "${PREV_VAL#CONFIG_*=}" = "m" ]; }; }; }; }; then
+ ${WARNOVERRIDE} Previous value: $PREV_VAL
+ ${WARNOVERRIDE} New value: $NEW_VAL
+ ${WARNOVERRIDE} -u passed, will demote neither y to m nor y or m to not set
+ ${WARNOVERRIDE}
+ OMIT_FLAG=true
+ elif [ "$BUILTIN" = "true" ] && [ "${NEW_VAL#CONFIG_*=}" = "m" ] && [ "${PREV_VAL#CONFIG_*=}" = "y" ]; then
${WARNOVERRIDE} Previous value: $PREV_VAL
${WARNOVERRIDE} New value: $NEW_VAL
${WARNOVERRIDE} -y passed, will not demote y to m
${WARNOVERRIDE}
- BUILTIN_FLAG=true
+ OMIT_FLAG=true
elif [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
${WARNOVERRIDE} Value of $CFG is redefined by fragment $ORIG_MERGE_FILE:
${WARNOVERRIDE} Previous value: $PREV_VAL
@@ -161,7 +178,7 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
elif [ "$WARNREDUN" = "true" ]; then
${WARNOVERRIDE} Value of $CFG is redundant by fragment $ORIG_MERGE_FILE:
fi
- if [ "$BUILTIN_FLAG" = "false" ]; then
+ if [ "$OMIT_FLAG" = "false" ]; then
sed -i "/$CFG[ =]/d" $TMP_FILE
else
sed -i "/$CFG[ =]/d" $MERGE_FILE
--
2.47.1
Powered by blists - more mailing lists