update-extents.krk 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env kuroko
  2. import fileio
  3. from util import ISO, FAT
  4. let image = ISO('image.iso')
  5. let fat = image.root.find('FAT.IMG')
  6. let fatfs = FAT(image, fat.extent_start_lsb * image.sector_size)
  7. def process(fatfile, path):
  8. if fatfile.is_long():
  9. return
  10. if fatfile.readable_name() == '.':
  11. return
  12. if fatfile.readable_name() == '..':
  13. return
  14. if fatfile.is_dir():
  15. for i in fatfile.to_dir().list():
  16. process(i, path + fatfile.readable_name() + '/')
  17. else:
  18. let cdfile = image.get_file(path + fatfile.readable_name())
  19. if not cdfile:
  20. if fatfile.readable_name() != 'bootia32.efi' and fatfile.readable_name() != 'bootx64.efi':
  21. print("Warning:", fatfile.readable_name(), "not found in ISO")
  22. else:
  23. cdfile.extent_start_lsb = fatfile.get_offset() // 2048
  24. cdfile.extent_length_lsb = fatfile.filesize
  25. cdfile.write_extents()
  26. for i in fatfs.root.list():
  27. process(i,'/')
  28. with fileio.open('image.iso','wb') as f:
  29. f.write(bytes(image.data))