From f470c3f3a355d0070315f0fe3e5e2eccdeb856cf Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Wed, 2 Oct 2019 00:00:02 +0200 Subject: [PATCH] assemblers/qemu: fix the partition UUID in the pipeline Otherwise, sfdik would pick one at random. We want our images to be reproducible to the extent possible, so we must move all randomness out of the assemblers when we can. Signed-off-by: Tom Gundersen --- README.md | 1 + assemblers/org.osbuild.qemu | 3 ++- samples/base-qcow2.json | 1 + test/pipelines/f30-boot.json | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 21f625a5..fae17c78 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ assembles it into an image. Pipelines are defined as JSON files like this one: "options": { "format": "qcow2", "filename": "example.qcow2", + "ptuuid": "0x7e83a7ba", "root_fs_uuid": "76a22bf4-f153-4541-b6c7-0332c0dfaeac", "size": 3221225472 } diff --git a/assemblers/org.osbuild.qemu b/assemblers/org.osbuild.qemu index 7e4b2852..5add2143 100755 --- a/assemblers/org.osbuild.qemu +++ b/assemblers/org.osbuild.qemu @@ -39,6 +39,7 @@ def loop_device(loop_client, image, size, offset=0): def main(tree, output_dir, options, loop_client): fmt = options["format"] filename = options["filename"] + ptuuid = options["ptuuid"] root_fs_uuid = options["root_fs_uuid"] size = options["size"] @@ -56,7 +57,7 @@ def main(tree, output_dir, options, loop_client): subprocess.run(["truncate", "--size", str(size), image], check=True) # Set up the partition table of the image - partition_table = "label: mbr\nbootable, type=83" + partition_table = f"label: mbr\nlabel-id: {ptuuid}\nbootable, type=83" subprocess.run(["sfdisk", "-q", image], input=partition_table, encoding='utf-8', check=True) r = subprocess.run(["sfdisk", "--json", image], stdout=subprocess.PIPE, encoding='utf-8', check=True) partition_table = json.loads(r.stdout) diff --git a/samples/base-qcow2.json b/samples/base-qcow2.json index 97b03177..312a97fb 100644 --- a/samples/base-qcow2.json +++ b/samples/base-qcow2.json @@ -72,6 +72,7 @@ "options": { "format": "qcow2", "filename": "base.qcow2", + "ptuuid": "0x14fc63d2", "root_fs_uuid": "76a22bf4-f153-4541-b6c7-0332c0dfaeac", "size": 3221225472 } diff --git a/test/pipelines/f30-boot.json b/test/pipelines/f30-boot.json index a5dcda4d..8c1a94c6 100644 --- a/test/pipelines/f30-boot.json +++ b/test/pipelines/f30-boot.json @@ -101,6 +101,7 @@ "options": { "format": "qcow2", "filename": "f30-boot.qcow2", + "ptuuid": "0x1cd1d44b", "root_fs_uuid": "76a22bf4-f153-4541-b6c7-0332c0dfaeac", "size": 3221225472 }