Skip to contentSkip to conversation

kconfig: add support for new option 'listnewdefconfig'

PATCH In review Don Zickus 2 participants 6 messages Apr 4, 2018 – Apr 7, 2018

Subsystems (2)
lore
Share & tools
lore

Don Zickus

author
#0 lore raw

PATCH 1/1 kconfig: add support for new option 'listnewdefconfig'

We at Red Hat/Fedora have generally tried to have a per file breakdown of every config option we set. This makes it easy for us to add new options when they are exposed and keep a changelog of why they were set.

A Fedora example is here:
https://src.fedoraproject.org/cgit/rpms/kernel.git/tree/configs/fedora/generic

Using various merge scripts, we build up a config file and run it through
'make listnewconfig' and 'make oldnoconfig'. The idea is to print out new
config options that haven't been manually set and use the default until a patch is posted to set it properly.

To speed things up, it would be nice to make it easier to generate a patch to post the default setting. The output of 'make listnewconfig' has two issues that limit us:

- it doesn't provide the default value
- it doesn't provide the new 'choice' options that get flagged in 'oldconfig'

This patch adds a new command 'listnewdefconfig' that does exactly what 'listnewconfig' does but addresses the above two issues too.

This allows us to run a script

make listnewdefconfig | rhconfig-tool -o patches; git send-email patches/

The output of 'make listnewconfig':

CONFIG_NET_EMATCH_IPT
CONFIG_IPVLAN
CONFIG_ICE
CONFIG_NET_VENDOR_NI
CONFIG_IEEE802154_MCR20A
CONFIG_IR_IMON_DECODER
CONFIG_IR_IMON_RAW

The output of 'make listnewdefconfig':

CONFIG_KERNEL_XZ=n #choice
CONFIG_KERNEL_LZO=n #choice
CONFIG_NET_EMATCH_IPT=n
CONFIG_IPVLAN=n
CONFIG_ICE=n
CONFIG_NET_VENDOR_NI=y
CONFIG_IEEE802154_MCR20A=n
CONFIG_IR_IMON_DECODER=n
CONFIG_IR_IMON_RAW=n

---
 scripts/kconfig/Makefile |  3 ++-
 scripts/kconfig/conf.c   | 23 ++++++++++++++++++++++-
 2 files changed, 24 insertions(+), 2 deletions(-)
scripts/kconfig/Makefile +2 -1
index f9bdd02c06a2..ebdf3b2e62dd 100644
@@ -80,7 +80,7 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
 
 # These targets map 1:1 to the commandline options of 'conf'
 simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
-	alldefconfig randconfig listnewconfig olddefconfig
+	alldefconfig randconfig listnewconfig listnewdefconfig olddefconfig
 PHONY += $(simple-targets)
 
 $(simple-targets): $(obj)/conf
@@ -167,6 +167,7 @@ help:
 	@echo  '  alldefconfig    - New config with all symbols set to default'
 	@echo  '  randconfig	  - New config with random answer to all options'
 	@echo  '  listnewconfig   - List new options'
+	@echo  '  listnewdefconfig - List new options and print defaults'
 	@echo  '  olddefconfig	  - Same as oldconfig but sets new symbols to their'
 	@echo  '                    default value without prompting'
 	@echo  '  kvmconfig	  - Enable additional options for kvm guest kernel support'
scripts/kconfig/conf.c +22 -1
index 4e08121a35fb..cd4f09b9df05 100644
@@ -33,6 +33,7 @@ enum input_mode {
 	defconfig,
 	savedefconfig,
 	listnewconfig,
+	listnewdefconfig,
 	olddefconfig,
 };
 static enum input_mode input_mode = oldaskconfig;
@@ -425,6 +426,21 @@ static void check_conf(struct menu *menu)
 				if (sym->name && !sym_is_choice_value(sym)) {
 					printf("%s%s\n", CONFIG_, sym->name);
 				}
