Allow M2-Mesoplanet to work on systems without /tmp

such as live-bootstrap
This commit is contained in:
fosslinux 2022-03-21 20:28:53 +11:00
parent bb0260eb1b
commit 03bd6bda76
2 changed files with 19 additions and 6 deletions

14
cc.c
View File

@ -288,8 +288,18 @@ int main(int argc, char** argv, char** envp)
}
else
{
char* prefix = calloc(10, sizeof(char));
if(0 == access("/tmp", 0))
{
strcpy(prefix, "/tmp/");
}
else
{
strcpy(prefix, "tmp-");
}
name = calloc(100, sizeof(char));
strcpy(name, "/tmp/M2-Mesoplanet-XXXXXX");
strcpy(name, prefix);
strcat(name, "M2-Mesoplanet-XXXXXX");
i = mkstemp(name);
tempfile = fdopen(i, "w");
if(NULL != tempfile)
@ -299,7 +309,7 @@ int main(int argc, char** argv, char** envp)
fclose(tempfile);
/* Make me a real binary */
spawn_processes(debug_flag, name, destination_name, envp);
spawn_processes(debug_flag, prefix, name, destination_name, envp);
/* And clean up the donkey */
if(!DIRTY_MODE) remove(name);

View File

@ -414,13 +414,14 @@ void spawn_M2(char* input, char* output, char* architecture, char** envp, int de
_execute("M2-Planet", array, envp);
}
void spawn_processes(int debug_flag, char* preprocessed_file, char* destination, char** envp)
void spawn_processes(int debug_flag, char* prefix, char* preprocessed_file, char* destination, char** envp)
{
int large_flag = FALSE;
if(WORDSIZE > 32) large_flag = TRUE;
char* M2_output = calloc(100, sizeof(char));
strcpy(M2_output, "/tmp/M2-Planet-XXXXXX");
strcpy(M2_output, prefix);
strcat(M2_output, "M2-Planet-XXXXXX");
int i = mkstemp(M2_output);
if(-1 != i)
{
@ -437,7 +438,8 @@ void spawn_processes(int debug_flag, char* preprocessed_file, char* destination,
if(debug_flag)
{
blood_output = calloc(100, sizeof(char));
strcpy(blood_output, "/tmp/blood-elf-XXXXXX");
strcpy(blood_output, prefix);
strcat(blood_output, "blood-elf-XXXXXX");
i = mkstemp(blood_output);
if(-1 != i)
{
@ -452,7 +454,8 @@ void spawn_processes(int debug_flag, char* preprocessed_file, char* destination,
}
char* M1_output = calloc(100, sizeof(char));
strcpy(M1_output, "/tmp/M1-macro-XXXXXX");
strcpy(M1_output, prefix);
strcat(M1_output, "M1-macro-XXXXXX");
i = mkstemp(M1_output);
if(-1 != i)
{