assemblers/loop_dev: take the size and optionally the offset as arguments
By default the whole image file is attechd to the loopback device, but we want to only attach a slice, namely individual partitions. This is a noop, just adds the parameters to the helpers. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
d8ff04cde6
commit
0252f42305
1 changed files with 3 additions and 3 deletions
|
|
@ -35,8 +35,8 @@ def mount_api(dest):
|
|||
yield
|
||||
|
||||
@contextlib.contextmanager
|
||||
def loop_device(image):
|
||||
r = subprocess.run(["losetup", "--partscan", "--show", "--find", image], stdout=subprocess.PIPE, encoding="utf-8", check=True)
|
||||
def loop_device(image, size, offset=0):
|
||||
r = subprocess.run(["losetup", "--partscan", "--show", "--find", "--sizelimit", str(size), "--offset", str(offset), image], stdout=subprocess.PIPE, encoding="utf-8", check=True)
|
||||
loop = r.stdout.strip()
|
||||
try:
|
||||
yield loop
|
||||
|
|
@ -63,7 +63,7 @@ def main(tree, input_dir, output_dir, options):
|
|||
subprocess.run(["sfdisk", "-q", image], input=partition_table, encoding='utf-8', check=True)
|
||||
|
||||
# Mount the created image as a loopback device
|
||||
with loop_device(image) as loop:
|
||||
with loop_device(image, size) as loop:
|
||||
# Populate the first partition of the image with an ext4 fs and fill it with the contents of the
|
||||
# tree we are operating on.
|
||||
subprocess.run(["mkfs.ext4", "-d", tree, "-U", root_fs_uuid, f"{loop}p1"], check=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue