Overlay step

Images are built in a sequence of five separate steps – pull, overlay, build, stage, and prime.

The overlay step in each part provides the means to refine the contents of the image. overlay-script will run the provided script in this step. The location of the default overlay is made available in the ${CRAFT_OVERLAY} environment variable. The location of the partition-specific overlays is made available in the ${CRAFT_<partition>_OVERLAY} environment variables. overlay can be used to specify which files will be migrated to the next steps, and when omitted its default value will be "*".

Overlay Parameters

A part has three parameters that can be used to adjust how the overlay step works: overlay-packages, overlay-script and overlay. overlay-packages and overlay (the overlay-files parameter) behave much the same way as the related parameters on the STAGE step. overlay-script likewise behaves similarly to override-stage, including having access to the craftctl command.

An example of a parts section with overlay parameters looks as follows:

parts:
  part_with_overlay:
    plugin: nil
    overlay-packages:
      - ed
    overlay-script: |
      rm -f ${CRAFT_OVERLAY}/usr/bin/vi ${CRAFT_OVERLAY}/usr/bin/vim*
      rm -f ${CRAFT_OVERLAY}/usr/bin/emacs*
      rm -f ${CRAFT_OVERLAY}/bin/nano
    overlay:
      - bin
      - usr/bin

After running this part, the overlay layer (and the final package) will only contain ed as an editor, with vi/vim, emacs, and nano all having been removed.