mirror of
https://github.com/ihaveamac/custom-install.git
synced 2026-01-21 14:06:02 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d7be0812e | ||
|
|
8c60eecec5 | ||
|
|
653569093d | ||
|
|
adccac9ee7 | ||
|
|
8629cbee8e | ||
|
|
740844e57a | ||
|
|
d847043045 | ||
|
|
217a508bf3 | ||
|
|
42ec2d760a | ||
|
|
938d8fd6aa | ||
|
|
ac0be9d61d | ||
|
|
d231e9c043 | ||
|
|
9c3c4ce5f9 | ||
|
|
6a324b9388 | ||
|
|
647e56cf05 | ||
|
|
643e4e4976 | ||
|
|
09ed0093df |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -18,3 +18,6 @@ venv/
|
|||||||
=======
|
=======
|
||||||
|
|
||||||
*.pyc
|
*.pyc
|
||||||
|
/build/
|
||||||
|
/dist/
|
||||||
|
/custom-install-finalize.3dsx
|
||||||
|
|||||||
24
ci-gui.py
24
ci-gui.py
@@ -306,12 +306,14 @@ class CustomInstallGUI(ttk.Frame):
|
|||||||
sd_selected.delete('1.0', tk.END)
|
sd_selected.delete('1.0', tk.END)
|
||||||
sd_selected.insert(tk.END, f)
|
sd_selected.insert(tk.END, f)
|
||||||
|
|
||||||
sd_msed_path = find_first_file([join(f, 'gm9', 'out', 'movable.sed'), join(f, 'movable.sed')])
|
for filename in ['boot9.bin', 'seeddb.bin', 'movable.sed']:
|
||||||
if sd_msed_path:
|
path = auto_input_filename(self, f, filename)
|
||||||
self.log('Found movable.sed on SD card at ' + sd_msed_path)
|
if filename == 'boot9.bin':
|
||||||
box = self.file_picker_textboxes['movable.sed']
|
self.check_b9_loaded()
|
||||||
box.delete('1.0', tk.END)
|
self.enable_buttons()
|
||||||
box.insert(tk.END, sd_msed_path)
|
if filename == 'seeddb.bin':
|
||||||
|
load_seeddb(path)
|
||||||
|
|
||||||
|
|
||||||
sd_type_label = ttk.Label(file_pickers, text='SD root')
|
sd_type_label = ttk.Label(file_pickers, text='SD root')
|
||||||
sd_type_label.grid(row=0, column=0)
|
sd_type_label.grid(row=0, column=0)
|
||||||
@@ -324,6 +326,16 @@ class CustomInstallGUI(ttk.Frame):
|
|||||||
|
|
||||||
self.file_picker_textboxes['sd'] = sd_selected
|
self.file_picker_textboxes['sd'] = sd_selected
|
||||||
|
|
||||||
|
def auto_input_filename(self, f, filename):
|
||||||
|
sd_msed_path = find_first_file([join(f, 'gm9', 'out', filename), join(f, filename)])
|
||||||
|
if sd_msed_path:
|
||||||
|
self.log('Found ' + filename + ' on SD card at ' + sd_msed_path)
|
||||||
|
if filename.endswith('bin'):
|
||||||
|
filename = filename.split('.')[0]
|
||||||
|
box = self.file_picker_textboxes[filename]
|
||||||
|
box.delete('1.0', tk.END)
|
||||||
|
box.insert(tk.END, sd_msed_path)
|
||||||
|
return sd_msed_path
|
||||||
# This feels so wrong.
|
# This feels so wrong.
|
||||||
def create_required_file_picker(type_name, types, default, row, callback=lambda filename: None):
|
def create_required_file_picker(type_name, types, default, row, callback=lambda filename: None):
|
||||||
def internal_callback():
|
def internal_callback():
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ from os import makedirs, rename, scandir
|
|||||||
from os.path import dirname, join, isdir, isfile
|
from os.path import dirname, join, isdir, isfile
|
||||||
from random import randint
|
from random import randint
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from locale import getpreferredencoding
|
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
from shutil import copyfile, copy2, rmtree
|
from shutil import copyfile, copy2, rmtree
|
||||||
import sys
|
import sys
|
||||||
@@ -45,7 +44,7 @@ if is_windows:
|
|||||||
else:
|
else:
|
||||||
from os import statvfs
|
from os import statvfs
|
||||||
|
|
||||||
CI_VERSION = '2.1b3'
|
CI_VERSION = '2.1b4'
|
||||||
|
|
||||||
# used to run the save3ds_fuse binary next to the script
|
# used to run the save3ds_fuse binary next to the script
|
||||||
frozen = getattr(sys, 'frozen', False)
|
frozen = getattr(sys, 'frozen', False)
|
||||||
@@ -365,7 +364,7 @@ class CustomInstall:
|
|||||||
out = subprocess.run(save3ds_fuse_common_args + ['-x'],
|
out = subprocess.run(save3ds_fuse_common_args + ['-x'],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
encoding=getpreferredencoding(),
|
encoding='utf-8',
|
||||||
**extra_kwargs)
|
**extra_kwargs)
|
||||||
if out.returncode:
|
if out.returncode:
|
||||||
for l in out.stdout.split('\n'):
|
for l in out.stdout.split('\n'):
|
||||||
@@ -606,7 +605,7 @@ class CustomInstall:
|
|||||||
out = subprocess.run(save3ds_fuse_common_args + ['-i'],
|
out = subprocess.run(save3ds_fuse_common_args + ['-i'],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
encoding=getpreferredencoding(),
|
encoding='utf-8',
|
||||||
**extra_kwargs)
|
**extra_kwargs)
|
||||||
if out.returncode:
|
if out.returncode:
|
||||||
for l in out.stdout.split('\n'):
|
for l in out.stdout.split('\n'):
|
||||||
@@ -734,7 +733,11 @@ if __name__ == "__main__":
|
|||||||
f'Free space: {free_space / (1024 * 1024):0.2f} MiB')
|
f'Free space: {free_space / (1024 * 1024):0.2f} MiB')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
result, copied_3dsx = installer.start()
|
result, copied_3dsx, application_count = installer.start()
|
||||||
if result is False:
|
if result is False:
|
||||||
# save3ds_fuse failed
|
# save3ds_fuse failed
|
||||||
installer.log('NOTE: Once save3ds_fuse is fixed, run the same command again with --skip-contents')
|
installer.log('NOTE: Once save3ds_fuse is fixed, run the same command again with --skip-contents')
|
||||||
|
if application_count >= 300:
|
||||||
|
installer.log(f'\n\nWarning: {application_count} installed applications were detected.\n'
|
||||||
|
f'The HOME Menu will only show 300 icons.\n'
|
||||||
|
f'Some applications (not updates or DLC) will need to be deleted.')
|
||||||
|
|||||||
@@ -197,31 +197,99 @@ fail:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result check_title_exist(u64 title_id, u64 *ticket_ids, u32 ticket_ids_length, u64 *title_ids, u32 title_ids_length)
|
||||||
|
{
|
||||||
|
Result ret = -2;
|
||||||
|
|
||||||
|
for (u32 i = 0; i < ticket_ids_length; i++)
|
||||||
|
{
|
||||||
|
if (ticket_ids[i] == title_id)
|
||||||
|
{
|
||||||
|
ret++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (u32 i = 0; i < title_ids_length; i++)
|
||||||
|
{
|
||||||
|
if (title_ids[i] == title_id)
|
||||||
|
{
|
||||||
|
ret++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void finalize_install(void)
|
void finalize_install(void)
|
||||||
{
|
{
|
||||||
Result res;
|
Result res;
|
||||||
Handle ticketHandle;
|
Handle ticketHandle;
|
||||||
struct ticket_dumb ticket_buf;
|
struct ticket_dumb ticket_buf;
|
||||||
struct finish_db_entry_final *entries;
|
struct finish_db_entry_final *entries = NULL;
|
||||||
int title_count;
|
int title_count;
|
||||||
|
|
||||||
title_count = load_cifinish(CIFINISH_PATH, &entries);
|
u32 titles_read;
|
||||||
if (title_count == -1)
|
u32 tickets_read;
|
||||||
|
|
||||||
|
res = AM_GetTitleCount(MEDIATYPE_SD, &titles_read);
|
||||||
|
|
||||||
|
if (R_FAILED(res))
|
||||||
{
|
{
|
||||||
free(entries);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (title_count == 0)
|
|
||||||
|
res = AM_GetTicketCount(&tickets_read);
|
||||||
|
|
||||||
|
if (R_FAILED(res))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
u64 *installed_ticket_ids = malloc(sizeof(u64) * tickets_read );
|
||||||
|
u64 *installed_title_ids = malloc(sizeof(u64) * titles_read );
|
||||||
|
|
||||||
|
res = AM_GetTitleList(&titles_read, MEDIATYPE_SD, titles_read, installed_title_ids);
|
||||||
|
|
||||||
|
if (R_FAILED(res))
|
||||||
|
{
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = AM_GetTicketList(&tickets_read, tickets_read, 0, installed_ticket_ids);
|
||||||
|
|
||||||
|
if (R_FAILED(res))
|
||||||
|
{
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
title_count = load_cifinish(CIFINISH_PATH, &entries);
|
||||||
|
|
||||||
|
if (title_count == -1)
|
||||||
|
{
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
else if (title_count == 0)
|
||||||
{
|
{
|
||||||
printf("No titles to finalize.\n");
|
printf("No titles to finalize.\n");
|
||||||
free(entries);
|
goto exit;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&ticket_buf, basetik_bin, basetik_bin_size);
|
memcpy(&ticket_buf, basetik_bin, basetik_bin_size);
|
||||||
|
|
||||||
|
Result exist_res = 0;
|
||||||
|
|
||||||
for (int i = 0; i < title_count; ++i)
|
for (int i = 0; i < title_count; ++i)
|
||||||
{
|
{
|
||||||
|
exist_res = check_title_exist(entries[i].title_id, installed_ticket_ids, tickets_read, installed_title_ids, titles_read);
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(exist_res))
|
||||||
|
{
|
||||||
|
printf("No need to finalize %016llx, skipping...\n", entries[i].title_id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
printf("Finalizing %016llx...\n", entries[i].title_id);
|
printf("Finalizing %016llx...\n", entries[i].title_id);
|
||||||
|
|
||||||
ticket_buf.title_id_be = __builtin_bswap64(entries[i].title_id);
|
ticket_buf.title_id_be = __builtin_bswap64(entries[i].title_id);
|
||||||
@@ -231,8 +299,7 @@ void finalize_install(void)
|
|||||||
{
|
{
|
||||||
printf("Failed to begin ticket install: %08lx\n", res);
|
printf("Failed to begin ticket install: %08lx\n", res);
|
||||||
AM_InstallTicketAbort(ticketHandle);
|
AM_InstallTicketAbort(ticketHandle);
|
||||||
free(entries);
|
goto exit;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res = FSFILE_Write(ticketHandle, NULL, 0, &ticket_buf, sizeof(struct ticket_dumb), 0);
|
res = FSFILE_Write(ticketHandle, NULL, 0, &ticket_buf, sizeof(struct ticket_dumb), 0);
|
||||||
@@ -240,8 +307,7 @@ void finalize_install(void)
|
|||||||
{
|
{
|
||||||
printf("Failed to write ticket: %08lx\n", res);
|
printf("Failed to write ticket: %08lx\n", res);
|
||||||
AM_InstallTicketAbort(ticketHandle);
|
AM_InstallTicketAbort(ticketHandle);
|
||||||
free(entries);
|
goto exit;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res = AM_InstallTicketFinish(ticketHandle);
|
res = AM_InstallTicketFinish(ticketHandle);
|
||||||
@@ -249,8 +315,7 @@ void finalize_install(void)
|
|||||||
{
|
{
|
||||||
printf("Failed to finish ticket install: %08lx\n", res);
|
printf("Failed to finish ticket install: %08lx\n", res);
|
||||||
AM_InstallTicketAbort(ticketHandle);
|
AM_InstallTicketAbort(ticketHandle);
|
||||||
free(entries);
|
goto exit;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entries[i].has_seed)
|
if (entries[i].has_seed)
|
||||||
@@ -267,7 +332,12 @@ void finalize_install(void)
|
|||||||
printf("Deleting %s...\n", CIFINISH_PATH);
|
printf("Deleting %s...\n", CIFINISH_PATH);
|
||||||
unlink(CIFINISH_PATH);
|
unlink(CIFINISH_PATH);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
|
||||||
free(entries);
|
free(entries);
|
||||||
|
free(installed_ticket_ids);
|
||||||
|
free(installed_title_ids);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
@@ -276,7 +346,7 @@ int main(int argc, char* argv[])
|
|||||||
gfxInitDefault();
|
gfxInitDefault();
|
||||||
consoleInit(GFX_TOP, NULL);
|
consoleInit(GFX_TOP, NULL);
|
||||||
|
|
||||||
printf("custom-install-finalize v1.5\n");
|
printf("custom-install-finalize v1.6\n");
|
||||||
|
|
||||||
finalize_install();
|
finalize_install();
|
||||||
// print this at the end in case it gets pushed off the screen
|
// print this at the end in case it gets pushed off the screen
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
-r requirements.txt
|
-r requirements.txt
|
||||||
comtypes==1.1.8
|
comtypes==1.1.10
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
events==0.4
|
events==0.4
|
||||||
pyctr==0.4.6
|
pyctr>=0.4,<0.6
|
||||||
|
|||||||
Reference in New Issue
Block a user