replace MBR extraction with python-native implementation
This commit is contained in:
@@ -246,17 +246,9 @@ def extract_mbr_from_iso(path_to_output_file, path_to_source_iso):
|
|||||||
f"Input file is not an image file: '{path_to_source_iso}'.")
|
f"Input file is not an image file: '{path_to_source_iso}'.")
|
||||||
|
|
||||||
# extract the MBR (first 432 Bytes) of the source ISO file
|
# extract the MBR (first 432 Bytes) of the source ISO file
|
||||||
# FIXME do this in python, dd is too dangerous
|
with open(path_to_source_iso, mode="r+b") as iso_file:
|
||||||
try:
|
with open(path_to_output_file, mode="w+b") as mbr_file:
|
||||||
subprocess.run(
|
mbr_file.write(iso_file.read(432))
|
||||||
["dd", f"if={path_to_source_iso.resolve()}", "bs=1", "count=432",
|
|
||||||
f"of={path_to_output_file.resolve()}"],
|
|
||||||
shell=True,
|
|
||||||
check=True)
|
|
||||||
|
|
||||||
except subprocess.CalledProcessError:
|
|
||||||
raise RuntimeError(f"Failed while extracting MBR from source file: "
|
|
||||||
f"'{path_to_source_iso}'.")
|
|
||||||
|
|
||||||
|
|
||||||
def repack_iso(path_to_output_iso,
|
def repack_iso(path_to_output_iso,
|
||||||
|
|||||||
12
udib/udib.py
12
udib/udib.py
@@ -200,6 +200,9 @@ def main():
|
|||||||
else:
|
else:
|
||||||
# modify image file using specified preseed file
|
# modify image file using specified preseed file
|
||||||
path_to_preseed_file = Path(args.existing_preseed_file)
|
path_to_preseed_file = Path(args.existing_preseed_file)
|
||||||
|
if not path_to_preseed_file.is_file():
|
||||||
|
p.error(f"No such file: '{path_to_preseed_file}'.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if args.path_to_existing_image:
|
if args.path_to_existing_image:
|
||||||
# user has specified an existing image file
|
# user has specified an existing image file
|
||||||
@@ -227,15 +230,14 @@ def main():
|
|||||||
# extract image MBR to a temporary directory
|
# extract image MBR to a temporary directory
|
||||||
p.info("Extracting master boot record...")
|
p.info("Extracting master boot record...")
|
||||||
path_to_mbr = Path(tempfile.mkdtemp())/"mbr.bin"
|
path_to_mbr = Path(tempfile.mkdtemp())/"mbr.bin"
|
||||||
# FIXME fix MBR extraction
|
modiso.extract_mbr_from_iso(
|
||||||
#modiso.extract_mbr_from_iso(
|
path_to_mbr,
|
||||||
# path_to_mbr,
|
path_to_image_file)
|
||||||
# path_to_image_file)
|
|
||||||
|
|
||||||
# append preseed file to extracted initrd
|
# append preseed file to extracted initrd
|
||||||
p.info("Appending preseed file...")
|
p.info("Appending preseed file...")
|
||||||
modiso.append_file_contents_to_initrd_archive(
|
modiso.append_file_contents_to_initrd_archive(
|
||||||
path_to_extracted_iso_dir,
|
path_to_extracted_iso_dir/"install.amd"/"initrd.gz",
|
||||||
path_to_preseed_file)
|
path_to_preseed_file)
|
||||||
|
|
||||||
# regenerate md5sum.txt
|
# regenerate md5sum.txt
|
||||||
|
|||||||
Reference in New Issue
Block a user