2 Commits

Author SHA1 Message Date
Ian Burgwin
a515ca7e61 finalize: fix using pointers incorrectly, meaning only one title would work 2020-05-23 11:02:25 -07:00
Ian Burgwin
167a80ff11 gui: use list for args instead of creating a string 2020-05-22 02:43:11 -07:00
2 changed files with 29 additions and 21 deletions

View File

@@ -85,6 +85,8 @@ int load_cifinish(char* path, struct finish_db_entry_final **entries)
struct finish_db_entry_v2 v2;
struct finish_db_entry_v3 v3;
struct finish_db_entry_final *tmp;
int i;
size_t read;
@@ -114,6 +116,12 @@ int load_cifinish(char* path, struct finish_db_entry_final **entries)
}
*entries = calloc(header.title_count, sizeof(struct finish_db_entry_final));
if (!*entries) {
printf("Couldn't allocate memory.\n");
printf("This should never happen.\n");
goto fail;
}
tmp = *entries;
if (header.version == 1)
{
@@ -133,9 +141,9 @@ int load_cifinish(char* path, struct finish_db_entry_final **entries)
printf(" Is the file corrupt?\n");
goto fail;
}
entries[i]->has_seed = v1.has_seed;
entries[i]->title_id = v1.title_id;
memcpy(entries[i]->seed, v1.seed, 16);
tmp[i].has_seed = v1.has_seed;
tmp[i].title_id = v1.title_id;
memcpy(tmp[i].seed, v1.seed, 16);
}
} else if (header.version == 2) {
for (i = 0; i < header.title_count; i++)
@@ -154,9 +162,9 @@ int load_cifinish(char* path, struct finish_db_entry_final **entries)
printf(" Is the file corrupt?\n");
goto fail;
}
entries[i]->has_seed = v2.has_seed;
entries[i]->title_id = v2.title_id;
memcpy(entries[i]->seed, v2.seed, 16);
tmp[i].has_seed = v2.has_seed;
tmp[i].title_id = v2.title_id;
memcpy(tmp[i].seed, v2.seed, 16);
}
} else if (header.version == 3) {
for (i = 0; i < header.title_count; i++)
@@ -175,9 +183,9 @@ int load_cifinish(char* path, struct finish_db_entry_final **entries)
printf(" Is the file corrupt?\n");
goto fail;
}
entries[i]->has_seed = v3.has_seed;
entries[i]->title_id = v3.title_id;
memcpy(entries[i]->seed, v3.seed, 16);
tmp[i].has_seed = v3.has_seed;
tmp[i].title_id = v3.title_id;
memcpy(tmp[i].seed, v3.seed, 16);
}
}
@@ -267,7 +275,7 @@ int main(int argc, char* argv[])
gfxInitDefault();
consoleInit(GFX_TOP, NULL);
printf("custom-install-finalize v1.3\n");
printf("custom-install-finalize v1.4\n");
finalize_install();
// print this at the end in case it gets pushed off the screen

22
gui.py
View File

@@ -342,7 +342,7 @@ class gui(tk.Tk):
run_button.place(relwidth=1, rely=1, y=- 22)
def run(self):
argstring = ""
args_extra = []
self.output_to_console("-----------------------\nStarting...\n")
@@ -350,32 +350,33 @@ class gui(tk.Tk):
if not boot9:
self.output_to_console(
"Warning - boot9 not selected, if it's not set externally you may run into problems.\n")
argstring += f"-b {boot9} "
else:
args_extra.extend(['-b', boot9])
sed = self.sed_box.get()
if not sed:
self.output_to_console("Failed to run - No movable.sed selected.\n")
return
argstring += f"-m {sed} "
args_extra.extend(['-m', sed])
sd = self.sd_box.get().strip()
if not sd:
self.output_to_console("Failed to run - SD path not selected.\n")
return
argstring += f"--sd {sd} "
args_extra.extend(['--sd', sd])
cias = []
for i in range(0, self.cia_box.size()):
cias.append(self.cia_box.get(i).strip())
for cia in cias:
argstring += f" {cia}"
args_extra.append(cia)
if self.skip_contents.get():
argstring += "--skip-contents "
args_extra.append('--skip-contents')
print(f"Running custom-install.py with args {args}\n")
print(f"Running custom-install.py with args {args_extra}\n")
self.threader.do_async(execute_script, [argstring, self.output_to_console])
self.threader.do_async(execute_script, [args_extra, self.output_to_console])
def output_to_console(self, outstring):
self.console.insert('end', outstring)
@@ -410,12 +411,11 @@ class gui(tk.Tk):
self.cia_box.select_set(0)
def execute_script(argstring, printer):
def execute_script(args_extra, printer):
"""Wrapper function to pipe install script output to a printer"""
try:
args = [sys.executable, '-u', os.path.join(os.path.dirname(__file__), "custominstall.py")]
for arg in argstring.split():
args.append(arg.strip())
args.extend(args_extra)
p = subprocess.Popen(args,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,