(micro) Howto migrate to core24

NOTE: The release of core24 is soon approaching! See road to core24 for timing. We encourage early testing and reporting issues here. Otherwise, snaps should not migrate to core24 until core24 is stable.


Overview

The Starcraft team is working on a series of changes to the Snapcraft codebase to make use of the new craft-application library and cleanup some 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 these changes.

Deprecated/removed features/commands/options

The following features are now 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.

Changes in behaviour

  • Trying to run destructive-mode builds (via --destructive-mode or SNAPCRAFT_BUILD_ENVIRONMENT=host) to generate more than one snap is no longer supported, as this feature was never intended.
  • Trying to run destructive-mode builds (via --destructive-mode or SNAPCRAFT_BUILD_ENVIRONMENT=host) to generate no snaps is no longer supported, as this feature was never intended. It used to be a no-op but now will fail with an error message.
  • Trying to run destructive-mode builds (via --destructive-mode or SNAPCRAFT_BUILD_ENVIRONMENT=host) 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.
  • 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.

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]

The details above will eventually be expanded upon and added to the existing documentation pages about architectures.

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.
  • Advanced grammar does not work on root-level keywords in a snapcraft.yaml

Further information

For details on changes between core20 and core22, see (micro) Howto migrate from core20 to core22.

4 Likes