From patchwork Sat Jul 29 21:41:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Rameshbabu X-Patchwork-Id: 13333233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1070C001DC for ; Sat, 29 Jul 2023 21:42:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229539AbjG2VmC (ORCPT ); Sat, 29 Jul 2023 17:42:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbjG2VmB (ORCPT ); Sat, 29 Jul 2023 17:42:01 -0400 Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DB6093 for ; Sat, 29 Jul 2023 14:41:58 -0700 (PDT) Date: Sat, 29 Jul 2023 21:41:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1690666916; x=1690926116; bh=ayP6Lyd6vT/OxN20N2dQ1W7dWvfMQN5QQ+y6w2FEL6Q=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=G60o1xdPn+JjOOgIzmI861dk2YeVZJ39YNneJhBKhlRLWSzwZgCKj9wgED7B0RKMA z1OxEZW+259UrII6jmqU7DG1xbnjdpl90TFCKkOEfluj2IzBDi8W+9jCqQnezkhNYt F9TCQHKjDpkQqU/2fj/e9t2Fh9uEuRJLI4MJVy0R23N2ZTWEDrk2WxgRjlEIab9H5/ Dnv9lNP7L8wPYpKmTg3QsDLyvNHTEKw78suejQklUbY/aMi3plT824ZAdui9A8HWYl KzDVr3RzDGFY6f01jhCmtY1iYITdVZojIt0BBz/0Ls56/nD2LE1XYFfEpr8jcpamL4 RAcyE3JxhJFvA== To: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org From: Rahul Rameshbabu Cc: Rahul Rameshbabu , Masahiro Yamada Subject: [PATCH] scripts: merge_config: Add flag to prevent unsetting config option Message-ID: <20230729214138.79902-1-sergeantsagara@protonmail.com> Feedback-ID: 26003777:user:proton MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org 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 Signed-off-by: Rahul Rameshbabu --- 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