+			} else if (input_mode == listnewdefconfig) {
+				if (sym->name) {
+					const char *str;
+
+					if (sym->type == S_STRING) {
+						str = sym_get_string_value(sym);
+						str = sym_escape_string_value(str);
+						printf("%s%s=%s\n", CONFIG_, sym->name, str);
+						free((void *)str);
+					} else {
+						bool choice = sym_is_choice_value(sym);
+						str = sym_get_string_value(sym);
+						printf("%s%s=%s%s\n", CONFIG_, sym->name, str, (choice ?" #choice":""));
+					}
+				}
 			} else {
 				if (!conf_cnt++)
 					printf(_("*\n* Restart config...\n*\n"));
@@ -450,6 +466,7 @@ static struct option long_opts[] = {
 	{"alldefconfig",    no_argument,       NULL, alldefconfig},
 	{"randconfig",      no_argument,       NULL, randconfig},
 	{"listnewconfig",   no_argument,       NULL, listnewconfig},
+	{"listnewdefconfig", no_argument,      NULL, listnewdefconfig},
 	{"olddefconfig",    no_argument,       NULL, olddefconfig},
 	/*
 	 * oldnoconfig is an alias of olddefconfig, because people already
@@ -466,6 +483,7 @@ static void conf_usage(const char *progname)
 	printf("Usage: %s [-s] [option] <kconfig-file>\n", progname);
 	printf("[option] is _one_ of the following:\n");
 	printf("  --listnewconfig         List new options\n");
+	printf("  --listnewdefconfig      List new options with defaults\n");
 	printf("  --oldaskconfig          Start a new configuration using a line-oriented program\n");
 	printf("  --oldconfig             Update a configuration using a provided .config as base\n");
 	printf("  --syncconfig            Similar to oldconfig but generates configuration in\n"
@@ -540,6 +558,7 @@ int main(int ac, char **av)
 		case allmodconfig:
 		case alldefconfig:
 		case listnewconfig:
+		case listnewdefconfig:
 		case olddefconfig:
 			break;
 		case '?':
@@ -587,6 +606,7 @@ int main(int ac, char **av)
 	case oldaskconfig:
 	case oldconfig:
 	case listnewconfig:
+	case listnewdefconfig:
 	case olddefconfig:
 		conf_read(NULL);
 		break;
@@ -667,6 +687,7 @@ int main(int ac, char **av)
 		/* fall through */
 	case oldconfig:
 	case listnewconfig:
+	case listnewdefconfig:
 	case syncconfig:
 		/* Update until a loop caused no more changes */
 		do {
@@ -697,7 +718,7 @@ int main(int ac, char **av)
 				defconfig_file);
 			return 1;
 		}
-	} else if (input_mode != listnewconfig) {
+	} else if ((input_mode != listnewconfig) && (input_mode != listnewdefconfig)) {
 		if (conf_write(NULL)) {
 			fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
 			exit(1);
Signature · 1 line
2.14.3
Acked-by Arjan van de Ven Acked-by Randy Dunlap on v1 1/1
#1 lore raw

2018-04-05 4:56 GMT+09:00 Don Zickus <[email protected]>:

Quoted 12 lines

We at Red Hat/Fedora have generally tried to have a per file breakdown of every config option we set. This makes it easy for us to add new options when they are exposed and keep a changelog of why they were set.

A Fedora example is here:
https://src.fedoraproject.org/cgit/rpms/kernel.git/tree/configs/fedora/generic

Using various merge scripts, we build up a config file and run it through
'make listnewconfig' and 'make oldnoconfig'. The idea is to print out new
config options that haven't been manually set and use the default until a patch is posted to set it properly.

Quoted 7 lines

To speed things up, it would be nice to make it easier to generate a patch to post the default setting. The output of 'make listnewconfig' has two issues that limit us:

- it doesn't provide the default value
- it doesn't provide the new 'choice' options that get flagged in 'oldconfig'

So, 'listnewconfig' is a subset of 'listnewdefconfig'.

I wonder if we could extend 'listnewconfig' to meet your demands instead of adding the new target.

I do not know why the current listnewconfig skips choice values.

(Anybody who relies on the current format of listnewconfig?)

Looks like the current listnewconfig
(it was 'nonint_oldconfig' before renaming)
was contributed from Fedora/RedHat side.

commit f0778c8c41001783d4074e34efc7d3e632d87ee3

Author: Aristeu Rozanski <[email protected]>
Date:   Thu May 6 12:48:34 2010 -0400

kconfig: introduce nonint_oldconfig and loose_nonint_oldconfig

This patch has been around for a long time in Fedora and Red Hat Enterprise Linux kernels and it may be useful for others. The nonint_oldconfig target will fail and print the unset config options while
loose_nonint_oldconfig will
simply let the config option unset. They're useful in distro kernel packages where the config files are built using a combination of smaller
config files.

Arjan van de Ven wrote the initial nonint_config and Roland
McGrath added the
loose_nonint_oldconfig.

Quoted 17 lines

This patch adds a new command 'listnewdefconfig' that does exactly what 'listnewconfig' does but addresses the above two issues too.

This allows us to run a script

make listnewdefconfig | rhconfig-tool -o patches; git send-email patches/

The output of 'make listnewconfig':

CONFIG_NET_EMATCH_IPT
CONFIG_IPVLAN
CONFIG_ICE
CONFIG_NET_VENDOR_NI
CONFIG_IEEE802154_MCR20A
CONFIG_IR_IMON_DECODER
CONFIG_IR_IMON_RAW

Quoted 4 lines

The output of 'make listnewdefconfig':

CONFIG_KERNEL_XZ=n #choice
CONFIG_KERNEL_LZO=n #choice

What for '#choice' comment ?

Quoted 10 lines

CONFIG_NET_EMATCH_IPT=n
CONFIG_IPVLAN=n
CONFIG_ICE=n
CONFIG_NET_VENDOR_NI=y
CONFIG_IEEE802154_MCR20A=n
CONFIG_IR_IMON_DECODER=n
CONFIG_IR_IMON_RAW=n

---

Signature · 2 lines
Best Regards
Masahiro Yamada
author
#2 lore raw
Quoted 22 lines · Masahiro Yamada

2018-04-05 4:56 GMT+09:00 Don Zickus <[email protected]>:

Quoted 12 lines

We at Red Hat/Fedora have generally tried to have a per file breakdown of every config option we set. This makes it easy for us to add new options when they are exposed and keep a changelog of why they were set.

A Fedora example is here:
https://src.fedoraproject.org/cgit/rpms/kernel.git/tree/configs/fedora/generic

Using various merge scripts, we build up a config file and run it through
'make listnewconfig' and 'make oldnoconfig'. The idea is to print out new
config options that haven't been manually set and use the default until a patch is posted to set it properly.

Quoted 7 lines

To speed things up, it would be nice to make it easier to generate a patch to post the default setting. The output of 'make listnewconfig' has two issues that limit us:

- it doesn't provide the default value
- it doesn't provide the new 'choice' options that get flagged in 'oldconfig'

Quoted 4 lines

So, 'listnewconfig' is a subset of 'listnewdefconfig'.

I wonder if we could extend 'listnewconfig' to meet your demands instead of adding the new target.

Sure. I am open to whatever you think is appropriate. :-)

Quoted 4 lines

I do not know why the current listnewconfig skips choice values.

(Anybody who relies on the current format of listnewconfig?)

I didn't either and didn't want to change it in case I was missing something. But it appears you are unsure too.

Quoted 5 lines

Looks like the current listnewconfig
(it was 'nonint_oldconfig' before renaming)
was contributed from Fedora/RedHat side.

Originally, nonint_oldconfig was needed to perform what 'oldnoconfig' does today. This allowed us to quickly use the defaults and move along.

The downside to that is, a lot of new options pop up that we should take advantage of and we don't because it is hidden away by process. We are working to change that internally so we can react quicker.

Quoted 48 lines

commit f0778c8c41001783d4074e34efc7d3e632d87ee3

Author: Aristeu Rozanski <[email protected]>
Date:   Thu May 6 12:48:34 2010 -0400

kconfig: introduce nonint_oldconfig and loose_nonint_oldconfig

This patch has been around for a long time in Fedora and Red Hat Enterprise Linux kernels and it may be useful for others. The nonint_oldconfig target will fail and print the unset config options while
loose_nonint_oldconfig will
simply let the config option unset. They're useful in distro kernel packages where the config files are built using a combination of smaller
config files.

Arjan van de Ven wrote the initial nonint_config and Roland
McGrath added the
loose_nonint_oldconfig.

Quoted 17 lines

This patch adds a new command 'listnewdefconfig' that does exactly what 'listnewconfig' does but addresses the above two issues too.

This allows us to run a script

make listnewdefconfig | rhconfig-tool -o patches; git send-email patches/

The output of 'make listnewconfig':

CONFIG_NET_EMATCH_IPT
CONFIG_IPVLAN
CONFIG_ICE
CONFIG_NET_VENDOR_NI
CONFIG_IEEE802154_MCR20A
CONFIG_IR_IMON_DECODER
CONFIG_IR_IMON_RAW

Quoted 7 lines
Quoted 4 lines

The output of 'make listnewdefconfig':

CONFIG_KERNEL_XZ=n #choice
CONFIG_KERNEL_LZO=n #choice

What for '#choice' comment ?

This was something silly added by me to make it obvious that CONFIG_KERNEL_XZ doesn't needed to be decided, it just needs us to re-review our current default to see if we should keep it or switch to something new.

We can drop that piece of the patch. I wasn't sure if that separating 'choices' from 'configs|menuconfigs' is interesting or not.

I used it as a comment to have it be auto dropped when we run our final configs through 'oldconfig'.

Thanks for the quick response!

Cheers,
Don

#3 lore raw

2018-04-06 0:03 GMT+09:00 Don Zickus <[email protected]>:

Quoted 23 lines · Masahiro Yamada
Quoted 22 lines

2018-04-05 4:56 GMT+09:00 Don Zickus <[email protected]>:

Quoted 19 lines

We at Red Hat/Fedora have generally tried to have a per file breakdown of every config option we set. This makes it easy for us to add new options when they are exposed and keep a changelog of why they were set.

A Fedora example is here:
https://src.fedoraproject.org/cgit/rpms/kernel.git/tree/configs/fedora/generic

Using various merge scripts, we build up a config file and run it through
'make listnewconfig' and 'make oldnoconfig'. The idea is to print out new
config options that haven't been manually set and use the default until a patch is posted to set it properly.

To speed things up, it would be nice to make it easier to generate a patch to post the default setting. The output of 'make listnewconfig' has two issues that limit us:

- it doesn't provide the default value
- it doesn't provide the new 'choice' options that get flagged in 'oldconfig'

Quoted 6 lines
Quoted 4 lines

So, 'listnewconfig' is a subset of 'listnewdefconfig'.

I wonder if we could extend 'listnewconfig' to meet your demands instead of adding the new target.

Sure. I am open to whatever you think is appropriate. :-)

