diff mbox series

[v3] merge_config.sh: merge also buildroot config files

Message ID 20181025022031.14043-1-afshin.nasser@gmail.com
State Superseded
Headers show
Series [v3] merge_config.sh: merge also buildroot config files | expand

Commit Message

Nasser Afshin Oct. 25, 2018, 2:20 a.m. UTC
From: Angelo Compagnucci <angelo.compagnucci@gmail.com>

This patch adds a way to merge buildroot config file programmatically.
It adds an option (-b, buildroot mode) to manage buildroot config files.
The buildroot mode changes the way the script looks for configurations
entries using the BR2_ prefix and modify the call to the make command
to be buildroot friendly.

Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
Signed-off-by: Nasser Afshin <afshin.nasser@gmail.com>
---
I forgot to apply the presented patch. Now it's applied.

 support/kconfig/merge_config.sh                    |  9 ++++-
 ...18-fix-finding-redundant-config-mechanism.patch | 41 ++++++++++++++++++++++
 support/kconfig/patches/series                     |  1 +
 3 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 support/kconfig/patches/18-fix-finding-redundant-config-mechanism.patch

Comments

Patzlaff, Marcel Oct. 25, 2018, 6:02 a.m. UTC | #1
Hi Nasser, Arnout,

after looking into the uclibc config, I think it would be better to
just remove the prefix restriction completely. What purpose does
filtering for "CONFIG_" or "BR2_" serve?

Kind regards,
Marcel

"buildroot" <buildroot-bounces@busybox.net> schrieb am 25.10.2018 
04:20:31:

> Von: Nasser Afshin <afshin.nasser@gmail.com>
> An: Arnout Vandecappelle <arnout@mind.be>
> Kopie: Nasser Afshin <afshin.nasser@gmail.com>, buildroot 
> <buildroot@buildroot.org>
> Datum: 25.10.2018 04:21
> Betreff: [Buildroot] [PATCH v3] merge_config.sh: merge also 
> buildroot config files
> Gesendet von: "buildroot" <buildroot-bounces@busybox.net>
> 
> From: Angelo Compagnucci <angelo.compagnucci@gmail.com>
> 
> This patch adds a way to merge buildroot config file programmatically.
> It adds an option (-b, buildroot mode) to manage buildroot config files.
> The buildroot mode changes the way the script looks for configurations
> entries using the BR2_ prefix and modify the call to the make command
> to be buildroot friendly.
> 
> Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
> Signed-off-by: Nasser Afshin <afshin.nasser@gmail.com>
> ---
> I forgot to apply the presented patch. Now it's applied.
> 
>  support/kconfig/merge_config.sh                    |  9 ++++-
>  ...18-fix-finding-redundant-config-mechanism.patch | 41 +++++++++++
> +++++++++++
>  support/kconfig/patches/series                     |  1 +
>  3 files changed, 50 insertions(+), 1 deletion(-)
>  create mode 100644 support/kconfig/patches/18-fix-finding-
> redundant-config-mechanism.patch
> 
> diff --git a/support/kconfig/merge_config.sh 
b/support/kconfig/merge_config.sh
> index 67d1314476..f22198023c 100755
> --- a/support/kconfig/merge_config.sh
> +++ b/support/kconfig/merge_config.sh
> @@ -29,6 +29,7 @@ trap clean_up HUP INT TERM
>  usage() {
>     echo "Usage: $0 [OPTIONS] [CONFIG [...]]"
>     echo "  -h    display this help text"
> +   echo "  -b    buildroot mode (searches for BR2_ and uses a 
> custom make command)"
>     echo "  -m    only merge the fragments, do not execute the make 
command"
>     echo "  -n    use allnoconfig instead of alldefconfig"
>     echo "  -r    list redundant entries when merging fragments"
> @@ -39,6 +40,7 @@ RUNMAKE=true
>  ALLTARGET=alldefconfig
>  WARNREDUN=false
>  OUTPUT=.
> +CONFIG_PREFIX=CONFIG_
> 
>  while true; do
>     case $1 in
> @@ -71,6 +73,11 @@ while true; do
>        shift 2
>        continue
>        ;;
> +   "-b")
> +      CONFIG_PREFIX=BR2_
> +      shift
> +      continue
> +      ;;
>     *)
>        break
>        ;;
> @@ -99,7 +106,7 @@ 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 ./.tmp.config.XXXXXXXXXX)
> 
>  echo "Using $INITFILE as base"
> diff --git a/support/kconfig/patches/18-fix-finding-redundant-
> config-mechanism.patch b/support/kconfig/patches/18-fix-finding-
> redundant-config-mechanism.patch
> new file mode 100644
> index 0000000000..eec92a5fad
> --- /dev/null
> +++ 
b/support/kconfig/patches/18-fix-finding-redundant-config-mechanism.patch
> @@ -0,0 +1,41 @@
> +Index: kconfig/merge_config.sh
> +===================================================================
> +--- kconfig.orig/merge_config.sh
> ++++ kconfig/merge_config.sh
> +@@ -29,6 +29,7 @@ trap clean_up HUP INT TERM
> + usage() {
> +    echo "Usage: $0 [OPTIONS] [CONFIG [...]]"
> +    echo "  -h    display this help text"
> ++   echo "  -b    buildroot mode (searches for BR2_ and uses a 
> custom make command)"
> +    echo "  -m    only merge the fragments, do not execute the make 
command"
> +    echo "  -n    use allnoconfig instead of alldefconfig"
> +    echo "  -r    list redundant entries when merging fragments"
> +@@ -39,6 +40,7 @@ RUNMAKE=true
> + ALLTARGET=alldefconfig
> + WARNREDUN=false
> + OUTPUT=.
> ++CONFIG_PREFIX=CONFIG_
> + 
> + while true; do
> +    case $1 in
> +@@ -71,6 +73,11 @@ while true; do
> +       shift 2
> +       continue
> +       ;;
> ++   "-b")
> ++      CONFIG_PREFIX=BR2_
> ++      shift
> ++      continue
> ++      ;;
> +    *)
> +       break
> +       ;;
> +@@ -99,7 +106,7 @@ 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 ./.tmp.config.XXXXXXXXXX)
> + 
> + echo "Using $INITFILE as base"
> diff --git a/support/kconfig/patches/series 
b/support/kconfig/patches/series
> index 36591e2189..5ebc2e0225 100644
> --- a/support/kconfig/patches/series
> +++ b/support/kconfig/patches/series
> @@ -6,3 +6,4 @@
>  14-support-out-of-tree-config.patch
>  16-fix-space-to-de-select-options.patch
>  17-backport-kecho.patch
> +18-fix-finding-redundant-config-mechanism.patch
> -- 
> 2.15.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot


