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!

Iā€™m trying to use the source tag as part of the version for the snap.

I have found nothing in the docs apart for something using git which kind of works. https://snapcraft.io/docs/using-craftctl

This is what Iā€™m trying:

name: polka
base: core22
summary: Polka Snap App
description: A Snap package for the Polka app.
adopt-info: polka-app

grade: stable
confinement: strict

apps:
  polka:
    command: bin/polka

parts:
  polka-app:
    plugin: dump
    source: https://github.com/erik78se/polka.git
    source-tag: v0.9.44
    override-pull: |
      craftctl default
      craftctl set version "$(craftctl get part.polkadot.source-tag)-$(git rev-parse --short HEAD)"

2023-06-21 00:24:09.848 :: 2023-06-20 22:24:07.917 :: error: ā€˜override-pullā€™ in part ā€˜polka-appā€™ executed an invalid control API call: ā€˜part.polkadot.source-tagā€™ is not a valid variable name.

How can I access the source-tag and use it in my version of the snap?

@cmatsuoka, correct me if Iā€™m wrong but craftctl can only get version and grade for snapcraft.

Youā€™re right, only version and grade are available to set with craftctl in Snapcraft.

I ended up calling on git in override-pull.

parts:
  polka-app:
    plugin: dump
    source: https://github.com/erik78se/polka.git
    source-tag: v0.9.44
    override-pull: |
      craftctl default
      craftctl set version="$(git describe --tags --abbrev=10)-$(git rev-parse --short HEAD)"
1 Like

@sergiusens Is there any specific reason for not transforming SNAPCRAFT_PROJECT_VERSION to something like CRAFT_PROJECT_VERSION since using craftctl get version doesnt seem to work on fetching sources for e.g -->

source: https:xyz.com/$(craftctl get version).deb

It would have been great if a better and working modern variant of the SNAPCRAFT_PROJECT_VERSION be provided.

If something does work for now, I think better utilise that option

CRAFT_PROJECT_VERSION is there, it is only assigned at project initialization time.

Worth mentioning the --target-arch=<arch> change too? https://github.com/snapcore/snapcraft/blob/main/docs/reference/architectures.rst#environment-variables-and-command-line-arguments.

I have a problem also migrating from core18 to core22 that maybe someone could assist with. I want to be able to access systemd-journal-remote from my snap, but it seems not to be enough to list it as a stage package anymore as I get many linker errors (examples of which are shown)

bin/bash: relocation error: /bin/bash: symbol dlclose version GLIBC_2.17 not defined in file libdl.so.2 with link time reference Running linter: library - (2.0s)

Unable to determine library dependencies for ā€˜usr/lib/aarch64-linux-gnu/libroken.so.18.1.0ā€™ /bin/bash: relocation error: /bin/bash: symbol dlclose version GLIBC_2.17 not defined in file libdl.so.2 with link time reference

Lint warnings:

This is my snapcraft contents:

apps:

download: command: lib/systemd/systemd-journal-remote plugs: - microstack-support - network - network-bind - system-observe daemon: simple sockets: systemd-journal-remote: listen-stream: 19532

parts:

download:
    plugin: nil
    stage-packages:
        - systemd-journal-remote

This looks like you are simply not building your core22 snap in a 22.04 environmentā€¦

1 Like

Any update or documentation on the use of the filesets field:

  • extra field ā€˜filesetsā€™ not permitted in ā€˜parts.move-configā€™ configuration

+1 Yes, any update on this?

I have made some progress in porting snapcraft.yaml files with the filesets keyword to core22. In the end, it was not difficult, here is an example which may help you:

Example part definition from before which was using dump plugin to move some but not all files:

 move-ext-lib:
         plugin: dump
         source: ./ext-lib/
         filesets: 
              platformIndependentJarFiles2: [ext-lib/*.jar, ext-lib/jaxrs-ri/*, -ext-lib/RXTXcomm.jar]
              platformDependentFiles: 
                  - on armhf: [rasp-pi/*]
                  - on amd64: [amd64/*]
                  - on arm64: [arm64/*]
         organize:
             "*": ext-lib/
         stage:
               - $platformIndependentJarFiles2

I replaced it as follows:

  move-ext-lib:
        plugin: dump
        source: ./ext-lib/

        organize:
            "*": ext-lib/
        stage:
          - ext-lib/*.jar
          - ext-lib/jaxrs-ri/*
          - -ext-lib/RXTXcomm.jar
1 Like