Migrate to core24

Overview

Support for core24 in Snapcraft 8 occurs via the new craft-application library. This allows for cleanup of the “cruft” that inevitably accumulates over the years. Following our commitment to preserve the behaviour and compatibility for existing projects, these changes will only affect Snapcraft projects whose base is core24. This document outlines important changes when upgrading an existing snap to core24.

Deprecated features

The following features are deprecated in core22 and removed in core24:

  • The parameters --enable-manifest and --manifest-image-information. Generation of the build’s manifest in core24 is controlled exclusively by the SNAPCRAFT_BUILD_INFO environment variable, and the image information parameter is completely removed.
  • The snapcraftctl command in scriptlets is no longer supported and should be replaced with craftctl.
  • The architectures top-level property has been replaced by platforms. See details below.
  • The environment variable CRAFT_ARCH_TRIPLET. Use CRAFT_ARCH_TRIPLET_BUILD_FOR instead.
  • The environment variable CRAFT_TARGET_ARCH. Use CRAFT_ARCH_BUILD_FOR instead.

Destructive builds

Destructive builds are executed via --destructive-mode or SNAPCRAFT_BUILD_ENVIRONMENT=host.

  • Destructive builds that generate more than one snap are no longer supported, as this feature was never intended.
  • Destructive builds that generate no snaps are no longer supported, as this feature was never intended. It used to be a no-op but now will fail with an error message.
  • Destructive builds with a project whose build-base does not match the host environment will fail with an error message. An exception is made for devel build-bases. In this case the only requirement is that the host be an Ubuntu system.

Remote build

  • The command snapcraft remote-build only allows a single active remote build per project for core24 snaps. As a consequence, snapcraft remote-build --recover no longer accepts a --build-id parameter. Instead, snapcraft will recover the remote build for the project in the current working directory.
  • Projects must be at the top level of a git repository.
  • Projects cannot be shallow clones (i.e. git clone --depth 1)

Platforms

A new platforms top-level property is the way for core24 snaps to declare the systems where the snap should be built. This aligns with Charmcraft’s and Rockcraft’s platforms keyword.

platforms is optional. If it is not defined, then Snapcraft will build a snap for the host architecture. Valid architectures are defined here.

The syntax is:

platforms:
  <platform-name>:
    build-on: <list-of-arch> | <arch>
    build-for: <list-of-arch> | <arch>

The definitions of build-on and build-for are unchanged (see core22 definitions here).

Similar to core22, only one build-for architecture is supported and it may be defined as a list or a string.

The platform name is a free-form string. Some simplifications are gained if the platform name is a supported architecture:

  • build-on and build-for may be omitted
  • build-for may be omitted if build-on is defined

When migrating an existing snap to core24, existing architectures definitions can be rewritten as platforms. For example:

architectures:
  - build-on: [amd64]
    build-for: [amd64]
  - build-on: [amd64, arm64]
    build-for: [arm64]

can be migrated to core24 as:

platforms:
  amd64:
  arm64:
    build-on: [amd64, arm64]
    build-for: [arm64]

For more information on platforms see the how-to, explanation, and reference pages.

Known issues

  • Using build-for: all to create platform-independent snaps is temporarily not supported.
  • The command snapcraft try is temporarily not supported. The implementation for core24 snaps has not been finalized.

Further information

For details on changes between core20 and core22, see the migrate to core22 page.

7 Likes

Initially I just changed core22 to core24 and the old architectures definition seemed to work, then I updated it:

from:

architectures:
  - build-on: [amd64]
    build-for: [amd64]
  - build-on: [arm64]
    build-for: [arm64]
  - build-on: [armhf]
    build-for: [armhf]

to

platforms:
  amd64:
  arm64:
  armhf:
    build-on: [amd64, arm64, armhf]
    build-for: [amd64, arm64, armhf]

and it tried to build for every target, seemed to be broken I don’t have time to fully test it.

can be rewritten for core24 with platforms as:

platforms:
  amd64:
  arm64:
  armhf:

When will support for platform-independent snaps be reinstated?

See the discussion here: Architectures - #25 by mr_cal

core22:

name: pacgal
base: core22
version: '1.0'
license: GPL-2.0-only
summary: Feminized PAC-MAN remake
description: |
  W,A,S,D / Arrow Keys = Move

grade: stable
confinement: strict

architectures:
  - build-on: [amd64]
    build-for: [amd64]
  - build-on: [arm64]
    build-for: [arm64]
  - build-on: [armhf]
    build-for: [armhf]

apps:
  pacgal:
    extensions: [gnome]
    command: pacgal
    plugs:
    - desktop
    - desktop-legacy
    - gsettings
    - opengl
    - wayland
    - x11

