mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	kconfig: fix silentoldconfig
Recent changes to oldconfig have mixed up the silentoldconfig handling, so this fixes that by clearly separating that special mode, e.g. KCONFIG_NOSILENTUPDATE is only relevant here, the .config is written as needed. This will also properly close Bug 11230. Signed-off-by: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
		
							parent
							
								
									d0185c0882
								
							
						
					
					
						commit
						204c96f609
					
				
					 1 changed files with 57 additions and 66 deletions
				
			
		| 
						 | 
					@ -32,6 +32,7 @@ char *defconfig_file;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int indent = 1;
 | 
					static int indent = 1;
 | 
				
			||||||
static int valid_stdin = 1;
 | 
					static int valid_stdin = 1;
 | 
				
			||||||
 | 
					static int sync_kconfig;
 | 
				
			||||||
static int conf_cnt;
 | 
					static int conf_cnt;
 | 
				
			||||||
static char line[128];
 | 
					static char line[128];
 | 
				
			||||||
static struct menu *rootEntry;
 | 
					static struct menu *rootEntry;
 | 
				
			||||||
| 
						 | 
					@ -65,7 +66,7 @@ static void strip(char *str)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void check_stdin(void)
 | 
					static void check_stdin(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (!valid_stdin && input_mode == ask_silent) {
 | 
						if (!valid_stdin) {
 | 
				
			||||||
		printf(_("aborted!\n\n"));
 | 
							printf(_("aborted!\n\n"));
 | 
				
			||||||
		printf(_("Console input/output is redirected. "));
 | 
							printf(_("Console input/output is redirected. "));
 | 
				
			||||||
		printf(_("Run 'make oldconfig' to update configuration.\n\n"));
 | 
							printf(_("Run 'make oldconfig' to update configuration.\n\n"));
 | 
				
			||||||
| 
						 | 
					@ -427,43 +428,6 @@ static void check_conf(struct menu *menu)
 | 
				
			||||||
		check_conf(child);
 | 
							check_conf(child);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void conf_do_update(void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/* Update until a loop caused no more changes */
 | 
					 | 
				
			||||||
	do {
 | 
					 | 
				
			||||||
		conf_cnt = 0;
 | 
					 | 
				
			||||||
		check_conf(&rootmenu);
 | 
					 | 
				
			||||||
	} while (conf_cnt);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int conf_silent_update(void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	const char *name;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (conf_get_changed()) {
 | 
					 | 
				
			||||||
		name = getenv("KCONFIG_NOSILENTUPDATE");
 | 
					 | 
				
			||||||
		if (name && *name) {
 | 
					 | 
				
			||||||
			fprintf(stderr,
 | 
					 | 
				
			||||||
			_("\n*** Kernel configuration requires explicit update.\n\n"));
 | 
					 | 
				
			||||||
			return 1;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		conf_do_update();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int conf_update(void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	rootEntry = &rootmenu;
 | 
					 | 
				
			||||||
	conf(&rootmenu);
 | 
					 | 
				
			||||||
	if (input_mode == ask_all) {
 | 
					 | 
				
			||||||
		input_mode = ask_silent;
 | 
					 | 
				
			||||||
		valid_stdin = 1;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	conf_do_update();
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int main(int ac, char **av)
 | 
					int main(int ac, char **av)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int opt;
 | 
						int opt;
 | 
				
			||||||
| 
						 | 
					@ -477,11 +441,11 @@ int main(int ac, char **av)
 | 
				
			||||||
	while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) {
 | 
						while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) {
 | 
				
			||||||
		switch (opt) {
 | 
							switch (opt) {
 | 
				
			||||||
		case 'o':
 | 
							case 'o':
 | 
				
			||||||
			input_mode = ask_new;
 | 
								input_mode = ask_silent;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case 's':
 | 
							case 's':
 | 
				
			||||||
			input_mode = ask_silent;
 | 
								input_mode = ask_silent;
 | 
				
			||||||
			valid_stdin = isatty(0) && isatty(1) && isatty(2);
 | 
								sync_kconfig = 1;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case 'd':
 | 
							case 'd':
 | 
				
			||||||
			input_mode = set_default;
 | 
								input_mode = set_default;
 | 
				
			||||||
| 
						 | 
					@ -519,6 +483,19 @@ int main(int ac, char **av)
 | 
				
			||||||
	name = av[optind];
 | 
						name = av[optind];
 | 
				
			||||||
	conf_parse(name);
 | 
						conf_parse(name);
 | 
				
			||||||
	//zconfdump(stdout);
 | 
						//zconfdump(stdout);
 | 
				
			||||||
 | 
						if (sync_kconfig) {
 | 
				
			||||||
 | 
							if (stat(".config", &tmpstat)) {
 | 
				
			||||||
 | 
								fprintf(stderr, _("***\n"
 | 
				
			||||||
 | 
									"*** You have not yet configured your kernel!\n"
 | 
				
			||||||
 | 
									"*** (missing kernel .config file)\n"
 | 
				
			||||||
 | 
									"***\n"
 | 
				
			||||||
 | 
									"*** Please run some configurator (e.g. \"make oldconfig\" or\n"
 | 
				
			||||||
 | 
									"*** \"make menuconfig\" or \"make xconfig\").\n"
 | 
				
			||||||
 | 
									"***\n"));
 | 
				
			||||||
 | 
								exit(1);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (input_mode) {
 | 
						switch (input_mode) {
 | 
				
			||||||
	case set_default:
 | 
						case set_default:
 | 
				
			||||||
		if (!defconfig_file)
 | 
							if (!defconfig_file)
 | 
				
			||||||
| 
						 | 
					@ -531,16 +508,6 @@ int main(int ac, char **av)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case ask_silent:
 | 
						case ask_silent:
 | 
				
			||||||
		if (stat(".config", &tmpstat)) {
 | 
					 | 
				
			||||||
			printf(_("***\n"
 | 
					 | 
				
			||||||
				"*** You have not yet configured your kernel!\n"
 | 
					 | 
				
			||||||
				"*** (missing kernel .config file)\n"
 | 
					 | 
				
			||||||
				"***\n"
 | 
					 | 
				
			||||||
				"*** Please run some configurator (e.g. \"make oldconfig\" or\n"
 | 
					 | 
				
			||||||
				"*** \"make menuconfig\" or \"make xconfig\").\n"
 | 
					 | 
				
			||||||
				"***\n"));
 | 
					 | 
				
			||||||
			exit(1);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	case ask_all:
 | 
						case ask_all:
 | 
				
			||||||
	case ask_new:
 | 
						case ask_new:
 | 
				
			||||||
		conf_read(NULL);
 | 
							conf_read(NULL);
 | 
				
			||||||
| 
						 | 
					@ -569,6 +536,19 @@ int main(int ac, char **av)
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (sync_kconfig) {
 | 
				
			||||||
 | 
							if (conf_get_changed()) {
 | 
				
			||||||
 | 
								name = getenv("KCONFIG_NOSILENTUPDATE");
 | 
				
			||||||
 | 
								if (name && *name) {
 | 
				
			||||||
 | 
									fprintf(stderr,
 | 
				
			||||||
 | 
										_("\n*** Kernel configuration requires explicit update.\n\n"));
 | 
				
			||||||
 | 
									return 1;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							valid_stdin = isatty(0) && isatty(1) && isatty(2);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (input_mode) {
 | 
						switch (input_mode) {
 | 
				
			||||||
	case set_no:
 | 
						case set_no:
 | 
				
			||||||
		conf_set_all_new_symbols(def_no);
 | 
							conf_set_all_new_symbols(def_no);
 | 
				
			||||||
| 
						 | 
					@ -585,27 +565,38 @@ int main(int ac, char **av)
 | 
				
			||||||
	case set_default:
 | 
						case set_default:
 | 
				
			||||||
		conf_set_all_new_symbols(def_default);
 | 
							conf_set_all_new_symbols(def_default);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case ask_silent:
 | 
					 | 
				
			||||||
	case ask_new:
 | 
						case ask_new:
 | 
				
			||||||
		if (conf_silent_update())
 | 
					 | 
				
			||||||
			exit(1);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case ask_all:
 | 
						case ask_all:
 | 
				
			||||||
		if (conf_update())
 | 
							rootEntry = &rootmenu;
 | 
				
			||||||
			exit(1);
 | 
							conf(&rootmenu);
 | 
				
			||||||
 | 
							input_mode = ask_silent;
 | 
				
			||||||
 | 
							/* fall through */
 | 
				
			||||||
 | 
						case ask_silent:
 | 
				
			||||||
 | 
							/* Update until a loop caused no more changes */
 | 
				
			||||||
 | 
							do {
 | 
				
			||||||
 | 
								conf_cnt = 0;
 | 
				
			||||||
 | 
								check_conf(&rootmenu);
 | 
				
			||||||
 | 
							} while (conf_cnt);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (sync_kconfig) {
 | 
				
			||||||
 | 
							/* silentoldconfig is used during the build so we shall update autoconf.
 | 
				
			||||||
 | 
							 * All other commands are only used to generate a config.
 | 
				
			||||||
 | 
							 */
 | 
				
			||||||
 | 
							if (conf_get_changed() && conf_write(NULL)) {
 | 
				
			||||||
 | 
								fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
 | 
				
			||||||
 | 
								exit(1);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (conf_write_autoconf()) {
 | 
				
			||||||
 | 
								fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n"));
 | 
				
			||||||
 | 
								return 1;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
		if (conf_write(NULL)) {
 | 
							if (conf_write(NULL)) {
 | 
				
			||||||
			fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
 | 
								fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
 | 
				
			||||||
			exit(1);
 | 
								exit(1);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	/* ask_silent is used during the build so we shall update autoconf.
 | 
					 | 
				
			||||||
	 * All other commands are only used to generate a config.
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	if (input_mode == ask_silent && conf_write_autoconf()) {
 | 
					 | 
				
			||||||
		fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
 | 
					 | 
				
			||||||
		return 1;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue