Skip to contentSkip to conversation

Fix merging configuration fragments

PATCH Superseded Nasser Afshin 5 participants 14 messages Nov 14, 2018 – Nov 24, 2018

lore
Share & tools
lore
#0 lore raw

v3 cover Fix merging configuration fragments

From: Nasser Afshin <[email protected]>

We use merge_config.sh as a helper script to merge many types of config fragments. The script has recently improved to better support buildroot. Now the report mechanism (-r -m) works as expected for buildroot configuration fragments.

When using this feature in buildroot with empty config prefixes, we have some false positive reports from comment lines. The last patch tries to avoid such false positive matches.

Nasser Afshin (3):
merge_config.sh: Fix merging buildroot config files
test-pkg: Use the correct config prefix when merging merge_config.sh: Avoid false positive matches from comment lines

 support/kconfig/merge_config.sh                    | 12 ++++++--
 ...e_config.sh-Allow-to-define-config-prefix.patch | 31 +++++++++++++++++++++
 ...false-positive-matches-from-comment-lines.patch | 32 ++++++++++++++++++++++
 support/kconfig/patches/series                     |  2 ++
 utils/test-pkg                                     |  2 +-
 5 files changed, 75 insertions(+), 4 deletions(-)
 create mode 100644 support/kconfig/patches/20-merge_config.sh-Allow-to-define-config-prefix.patch
 create mode 100644 support/kconfig/patches/21-Avoid-false-positive-matches-from-comment-lines.patch
Signature · 1 line
2.15.0
#1 lore raw

PATCH v3 1/3 merge_config.sh: Fix merging buildroot config files

This patch allows us to define config prefix with CONFIG_ environment variable.

By setting the proper config prefix, we will have proper 'redundant configuration warnings' when we use '-r -m' options.

This is actually already in mainline for v4.20-rc1:
2cd3faf87d2d8f6123adf34741b9a7b98828a76f ("merge_config.sh: Allow to define config prefix")

---
 support/kconfig/merge_config.sh                    |  7 ++++-
 ...e_config.sh-Allow-to-define-config-prefix.patch | 31 ++++++++++++++++++++++
 support/kconfig/patches/series                     |  1 +
 3 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 support/kconfig/patches/20-merge_config.sh-Allow-to-define-config-prefix.patch
support/kconfig/merge_config.sh +6 -1
index 50de5114dc..404ca3864f 100755
@@ -34,12 +34,16 @@ usage() {
 	echo "  -r    list redundant entries when merging fragments"
 	echo "  -O    dir to put generated output files.  Consider setting \$KCONFIG_CONFIG instead."
 	echo "  -e    colon-separated list of br2-external trees to use (optional)"
+	echo
+	echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_
+	environment variable."
 }
 
 RUNMAKE=true
 ALLTARGET=alldefconfig
 WARNREDUN=false
 OUTPUT=.
+CONFIG_PREFIX=${CONFIG_-CONFIG_}
 
 while true; do
 	case $1 in
@@ -105,7 +109,8 @@ if [ ! -r "$INITFILE" ]; then
 fi
 
 MERGE_LIST=$*
-SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p"
+SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)[= ].*/\2/p"
+
 TMP_FILE=$(mktemp -t .tmp.config.XXXXXXXXXX)
 
 echo "Using $INITFILE as base"
support/kconfig/patches/20-merge_config.sh-Allow-to-define-config-prefix.patch new file +31 -0
new file mode 100644
index 0000000000..645043b163
@@ -0,0 +1,31 @@
+Index: kconfig/merge_config.sh
+===================================================================
+--- kconfig.orig/merge_config.sh
++++ kconfig/merge_config.sh
+@@ -34,12 +34,16 @@ usage() {
+ 	echo "  -r    list redundant entries when merging fragments"
+ 	echo "  -O    dir to put generated output files.  Consider setting \$KCONFIG_CONFIG instead."
+ 	echo "  -e    colon-separated list of br2-external trees to use (optional)"
++	echo
++	echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_
++	environment variable."
+ }
+ 
+ RUNMAKE=true
+ ALLTARGET=alldefconfig
+ WARNREDUN=false
+ OUTPUT=.
++CONFIG_PREFIX=${CONFIG_-CONFIG_}
+ 
+ while true; do
+ 	case $1 in
+@@ -105,7 +109,8 @@ if [ ! -r "$INITFILE" ]; then
+ fi
+ 
+ MERGE_LIST=$*
+-SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p"
++SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)[= ].*/\2/p"
++
+ TMP_FILE=$(mktemp -t .tmp.config.XXXXXXXXXX)
+ 
+ echo "Using $INITFILE as base"
support/kconfig/patches/series +1 -0
index e136de7937..be8627db13 100644
@@ -8,3 +8,4 @@
 17-backport-kecho.patch
 18-merge-config.sh-create-temporary-files-in-tmp.patch
 19-merge_config.sh-add-br2-external-support.patch
