kbuld: Implement oldmodconfig
Subsystems (3)
PATCH 1/1 kbuld: Implement oldmodconfig
While verifying that my user namespace patches are as complete as I expect them to be I came a came across the need to build kernel configurations with a few choice settings disabled and everything else enabled. Adding a make oldmodconfig made generating those configurations straight forward, as now I can set the options I care about and the oldmodconfig can answering everything else for me in a consistent way.
Respond with mod/yes/default to every question for every unset symbol depending if the symbol is tristate, boolean or something else.
--- scripts/kconfig/Makefile | 5 +++-- scripts/kconfig/conf.c | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-)
scripts/kconfig/Makefile +3 -2
@@ -76,9 +76,9 @@ PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf $< --$@ $(Kconfig) -PHONY += listnewconfig oldnoconfig savedefconfig defconfig +PHONY += listnewconfig oldnoconfig oldmodconfig savedefconfig defconfig -listnewconfig oldnoconfig: $(obj)/conf +listnewconfig oldnoconfig oldmodconfig: $(obj)/conf $< --$@ $(Kconfig) savedefconfig: $(obj)/conf
@@ -115,6 +115,7 @@ help: @echo ' randconfig - New config with random answer to all options' @echo ' listnewconfig - List new options' @echo ' oldnoconfig - Same as silentoldconfig but set new symbols to n (unset)' + @echo ' oldmodconfig - Same as silentoldconfig but set new symbols to m (module)' # lxdialog stuff check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
scripts/kconfig/conf.c +8 -0
@@ -33,6 +33,7 @@ enum input_mode { savedefconfig, listnewconfig, oldnoconfig, + oldmodconfig, } input_mode = oldaskconfig;static int indent =1 ;
@@ -455,6 +456,7 @@ static struct option long_opts[] = { {"randconfig", no_argument, NULL, randconfig}, {"listnewconfig", no_argument, NULL, listnewconfig}, {"oldnoconfig", no_argument, NULL, oldnoconfig}, + {"oldmodconfig", no_argument, NULL, oldmodconfig}, {NULL, 0, NULL, 0} };
@@ -468,6 +470,7 @@ static void conf_usage(const char *progname)printf (" --oldconfig Update a configuration using a provided .config as base\n" );printf (" --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n" );printf (" --oldnoconfig Same as silentoldconfig but set new symbols to no\n" ); +printf (" --oldmodconfig Same as silentoldconfig but set new symbols to mod\n" );printf (" --defconfig <file> New config with default defined in <file>\n" );printf (" --savedefconfig <file> Save the minimal current configuration to <file>\n" );printf (" --allnoconfig New config where all options are answered with no\n" );
@@ -521,6 +524,7 @@ int main(int ac, char **av)case alldefconfig:case listnewconfig:case oldnoconfig: +case oldmodconfig:break ;case '?' :conf_usage (progname);
@@ -566,6 +570,7 @@ int main(int ac, char **av)case oldconfig:case listnewconfig:case oldnoconfig: +case oldmodconfig:conf_read (NULL );break ;case allnoconfig:
@@ -626,6 +631,9 @@ int main(int ac, char **av)case defconfig:conf_set_all_new_symbols (def_default);break ; +case oldmodconfig: +conf_set_all_new_symbols (def_mod); +break ;case savedefconfig:break ;case oldaskconfig:
Signature · 1 line
1.7.2.5
Dne 24.4.2012 02:59, Eric W. Biederman napsal(a):
Quoted 8 lines
While verifying that my user namespace patches are as complete as I expect them to be I came a came across the need to build kernel configurations with a few choice settings disabled and everything else enabled. Adding a make oldmodconfig made generating those configurations straight forward, as now I can set the options I care about and the oldmodconfig can answering everything else for me in a consistent way.
Doesn't
KCONFIG_ALLCONFIG=base.config make allmodconfig
do the same thing? If not, the difference should be explained in the changelog.
Michal
Quoted 10 lines · Michal Marek
Dne 24.4.2012 02:59, Eric W. Biederman napsal(a):
Quoted 8 lines
While verifying that my user namespace patches are as complete as I expect them to be I came a came across the need to build kernel configurations with a few choice settings disabled and everything else enabled. Adding a make oldmodconfig made generating those configurations straight forward, as now I can set the options I care about and the oldmodconfig can answering everything else for me in a consistent way.
Quoted 6 lines
Doesn't
KCONFIG_ALLCONFIG=base.config make allmodconfig
do the same thing? If not, the difference should be explained in the changelog.
The only difference apparently is that KCONFIG_ALLCONFIG... allmodconfig does not show up in the help and is rather unintuitively named so I totally missed it's presence.
If I get ambitious I might fix the bug that KCONFIG_ALLCONFIG uses some other working directory when reading a file than the directory that make was run in. Which is compounded by the fact that if KCONFIG_ALLCONFIG can't find your file it treats it as if you had not specified the file and does this all silently making it just about impossible to debug without instrumenting up conf.c and confdata.c
So please feel free to drop my patch.
Eric
PATCH 1/1 kbuild: Add error handling to KCONFIG_ALL_CONFIG
In reply to Michal Marek- Only try to read the file specified if KCONFIG_ALL_CONFIG is set to something other than the empty string.
- Don't use stat to check the name passed to conf_read_simple so that zconf_fopen can find the file in the current directory or in SRCTREE removing a extremely confusing failure mode, where KCONFIG_ALL_CONFIG was not interpreted with respect to the directory make was called in.
- If conf_read_simple fails complain clearly and stop processing. Allowing the simple discovery and debugging of command line typos.
--- scripts/kconfig/conf.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
scripts/kconfig/conf.c +7 -2
@@ -579,8 +579,13 @@ int main(int ac, char **av)case alldefconfig:case randconfig: name =getenv ("KCONFIG_ALLCONFIG" ); -if (name && !stat (name, &tmpstat)) { -conf_read_simple (name,S_DEF_USER ); +if (name && name[0 ] !='\0' ) { +if (conf_read_simple (name,S_DEF_USER )) { +fprintf (stderr, +_ ("*** Can't read seed configuration \"%s\"!\n" ), + name); +exit (1 ); + }break ; }switch (input_mode) {
Signature · 1 line
1.7.2.5
Re: [PATCH] kbuild: Add error handling to KCONFIG_ALL_CONFIG
Review
Quoted 13 lines · Eric W. Biederman
(quoted diff) +7
-2name = getenv("KCONFIG_ALLCONFIG"); - if (name && !stat(name, &tmpstat)) { - conf_read_simple(name, S_DEF_USER); + if (name && name[0] != '\0') { + if (conf_read_simple(name, S_DEF_USER)) { + fprintf(stderr, + _("*** Can't read seed configuration \"%s\"!\n"), + name); + exit(1); + } break; } switch (input_mode) {
Before this patch, the code would fall back to a file named all{no,yes,mod,def,random}.config and then to all.config. Now you require $KCONFIG_ALLCONFIG to always be a file. I suggest we keep the fallback at least for KCONFIG_ALLCONFIG=1, like this:
scripts/kconfig/conf.c +18 -7
@@ -574,9 +574,17 @@ int main(int ac, char **av)case alldefconfig:case randconfig: name =getenv ("KCONFIG_ALLCONFIG" ); -if (name && !stat (name, &tmpstat)) { -conf_read_simple (name,S_DEF_USER ); -break ; +if (name && name[0 ] !='\0' ) { +if (conf_read_simple (name,S_DEF_USER )) { +if (strcmp (name,"1" ) !=0 ) { +fprintf (stderr, +_ ("*** Can't read seed configuration \"%s\"!\n" ), + name); +exit (1 ); + } + }else { +break ; + } }switch (input_mode) {case allnoconfig: name ="allno.config" ;break ;
@@ -586,10 +594,13 @@ int main(int ac, char **av)case randconfig: name ="allrandom.config" ;break ;default :break ; } -if (!stat (name, &tmpstat)) -conf_read_simple (name,S_DEF_USER ); -else if (!stat ("all.config" , &tmpstat)) -conf_read_simple ("all.config" ,S_DEF_USER ); +if (conf_read_simple (name,S_DEF_USER ) && +conf_read_simple ("all.config" ,S_DEF_USER )) { +fprintf (stderr, +_ ("*** KCONFIG_ALLCONFIG=1 set, but no \"%s\" or \"all.config\" file found\n" ), + name); +exit (1 ); + }break ;default :break ;
And update Documentation/kbuild/kconfig.txt.
Michal
Re: [PATCH] kbuild: Add error handling to KCONFIG_ALL_CONFIG
Quoted 12 lines · Michal Marek
Quoted 11 lines · Eric W. Biederman
scripts/kconfig/conf.c +7
-2name =getenv ("KCONFIG_ALLCONFIG" ); -if (name && !stat (name, &tmpstat)) { -conf_read_simple (name,S_DEF_USER ); +if (name && name[0 ] !='\0' ) { +if (conf_read_simple (name,S_DEF_USER )) { +fprintf (stderr, +_ ("*** Can't read seed configuration \"%s\"!\n" ), + name); +exit (1 ); + }break ;
Quoted 8 lines
scripts/kconfig/conf.c int main(int ac, char **av) · line 589
Quoted 2 lines
scripts/kconfig/conf.c +0
-0}switch (input_mode) {Before this patch, the code would fall back to a file named all{no,yes,mod,def,random}.config and then to all.config. Now you require $KCONFIG_ALLCONFIG to always be a file. I suggest we keep the fallback at least for KCONFIG_ALLCONFIG=1, like this:
I don't require KCONFIG_ALLCONFIG to always be a file if it is an empty string we continue to fallback to the predefined file names. Which is the currently documented behavior.
As for KCONFIG_ALLCONFIG=1 if people are a actually doing that the complexity seems worth it (to not break muscle memory and/or scripts). I was just aiming for an absolutely trivial and simple implementation.
Why do you think people have been specifying KCONFIG_ALLCONFIG=1? instead of simply exporting KCONFIG_ALLCONFIG with an empty string?
Eric
Quoted 48 lines
scripts/kconfig/conf.c +18
-7@@ -574,9 +574,17 @@ int main(int ac, char **av)case alldefconfig:case randconfig: name =getenv ("KCONFIG_ALLCONFIG" ); -if (name && !stat (name, &tmpstat)) { -conf_read_simple (name,S_DEF_USER ); -break ; +if (name && name[0 ] !='\0' ) { +if (conf_read_simple (name,S_DEF_USER )) { +if (strcmp (name,"1" ) !=0 ) { +fprintf (stderr, +_ ("*** Can't read seed configuration \"%s\"!\n" ), + name); +exit (1 ); + } + }else { +break ; + } }switch (input_mode) {case allnoconfig: name ="allno.config" ;break ;@@ -586,10 +594,13 @@ int main(int ac, char **av)case randconfig: name ="allrandom.config" ;break ;default :break ; } -if (!stat (name, &tmpstat)) -conf_read_simple (name,S_DEF_USER ); -else if (!stat ("all.config" , &tmpstat)) -conf_read_simple ("all.config" ,S_DEF_USER ); +if (conf_read_simple (name,S_DEF_USER ) && +conf_read_simple ("all.config" ,S_DEF_USER )) { +fprintf (stderr, +_ ("*** KCONFIG_ALLCONFIG=1 set, but no \"%s\" or \"all.config\" file found\n" ), + name); +exit (1 ); + }break ;default :break ;And update
Documentation/kbuild/kconfig.txt.Michal
Re: [PATCH] kbuild: Add error handling to KCONFIG_ALL_CONFIG
Dne 24.4.2012 14:54, Eric W. Biederman napsal(a):
Quoted 23 lines
Quoted 12 lines · Michal Marek
Quoted 11 lines · Eric W. Biederman
scripts/kconfig/conf.c +7
-2name =getenv ("KCONFIG_ALLCONFIG" ); -if (name && !stat (name, &tmpstat)) { -conf_read_simple (name,S_DEF_USER ); +if (name && name[0 ] !='\0' ) { +if (conf_read_simple (name,S_DEF_USER )) { +fprintf (stderr, +_ ("*** Can't read seed configuration \"%s\"!\n" ), + name); +exit (1 ); + }break ;Quoted 8 lines
scripts/kconfig/conf.c int main(int ac, char **av) · line 589
Quoted 2 lines
scripts/kconfig/conf.c +0
-0}switch (input_mode) {Before this patch, the code would fall back to a file named all{no,yes,mod,def,random}.config and then to all.config. Now you require $KCONFIG_ALLCONFIG to always be a file. I suggest we keep the fallback at least for KCONFIG_ALLCONFIG=1, like this:
Quoted 3 lines
I don't require
KCONFIG_ALLCONFIGto always be a file if it is an empty string we continue to fallback to the predefined file names. Which is the currently documented behavior.
Ah, right, it says "If KCONFIG_ALLCONFIG is used without a filename, ...".
Quoted 6 lines
As for KCONFIG_ALLCONFIG=1 if people are a actually doing that the complexity seems worth it (to not break muscle memory and/or scripts). I was just aiming for an absolutely trivial and simple implementation.
Why do you think people have been specifying KCONFIG_ALLCONFIG=1? instead of simply exporting
KCONFIG_ALLCONFIGwith an empty string?
I have been using KCONFIG_ALLCONFIG=1 :). It's quite natural to set env variables to "1" to enable something. But I don't insist that this is retained.
Michal
PATCH 1/1 kbuild: Add error handling to KCONFIG_ALL_CONFIG
- Only try to read the file specified if KCONFIG_ALL_CONFIG is set to something other than the empty string or "1".
- Don't use stat to check the name passed to conf_read_simple so that zconf_fopen can find the file in the current directory or in SRCTREE removing a extremely source of confusing failure, where KCONFIG_ALL_CONFIG was not interpreted with respect to the directory make was called in.
- If conf_read_simple fails complain clearly and stop processing. Allowing the simple debugging of typos.
- Clearly document the behavior so it is clear to users which values are treated as flags and which values are treated as filenames.
--- Documentation/kbuild/kconfig.txt | 18 +++++++++--------- scripts/kconfig/conf.c | 20 ++++++++++++++------ 2 files changed, 23 insertions(+), 15 deletions(-)
Documentation/kbuild/kconfig.txt +9 -9
@@ -53,15 +53,15 @@ KCONFIG_ALLCONFIG -------------------------------------------------- (partially based on lkml email from/by Rob Landley, re: miniconfig) -------------------------------------------------- -The allyesconfig/allmodconfig/allnoconfig/randconfig variants can -also use the environment variable KCONFIG_ALLCONFIG as a flag or a -filename that contains config symbols that the user requires to be -set to a specific value. If KCONFIG_ALLCONFIG is used without a -filename, "make *config" checks for a file named -"all{yes/mod/no/def/random}.config" (corresponding to the *config command -that was used) for symbol values that are to be forced. If this file -is not found, it checks for a file named "all.config" to contain forced -values. +The allyesconfig/allmodconfig/allnoconfig/randconfig variants can also +use the environment variable KCONFIG_ALLCONFIG as a flag or a filename +that contains config symbols that the user requires to be set to a +specific value. If KCONFIG_ALLCONFIG is used without a filename where +KCONFIG_ALLCONFIG == "" or KCONFIG_ALLCONFIG == "1", "make *config" +checks for a file named "all{yes/mod/no/def/random}.config" +(corresponding to the *config command that was used) for symbol values +that are to be forced. If this file is not found, it checks for a +file named "all.config" to contain forced values. This enables you to create "miniature" config (miniconfig) or custom config files containing just the config symbols that you are interested
scripts/kconfig/conf.c +14 -6
@@ -574,8 +574,13 @@ int main(int ac, char **av)case alldefconfig:case randconfig: name =getenv ("KCONFIG_ALLCONFIG" ); -if (name && !stat (name, &tmpstat)) { -conf_read_simple (name,S_DEF_USER ); +if (name && (strcmp (name,"" ) !=0 ) && (strcmp (name,"1" ) !=0 )) { +if (conf_read_simple (name,S_DEF_USER )) { +fprintf (stderr, +_ ("*** Can't read seed configuration \"%s\"!\n" ), + name); +exit (1 ); + }break ; }switch (input_mode) {
@@ -586,10 +591,13 @@ int main(int ac, char **av)case randconfig: name ="allrandom.config" ;break ;default :break ; } -if (!stat (name, &tmpstat)) -conf_read_simple (name,S_DEF_USER ); -else if (!stat ("all.config" , &tmpstat)) -conf_read_simple ("all.config" ,S_DEF_USER ); +if (conf_read_simple (name,S_DEF_USER ) && +conf_read_simple ("all.config" ,S_DEF_USER )) { +fprintf (stderr, +_ ("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n" ), + name); +exit (1 ); + }break ;default :break ;
Signature · 1 line
1.7.2.5
Re: [PATCH] kbuild: Add error handling to KCONFIG_ALL_CONFIG
Quoted 9 lines · Eric W. Biederman
- Only try to read the file specified if
KCONFIG_ALL_CONFIGis set to something other than the empty string or "1".- Don't use stat to check the name passed to
conf_read_simpleso thatzconf_fopencan find the file in the current directory or in SRCTREE removing a extremely source of confusing failure, whereKCONFIG_ALL_CONFIGwas not interpreted with respect to the directory make was called in.
Quoted 6 lines
- If
conf_read_simplefails complain clearly and stop processing. Allowing the simple debugging of typos.- Clearly document the behavior so it is clear to users which values are treated as flags and which values are treated as filenames.
Thanks, applied to kbuild.git#kconfig.
Michal