import pefile # type: ignore
pe = pefile.PE(boot_binary, fast_load=True)
linux = {s.Name.decode().strip("\0"): s for s in pe.sections}[".linux"]
- run(["dd",
- f"if={boot_binary}",
- f"of={state.staging / state.config.output_split_kernel}",
- f"skip={linux.PointerToRawData}",
- # Get the actual size using Misc_VirtualSize instead of the aligned size from SizeOfRawData.
- f"count={linux.Misc_VirtualSize}",
- "iflag=skip_bytes,count_bytes"])
+ # TODO: Use ignore_padding=True instead of length once we can depend on a newer pefile.
+ (state.root / state.config.output_split_kernel).write_bytes(linux.get_data(length=linux.Misc_VirtualSize))
print_output_size(boot_binary)
requires-python = ">=3.9"
license = {file = "LICENSE"}
+[project.optional-dependencies]
+bootable = [
+ "pefile >= 2021.9.3",
+]
+
[project.scripts]
mkosi = "mkosi.__main__:main"