diff options
author | Roman Zippel <zippel@linux-m68k.org> | 2006-06-09 01:12:51 -0400 |
---|---|---|
committer | Sam Ravnborg <sam@mars.ravnborg.org> | 2006-06-09 10:28:07 -0400 |
commit | 14cdd3c402bf7c66f0bcd76e290f0770a54a4b21 (patch) | |
tree | 1a58bdd177f1d5723a1a695e6165c5904c641c55 /scripts | |
parent | 250725aa13f5c9595e5bc265ebed8471e816d8b4 (diff) |
kconfig: KCONFIG_OVERWRITECONFIG
If you set KCONFIG_OVERWRITECONFIG in environment, Kconfig will not break
symlinks when .config is a symlink to somewhere else.
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/kconfig/confdata.c | 46 | ||||
-rw-r--r-- | scripts/kconfig/lkc.h | 2 |
2 files changed, 29 insertions, 19 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 5bd66f451189..2ee48c377b66 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c | |||
@@ -21,8 +21,6 @@ static void conf_warning(const char *fmt, ...) | |||
21 | static const char *conf_filename; | 21 | static const char *conf_filename; |
22 | static int conf_lineno, conf_warnings, conf_unsaved; | 22 | static int conf_lineno, conf_warnings, conf_unsaved; |
23 | 23 | ||
24 | const char conf_def_filename[] = ".config"; | ||
25 | |||
26 | const char conf_defname[] = "arch/$ARCH/defconfig"; | 24 | const char conf_defname[] = "arch/$ARCH/defconfig"; |
27 | 25 | ||
28 | static void conf_warning(const char *fmt, ...) | 26 | static void conf_warning(const char *fmt, ...) |
@@ -36,6 +34,13 @@ static void conf_warning(const char *fmt, ...) | |||
36 | conf_warnings++; | 34 | conf_warnings++; |
37 | } | 35 | } |
38 | 36 | ||
37 | const char *conf_get_configname(void) | ||
38 | { | ||
39 | char *name = getenv("KCONFIG_CONFIG"); | ||
40 | |||
41 | return name ? name : ".config"; | ||
42 | } | ||
43 | |||
39 | static char *conf_expand_value(const char *in) | 44 | static char *conf_expand_value(const char *in) |
40 | { | 45 | { |
41 | struct symbol *sym; | 46 | struct symbol *sym; |
@@ -91,7 +96,7 @@ int conf_read_simple(const char *name, int def) | |||
91 | } else { | 96 | } else { |
92 | struct property *prop; | 97 | struct property *prop; |
93 | 98 | ||
94 | name = conf_def_filename; | 99 | name = conf_get_configname(); |
95 | in = zconf_fopen(name); | 100 | in = zconf_fopen(name); |
96 | if (in) | 101 | if (in) |
97 | goto load; | 102 | goto load; |
@@ -381,7 +386,7 @@ int conf_write(const char *name) | |||
381 | if (!stat(name, &st) && S_ISDIR(st.st_mode)) { | 386 | if (!stat(name, &st) && S_ISDIR(st.st_mode)) { |
382 | strcpy(dirname, name); | 387 | strcpy(dirname, name); |
383 | strcat(dirname, "/"); | 388 | strcat(dirname, "/"); |
384 | basename = conf_def_filename; | 389 | basename = conf_get_configname(); |
385 | } else if ((slash = strrchr(name, '/'))) { | 390 | } else if ((slash = strrchr(name, '/'))) { |
386 | int size = slash - name + 1; | 391 | int size = slash - name + 1; |
387 | memcpy(dirname, name, size); | 392 | memcpy(dirname, name, size); |
@@ -389,16 +394,24 @@ int conf_write(const char *name) | |||
389 | if (slash[1]) | 394 | if (slash[1]) |
390 | basename = slash + 1; | 395 | basename = slash + 1; |
391 | else | 396 | else |
392 | basename = conf_def_filename; | 397 | basename = conf_get_configname(); |
393 | } else | 398 | } else |
394 | basename = name; | 399 | basename = name; |
395 | } else | 400 | } else |
396 | basename = conf_def_filename; | 401 | basename = conf_get_configname(); |
397 | 402 | ||
398 | sprintf(newname, "%s.tmpconfig.%d", dirname, (int)getpid()); | 403 | sprintf(newname, "%s%s", dirname, basename); |
399 | out = fopen(newname, "w"); | 404 | env = getenv("KCONFIG_OVERWRITECONFIG"); |
405 | if (!env || !*env) { | ||
406 | sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid()); | ||
407 | out = fopen(tmpname, "w"); | ||
408 | } else { | ||
409 | *tmpname = 0; | ||
410 | out = fopen(newname, "w"); | ||
411 | } | ||
400 | if (!out) | 412 | if (!out) |
401 | return 1; | 413 | return 1; |
414 | |||
402 | sym = sym_lookup("KERNELVERSION", 0); | 415 | sym = sym_lookup("KERNELVERSION", 0); |
403 | sym_calc_value(sym); | 416 | sym_calc_value(sym); |
404 | time(&now); | 417 | time(&now); |
@@ -498,19 +511,18 @@ int conf_write(const char *name) | |||
498 | } | 511 | } |
499 | } | 512 | } |
500 | fclose(out); | 513 | fclose(out); |
501 | if (!name || basename != conf_def_filename) { | 514 | |
502 | if (!name) | 515 | if (*tmpname) { |
503 | name = conf_def_filename; | 516 | strcat(dirname, name ? name : conf_get_configname()); |
504 | sprintf(tmpname, "%s.old", name); | 517 | strcat(dirname, ".old"); |
505 | rename(name, tmpname); | 518 | rename(newname, dirname); |
519 | if (rename(tmpname, newname)) | ||
520 | return 1; | ||
506 | } | 521 | } |
507 | sprintf(tmpname, "%s%s", dirname, basename); | ||
508 | if (rename(newname, tmpname)) | ||
509 | return 1; | ||
510 | 522 | ||
511 | printf(_("#\n" | 523 | printf(_("#\n" |
512 | "# configuration written to %s\n" | 524 | "# configuration written to %s\n" |
513 | "#\n"), tmpname); | 525 | "#\n"), newname); |
514 | 526 | ||
515 | sym_change_count = 0; | 527 | sym_change_count = 0; |
516 | 528 | ||
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 2d3d4ed3c9f2..2628023a1fe1 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h | |||
@@ -64,8 +64,6 @@ int zconf_lineno(void); | |||
64 | char *zconf_curname(void); | 64 | char *zconf_curname(void); |
65 | 65 | ||
66 | /* confdata.c */ | 66 | /* confdata.c */ |
67 | extern const char conf_def_filename[]; | ||
68 | |||
69 | char *conf_get_default_confname(void); | 67 | char *conf_get_default_confname(void); |
70 | 68 | ||
71 | /* kconfig_load.c */ | 69 | /* kconfig_load.c */ |