提交 a325db2d 编写于 作者: M Matthias Maennich 提交者: Masahiro Yamada

scripts: merge_config: add strict mode to fail upon any redefinition

When merging configuration fragments, it might be of interest to
identify mismatches (redefinitions) programmatically. Hence add the
option -s (strict mode) to instruct merge_config.sh to bail out in
case any redefinition has been detected.

With strict mode, warnings are emitted as before, but the script
terminates with rc=1. If -y is set to define "builtin having
precedence over modules", fragments are still allowed to set =m (while
the base config has =y). Strict mode will tolerate that as demotions
from =y to =m are ignored when setting -y.
Signed-off-by: NMatthias Maennich <maennich@google.com>
Reviewed-by: NLee Jones <lee.jones@linaro.org>
Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
上级 36a21d51
...@@ -28,6 +28,7 @@ usage() { ...@@ -28,6 +28,7 @@ usage() {
echo " -r list redundant entries when merging fragments" echo " -r list redundant entries when merging fragments"
echo " -y make builtin have precedence over modules" echo " -y make builtin have precedence over modules"
echo " -O dir to put generated output files. Consider setting \$KCONFIG_CONFIG instead." 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 echo
echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_ environment variable." echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_ environment variable."
} }
...@@ -37,6 +38,7 @@ ALLTARGET=alldefconfig ...@@ -37,6 +38,7 @@ ALLTARGET=alldefconfig
WARNREDUN=false WARNREDUN=false
BUILTIN=false BUILTIN=false
OUTPUT=. OUTPUT=.
STRICT=false
CONFIG_PREFIX=${CONFIG_-CONFIG_} CONFIG_PREFIX=${CONFIG_-CONFIG_}
while true; do while true; do
...@@ -75,6 +77,11 @@ while true; do ...@@ -75,6 +77,11 @@ while true; do
shift 2 shift 2
continue continue
;; ;;
"-s")
STRICT=true
shift
continue
;;
*) *)
break break
;; ;;
...@@ -141,6 +148,9 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do ...@@ -141,6 +148,9 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
echo Previous value: $PREV_VAL echo Previous value: $PREV_VAL
echo New value: $NEW_VAL echo New value: $NEW_VAL
echo echo
if [ "$STRICT" = "true" ]; then
STRICT_MODE_VIOLATED=true
fi
elif [ "$WARNREDUN" = "true" ]; then elif [ "$WARNREDUN" = "true" ]; then
echo Value of $CFG is redundant by fragment $ORIG_MERGE_FILE: echo Value of $CFG is redundant by fragment $ORIG_MERGE_FILE:
fi fi
...@@ -153,6 +163,11 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do ...@@ -153,6 +163,11 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
cat $MERGE_FILE >> $TMP_FILE cat $MERGE_FILE >> $TMP_FILE
done done
if [ "$STRICT_MODE_VIOLATED" = "true" ]; then
echo "The fragment redefined a value and strict mode had been passed."
exit 1
fi
if [ "$RUNMAKE" = "false" ]; then if [ "$RUNMAKE" = "false" ]; then
cp -T -- "$TMP_FILE" "$KCONFIG_CONFIG" cp -T -- "$TMP_FILE" "$KCONFIG_CONFIG"
echo "#" echo "#"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册