Charmcraft 3.0 in the beta channel

Happy Pi Day folks!

Today we’re releasing the first beta release of Charmcraft 3.0. It’s currently building and will be in the latest/beta and 3.x/beta snap channels soon!

New Features

Breaking changes!

We’ve got a few breaking changes, mostly to align charmcraft with other craft apps like snapcraft and rockcraft. The highlights are:

  • The prime keyword no longer adds extra files to a charm. If you need this functionality, please use the dump plugin instead.
  • The bases keyword is deprecated. All bases that were supported in Charmcraft 2.x (Ubuntu LTS up to 22.04, CentOS 7, AlmaLinux 9) still accept these, but new bases will all use the platforms keyword in charmcraft.yaml (details below).
  • The --bases-index parameter is deprecated. Please start using the new --platform parameter instead

platforms

The good news: Your current charms using the bases keyword should continue to build as expected! The bad news: If you want to use Ubuntu 24.04 for your charm, you’ll need to change your charm.

The short version: Here’s an example replacement for bases in an Ubuntu 24.04 charm:

base: ubuntu@24.04
build-base: ubuntu@24.04  # Optional
platforms:
  amd64:

This will build and run your charm on Ubuntu 24.04 for amd64. Full documentation is incoming before the final release, but it works roughly the same way as Rockcraft, so you can probably reference their documentation in the meantime.

Please note that this does mean that from Ubuntu 24.04 and on, we don’t support a single charmcraft.yaml building charms for multiple bases.

Feedback

As usual, please feel free to file bug reports or open PRs.

1 Like

Hi,

I have a couple of questions, we are planning the migration from charmcraft-2.x for the OpenStack charms.

This is a single base, how do I declare/define a charmcraft.yaml when the charm’s source code is meant to be used to build charms for 22.04 and 24.04?

With charmcraft-2.x we define a large list of build-on/run-on for each base+arch combintation, see charmcraft.yaml from ovn-central for an example.

The rockcraft docs say:

At the moment Rockcraft will only build for a single architecture, so if provided build-for must be a single string or a list with exactly one element.

does this limitation apply for charmcraft too?.

Thanks,

3 Likes

It seems to be the case that from 3.0 onwards, a charm is built for a single base.

Doc ref: https://juju.is/docs/sdk/charmcraft-yaml#heading--bases

Juju will have support a mix of bases.

That being said, charmcraft is only available in the beta and edge channels today, so things could potentially change, and I’m not in the charmcraft team, I don’t claim authoritative knowledge.

Trying the latest, I get:

> charmcraft pack
Bad charmcraft.yaml content:
- field 'parts' required in top-level configuration

I’m unsure what to specify in parts for an existing charm, when I didn’t have to do so before.

Try

parts:
  charm:
    plugin: charm
    source: .

(It’s supposed to be the default value for parts.)

1 Like

Thank you, build started, will update this comment if the charm is functional.

Edit: confirming that this produces a functional charm.

1 Like

Here’s my config which I feel is probably useful to a whole bunch of charmers, as many charms use libs that use pydantic in turn, and rust :crab: is required to build pydantic-core.

# charmcraft 3.0
base: ubuntu@24.04
build-base: ubuntu@24.04

platforms:
    amd64:
    arm64:

parts:
    charm:
        plugin: charm
        source: .
        build-packages:
            - rustc
            - cargo