ubuntu_image/parser.py Gadget YAML Definition needs updating

Bug #1856903 reported by Emilio Lopez
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Image
Fix Released
Undecided
Unassigned

Bug Description

See original post on the snapcraft forum. https://forum.snapcraft.io/t/gadget-schema-for-ubuntu-image-parser-might-be-broken/14723

I am using `ubuntu-image` to make a ubuntu-core image. In the gadget.yaml definition, I added the `update` and `edition` definitions (link to documentation found in [The gadget snap](https://snapcraft.io/docs/gadget-snap) Snapcraft documentation.

The `ubuntu_image/parser.py`:181-236 does _not_ include the this in the schema. As a result calling `ubuntu_image` will fail because of that added key that is not in the schema. Is it expected to not have an update when making an image for the first time?

**Here is the Schema in parser.py**

    GadgetYAML = Schema({
        Optional('defaults'): {
            str: {
                str: object
            }
        },
        Optional('connections'): [Schema({
            Required('plug'): str,
            Optional('slot'): str,
            })
        ],
        Optional('device-tree-origin', default='gadget'): str,
        Optional('device-tree'): str,
        Optional('format'): YAMLFormat,
        Required('volumes'): {
            Match('^[a-zA-Z0-9][-a-zA-Z0-9]*$'): Schema({
                Optional('schema', default='gpt' if has_new_voluptuous()
                        else VolumeSchema.gpt):
                    Enumify(VolumeSchema),
                Optional('bootloader'): Enumify(
                    BootLoader, preprocessor=methodcaller('replace', '-', '')),
                Optional('id'): Coerce(Id),
                Required('structure'): [Schema({
                    Optional('name'): str,
                    Optional('offset'): Coerce(as_size),
                    Optional('offset-write'): Any(
                        Coerce(Size32bit), RelativeOffset),
                    Required('size'): Coerce(as_size),
                    Required('type'): Any('mbr', 'bare', Coerce(HybridId)),
                    Optional('role'): Enumify(
                        StructureRole,
                        preprocessor=methodcaller('replace', '-', '_')),
                    Optional('id'): Coerce(UUID),
                    Optional('filesystem', default='none' if has_new_voluptuous()
                            else FileSystemType.none):
                        Enumify(FileSystemType),
                    Optional('filesystem-label'): str,
                    Optional('content'): Any(
                        [Schema({
                            Required('source'): str,
                            Required('target'): str,
                            })
                        ], # noqa: E124
                        [Schema({
                            Required('image'): str,
                            Optional('offset'): Coerce(as_size),
                            Optional('offset-write'): Any(
                                Coerce(Size32bit), RelativeOffset),
                            Optional('size'): Coerce(as_size),
                            })
                        ],
                    )
                })]
            })
        }
    })

**Here is the YAML definition with the addition based off [pc-amd64-gadget:gadget.yaml](https://github.com/snapcore/pc-amd64-gadget/blob/18/gadget.yaml) on the 18 branch**

    volumes:
      pc:
        bootloader: grub
        structure:
          - name: mbr
            type: mbr
            size: 440
            content:
              - image: pc-boot.img
          - name: BIOS Boot
            type: DA,21686148-6449-6E6F-744E-656564454649
            size: 1M
            offset: 1M
            offset-write: mbr+92
            content:
              - image: pc-core.img
          - name: EFI System
            type: EF,C12A7328-F81F-11D2-BA4B-00A0C93EC93B
            filesystem: vfat
            filesystem-label: system-boot
            size: 50M
            content:
              - source: grubx64.efi
                target: EFI/boot/grubx64.efi
              - source: shim.efi.signed
                target: EFI/boot/bootx64.efi
              - source: mmx64.efi
                target: EFI/boot/mmx64.efi
              - source: grub.cfg
                target: EFI/ubuntu/grub.cfg
            update:
              - edition: 0

Tags: gadget
Changed in ubuntu-image:
milestone: none → 1.9
Revision history for this message
Emilio Lopez (lopezem) wrote :

Just updating tracking. PR was created: https://github.com/CanonicalLtd/ubuntu-image/pull/180

Changed in ubuntu-image:
status: New → Fix Committed
Changed in ubuntu-image:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.