Geschäftsführung: Susanne Kunschert, Thomas Pilz
Pilz GmbH & Co. KG, Sitz: Ostfildern, HRA 210 893, Amtsgericht Stuttgart
Kompl. Ges. Peter Pilz GmbH, Sitz: Ostfildern, HRB 210 612, Amtsgericht Stuttgart
Umsatzsteuer: ID-Nr. DE 145 355 773, WEEE-Reg.-Nr. DE 71636849
This email is intended solely for the use of the named address(es). Any unauthorised disclosure, copying or distribution of these confidential information contained therein, or the taking of any action based on it, is prohibited. The sender disclaims any liability for the integrity of this email. Legally binding declarations must be in written form.
Umweltschutz liegt uns am Herzen! - Bitte denken Sie an unsere Umwelt, bevor Sie diese E-Mail drucken.
We do care about the environment! - Please consider the environment before printing this e-mail.
Petr Vorel Oct. 25, 2018, 7:43 a.m. UTC | #2
Hi Angelo,

> From: Angelo Compagnucci <angelo.compagnucci@gmail.com>

> This patch adds a way to merge buildroot config file programmatically.
> It adds an option (-b, buildroot mode) to manage buildroot config files.
> The buildroot mode changes the way the script looks for configurations
> entries using the BR2_ prefix and modify the call to the make command
> to be buildroot friendly.

> Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
> Signed-off-by: Nasser Afshin <afshin.nasser@gmail.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>

LGTM. Could you please add commit where you actually use -b option?
I guess it should be in utils/test-pkg and support/kconfig/Makefile.
Not sure whether all packages using kconfig-package are using prefix CONFIG_,
but probably yes.

I'd suggest to move underscore to $SED_CONFIG_EXP. Or is it less intuitive?

> +CONFIG_PREFIX=CONFIG_
   CONFIG_PREFIX=CONFIG

>  while true; do
>  	case $1 in
> @@ -71,6 +73,11 @@ while true; do
>  		shift 2
>  		continue
>  		;;
> +	"-b")
> +		CONFIG_PREFIX=BR2_
		CONFIG_PREFIX=BR2

...
>  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"
   SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(${CONFIG_PREFIX}_[a-zA-Z0-9_]*\)[= ].*/\2/p"