+20-merge_config.sh-Allow-to-define-config-prefix.patch
Signature · 1 line
2.15.0
#2 lore raw

PATCH v3 1/3 merge_config.sh: Fix merging buildroot config files

Nasser, All,

On 2018-11-14 10:41 +0330, Nasser Afshin spake thusly:

Quoted 6 lines

This patch allows us to define config prefix with CONFIG_ environment variable.

By setting the proper config prefix, we will have proper 'redundant configuration warnings' when we use '-r -m' options.

Quoted 6 lines

This is actually already in mainline for v4.20-rc1:
2cd3faf87d2d8f6123adf34741b9a7b98828a76f ("merge_config.sh: Allow to define config prefix")

Regards,
Yann E. MORIN.

Quoted 91 lines
---
 support/kconfig/merge_config.sh                    |  7 ++++-
 ...e_config.sh-Allow-to-define-config-prefix.patch | 31 ++++++++++++++++++++++
 support/kconfig/patches/series                     |  1 +
 3 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 support/kconfig/patches/20-merge_config.sh-Allow-to-define-config-prefix.patch
support/kconfig/merge_config.sh +6 -1
index 50de5114dc..404ca3864f 100755
@@ -34,12 +34,16 @@ usage() {
 	echo "  -r    list redundant entries when merging fragments"
 	echo "  -O    dir to put generated output files.  Consider setting \$KCONFIG_CONFIG instead."
 	echo "  -e    colon-separated list of br2-external trees to use (optional)"
+	echo
+	echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_
+	environment variable."
 }
 
 RUNMAKE=true
 ALLTARGET=alldefconfig
 WARNREDUN=false
 OUTPUT=.
+CONFIG_PREFIX=${CONFIG_-CONFIG_}
 
 while true; do
 	case $1 in
@@ -105,7 +109,8 @@ if [ ! -r "$INITFILE" ]; then
 fi
 
 MERGE_LIST=$*
-SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p"
+SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)[= ].*/\2/p"
+
 TMP_FILE=$(mktemp -t .tmp.config.XXXXXXXXXX)
 
 echo "Using $INITFILE as base"
support/kconfig/patches/20-merge_config.sh-Allow-to-define-config-prefix.patch new file +31 -0
new file mode 100644
index 0000000000..645043b163
@@ -0,0 +1,31 @@
+Index: kconfig/merge_config.sh
+===================================================================
+--- kconfig.orig/merge_config.sh
++++ kconfig/merge_config.sh
+@@ -34,12 +34,16 @@ usage() {
+ 	echo "  -r    list redundant entries when merging fragments"
+ 	echo "  -O    dir to put generated output files.  Consider setting \$KCONFIG_CONFIG instead."
+ 	echo "  -e    colon-separated list of br2-external trees to use (optional)"
++	echo
++	echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_
++	environment variable."
+ }
+ 
+ RUNMAKE=true
+ ALLTARGET=alldefconfig
+ WARNREDUN=false
+ OUTPUT=.
++CONFIG_PREFIX=${CONFIG_-CONFIG_}
+ 
+ while true; do
+ 	case $1 in
+@@ -105,7 +109,8 @@ if [ ! -r "$INITFILE" ]; then
+ fi
+ 
+ MERGE_LIST=$*
+-SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p"
++SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)[= ].*/\2/p"
++
+ TMP_FILE=$(mktemp -t .tmp.config.XXXXXXXXXX)
+ 
+ echo "Using $INITFILE as base"
support/kconfig/patches/series +1 -0
index e136de7937..be8627db13 100644
@@ -8,3 +8,4 @@
 17-backport-kecho.patch
 18-merge-config.sh-create-temporary-files-in-tmp.patch
 19-merge_config.sh-add-br2-external-support.patch
+20-merge_config.sh-Allow-to-define-config-prefix.patch
Signature · 6 lines
2.15.0

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH v3 1/3 merge_config.sh: Fix merging buildroot config files

