kconfig: Use config's full path when generating tmp file
If KCONFIG_CONFIG is set to a full path, we should generate the tmp file in the same directory instead of the current working directory. BUG=b:112267918 TEST=emerge-grunt coreboot and verified with print statements that the correct path was used. Change-Id: Ia21e930a9b0a693f851c34bcde26b34886cbe902 Signed-off-by: Raul E Rangel <rrangel@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/34243 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
parent
d12d25227f
commit
d2f90a0659
|
@ -769,7 +769,7 @@ int conf_write(const char *name)
|
||||||
FILE *out;
|
FILE *out;
|
||||||
struct symbol *sym;
|
struct symbol *sym;
|
||||||
struct menu *menu;
|
struct menu *menu;
|
||||||
const char *basename;
|
const char *basename = NULL;
|
||||||
const char *str;
|
const char *str;
|
||||||
char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1];
|
char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1];
|
||||||
char *env;
|
char *env;
|
||||||
|
@ -777,13 +777,20 @@ int conf_write(const char *name)
|
||||||
dirname[0] = 0;
|
dirname[0] = 0;
|
||||||
if (name && name[0]) {
|
if (name && name[0]) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char *slash;
|
|
||||||
|
|
||||||
if (!stat(name, &st) && S_ISDIR(st.st_mode)) {
|
if (!stat(name, &st) && S_ISDIR(st.st_mode)) {
|
||||||
strcpy(dirname, name);
|
strcpy(dirname, name);
|
||||||
strcat(dirname, "/");
|
strcat(dirname, "/");
|
||||||
basename = conf_get_configname();
|
basename = conf_get_configname();
|
||||||
} else if ((slash = strrchr(name, '/'))) {
|
}
|
||||||
|
} else {
|
||||||
|
name = conf_get_configname();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!basename) {
|
||||||
|
char *slash = strrchr(name, '/');
|
||||||
|
|
||||||
|
if (slash) {
|
||||||
int size = slash - name + 1;
|
int size = slash - name + 1;
|
||||||
memcpy(dirname, name, size);
|
memcpy(dirname, name, size);
|
||||||
dirname[size] = 0;
|
dirname[size] = 0;
|
||||||
|
@ -791,10 +798,10 @@ int conf_write(const char *name)
|
||||||
basename = slash + 1;
|
basename = slash + 1;
|
||||||
else
|
else
|
||||||
basename = conf_get_configname();
|
basename = conf_get_configname();
|
||||||
} else
|
} else {
|
||||||
basename = name;
|
basename = name;
|
||||||
} else
|
}
|
||||||
basename = conf_get_configname();
|
}
|
||||||
|
|
||||||
sprintf(newname, "%s%s", dirname, basename);
|
sprintf(newname, "%s%s", dirname, basename);
|
||||||
env = getenv("KCONFIG_OVERWRITECONFIG");
|
env = getenv("KCONFIG_OVERWRITECONFIG");
|
||||||
|
|
Loading…
Reference in New Issue