BTW There is some mixed spaces and tabs (pwclient fixed that but bare that in
mind next time):
Description: [v3] merge_config.sh: merge also buildroot config files
Applying: merge_config.sh: merge also buildroot config files
.git/rebase-apply/patch:63: space before tab in indent.
 	echo "Usage: $0 [OPTIONS] [CONFIG [...]]"
.git/rebase-apply/patch:64: space before tab in indent.
 	echo "  -h    display this help text"
.git/rebase-apply/patch:66: space before tab in indent.
 	echo "  -m    only merge the fragments, do not execute the make command"
.git/rebase-apply/patch:67: space before tab in indent.
 	echo "  -n    use allnoconfig instead of alldefconfig"
.git/rebase-apply/patch:68: space before tab in indent.
 	echo "  -r    list redundant entries when merging fragments"
warning: squelched 10 whitespace errors


Kind regards,
Petr
Patzlaff, Marcel Oct. 25, 2018, 9:43 a.m. UTC | #3
Hi Petr,

> Not sure whether all packages using kconfig-package are using prefix 
CONFIG_,
> but probably yes.

at least the uclibc package does not use this prefix.

Geschäftsführung: Susanne Kunschert, Thomas Pilz
Pilz GmbH & Co. KG, Sitz: Ostfildern, HRA 210 893, Amtsgericht Stuttgart
Kompl. Ges. Peter Pilz GmbH, Sitz: Ostfildern, HRB 210 612, Amtsgericht Stuttgart
Umsatzsteuer: ID-Nr. DE 145 355 773, WEEE-Reg.-Nr. DE 71636849
This email is intended solely for the use of the named address(es). Any unauthorised disclosure, copying or distribution of these confidential information contained therein, or the taking of any action based on it, is prohibited. The sender disclaims any liability for the integrity of this email. Legally binding declarations must be in written form.
Umweltschutz liegt uns am Herzen! - Bitte denken Sie an unsere Umwelt, bevor Sie diese E-Mail drucken.
We do care about the environment! - Please consider the environment before printing this e-mail.
Petr Vorel Oct. 25, 2018, 9:43 p.m. UTC | #4
Hi Thomas,

> Hi Petr,

> > Not sure whether all packages using kconfig-package are using prefix 
> CONFIG_,
> > but probably yes.

> at least the uclibc package does not use this prefix.

Looking in the code uclibc-ng uses several prefixes: CONFIG_, TARGET_, UCLIBC_
and sometimes even configs without prefix: VERSION, WARNINGS, EXTRA_WARNINGS [1].

But their SED_CONFIG_EXP uses also CONFIG_.

BTW their kconfig is from linux-3.11, suppose our recent merge_config.sh would work with it.


Kind regards,
Petr


[1] https://cgit.openadk.org/cgi/cgit/uclibc-ng.git/tree/extra/Configs/Config.in
[2] https://cgit.openadk.org/cgi/cgit/uclibc-ng.git/tree/extra/config/merge_config.sh#n84
Patzlaff, Marcel Oct. 26, 2018, 6:03 a.m. UTC | #5
Hi Petr,

> Looking in the code uclibc-ng uses several prefixes: CONFIG_, TARGET_, 
UCLIBC_
> and sometimes even configs without prefix: VERSION, WARNINGS, 
> EXTRA_WARNINGS [1].
> 
> But their SED_CONFIG_EXP uses also CONFIG_.

As you said, they use several prefixes. IMHO, it does not make sense to
filter out configuration items based on a prefix.
And BTW, uclibc does not use it's own merge_config.sh anywhere and I
assume that it is also not used elsewhere.

I would suggest to just remove the prefix restrictions in buildroot's
merge_config.sh unless someone can tell why they are important to be
there.

Kind regards,
Marcel

