2008-03-05 18:56:54

by Dave Jones

[permalink] [raw]
Subject: rfc: nonint_oldconfig

Hi Sam.
We've had this kicking around in Fedora forever
(Seriously, even our 2.4 kernels had it)
The basic behaviour is to run oldconfig, but instead of
stopping and prompting for each unknown option, print
out a list of the unknowns at the end.
This is useful for us for the case where we're rebasing
to a new kernel. Instead of having to add an option to
our configs and rerun make oldconfig n times, we do it just once,
adding all the new options in one go.
(Well, sometimes it still takes 1-2 more runs if the new options
are dependancies of other new options, but it still cuts down
the number of times to rerun oldconfig a lot).

There's also an additional target that does the same, but
ignores any options defined in the local configs that the kernel
being configured doesn't know about.

Any comments?

Dave

--
http://www.codemonkey.org.uk



diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 32e8c5a..8020453 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -24,6 +24,11 @@ oldconfig: $(obj)/conf
silentoldconfig: $(obj)/conf
$< -s $(Kconfig)

+nonint_oldconfig: $(obj)/conf
+ $< -b $(Kconfig)
+loose_nonint_oldconfig: $(obj)/conf
+ $< -B $(Kconfig)
+
# Create new linux.pot file
# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
# The symlink is used to repair a deficiency in arch/um
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index fda6313..ed33b66 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -22,6 +22,8 @@ enum {
ask_all,
ask_new,
ask_silent,
+ dont_ask,
+ dont_ask_dont_tell,
set_default,
set_yes,
set_mod,
@@ -38,6 +40,8 @@ static struct menu *rootEntry;

static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");

+static int return_value = 0;
+
static const char *get_help(struct menu *menu)
{
if (menu_has_help(menu))
@@ -112,6 +116,16 @@ static int conf_askvalue(struct symbol *sym, const char *def)
fflush(stdout);
fgets(line, 128, stdin);
return 1;
+ case dont_ask:
+ if (!sym_has_value(sym)) {
+ fprintf(stderr,"CONFIG_%s\n",sym->name);
+ return_value++;
+ }
+ /*FALLTHROUGH*/
+ case dont_ask_dont_tell:
+ if (sym_has_value(sym))
+ return 0;
+ return 1;
case set_default:
printf("%s\n", def);
return 1;
@@ -351,6 +365,11 @@ static int conf_choice(struct menu *menu)
printf("?");
printf("]: ");
switch (input_mode) {
+ case dont_ask:
+ case dont_ask_dont_tell:
+ cnt = def;
+ printf("%d\n", cnt);
+ break;
case ask_new:
case ask_silent:
if (!is_new) {
@@ -486,6 +505,10 @@ static void check_conf(struct menu *menu)
if (!conf_cnt++)
printf(_("*\n* Restart config...\n*\n"));
rootEntry = menu_get_parent_menu(menu);
+ if (input_mode == dont_ask
+ || input_mode == dont_ask_dont_tell)
+ fprintf(stderr,"CONFIG_%s\n",sym->name);
+ else
conf(rootEntry);
}
}
@@ -504,11 +527,17 @@ int main(int ac, char **av)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);

- while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) {
+ while ((opt = getopt(ac, av, "osbBdD:nmyrh")) != -1) {
switch (opt) {
case 'o':
input_mode = ask_new;
break;
+ case 'b':
+ input_mode = dont_ask;
+ break;
+ case 'B':
+ input_mode = dont_ask_dont_tell;
+ break;
case 's':
input_mode = ask_silent;
valid_stdin = isatty(0) && isatty(1) && isatty(2);
@@ -573,6 +602,8 @@ int main(int ac, char **av)
}
case ask_all:
case ask_new:
+ case dont_ask:
+ case dont_ask_dont_tell:
conf_read(NULL);
break;
case set_no:
@@ -619,7 +650,8 @@ int main(int ac, char **av)
do {
conf_cnt = 0;
check_conf(&rootmenu);
- } while (conf_cnt);
+ } while (conf_cnt && (input_mode != dont_ask
+ && input_mode != dont_ask_dont_tell));
if (conf_write(NULL)) {
fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
return 1;
@@ -630,5 +662,5 @@ skip_check:
return 1;
}

- return 0;
+ return return_value;
}


2008-03-06 01:38:09

by Roland McGrath

[permalink] [raw]
Subject: Re: rfc: nonint_oldconfig

> There's also an additional target that does the same, but
> ignores any options defined in the local configs that the kernel
> being configured doesn't know about.

I added this one (loose_nonint_oldconfig target, -B option to conf).
It is the noninteractive equivalent of taking your old .config after a
source upgrade, running 'make oldconfig' and hitting return a lot.
(If options from your old .config went away, you get harmless warnings.
If new options appeared, you get the defaults for those.)
That's what I do in my hand builds after a git pull (hit return a lot).

The benefit of 'make loose_nonint_oldconfig' is it lets me do the same
thing with scripted rpm builds made from fresh git snapshot code. These
builds use a .config chosen for the Fedora production kernel, but a new
code snapshot (sometimes with and sometimes without the Fedora patches to
the kernel). The Fedora patches sometimes add nonstandard config options,
and the bleeding edge kernel snapshot I try sometimes had added new config
options that Fedora's kernel configs do not yet set or clear explicitly.

For development, it is very handy to just get a build that approximates the
Fedora config for the stable kernel but uses the latest development kernel
source. 99% of the time the default for new options works fine for my
purposes. When a new kernel is imported for proper Fedora builds, then
we'll update the standard configs with tested settings for the new source.
Having to tweak those every time I want to spin a testing kernel rpm would
be a waste.


Thanks,
Roland