From 129462da1b6b5c3b2649c99cc6c75fb275bff21d Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Mon, 17 Nov 2014 14:56:49 +0100 Subject: kconfig: create files in target directory if requested Otherwise rename() fails when used across filesystem boundaries. Change-Id: I22a62310f0e46ac9cfee50b7e9eeed93536ed409 Signed-off-by: Patrick Georgi Reviewed-on: http://review.coreboot.org/7504 Reviewed-by: Edward O'Callaghan Tested-by: build bot (Jenkins) --- util/kconfig/confdata.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/util/kconfig/confdata.c b/util/kconfig/confdata.c index a611ed7b01..149e27aec5 100644 --- a/util/kconfig/confdata.c +++ b/util/kconfig/confdata.c @@ -980,14 +980,26 @@ int conf_write_autoconf(void) if (conf_split_config()) return 1; - char *tmpconfig_name = strdup(".tmpconfig.XXXXXX"); + char *tmpconfig_name = malloc(PATH_MAX); + if (getenv("COREBOOT_BUILD_DIR")) { + sprintf(tmpconfig_name, "%s/.tmpconfig.XXXXXX", + getenv("COREBOOT_BUILD_DIR")); + } else { + tmpconfig_name = strdup(".tmpconfig.XXXXXX"); + } if ((i = mkstemp(tmpconfig_name)) == -1) return 1; out = fdopen(i, "w"); if (!out) return 1; - char *tmpconfig_triname = strdup(".tmpconfig_tristate.XXXXXX"); + char *tmpconfig_triname = malloc(PATH_MAX); + if (getenv("COREBOOT_BUILD_DIR")) { + sprintf(tmpconfig_triname, "%s/.tmpconfig_tristate.XXXXXX", + getenv("COREBOOT_BUILD_DIR")); + } else { + tmpconfig_triname = strdup(".tmpconfig_tristate.XXXXXX"); + } if ((i = mkstemp(tmpconfig_triname)) == -1) return 1; tristate = fdopen(i, "w"); @@ -996,7 +1008,13 @@ int conf_write_autoconf(void) return 1; } - char *tmpconfig_h = strdup(".tmpconfig_tristate.XXXXXX"); + char *tmpconfig_h = malloc(PATH_MAX); + if (getenv("COREBOOT_BUILD_DIR")) { + sprintf(tmpconfig_h, "%s/.tmpconfig_tristate.XXXXXX", + getenv("COREBOOT_BUILD_DIR")); + } else { + tmpconfig_h = strdup(".tmpconfig_tristate.XXXXXX"); + } if ((i = mkstemp(tmpconfig_h)) == -1) return 1; out_h = fdopen(i, "w"); -- cgit v1.2.3