summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorRoman Zippel <zippel@linux-m68k.org>2006-06-09 07:12:51 +0200
committerSam Ravnborg <sam@mars.ravnborg.org>2006-06-09 16:28:07 +0200
commit14cdd3c402bf7c66f0bcd76e290f0770a54a4b21 (patch)
tree1a58bdd177f1d5723a1a695e6165c5904c641c55 /scripts
parentkconfig: exit if no beginning filename (diff)
downloadlinux-14cdd3c402bf7c66f0bcd76e290f0770a54a4b21.tar.xz
linux-14cdd3c402bf7c66f0bcd76e290f0770a54a4b21.zip
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.c46
-rw-r--r--scripts/kconfig/lkc.h2
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, ...)
static const char *conf_filename;
static int conf_lineno, conf_warnings, conf_unsaved;
-const char conf_def_filename[] = ".config";
-
const char conf_defname[] = "arch/$ARCH/defconfig";
static void conf_warning(const char *fmt, ...)
@@ -36,6 +34,13 @@ static void conf_warning(const char *fmt, ...)
conf_warnings++;
}
+const char *conf_get_configname(void)
+{
+ char *name = getenv("KCONFIG_CONFIG");
+
+ return name ? name : ".config";
+}
+
static char *conf_expand_value(const char *in)
{
struct symbol *sym;
@@ -91,7 +96,7 @@ int conf_read_simple(const char *name, int def)
} else {
struct property *prop;
- name = conf_def_filename;
+ name = conf_get_configname();
in = zconf_fopen(name);
if (in)
goto load;
@@ -381,7 +386,7 @@ int conf_write(const char *name)
if (!stat(name, &st) && S_ISDIR(st.st_mode)) {
strcpy(dirname, name);
strcat(dirname, "/");
- basename = conf_def_filename;
+ basename = conf_get_configname();
} else if ((slash = strrchr(name, '/'))) {
int size = slash - name + 1;
memcpy(dirname, name, size);
@@ -389,16 +394,24 @@ int conf_write(const char *name)
if (slash[1])
basename = slash + 1;
else
- basename = conf_def_filename;
+ basename = conf_get_configname();
} else
basename = name;
} else
- basename = conf_def_filename;
+ basename = conf_get_configname();
- sprintf(newname, "%s.tmpconfig.%d", dirname, (int)getpid());
- out = fopen(newname, "w");
+ sprintf(newname, "%s%s", dirname, basename);
+ env = getenv("KCONFIG_OVERWRITECONFIG");
+ if (!env || !*env) {
+ sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
+ out = fopen(tmpname, "w");
+ } else {
+ *tmpname = 0;
+ out = fopen(newname, "w");
+ }
if (!out)
return 1;
+
sym = sym_lookup("KERNELVERSION", 0);
sym_calc_value(sym);
time(&now);
@@ -498,19 +511,18 @@ int conf_write(const char *name)
}
}
fclose(out);
- if (!name || basename != conf_def_filename) {
- if (!name)
- name = conf_def_filename;
- sprintf(tmpname, "%s.old", name);
- rename(name, tmpname);
+
+ if (*tmpname) {
+ strcat(dirname, name ? name : conf_get_configname());
+ strcat(dirname, ".old");
+ rename(newname, dirname);
+ if (rename(tmpname, newname))
+ return 1;
}
- sprintf(tmpname, "%s%s", dirname, basename);
- if (rename(newname, tmpname))
- return 1;
printf(_("#\n"
"# configuration written to %s\n"
- "#\n"), tmpname);
+ "#\n"), newname);
sym_change_count = 0;
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);
char *zconf_curname(void);
/* confdata.c */
-extern const char conf_def_filename[];
-
char *conf_get_default_confname(void);
/* kconfig_load.c */