toaruos/util/package-mods.py

37 lines
778 B
Python
Raw Normal View History

2017-01-08 13:38:48 +03:00
#!/usr/bin/env python3
import os
import struct
# This is ORDERED, so don't screw it up.
mods_to_pack = [
'zero',
'random',
'serial',
'procfs',
'tmpfs',
'ext2',
'ps2kbd',
'ps2mouse',
'lfbvideo',
'packetfs',
]
with open('modpack.kop','wb') as pack:
for mod in mods_to_pack:
with open('hdd/mod/{mod}.ko'.format(mod=mod),'rb') as m:
2017-01-08 13:38:48 +03:00
pack.write(b"PACK")
size = os.stat(m.name).st_size
extra = 0
while (size + extra) % 4096 != 0:
extra += 1
pack.write(struct.pack("I", size+extra))
2017-01-08 13:38:48 +03:00
pack.write(b'\0' * (4096-8))
pack.write(m.read(size))
2017-01-08 13:38:48 +03:00
pack.write(b'\0' * extra)
pack.write(b"PACK")
pack.write(b'\0\0\0\0')