Modify rootfs.py infrastructure to support the new layout

This commit is contained in:
fosslinux 2023-11-08 11:30:20 +11:00
parent 6ed2e09f3a
commit 05c13dd64e
8 changed files with 374 additions and 410 deletions

View file

@ -31,7 +31,7 @@ def run_as_root(*args, **kwargs):
return run("sudo", *args, **kwargs)
return run(*args, **kwargs)
def create_disk(image, disk_type, fs_type, size):
def create_disk(image, disk_type, fs_type, size, mkfs_args=[]):
"""Create a disk image, with a filesystem on it"""
run('truncate', '-s', size, image)
# First find the device we will use, then actually use it
@ -40,9 +40,9 @@ def create_disk(image, disk_type, fs_type, size):
# Create the partition
if disk_type != "none":
run_as_root('parted', '--script', image, 'mklabel', disk_type, 'mkpart',
'primary', 'ext4', '0%', '100%')
'primary', fs_type, '0%', '100%')
run_as_root('partprobe', loop_dev)
run_as_root('mkfs.' + fs_type, loop_dev + "p1")
run_as_root('mkfs.' + fs_type, loop_dev + "p1", *mkfs_args)
return loop_dev
def mount(source, target, fs_type, options='', **kwargs):