hbc/pywii/pywii-tools/wadpack-boot2.py

35 lines
799 B
Python
Raw Normal View History

2016-11-30 10:57:03 +01:00
#!/usr/bin/env python2
2016-11-23 06:35:12 +01:00
import sys, os, os.path
import pywii as wii
wii.loadkeys()
wadfile = sys.argv[1]
indir = sys.argv[2]
tmd = wii.WiiTmd(open(indir+os.sep+"tmd", "rb").read())
tik = wii.WiiTik(open(indir+os.sep+"cetk", "rb").read())
certs, certlist = wii.parse_certs(open(os.path.join(indir, "certs"), "rb").read())
footer = open(indir+os.sep+"footer", "rb").read()
wad = wii.WiiWadMaker(wadfile, tmd, tik, certlist, footer, nandwad=True)
for i,ct in enumerate(tmd.get_content_records()):
data = open(indir+os.sep+"%08X"%ct.cid, "rb").read()
wad.adddata(data,ct.cid)
wad.finish()
if not wad.tik.signcheck(wad.certs):
wad.tik.null_signature()
wad.tik.brute_sha()
wad.updatetik()
if not wad.tmd.signcheck(wad.certs):
wad.tmd.null_signature()
wad.tmd.brute_sha()
wad.updatetmd()