From e191dc1d0dd8086067ac4a241d51501bd8f93060 Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Mon, 27 Nov 2023 15:53:13 -0500 Subject: [PATCH] tools/osbuild-mpp: set part ID from name if missing For our Fedora CoreOS disk images we set the partition labels (name) for the partitions. This is also supported using the primitives here in OSBuild, but it wasn't obvious that I needed to set the name in the mpp-define-images definition. Let's set the name there, but let's also allow osbuild-mpp to set the `id`, which is what is used later to access that partition from the `name` too if `id` isn't set. This means we allow something like: - name: BIOS-BOOT type: 21686148-6449-6E6F-744E-656564454649 bootable: true uuid: FAC7F1FB-3E8D-4137-A512-961DE09A5549 size: 100 rather than requiring something like: - id: BIOS-BOOT name: BIOS-BOOT type: 21686148-6449-6E6F-744E-656564454649 bootable: true uuid: FAC7F1FB-3E8D-4137-A512-961DE09A5549 size: 100 --- test/data/manifests/fedora-coreos-container.json | 8 ++++++++ .../manifests/fedora-coreos-container.mpp.yaml | 16 ++++++++-------- tools/osbuild-mpp | 4 +++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/test/data/manifests/fedora-coreos-container.json b/test/data/manifests/fedora-coreos-container.json index 02ca9608..8b013aa4 100644 --- a/test/data/manifests/fedora-coreos-container.json +++ b/test/data/manifests/fedora-coreos-container.json @@ -567,24 +567,28 @@ "size": 2048, "type": "21686148-6449-6E6F-744E-656564454649", "bootable": true, + "name": "BIOS-BOOT", "uuid": "FAC7F1FB-3E8D-4137-A512-961DE09A5549" }, { "start": 4096, "size": 260096, "type": "C12A7328-F81F-11D2-BA4B-00A0C93EC93B", + "name": "EFI-SYSTEM", "uuid": "68B2905B-DF3E-4FB3-80FA-49D1E773AA33" }, { "start": 264192, "size": 786432, "type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4", + "name": "boot", "uuid": "61B2905B-DF3E-4FB3-80FA-49D1E773AA32" }, { "start": 1050624, "size": 4194304, "type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4", + "name": "root", "uuid": "CA7D7CCB-63ED-4C53-861C-1742536059CC" } ] @@ -762,24 +766,28 @@ "size": 256, "type": "21686148-6449-6E6F-744E-656564454649", "bootable": true, + "name": "BIOS-BOOT", "uuid": "FAC7F1FB-3E8D-4137-A512-961DE09A5549" }, { "start": 512, "size": 32512, "type": "C12A7328-F81F-11D2-BA4B-00A0C93EC93B", + "name": "EFI-SYSTEM", "uuid": "68B2905B-DF3E-4FB3-80FA-49D1E773AA33" }, { "start": 33024, "size": 98304, "type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4", + "name": "boot", "uuid": "61B2905B-DF3E-4FB3-80FA-49D1E773AA32" }, { "start": 131328, "size": 524288, "type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4", + "name": "root", "uuid": "CA7D7CCB-63ED-4C53-861C-1742536059CC" } ] diff --git a/test/data/manifests/fedora-coreos-container.mpp.yaml b/test/data/manifests/fedora-coreos-container.mpp.yaml index 2caf556b..95828a1a 100644 --- a/test/data/manifests/fedora-coreos-container.mpp.yaml +++ b/test/data/manifests/fedora-coreos-container.mpp.yaml @@ -15,23 +15,23 @@ mpp-define-images: uuid: 00000000-0000-4000-a000-000000000001 label: gpt partitions: - - id: BIOS-BOOT + - name: BIOS-BOOT type: 21686148-6449-6E6F-744E-656564454649 bootable: true uuid: FAC7F1FB-3E8D-4137-A512-961DE09A5549 size: mpp-format-int: "{bios_boot_size_mb * 1024 * 1024 / sector_size}" - - id: EFI-SYSTEM + - name: EFI-SYSTEM type: C12A7328-F81F-11D2-BA4B-00A0C93EC93B uuid: 68B2905B-DF3E-4FB3-80FA-49D1E773AA33 size: mpp-format-int: "{efi_system_size_mb * 1024 * 1024 / sector_size}" - - id: boot + - name: boot type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 uuid: 61B2905B-DF3E-4FB3-80FA-49D1E773AA32 size: mpp-format-int: "{boot_size_mb * 1024 * 1024 / sector_size}" - - id: root + - name: root type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 uuid: CA7D7CCB-63ED-4C53-861C-1742536059CC size: @@ -45,23 +45,23 @@ mpp-define-images: uuid: 00000000-0000-4000-a000-000000000001 label: gpt partitions: - - id: BIOS-BOOT + - name: BIOS-BOOT type: 21686148-6449-6E6F-744E-656564454649 bootable: true uuid: FAC7F1FB-3E8D-4137-A512-961DE09A5549 size: mpp-format-int: "{bios_boot_size_mb * 1024 * 1024 / four_k_sector_size}" - - id: EFI-SYSTEM + - name: EFI-SYSTEM type: C12A7328-F81F-11D2-BA4B-00A0C93EC93B uuid: 68B2905B-DF3E-4FB3-80FA-49D1E773AA33 size: mpp-format-int: "{efi_system_size_mb * 1024 * 1024 / four_k_sector_size}" - - id: boot + - name: boot type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 uuid: 61B2905B-DF3E-4FB3-80FA-49D1E773AA32 size: mpp-format-int: "{boot_size_mb * 1024 * 1024 / four_k_sector_size}" - - id: root + - name: root type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 uuid: CA7D7CCB-63ED-4C53-861C-1742536059CC size: diff --git a/tools/osbuild-mpp b/tools/osbuild-mpp index c2f440a7..3214e647 100755 --- a/tools/osbuild-mpp +++ b/tools/osbuild-mpp @@ -283,6 +283,7 @@ Example: "partitions": [ { "id": "bios-boot", + "name": "BIOS-BOOT", "start": 2048, "size": 2048, "type": "21686148-6449-6E6F-744E-656564454649", @@ -820,7 +821,8 @@ class Partition: name: str = None, uuid: str = None, attrs: List[int] = None): - self.id = uid + # if no id provided, use the part-label (name) as the id + self.id = uid or name self.type = pttype self.start = start self.size = size