(micro) Howto migrate from core20 to core22

@sergiusens Is there an intentional change to the way slots work?

I found that a snap with:

apps:
  confined-shell:
    command-chain:
      - bin/run-shell
    command: usr/local/bin/miriway
    desktop: usr/share/wayland-sessions/confined-shell.desktop
    slots:
      - wayland

Fails to provide a wayland slot, and that I needed to add the slot globally:

slots:
  wayland:

I have a project with a file VERSION in the root. With core18 I used

    override-pull: |
      snapcraftctl pull
      snapcraftctl set-version "$(cat VERSION)"

With core22 this gives me

variable 'version' can only be set in a part that adopts external metadata.

But, you give override-<step> and I fail to find what a “part that adopts external metadata” means :frowning: Is there any example of setting the version from a command that reads the version from the sources that works with core22?

Just declare adopt-info: <part name> in the yaml top level. adopt-info is explained in the external metadata documentation.

2 Likes

Thanks. For those still wondering, <part name> can be a dedicated part, but can also be the name of the part that used to set the version.

Is there a way to have both the snapcraft default and append to it? Rather than just override.

In core20, if I do e.g:

environment:
  PATH: ${SNAP}/custom/bin

Then this will be appended to the default $PATH. With the new logic, it’s entirely replaces the default path, and the following doesn’t work.

PATH: ${SNAP}/custom/bin:${PATH}

Where this is more problematic is for $LD_LIBRARY_PATH, because of the common usage of architecture triplets in file paths, you end up having to resort to using a wrapper script to append the value or else the alternative would be hardcoding the value in a way that would probably only work on a single architecture.

Plus, personally, I liked the old way for being cleaner!