PS: Sorry for the second reply. My mailclient dropped the list...
Nasser Afshin Oct. 26, 2018, 11:05 p.m. UTC | #6
Hi Marcel, Petr,
On Fri, Oct 26, 2018 at 08:03:59AM +0200, Marcel Patzlaff wrote:
> Hi Petr,
> 
> > Looking in the code uclibc-ng uses several prefixes: CONFIG_, TARGET_, 
> UCLIBC_
> > and sometimes even configs without prefix: VERSION, WARNINGS, 
> > EXTRA_WARNINGS [1].
> > 
> > But their SED_CONFIG_EXP uses also CONFIG_.
> 
> As you said, they use several prefixes. IMHO, it does not make sense to
> filter out configuration items based on a prefix.
> And BTW, uclibc does not use it's own merge_config.sh anywhere and I
> assume that it is also not used elsewhere.
Yes uclibc does not use it's own merge_config.sh anywhere.
> 
> I would suggest to just remove the prefix restrictions in buildroot's
> merge_config.sh unless someone can tell why they are important to be
> there.
The problem is that some of our defconfig files include comment lines
(e.g raspberrypi_defconfig, cubieboard2_defconfig,
qemu_arm_versatile_defconfig, ...). If we completely omit the
${CONFIG_PREFIX} we will add first word of comments to $CFG_LIST and
therefor will produce some false warning reports for comment lines (if
the fist word is just repeated anywhere throughout the fragments which
is none sense)

If we consider the controversial part of the script which is either:
sed -n 's/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p' \
defconfig_file_name

for kernel style config files or

sed -n 's/^\(# \)\{0,1\}\(BR2_[a-zA-Z0-9_]*\)[= ].*/\2/p' \
defconfig_file_name

for buildroot style config files or

sed -n 's/^\(# \)\{0,1\}\([a-zA-Z0-9_]*\)[= ].*/\2/p' \
defconfig_file_name

as a general command then for different buildroot/kernel defconfig
files, the last one will extract comments as well which IMHO is not what we
want.
> 
> Kind regards,
> Marcel
> 
> PS: Sorry for the second reply. My mailclient dropped the list...
> 
> -- 
> 
> Geschäftsführung: Susanne Kunschert, Thomas Pilz
> Pilz GmbH & Co. KG, Sitz: Ostfildern, HRA 210 893, Amtsgericht Stuttgart
> Kompl. Ges. Peter Pilz GmbH, Sitz: Ostfildern, HRB 210 612, Amtsgericht Stuttgart
> Umsatzsteuer: ID-Nr. DE 145 355 773, WEEE-Reg.-Nr. DE 71636849
> This email is intended solely for the use of the named address(es). Any unauthorised disclosure, copying or distribution of these confidential information contained therein, or the taking of any action based on it, is prohibited. The sender disclaims any liability for the integrity of this email. Legally binding declarations must be in written form.
> Umweltschutz liegt uns am Herzen! - Bitte denken Sie an unsere Umwelt, bevor Sie diese E-Mail drucken.
> We do care about the environment! - Please consider the environment before printing this e-mail.
Kind regards,
Nasser
Petr Vorel Oct. 27, 2018, 4:46 a.m. UTC | #7
Hi Marcel, Nasser,

> > I would suggest to just remove the prefix restrictions in buildroot's
> > merge_config.sh unless someone can tell why they are important to be
> > there.
> The problem is that some of our defconfig files include comment lines
> (e.g raspberrypi_defconfig, cubieboard2_defconfig,
> qemu_arm_versatile_defconfig, ...). If we completely omit the
> ${CONFIG_PREFIX} we will add first word of comments to $CFG_LIST and
> therefor will produce some false warning reports for comment lines (if
> the fist word is just repeated anywhere throughout the fragments which
> is none sense)

> If we consider the controversial part of the script which is either:
> sed -n 's/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p' \
> defconfig_file_name

> for kernel style config files or

> sed -n 's/^\(# \)\{0,1\}\(BR2_[a-zA-Z0-9_]*\)[= ].*/\2/p' \
> defconfig_file_name

> for buildroot style config files or

> sed -n 's/^\(# \)\{0,1\}\([a-zA-Z0-9_]*\)[= ].*/\2/p' \
> defconfig_file_name

> as a general command then for different buildroot/kernel defconfig
> files, the last one will extract comments as well which IMHO is not what we
> want.

Agree. Maybe we could try to add "any prefix" pattern: '[A-Z0-9_]\+'

sed -n 's/^\(# \)\{0,1\}\([A-Z0-9_]\+_[a-zA-Z0-9_]*\)[= ].*/\2/p' \
defconfig_file_name


