Replace Fiwix filelist with parsing builder-hex0's FS structures

And while we're at it, use a more sustainable way of getting the
address of the next file to be written to.

Since builder-hex0 doesn't distinguish directories from zero-length
files, this has a limitation that it won't copy any zero-length
files or empty directories. Only one such file is important for the
bootstrap process (mes/config.h), which is recreated using an
improve step.
This commit is contained in:
Gábor Stefanik 2024-02-05 09:55:31 +01:00
parent 49f5520143
commit 5945bdc1e8
7 changed files with 51 additions and 259 deletions

View file

@ -412,22 +412,6 @@ Directive *interpreter(Directive *directives) {
return directives;
}
void add_to_fiwix_filelist(char *filename) {
/* Add the filename to fiwix-file-list.txt */
FILE *fiwix_list = fopen("/steps/lwext4-1.0.0-lb1/files/fiwix-file-list.txt", "r");
fseek(fiwix_list, 0, SEEK_END);
long size = ftell(fiwix_list);
char *contents = calloc(size, sizeof(char));
fseek(fiwix_list, 0, SEEK_SET);
fread(contents, 1, size, fiwix_list);
fclose(fiwix_list);
fiwix_list = fopen("/steps/lwext4-1.0.0-lb1/files/fiwix-file-list.txt", "w");
fwrite(contents, 1, size, fiwix_list);
fputs(filename, fiwix_list);
fputc('\n', fiwix_list);
fclose(fiwix_list);
}
/* Script generator. */
FILE *start_script(int id, int bash_build) {
/* Create the file /steps/$id.sh */
@ -435,7 +419,6 @@ FILE *start_script(int id, int bash_build) {
strcpy(filename, "/steps/");
strcat(filename, int2str(id, 10, 0));
strcat(filename, ".sh");
add_to_fiwix_filelist(filename);
FILE *out = fopen(filename, "w");
if (out == NULL) {
@ -608,12 +591,6 @@ void generate(Directive *directives) {
output_call_script(out, "jump", directive->arg, bash_build, 1);
fclose(out);
/*
* This cannot go before here as builder-hex0 does not like having
* multiple files open at once!
*/
add_to_fiwix_filelist(filename);
if (bash_build) {
out = fopen(filename, "w");
if (out == NULL) {