From: Rahul Rameshbabu <sergeantsagara@protonmail.com>
To: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Rahul Rameshbabu <sergeantsagara@protonmail.com>,
Masahiro Yamada <masahiroy@kernel.org>
Subject: [PATCH] scripts: merge_config: Add flag to prevent unsetting config option
Date: Sat, 29 Jul 2023 21:41:51 +0000 [thread overview]
Message-ID: <20230729214138.79902-1-sergeantsagara@protonmail.com> (raw)
Overriding a previously defined entry for a config option with 'is not set'
may be undesirable in some fragment configuration setups. Provide a flag to
change the behavior, so 'is not set' is not overridden when a previous
value for the same config option already exists.
Cc: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Rahul Rameshbabu <sergeantsagara@protonmail.com>
---
scripts/kconfig/merge_config.sh | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh
index 902eb429b9db..bbe235f2df70 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 " -N not set entries in fragments will not override options."
echo
echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_ environment variable."
}
@@ -42,6 +43,7 @@ OUTPUT=.
STRICT=false
CONFIG_PREFIX=${CONFIG_-CONFIG_}
WARNOVERRIDE=echo
+OVERRIDENOTSET=true
while true; do
case $1 in
@@ -89,6 +91,11 @@ while true; do
shift
continue
;;
+ "-N")
+ OVERRIDENOTSET=false
+ shift
+ continue
+ ;;
*)
break
;;
@@ -143,13 +150,20 @@ 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
+ NO_OVERRIDE_FLAG=false
+ if [ "$OVERRIDENOTSET" = "false" ] && [ "${NEW_VAL#\# CONFIG_* }" = "is not set" ] &&
+ [ "$PREV_VAL" != "" ] && [ "${PREV_VAL#\# CONFIG_* }" != "is not set" ]; then
+ ${WARNOVERRIDE} Previous value: $PREV_VAL
+ ${WARNOVERRIDE} New value: $NEW_VAL
+ ${WARNOVERRIDE} -N passed, will not unset option
+ ${WARNOVERRIDE}
+ NO_OVERRIDE_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
+ NO_OVERRIDE_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 +175,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 [ "$NO_OVERRIDE_FLAG" = "false" ]; then
sed -i "/$CFG[ =]/d" $TMP_FILE
else
sed -i "/$CFG[ =]/d" $MERGE_FILE
--
2.40.1
next reply other threads:[~2023-07-29 21:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-29 21:41 Rahul Rameshbabu [this message]
2023-08-06 14:19 ` Masahiro Yamada
2023-08-07 4:13 ` Rahul Rameshbabu
2023-08-07 19:04 ` Masahiro Yamada
2023-08-12 16:44 ` Rahul Rameshbabu
2023-08-16 3:18 ` Masahiro Yamada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230729214138.79902-1-sergeantsagara@protonmail.com \
--to=sergeantsagara@protonmail.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®