Kind regards,
Petr
Nasser Afshin Oct. 27, 2018, 10:48 a.m. UTC | #8
Hi Petr, Marcel,
On Sat, Oct 27, 2018 at 06:46:36AM +0200, Petr Vorel wrote:
> Hi Marcel, Nasser,
> 
> > > I would suggest to just remove the prefix restrictions in buildroot's
> > > merge_config.sh unless someone can tell why they are important to be
> > > there.
> > The problem is that some of our defconfig files include comment lines
> > (e.g raspberrypi_defconfig, cubieboard2_defconfig,
> > qemu_arm_versatile_defconfig, ...). If we completely omit the
> > ${CONFIG_PREFIX} we will add first word of comments to $CFG_LIST and
> > therefor will produce some false warning reports for comment lines (if
> > the fist word is just repeated anywhere throughout the fragments which
> > is none sense)
> 
> > If we consider the controversial part of the script which is either:
> > sed -n 's/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p' \
> > defconfig_file_name
> 
> > for kernel style config files or
> 
> > sed -n 's/^\(# \)\{0,1\}\(BR2_[a-zA-Z0-9_]*\)[= ].*/\2/p' \
> > defconfig_file_name
> 
> > for buildroot style config files or
> 
> > sed -n 's/^\(# \)\{0,1\}\([a-zA-Z0-9_]*\)[= ].*/\2/p' \
> > defconfig_file_name
> 
> > as a general command then for different buildroot/kernel defconfig
> > files, the last one will extract comments as well which IMHO is not what we
> > want.
> 
> Agree. Maybe we could try to add "any prefix" pattern: '[A-Z0-9_]\+'
> 
> sed -n 's/^\(# \)\{0,1\}\([A-Z0-9_]\+_[a-zA-Z0-9_]*\)[= ].*/\2/p' \
> defconfig_file_name
I agree. It seems to be a better solution.
> 
> 
> Kind regards,
> Petr
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

Kind regards,
Nasser
Petr Vorel Oct. 29, 2018, 3:46 p.m. UTC | #9
Hi,

FYI: Masahiro Yamada (kconfig kernel maintainer) proposed [1] solution using env.
variable CONFIG_ (as it's already used in kconfig binary). I'm ok with it,
I propose to take upstream commit from kernel.


Kind regards,
Petr

[1] https://patchwork.kernel.org/patch/10658589/#22289439
Petr Vorel Oct. 31, 2018, 7:35 p.m. UTC | #10
Hi Nasser,

> > > as a general command then for different buildroot/kernel defconfig
> > > files, the last one will extract comments as well which IMHO is not what we
> > > want.

> > Agree. Maybe we could try to add "any prefix" pattern: '[A-Z0-9_]\+'

> > sed -n 's/^\(# \)\{0,1\}\([A-Z0-9_]\+_[a-zA-Z0-9_]*\)[= ].*/\2/p' \
> > defconfig_file_name
> I agree. It seems to be a better solution.
Upstream solution in kernel has been merged [1] and will be part of kernel 4.21
(kbuild updates for 4.20 has been merged day before).
Would you like to backport it to buildroot + add necessary applications (setting
the variable?) or shell I do it?

I also have plans to upgrade our kconfig to 4.19 + review the patches (some of
them might can be adjusted to be suitable for upstream, so we'd be able to get
rid of them).


> Kind regards,
> Nasser

Kind regards,
Petr

[1] https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/commit/?h=for-next&id=f6fe19e9d84400e1c9544c1909952c2c7c6a90a2
Nasser Afshin Oct. 31, 2018, 8:38 p.m. UTC | #11
On Wed, Oct 31, 2018 at 08:35:51PM +0100, Petr Vorel wrote:
> Hi Nasser,
> 
> > > > as a general command then for different buildroot/kernel defconfig
> > > > files, the last one will extract comments as well which IMHO is not what we
> > > > want.
> 
> > > Agree. Maybe we could try to add "any prefix" pattern: '[A-Z0-9_]\+'
> 
> > > sed -n 's/^\(# \)\{0,1\}\([A-Z0-9_]\+_[a-zA-Z0-9_]*\)[= ].*/\2/p' \
> > > defconfig_file_name
> > I agree. It seems to be a better solution.
> Upstream solution in kernel has been merged [1] and will be part of kernel 4.21
> (kbuild updates for 4.20 has been merged day before).
I see. Seems great.
> Would you like to backport it to buildroot + add necessary applications (setting
> the variable?) or shell I do it?
Sure, I'll do it.
> 
> I also have plans to upgrade our kconfig to 4.19 + review the patches (some of
> them might can be adjusted to be suitable for upstream, so we'd be able to get
> rid of them).
Yes, I would like to do it also.
I think I should begin with the first task and then upgrade our kconfig
to 4.19.
> 
> 
> > Kind regards,
> > Nasser
> 
> Kind regards,
> Petr
> 
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/commit/?h=for-next&id=f6fe19e9d84400e1c9544c1909952c2c7c6a90a2
Kind regards,
Nasser
Petr Vorel Oct. 31, 2018, 8:56 p.m. UTC | #12
Hi Nasser,

> > Upstream solution in kernel has been merged [1] and will be part of kernel 4.21
> > (kbuild updates for 4.20 has been merged day before).
> I see. Seems great.
> > Would you like to backport it to buildroot + add necessary applications (setting
> > the variable?) or shell I do it?
> Sure, I'll do it.
Good, leave it for you.

> > I also have plans to upgrade our kconfig to 4.19 + review the patches (some of
> > them might can be adjusted to be suitable for upstream, so we'd be able to get
> > rid of them).
> Yes, I would like to do it also.
> I think I should begin with the first task and then upgrade our kconfig
> to 4.19.
Good. I'll leave update kconfig in buildroot for you.
I also leave upstreaming kconfig patches for you, if you want.
Please CC me on these patches.
Thanks a lot.

Kind regards,
Petr
diff mbox series

Patch

diff --git a/support/kconfig/merge_config.sh b/support/kconfig/merge_config.sh
index 67d1314476..f22198023c 100755
--- a/support/kconfig/merge_config.sh
+++ b/support/kconfig/merge_config.sh
@@ -29,6 +29,7 @@  trap clean_up HUP INT TERM
 usage() {
 	echo "Usage: $0 [OPTIONS] [CONFIG [...]]"
 	echo "  -h    display this help text"
+	echo "  -b    buildroot mode (searches for BR2_ and uses a custom make command)"
 	echo "  -m    only merge the fragments, do not execute the make command"
 	echo "  -n    use allnoconfig instead of alldefconfig"
 	echo "  -r    list redundant entries when merging fragments"
@@ -39,6 +40,7 @@  RUNMAKE=true
 ALLTARGET=alldefconfig
 WARNREDUN=false
 OUTPUT=.
+CONFIG_PREFIX=CONFIG_
 
 while true; do
 	case $1 in
@@ -71,6 +73,11 @@  while true; do
 		shift 2
 		continue
 		;;
+	"-b")
+		CONFIG_PREFIX=BR2_
+		shift
+		continue
+		;;
 	*)
 		break
 		;;