I prefer extending the existing target.

Quoted 10 lines
Quoted 3 lines

What for '#choice' comment ?

This was something silly added by me to make it obvious that CONFIG_KERNEL_XZ doesn't needed to be decided, it just needs us to re-review our current default to see if we should keep it or switch to something new.

We can drop that piece of the patch. I wasn't sure if that separating 'choices' from 'configs|menuconfigs' is interesting or not.

I think it is better to drop '#choice'.

Signature · 2 lines
Best Regards
Masahiro Yamada
author
#4 lore raw
Quoted 26 lines · Masahiro Yamada

2018-04-06 0:03 GMT+09:00 Don Zickus <[email protected]>:

Quoted 25 lines · Masahiro Yamada
Quoted 24 lines

2018-04-05 4:56 GMT+09:00 Don Zickus <[email protected]>:

Quoted 12 lines

We at Red Hat/Fedora have generally tried to have a per file breakdown of every config option we set. This makes it easy for us to add new options when they are exposed and keep a changelog of why they were set.

A Fedora example is here:
https://src.fedoraproject.org/cgit/rpms/kernel.git/tree/configs/fedora/generic

Using various merge scripts, we build up a config file and run it through
'make listnewconfig' and 'make oldnoconfig'. The idea is to print out new
config options that haven't been manually set and use the default until a patch is posted to set it properly.

