2021-10-13 15:04:06 +03:00
|
|
|
#!/usr/bin/env kuroko
|
|
|
|
import fileio
|
2021-10-20 17:03:32 +03:00
|
|
|
from util import ISO, FAT
|
2021-05-31 06:31:01 +03:00
|
|
|
|
2021-10-13 15:04:06 +03:00
|
|
|
let image = ISO('image.iso')
|
|
|
|
let fat = image.root.find('FAT.IMG')
|
|
|
|
let fatfs = FAT(image, fat.extent_start_lsb * image.sector_size)
|
2021-05-31 06:31:01 +03:00
|
|
|
|
|
|
|
def process(fatfile, path):
|
|
|
|
if fatfile.is_long():
|
|
|
|
return
|
|
|
|
if fatfile.readable_name() == '.':
|
|
|
|
return
|
|
|
|
if fatfile.readable_name() == '..':
|
|
|
|
return
|
|
|
|
if fatfile.is_dir():
|
|
|
|
for i in fatfile.to_dir().list():
|
|
|
|
process(i, path + fatfile.readable_name() + '/')
|
|
|
|
else:
|
2021-10-13 15:04:06 +03:00
|
|
|
let cdfile = image.get_file(path + fatfile.readable_name())
|
2021-05-31 06:31:01 +03:00
|
|
|
if not cdfile:
|
|
|
|
if fatfile.readable_name() != 'bootia32.efi' and fatfile.readable_name() != 'bootx64.efi':
|
|
|
|
print("Warning:", fatfile.readable_name(), "not found in ISO")
|
|
|
|
else:
|
|
|
|
cdfile.extent_start_lsb = fatfile.get_offset() // 2048
|
|
|
|
cdfile.extent_length_lsb = fatfile.filesize
|
|
|
|
cdfile.write_extents()
|
|
|
|
|
|
|
|
|
|
|
|
for i in fatfs.root.list():
|
|
|
|
process(i,'/')
|
|
|
|
|
2021-10-13 15:04:06 +03:00
|
|
|
with fileio.open('image.iso','wb') as f:
|
|
|
|
f.write(bytes(image.data))
|
2021-05-31 06:31:01 +03:00
|
|
|
|