@@ -99,7 +106,7 @@  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 ./.tmp.config.XXXXXXXXXX)
 
 echo "Using $INITFILE as base"
diff --git a/support/kconfig/patches/18-fix-finding-redundant-config-mechanism.patch b/support/kconfig/patches/18-fix-finding-redundant-config-mechanism.patch
new file mode 100644
index 0000000000..eec92a5fad
--- /dev/null
+++ b/support/kconfig/patches/18-fix-finding-redundant-config-mechanism.patch
@@ -0,0 +1,41 @@ 
+Index: kconfig/merge_config.sh
+===================================================================
+--- kconfig.orig/merge_config.sh
++++ kconfig/merge_config.sh
+@@ -29,6 +29,7 @@ trap clean_up HUP INT TERM
+ usage() {
+ 	echo "Usage: $0 [OPTIONS] [CONFIG [...]]"
+ 	echo "  -h    display this help text"
++	echo "  -b    buildroot mode (searches for BR2_ and uses a custom make command)"
+ 	echo "  -m    only merge the fragments, do not execute the make command"
+ 	echo "  -n    use allnoconfig instead of alldefconfig"
+ 	echo "  -r    list redundant entries when merging fragments"
+@@ -39,6 +40,7 @@ RUNMAKE=true
+ ALLTARGET=alldefconfig
+ WARNREDUN=false
+ OUTPUT=.
++CONFIG_PREFIX=CONFIG_
+ 
+ while true; do
+ 	case $1 in
+@@ -71,6 +73,11 @@ while true; do
+ 		shift 2
+ 		continue
+ 		;;
++	"-b")
++		CONFIG_PREFIX=BR2_
++		shift
++		continue
++		;;
+ 	*)
+ 		break
+ 		;;
+@@ -99,7 +106,7 @@ 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 ./.tmp.config.XXXXXXXXXX)
+ 
+ echo "Using $INITFILE as base"
diff --git a/support/kconfig/patches/series b/support/kconfig/patches/series
index 36591e2189..5ebc2e0225 100644
--- a/support/kconfig/patches/series
+++ b/support/kconfig/patches/series
@@ -6,3 +6,4 @@ 
 14-support-out-of-tree-config.patch
 16-fix-space-to-de-select-options.patch
 17-backport-kecho.patch
+18-fix-finding-redundant-config-mechanism.patch