Quoted 7 lines

To speed things up, it would be nice to make it easier to generate a patch to post the default setting. The output of 'make listnewconfig' has two issues that limit us:

- it doesn't provide the default value
- it doesn't provide the new 'choice' options that get flagged in 'oldconfig'

So, 'listnewconfig' is a subset of 'listnewdefconfig'.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I wonder if we could extend 'listnewconfig' to meet your demands instead of adding the new target.

Sure. I am open to whatever you think is appropriate. :-)

I prefer extending the existing target.

Ok. So, you want me to respin with my additions added to listnewconfig, right? Easy enough.

Quoted 12 lines
Quoted 12 lines
Quoted 7 lines

What for '#choice' comment ?

This was something silly added by me to make it obvious that CONFIG_KERNEL_XZ doesn't needed to be decided, it just needs us to re-review our current default to see if we should keep it or switch to something new.

Quoted 5 lines
Quoted 2 lines

We can drop that piece of the patch. I wasn't sure if that separating 'choices' from 'configs|menuconfigs' is interesting or not.

I think it is better to drop '#choice'.

Sure. No problem. :-)

Cheers,
Don

#5 lore raw

2018-04-06 22:23 GMT+09:00 Don Zickus <[email protected]>:

Quoted 30 lines · Masahiro Yamada
Quoted 29 lines

2018-04-06 0:03 GMT+09:00 Don Zickus <[email protected]>:

Quoted 28 lines · Masahiro Yamada
Quoted 26 lines

2018-04-05 4:56 GMT+09:00 Don Zickus <[email protected]>:

Quoted 12 lines

We at Red Hat/Fedora have generally tried to have a per file breakdown of every config option we set. This makes it easy for us to add new options when they are exposed and keep a changelog of why they were set.

A Fedora example is here:
https://src.fedoraproject.org/cgit/rpms/kernel.git/tree/configs/fedora/generic

Using various merge scripts, we build up a config file and run it through
'make listnewconfig' and 'make oldnoconfig'. The idea is to print out new
config options that haven't been manually set and use the default until a patch is posted to set it properly.

Quoted 7 lines

To speed things up, it would be nice to make it easier to generate a patch to post the default setting. The output of 'make listnewconfig' has two issues that limit us:

- it doesn't provide the default value
- it doesn't provide the new 'choice' options that get flagged in 'oldconfig'

So, 'listnewconfig' is a subset of 'listnewdefconfig'.

I wonder if we could extend 'listnewconfig' to meet your demands instead of adding the new target.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Sure. I am open to whatever you think is appropriate. :-)

I prefer extending the existing target.

Ok. So, you want me to respin with my additions added to listnewconfig, right? Easy enough.

Yes, please.

Signature · 2 lines
Best Regards
Masahiro Yamada