mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 12:21:18 +00:00
Make build_package3.py Python 2&3 compatible
This commit is contained in:
parent
006f8022c0
commit
56bfbb02ec
1 changed files with 19 additions and 19 deletions
|
@ -15,12 +15,12 @@ def read_file(fn):
|
||||||
|
|
||||||
def pad(data, size):
|
def pad(data, size):
|
||||||
assert len(data) <= size
|
assert len(data) <= size
|
||||||
return (data + '\x00' * size)[:size]
|
return (data + b'\x00' * size)[:size]
|
||||||
|
|
||||||
def get_overlay(program, i):
|
def get_overlay(program, i):
|
||||||
return program[0x2B000 + 0x14000 * i:0x2B000 + 0x14000 * (i+1)]
|
return program[0x2B000 + 0x14000 * i:0x2B000 + 0x14000 * (i+1)]
|
||||||
|
|
||||||
KIP_NAMES = ['Loader', 'NCM', 'ProcessManager', 'sm', 'boot', 'spl', 'ams_mitm']
|
KIP_NAMES = [b'Loader', b'NCM', b'ProcessManager', b'sm', b'boot', b'spl', b'ams_mitm']
|
||||||
|
|
||||||
def get_kips(ams_dir):
|
def get_kips(ams_dir):
|
||||||
emummc = read_file(os.path.join(ams_dir, 'emummc/emummc_unpacked.kip'))
|
emummc = read_file(os.path.join(ams_dir, 'emummc/emummc_unpacked.kip'))
|
||||||
|
@ -32,13 +32,13 @@ def get_kips(ams_dir):
|
||||||
spl = read_file(os.path.join(ams_dir, 'stratosphere/spl/spl.kip'))
|
spl = read_file(os.path.join(ams_dir, 'stratosphere/spl/spl.kip'))
|
||||||
ams_mitm = read_file(os.path.join(ams_dir, 'stratosphere/ams_mitm/ams_mitm.kip'))
|
ams_mitm = read_file(os.path.join(ams_dir, 'stratosphere/ams_mitm/ams_mitm.kip'))
|
||||||
return (emummc, {
|
return (emummc, {
|
||||||
'Loader' : loader,
|
b'Loader' : loader,
|
||||||
'NCM' : ncm,
|
b'NCM' : ncm,
|
||||||
'ProcessManager' : pm,
|
b'ProcessManager' : pm,
|
||||||
'sm' : sm,
|
b'sm' : sm,
|
||||||
'boot' : boot,
|
b'boot' : boot,
|
||||||
'spl' : spl,
|
b'spl' : spl,
|
||||||
'ams_mitm' : ams_mitm,
|
b'ams_mitm' : ams_mitm,
|
||||||
})
|
})
|
||||||
|
|
||||||
def write_kip_meta(f, kip, ofs):
|
def write_kip_meta(f, kip, ofs):
|
||||||
|
@ -81,14 +81,14 @@ def write_header(f, all_kips, wb_size, tk_size, xf_size, ex_size, ms_size, fs_si
|
||||||
# Write git_revision;
|
# Write git_revision;
|
||||||
f.write(pk('<I', git_revision))
|
f.write(pk('<I', git_revision))
|
||||||
# Write content metas
|
# Write content metas
|
||||||
f.write(pk('<IIBBBBI16s', 0x000800, wb_size, 2, 0, 0, 0, 0xCCCCCCCC, 'warmboot'))
|
f.write(pk('<IIBBBBI16s', 0x000800, wb_size, 2, 0, 0, 0, 0xCCCCCCCC, b'warmboot'))
|
||||||
f.write(pk('<IIBBBBI16s', 0x002000, tk_size, 12, 0, 0, 0, 0xCCCCCCCC, 'tsec_keygen'))
|
f.write(pk('<IIBBBBI16s', 0x002000, tk_size, 12, 0, 0, 0, 0xCCCCCCCC, b'tsec_keygen'))
|
||||||
f.write(pk('<IIBBBBI16s', 0x004000, xf_size, 11, 0, 0, 0, 0xCCCCCCCC, 'exosphere_fatal'))
|
f.write(pk('<IIBBBBI16s', 0x004000, xf_size, 11, 0, 0, 0, 0xCCCCCCCC, b'exosphere_fatal'))
|
||||||
f.write(pk('<IIBBBBI16s', 0x048000, ex_size, 1, 0, 0, 0, 0xCCCCCCCC, 'exosphere'))
|
f.write(pk('<IIBBBBI16s', 0x048000, ex_size, 1, 0, 0, 0, 0xCCCCCCCC, b'exosphere'))
|
||||||
f.write(pk('<IIBBBBI16s', 0x056000, ms_size, 10, 0, 0, 0, 0xCCCCCCCC, 'mesosphere'))
|
f.write(pk('<IIBBBBI16s', 0x056000, ms_size, 10, 0, 0, 0, 0xCCCCCCCC, b'mesosphere'))
|
||||||
f.write(pk('<IIBBBBI16s', 0x7C0000, fs_size, 0, 0, 0, 0, 0xCCCCCCCC, 'fusee'))
|
f.write(pk('<IIBBBBI16s', 0x7C0000, fs_size, 0, 0, 0, 0, 0xCCCCCCCC, b'fusee'))
|
||||||
f.write(pk('<IIBBBBI16s', 0x7E0000, rb_size, 3, 0, 0, 0, 0xCCCCCCCC, 'rebootstub'))
|
f.write(pk('<IIBBBBI16s', 0x7E0000, rb_size, 3, 0, 0, 0, 0xCCCCCCCC, b'rebootstub'))
|
||||||
f.write(pk('<IIBBBBI16s', 0x100000, len(emummc), 8, 0, 0, 0, 0xCCCCCCCC, 'emummc'))
|
f.write(pk('<IIBBBBI16s', 0x100000, len(emummc), 8, 0, 0, 0, 0xCCCCCCCC, b'emummc'))
|
||||||
ofs = (0x100000 + len(emummc) + 0xF) & ~0xF
|
ofs = (0x100000 + len(emummc) + 0xF) & ~0xF
|
||||||
for kip_name in KIP_NAMES:
|
for kip_name in KIP_NAMES:
|
||||||
kip_data = kips[kip_name]
|
kip_data = kips[kip_name]
|
||||||
|
@ -119,7 +119,7 @@ def write_kips(f, all_kips):
|
||||||
# Write kips
|
# Write kips
|
||||||
tot = len(emummc)
|
tot = len(emummc)
|
||||||
if (tot & 0xF):
|
if (tot & 0xF):
|
||||||
f.write('\xCC' * (0x10 - (tot & 0xF)))
|
f.write(b'\xCC' * (0x10 - (tot & 0xF)))
|
||||||
tot += 0xF
|
tot += 0xF
|
||||||
tot &= ~0xF
|
tot &= ~0xF
|
||||||
for kip_name in KIP_NAMES:
|
for kip_name in KIP_NAMES:
|
||||||
|
@ -127,7 +127,7 @@ def write_kips(f, all_kips):
|
||||||
f.write(kip_data)
|
f.write(kip_data)
|
||||||
tot += len(kip_data)
|
tot += len(kip_data)
|
||||||
if (tot & 0xF):
|
if (tot & 0xF):
|
||||||
f.write('\xCC' * (0x10 - (tot & 0xF)))
|
f.write(b'\xCC' * (0x10 - (tot & 0xF)))
|
||||||
tot += 0xF
|
tot += 0xF
|
||||||
tot &= ~0xF
|
tot &= ~0xF
|
||||||
# Pad to 3 MB
|
# Pad to 3 MB
|
||||||
|
|
Loading…
Reference in a new issue