How to pack your reactive-based charm with Charmcraft

See also:

Suppose you want a reactive-based charm. Such a charm cannot be initialised with Charmcraft. However, it can be packed with Charmcraft. This document shows you how.

Introduced in Charmcraft 1.4.

The reactive way to write a charm represents an old standard. The recommended way to create a charm now is using Charmcraft and Ops.

To pack a reactive-based charm with Charmcraft, in the charm directory create a charmcraft.yaml file with the part definition for a reactive-based charm:

type: "charm"
bases:
  - build-on:
      - name: "ubuntu"
        channel: "20.04"
    run-on:
      - name: "ubuntu"
        channel: "20.04"
parts:
  charm:
    source: .
    plugin: reactive
    build-snaps: [charm]

Done. Now you can go ahead and pack your reactive-based charm with Charmcraft in the usual way using charmcraft pack.