diff --git a/test/data/manifests/fedora-coreos-container.mpp.yaml b/test/data/manifests/fedora-coreos-container.mpp.yaml index e526d16d..6d192438 100644 --- a/test/data/manifests/fedora-coreos-container.mpp.yaml +++ b/test/data/manifests/fedora-coreos-container.mpp.yaml @@ -6,35 +6,35 @@ mpp-vars: boot_size_mb: 384 root_size_mb: 2048 sector_size: 512 -mpp-define-image: - id: image - size: - mpp-format-string: "{disk_size_gb * 1024 * 1024 * 1024}" - table: - uuid: 00000000-0000-4000-a000-000000000001 - label: gpt - partitions: - - id: 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 - 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 - 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 - type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 - uuid: CA7D7CCB-63ED-4C53-861C-1742536059CC - size: - mpp-format-int: "{root_size_mb * 1024 * 1024 / sector_size}" +mpp-define-images: + - id: image + size: + mpp-format-string: "{disk_size_gb * 1024 * 1024 * 1024}" + table: + uuid: 00000000-0000-4000-a000-000000000001 + label: gpt + partitions: + - id: 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 + 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 + 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 + type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 + uuid: CA7D7CCB-63ED-4C53-861C-1742536059CC + size: + mpp-format-int: "{root_size_mb * 1024 * 1024 / sector_size}" pipelines: - mpp-import-pipelines: path: fedora-vars.ipp.yaml diff --git a/tools/osbuild-mpp b/tools/osbuild-mpp index 2bc33ac6..b3165936 100755 --- a/tools/osbuild-mpp +++ b/tools/osbuild-mpp @@ -263,8 +263,8 @@ Example: Defining partition layouts for disk images: -It is possbile to define a partition layout via `mpp-define-image`. The defined layout -is actually written to a temporary sparse file and read back via `sfdisk`, so that all +It is possbile to define partition layouts via `mpp-define-images`. The defined layouts +are actually written to a temporary sparse file and read back via `sfdisk`, so that all partition data like `size` and `start` include actual padding and such. The `image` variable will be defined with `size` and `layout` keys, the latter containing the partition layout data. It can be accessed via the "String expansion" explained above. @@ -273,23 +273,28 @@ Example: ``` ... - "mpp-define-image": { - "size": "10737418240", - "table": { - "uuid": "D209C89E-EA5E-4FBD-B161-B461CCE297E0", - "label": "gpt", - "partitions": [ - { - "id": "bios-boot", - "start": 2048, - "size": 2048, - "type": "21686148-6449-6E6F-744E-656564454649", - "bootable": true, - "uuid": "FAC7F1FB-3E8D-4137-A512-961DE09A5549" - "attrs": [ 60 ] - }, - ... - } + "mpp-define-images": [ + { + "id": "image", + "size": "10737418240", + "table": { + "uuid": "D209C89E-EA5E-4FBD-B161-B461CCE297E0", + "label": "gpt", + "partitions": [ + { + "id": "bios-boot", + "start": 2048, + "size": 2048, + "type": "21686148-6449-6E6F-744E-656564454649", + "bootable": true, + "uuid": "FAC7F1FB-3E8D-4137-A512-961DE09A5549", + "attrs": [ 60 ] + }, + ... + ] + } + } + ] ... ``` @@ -1016,7 +1021,7 @@ class ManifestFile: raise ValueError(f"Unknown manfest version {version}") m.process_imports() - m.process_partition() + m.process_partitions() return m @@ -1303,16 +1308,23 @@ class ManifestFile: def process_format(self): self._process_format(self.root) - def process_partition(self): - desc = self.get_mpp_node(self.root, "define-image") + def process_partitions(self): + images = self.get_mpp_node(self.root, "define-images") or [] - if not desc: + # Backwards compat for mpp-define-image (no list) + image = self.get_mpp_node(self.root, "define-image") + if image: + if id not in image: + image['id'] = "image" + images.append(image) + + if len(images) == 0: return - self._process_format(desc) - - name = desc.get("id", "image") - self.vars[name] = Image.from_dict(desc) + for image in images: + self._process_format(image) + name = image["id"] + self.vars[name] = Image.from_dict(image) # pylint: disable=no-self-use def get_pipeline_name(self, node):