(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!

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…