parts:
  pacgal:
    source: https://github.com/mrbid/PAC-GAL
    source-type: git
    plugin: make
    source-subdir: snap
    build-packages:
    - libglfw3-dev
    stage-packages:
    - libglfw3
    - libgles2

vs

core24:

name: pacgal
base: core24
version: '1.0'
license: GPL-2.0-only
summary: Feminized PAC-MAN remake
description: |
  W,A,S,D / Arrow Keys = Move

grade: stable
confinement: strict

platforms:
  amd64:
  arm64:
  armhf:

apps:
  pacgal:
    extensions: [gnome]
    command: pacgal
    plugs:
    - desktop
    - desktop-legacy
    - gsettings
    - opengl
    - wayland
    - x11

parts:
  pacgal:
    source: https://github.com/mrbid/PAC-GAL
    source-type: git
    plugin: make
    source-subdir: snap
    build-packages:
    - libglfw3-dev
    stage-packages:
    - libglfw3
    - libgles2

Just builds for everything, as if the platforms: is not detected.

If I use core24 with:

architectures:
  - build-on: [amd64]
    build-for: [amd64]
  - build-on: [arm64]
    build-for: [arm64]
  - build-on: [armhf]
    build-for: [armhf]

It compiles for the correct platforms only. So platforms: is not detected with core24? and only architectures: from core22 works on core24?

Trying to build with core24 ends in this build failure:

Cloning into 'pacgal'...
[01/Jun/2024:05:06:09 +0000] "CONNECT github.com:443 HTTP/1.1" 200 7235296 "-" "git/2.43.0"
Running pull phase...
Extension is experimental: 'gnome'
For more information, check out: https://snapcraft.io/docs/supported-extensions
Full execution log: '/root/.local/state/snapcraft/log/snapcraft-20240601-050613.389282.log'
Build failed
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/lpbuildd/target/build_snap.py", line 307, in run
    self.pull()
  File "/usr/lib/python3/dist-packages/lpbuildd/target/build_snap.py", line 245, in pull
    self.run_build_command(
  File "/usr/lib/python3/dist-packages/lpbuildd/target/operation.py", line 62, in run_build_command
    return self.backend.run(args, cwd=cwd, env=full_env, **kwargs)
  File "/usr/lib/python3/dist-packages/lpbuildd/target/lxd.py", line 718, in run
    subprocess.check_call(cmd, **kwargs)
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['lxc', 'exec', 'lp-noble-amd64', '--env', 'LANG=C.UTF-8', '--env', 'SHELL=/bin/sh', '--env', 'http_proxy=http://10.10.10.1:8222/', '--env', 'https_proxy=http://10.10.10.1:8222/', '--env', 'GIT_PROXY_COMMAND=/usr/local/bin/lpbuildd-git-proxy', '--env', 'SNAPPY_STORE_NO_CDN=1', '--env', 'SNAPCRAFT_LOCAL_SOURCES=1', '--env', 'SNAPCRAFT_SETUP_CORE=1', '--env', 'SNAPCRAFT_BUILD_INFO=1', '--env', 'SNAPCRAFT_IMAGE_INFO={"build-request-id": "lp-89453969", "build-request-timestamp": "2024-06-01T05:04:17Z", "build_url": "https://launchpad.net/~build.snapcraft.io/+snap/24b92e0d68bb9f7faca78688a0935bd5/+build/2499305"}', '--env', 'SNAPCRAFT_BUILD_ENVIRONMENT=host', '--', '/bin/sh', '-c', 'cd /build/pacgal && linux64 snapcraft pull']' returned non-zero exit status 1.
Revoking proxy token...
RUN: /usr/share/launchpad-buildd/bin/in-target scan-for-processes --backend=lxd --series=noble --arch=amd64 SNAPBUILD-2499305
Scanning for processes to kill in build SNAPBUILD-2499305

I assume that core24 does not exist yet in the snapcraft.io website/GUI build system due to being in some sort of beta stage?

The problem is, if this is the case, that core24 is not stable yet; it is not made clear in this webpage which would suggest that it is a “supported” aka stable base:

Core24 and gnome extension might be in clash here, not core24 alone

The Gnome extension is in experimental mode. To try it out, export this

SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1, then run snapcraft.

I’m trying to get my snap (core24) only build on: image

However, in launchpad/snapcradft.io:

Seems like its ignoring this and build for everying.

What am I doing wrong?

Here is the repo: GitHub - dwellir-public/snap-besu: Besu is a ethereum client written in Java - this is the snap

1 Like

Launchpad isn’t parsing platforms correctly, I have some more details and links here: Call for testing: Snapcraft 8.3.0 - #16 by mr_cal

2 Likes

Update: Launchpad is now able to parse the platforms keyword for core24 snaps: Bug #2072622 “snap build recipes don't seem to handle core24 “pl...” : Bugs : Launchpad itself

1 Like