Using "content:" for a "role: system-data" partition makes it not be system-data anymore

When i use a gadget.yaml entry like:

      - name: writable
        type: 83,0FC63DAF-8483-4772-8E79-3D69D8477DE4
        filesystem: ext4
        filesystem-label: writable
        size: 270M
        role: system-data
        content:
          - source: writable/
            target: /

The partition is not pre-populated with snaps and seed but only the files defined in content are copied in.

I would expect that the partition is still properly pre-populated with the usual writable/system-data content and that the content from the content: entry is additionally copied in place. Or at least that the role: system-data takes precedence here if this combination is not allowed (though snapcraft or ubuntu-image should then spill a warning at least) so that a bootable system exists.

using ubuntu-image with -b ./build:

$ find build/volumes/beaglebone/part3
build/volumes/beaglebone/part3
build/volumes/beaglebone/part3/meep.txt
build/volumes/beaglebone/part3/system-data
build/volumes/beaglebone/part3/system-data/etc
build/volumes/beaglebone/part3/system-data/etc/foo.txt
$ find build/unpack/gadget/writable/
build/unpack/gadget/writable/
build/unpack/gadget/writable/meep.txt
build/unpack/gadget/writable/system-data
build/unpack/gadget/writable/system-data/etc
build/unpack/gadget/writable/system-data/etc/foo.txt

in ubuntu_image/assertion_builder.py:

    def populate_rootfs_contents(self):
        src = os.path.join(self.unpackdir, 'image')
        dst = os.path.join(self.rootfs, 'system-data')
        for subdir in os.listdir(src):
            # LP: #1632134 - copy everything under the image directory except
            # /boot which goes to the boot partition.
            if subdir != 'boot':
                shutil.move(os.path.join(src, subdir),
                            os.path.join(dst, subdir))
$ find build/unpack/image/
build/unpack/image/
build/unpack/image/boot
build/unpack/image/boot/grub

i think either snap prepare-image should actually move the content to the “image” dir if
role: system-data is set for the partition and it has a content: entry when preparing the gadget or ubuntu-image should do this.

since i’m not sure which part is at fault here i also filed