Skip to content

Commit

Permalink
Replace Fiwix filelist with parsing builder-hex0's FS structures
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Googulator committed Feb 6, 2024
1 parent 49f5520 commit 5c19cbd
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 260 deletions.
2 changes: 1 addition & 1 deletion builder-hex0
26 changes: 0 additions & 26 deletions lib/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ def prepare(self, target, using_kernel=False, kernel_bootstrap=False, target_siz

self.distfiles()

self.create_fiwix_file_list()

if self.repo_path:
repo_dir = os.path.join(self.external_dir, 'repo-preseeded')
shutil.copytree(self.repo_path, repo_dir)
Expand Down Expand Up @@ -134,30 +132,6 @@ def seed(self):
if os.path.isfile(os.path.join(seed_dir, entry)):
shutil.copy2(os.path.join(seed_dir, entry), os.path.join(self.target_dir, entry))

@staticmethod
def add_fiwix_files(file_list_path, dirpath):
"""Add files to the list to populate Fiwix file system"""
for root, _, filepaths in os.walk(dirpath):
if 'stage0-posix' in root:
continue
with open(file_list_path, 'a', encoding="utf-8") as file_list:
for filepath in filepaths:
file_list.write(f"/{os.path.join(root, filepath)}\n")

def create_fiwix_file_list(self):
"""Create a list of files to populate Fiwix file system"""
file_list_path = os.path.join(self.target_dir, 'steps', 'lwext4-1.0.0-lb1',
'files', 'fiwix-file-list.txt')
shutil.copyfile(os.path.join(self.target_dir, 'steps', 'lwext4-1.0.0-lb1',
'files', 'early-artifacts-needed-after-fiwix.txt'),
file_list_path)

save_cwd = os.getcwd()
os.chdir(self.target_dir)
self.add_fiwix_files(file_list_path, 'steps')
self.add_fiwix_files(file_list_path, 'distfiles')
os.chdir(save_cwd)

def distfiles(self):
"""Copy in distfiles"""
def copy_no_network_distfiles(out, early):
Expand Down
23 changes: 0 additions & 23 deletions seed/script-generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,30 +412,13 @@ 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 */
char *filename = calloc(MAX_STRING, sizeof(char));
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) {
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion steps/jump/linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ set -e

# Perform the actual kexec
if [ "${KERNEL_BOOTSTRAP}" = True ]; then
mv "/High Level Prototypes" "/High_Level_Prototypes"
sync
# We don't use the gen_initramfs_list.sh script because it is so *SLOW*
# This emulates the same thing it does
find / -xdev -type d -printf "dir %p %m %U %G\n" >> /initramfs.list
find / -xdev -type f -printf "file %p %p %m %U %G\n" >> /initramfs.list
find / -xdev -type l -printf "slink %p %l %m %U %G\n" >> /initramfs.list
kexec-linux "/dev/ram1" "/boot/linux-4.9.10" "!$(command -v gen_init_cpio) /initramfs.list"
kexec-linux "/dev/ram1" "/boot/linux-4.9.10" "!gen_init_cpio /initramfs.list | gzip -c"
else
mkdir /etc
# kexec time
Expand Down
177 changes: 0 additions & 177 deletions steps/lwext4-1.0.0-lb1/files/early-artifacts-needed-after-fiwix.txt

This file was deleted.

Loading

0 comments on commit 5c19cbd

Please sign in to comment.