In reply to Nasser Afshin

Hello,

Quoted 10 lines · Nasser Afshin

This patch allows us to define config prefix with CONFIG_ environment variable.

By setting the proper config prefix, we will have proper 'redundant configuration warnings' when we use '-r -m' options.

This is actually already in mainline for v4.20-rc1:
2cd3faf87d2d8f6123adf34741b9a7b98828a76f ("merge_config.sh: Allow to define config prefix")

Quoted 8 lines
---
 support/kconfig/merge_config.sh                    |  7 ++++-
 ...e_config.sh-Allow-to-define-config-prefix.patch | 31 ++++++++++++++++++++++
 support/kconfig/patches/series                     |  1 +
 3 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 support/kconfig/patches/20-merge_config.sh-Allow-to-define-config-prefix.patch

Applied to next, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH v3 2/3 test-pkg: Use the correct config prefix when merging

In reply to Nasser Afshin

From: Nasser Afshin <[email protected]>

We should use an empty prefix as we do not have any prefix. Note that BR2_ is mere a convention.

---
 utils/test-pkg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/test-pkg +1 -1
index aa91ee02cf..e4f68ed061 100755
@@ -129,7 +129,7 @@ build_one() {
 
     mkdir -p "${dir}"
 
-    support/kconfig/merge_config.sh -O "${dir}" \
+    CONFIG_= support/kconfig/merge_config.sh -O "${dir}" \
         "${toolchainconfig}" "support/config-fragments/minimal.config" "${cfg}" \
         >> "${dir}/logfile" 2>&1
     # We want all the options from the snippet to be present as-is (set
Signature · 1 line
2.15.0
#5 lore raw

PATCH v3 2/3 test-pkg: Use the correct config prefix when merging

Hi Nasser,

Quoted 6 lines

From: Nasser Afshin <[email protected]>

We should use an empty prefix as we do not have any prefix. Note that BR2_ is mere a convention.

Quoted 9 lines
---
 utils/test-pkg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/test-pkg +0 -0
index aa91ee02cf..e4f68ed061 100755

utils/test-pkg build_one() { · line 132

Quoted 5 lines
utils/test-pkg +1 -1
@@ -129,7 +129,7 @@ build_one() {
 
     mkdir -p "${dir}"
 
-    support/kconfig/merge_config.sh -O "${dir}" \
+    CONFIG_= support/kconfig/merge_config.sh -O "${dir}" \

Thanks for a change.

Kind regards,
Petr

#6 lore raw

PATCH v3 2/3 test-pkg: Use the correct config prefix when merging

Hi Petr

Quoted 9 lines · Petr Vorel

Hi Nasser,

Quoted 6 lines

From: Nasser Afshin <[email protected]>

We should use an empty prefix as we do not have any prefix. Note that BR2_ is mere a convention.

Sorry I forgot to mention that. Resent.

Quoted 12 lines
Quoted 11 lines
---
 utils/test-pkg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/test-pkg +0 -0
index aa91ee02cf..e4f68ed061 100755
@@ -129,7 +129,7 @@ build_one() {
 
     mkdir -p "${dir}"
Quoted 7 lines

utils/test-pkg build_one() { · line 132

Quoted 2 lines
utils/test-pkg +1 -1
-    support/kconfig/merge_config.sh -O "${dir}" \
+    CONFIG_= support/kconfig/merge_config.sh -O "${dir}" \

Thanks for a change.

Kind regards,
Petr

Kind regards,
Nasser

#7 lore raw

PATCH v3 2/3 test-pkg: Use the correct config prefix when merging

Hi Nasser,

Two remarks for your future contributions.

Quoted 10 lines · Nasser Afshin

Hi Petr

Quoted 8 lines · Petr Vorel

Hi Nasser,

Quoted 6 lines

From: Nasser Afshin <[email protected]>

We should use an empty prefix as we do not have any prefix. Note that BR2_ is mere a convention.

When you send a v2 or later, please include a patch changelog, like so:

---
v2: remove quotes from the empty CONFIG_ assignment (suggested by Peter Vorel)

The --- splits the commit message from additional notes that won't be included
when the patch is applied.

Quoted 2 lines
Quoted 1 line

Sorry I forgot to mention that. Resent.

There is no need to resend for that: patchwork will include it automatically.

Regards,
Arnout

Quoted 22 lines
Quoted 12 lines
Quoted 11 lines
---
 utils/test-pkg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/test-pkg +0 -0
index aa91ee02cf..e4f68ed061 100755
@@ -129,7 +129,7 @@ build_one() {
 
     mkdir -p "${dir}"
Quoted 7 lines

utils/test-pkg build_one() { · line 132

Quoted 2 lines
utils/test-pkg +1 -1
-    support/kconfig/merge_config.sh -O "${dir}" \
+    CONFIG_= support/kconfig/merge_config.sh -O "${dir}" \

Thanks for a change.

Kind regards,
Petr

Kind regards,
Nasser

#8 lore raw

PATCH v3 2/3 test-pkg: Use the correct config prefix when merging

Hi Nasser,

agree with Arnout. + one more tip: increase version each time you send it, even it's just a tiny change.

Kind regards,
Petr

#9 lore raw

PATCH v3 2/3 test-pkg: Use the correct config prefix when merging

Dear Petr,

Quoted 7 lines · Petr Vorel

Hi Nasser,

agree with Arnout. + one more tip: increase version each time you send it, even it's just a tiny change.

Kind regards,
Petr

Thank you for your tip. Yes, you are right, I forgot to do so. Kind regards,
Nasser

#10 lore raw

PATCH v3 2/3 test-pkg: Use the correct config prefix when merging

In reply to Arnout Vandecappelle

Hi Arnout,

Quoted 16 lines · Arnout Vandecappelle

Hi Nasser,

Two remarks for your future contributions.

Quoted 10 lines · Nasser Afshin

Hi Petr

Quoted 8 lines · Petr Vorel

Hi Nasser,

Quoted 6 lines

From: Nasser Afshin <[email protected]>

We should use an empty prefix as we do not have any prefix. Note that BR2_ is mere a convention.

Quoted 9 lines

When you send a v2 or later, please include a patch changelog, like so:

---
v2: remove quotes from the empty CONFIG_ assignment (suggested by Peter Vorel)

The --- splits the commit message from additional notes that won't be included
when the patch is applied.

I thought it's a tiny change. You're right I should have included the changelog anyway.

Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Sorry I forgot to mention that. Resent.

There is no need to resend for that: patchwork will include it automatically.

Ok. Thank you for reviewing my patch and sending your tips. Sorry for being a novice.

Quoted 27 lines

Regards,
Arnout

Quoted 22 lines
Quoted 12 lines
Quoted 11 lines
---
 utils/test-pkg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/test-pkg +0 -0
index aa91ee02cf..e4f68ed061 100755
@@ -129,7 +129,7 @@ build_one() {
 
     mkdir -p "${dir}"
Quoted 7 lines

utils/test-pkg build_one() { · line 132

Quoted 2 lines
utils/test-pkg +1 -1
-    support/kconfig/merge_config.sh -O "${dir}" \
+    CONFIG_= support/kconfig/merge_config.sh -O "${dir}" \

Thanks for a change.

Kind regards,
Petr

Kind regards,
Nasser

Kind regards,
Nasser

#11 lore raw

PATCH v3 3/3 merge_config.sh: Avoid false positive matches from comment lines

In reply to Nasser Afshin

From: Nasser Afshin <[email protected]>

We are using empty CONFIG_PREFIX_. This results in false positive match for comment lines when merging config fragments.

To avoid false positive reports, we use separate sed expressions and address comment lines explicitly.

This is actually is in the Linux kernel mainline (v4.20-rc2):
6bbe4385d035c6fac56f840a59861a0310ce137b
("kconfig: merge_config: avoid false positive matches from comment lines")

---
 support/kconfig/merge_config.sh                    |  7 +++--
 ...false-positive-matches-from-comment-lines.patch | 32 ++++++++++++++++++++++
 support/kconfig/patches/series                     |  1 +
 3 files changed, 37 insertions(+), 3 deletions(-)
 create mode 100644 support/kconfig/patches/21-Avoid-false-positive-matches-from-comment-lines.patch
support/kconfig/merge_config.sh +4 -3
index 404ca3864f..14917806a3 100755
@@ -109,7 +109,8 @@ if [ ! -r "$INITFILE" ]; then
 fi
 
 MERGE_LIST=$*
-SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)[= ].*/\2/p"
+SED_CONFIG_EXP1="s/^\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)=.*/\1/p"
+SED_CONFIG_EXP2="s/^# \(${CONFIG_PREFIX}[a-zA-Z0-9_]*\) is not set$/\1/p"
 
 TMP_FILE=$(mktemp -t .tmp.config.XXXXXXXXXX)
 
@@ -123,7 +124,7 @@ for MERGE_FILE in $MERGE_LIST ; do
 		echo "The merge file '$MERGE_FILE' does not exist.  Exit." >&2
 		exit 1
 	fi
-	CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE)
+	CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $MERGE_FILE)
 
 	for CFG in $CFG_LIST ; do
 		grep -q -w $CFG $TMP_FILE || continue
@@ -166,7 +167,7 @@ make KCONFIG_ALLCONFIG=$TMP_FILE $EXTERNAL_ARG $OUTPUT_ARG $ALLTARGET
 
 
 # Check all specified config values took (might have missed-dependency issues)
-for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do
+for CFG in $(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $TMP_FILE); do
 
 	REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE)
 	ACTUAL_VAL=$(grep -w -e "$CFG" "$KCONFIG_CONFIG")
support/kconfig/patches/21-Avoid-false-positive-matches-from-comment-lines.patch new file +32 -0
new file mode 100644
index 0000000000..c11144e47e
@@ -0,0 +1,32 @@
+Index: kconfig/merge_config.sh
+===================================================================
+--- kconfig.orig/merge_config.sh
++++ kconfig/merge_config.sh
+@@ -109,7 +109,8 @@ if [ ! -r "$INITFILE" ]; then
+ fi
+ 
+ MERGE_LIST=$*
+-SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)[= ].*/\2/p"
++SED_CONFIG_EXP1="s/^\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)=.*/\1/p"
++SED_CONFIG_EXP2="s/^# \(${CONFIG_PREFIX}[a-zA-Z0-9_]*\) is not set$/\1/p"
+ 
+ TMP_FILE=$(mktemp -t .tmp.config.XXXXXXXXXX)
+ 
+@@ -123,7 +124,7 @@ for MERGE_FILE in $MERGE_LIST ; do
+ 		echo "The merge file '$MERGE_FILE' does not exist.  Exit." >&2
+ 		exit 1
+ 	fi
+-	CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE)
++	CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $MERGE_FILE)
+ 
+ 	for CFG in $CFG_LIST ; do
+ 		grep -q -w $CFG $TMP_FILE || continue
+@@ -166,7 +167,7 @@ make KCONFIG_ALLCONFIG=$TMP_FILE $EXTERN
+ 
+ 
+ # Check all specified config values took (might have missed-dependency issues)
+-for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do
++for CFG in $(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $TMP_FILE); do
+ 
+ 	REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE)
+ 	ACTUAL_VAL=$(grep -w -e "$CFG" "$KCONFIG_CONFIG")
support/kconfig/patches/series +1 -0
index be8627db13..e5a6f69d8f 100644
@@ -9,3 +9,4 @@
 18-merge-config.sh-create-temporary-files-in-tmp.patch
 19-merge_config.sh-add-br2-external-support.patch
 20-merge_config.sh-Allow-to-define-config-prefix.patch
+21-Avoid-false-positive-matches-from-comment-lines.patch
Signature · 1 line
2.15.0
#12 lore raw

PATCH v3 3/3 merge_config.sh: Avoid false positive matches from comment lines

Nasser, All,

On 2018-11-14 10:41 +0330, Nasser Afshin spake thusly:

Quoted 8 lines

From: Nasser Afshin <[email protected]>

We are using empty CONFIG_PREFIX_. This results in false positive match for comment lines when merging config fragments.

To avoid false positive reports, we use separate sed expressions and address comment lines explicitly.

Quoted 6 lines

This is actually is in the Linux kernel mainline (v4.20-rc2):
6bbe4385d035c6fac56f840a59861a0310ce137b
("kconfig: merge_config: avoid false positive matches from comment lines")

Regards,
Yann E. MORIN.

Quoted 93 lines
---
 support/kconfig/merge_config.sh                    |  7 +++--
 ...false-positive-matches-from-comment-lines.patch | 32 ++++++++++++++++++++++
 support/kconfig/patches/series                     |  1 +
 3 files changed, 37 insertions(+), 3 deletions(-)
 create mode 100644 support/kconfig/patches/21-Avoid-false-positive-matches-from-comment-lines.patch
support/kconfig/merge_config.sh +4 -3
index 404ca3864f..14917806a3 100755
@@ -109,7 +109,8 @@ if [ ! -r "$INITFILE" ]; then
 fi
 
 MERGE_LIST=$*
-SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)[= ].*/\2/p"
+SED_CONFIG_EXP1="s/^\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)=.*/\1/p"
+SED_CONFIG_EXP2="s/^# \(${CONFIG_PREFIX}[a-zA-Z0-9_]*\) is not set$/\1/p"
 
 TMP_FILE=$(mktemp -t .tmp.config.XXXXXXXXXX)
 
@@ -123,7 +124,7 @@ for MERGE_FILE in $MERGE_LIST ; do
 		echo "The merge file '$MERGE_FILE' does not exist.  Exit." >&2
 		exit 1
 	fi
-	CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE)
+	CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $MERGE_FILE)
 
 	for CFG in $CFG_LIST ; do
 		grep -q -w $CFG $TMP_FILE || continue
@@ -166,7 +167,7 @@ make KCONFIG_ALLCONFIG=$TMP_FILE $EXTERNAL_ARG $OUTPUT_ARG $ALLTARGET
 
 
 # Check all specified config values took (might have missed-dependency issues)
-for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do
+for CFG in $(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $TMP_FILE); do
 
 	REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE)
 	ACTUAL_VAL=$(grep -w -e "$CFG" "$KCONFIG_CONFIG")
support/kconfig/patches/21-Avoid-false-positive-matches-from-comment-lines.patch new file +32 -0
new file mode 100644
index 0000000000..c11144e47e
@@ -0,0 +1,32 @@
+Index: kconfig/merge_config.sh
+===================================================================
+--- kconfig.orig/merge_config.sh
++++ kconfig/merge_config.sh
+@@ -109,7 +109,8 @@ if [ ! -r "$INITFILE" ]; then
+ fi
+ 
+ MERGE_LIST=$*
+-SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)[= ].*/\2/p"
++SED_CONFIG_EXP1="s/^\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)=.*/\1/p"
++SED_CONFIG_EXP2="s/^# \(${CONFIG_PREFIX}[a-zA-Z0-9_]*\) is not set$/\1/p"
+ 
+ TMP_FILE=$(mktemp -t .tmp.config.XXXXXXXXXX)
+ 
+@@ -123,7 +124,7 @@ for MERGE_FILE in $MERGE_LIST ; do
+ 		echo "The merge file '$MERGE_FILE' does not exist.  Exit." >&2
+ 		exit 1
+ 	fi
+-	CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE)
++	CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $MERGE_FILE)
+ 
+ 	for CFG in $CFG_LIST ; do
+ 		grep -q -w $CFG $TMP_FILE || continue
+@@ -166,7 +167,7 @@ make KCONFIG_ALLCONFIG=$TMP_FILE $EXTERN
+ 
+ 
+ # Check all specified config values took (might have missed-dependency issues)
+-for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do
++for CFG in $(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $TMP_FILE); do
+ 
+ 	REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE)
+ 	ACTUAL_VAL=$(grep -w -e "$CFG" "$KCONFIG_CONFIG")
support/kconfig/patches/series +1 -0
index be8627db13..e5a6f69d8f 100644
@@ -9,3 +9,4 @@
 18-merge-config.sh-create-temporary-files-in-tmp.patch
 19-merge_config.sh-add-br2-external-support.patch
 20-merge_config.sh-Allow-to-define-config-prefix.patch
+21-Avoid-false-positive-matches-from-comment-lines.patch
Signature · 6 lines
2.15.0

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#13 lore raw

PATCH v3 3/3 merge_config.sh: Avoid false positive matches from comment lines

In reply to Nasser Afshin

Hello,

Quoted 12 lines · Nasser Afshin

From: Nasser Afshin <[email protected]>

We are using empty CONFIG_PREFIX_. This results in false positive match for comment lines when merging config fragments.

To avoid false positive reports, we use separate sed expressions and address comment lines explicitly.

This is actually is in the Linux kernel mainline (v4.20-rc2):
6bbe4385d035c6fac56f840a59861a0310ce137b
("kconfig: merge_config: avoid false positive matches from comment lines")

Quoted 8 lines
---
 support/kconfig/merge_config.sh                    |  7 +++--
 ...false-positive-matches-from-comment-lines.patch | 32 ++++++++++++++++++++++
 support/kconfig/patches/series                     |  1 +
 3 files changed, 37 insertions(+), 3 deletions(-)
 create mode 100644 support/kconfig/patches/21-Avoid-false-positive-matches-from-comment-lines.patch

Applied to next, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com