The dump plugin

The dump plugin makes all files from a specified source available to a part. It copies the contents of a source into the root directory of the snap without changing the files. It provides an easy way to add pre-built binaries, scripts and other assets to a snap.

It’s equivalent to running the following command in a source’s directory:

cp --archive --link --no-dereference . "${CRAFT_PART_INSTALL}"

:white_check_mark: Tip

If you aren’t using the source files directly in the package, but want to run some custom commands to generate them, then you should instead use the nil plugin so no files are copied unnecessarily.

The source and other source-* properties specify the location from where to retrieve the files, or if the source is a git repository, the branch, tag, or commit to clone.

For a simple example of the plugin that copies the contents of a .deb package:

parts:
    my-remote-part:
        plugin: dump
        source: https://www.example.com/builds/example.deb
        source-type: deb

Modify the files after copying

Certain keys in the part can be configured to filter which files are copied, and modify, rename, or alter the files after they’re copied. Doing so is especially suitable when building a snap from multiple parts, where the main app expects to find supporting binaries, libraries, and assets such as themes or plugins in special locations. They also help when the source contains components for multiple architectures, and it’s only necessary to copy files for one architecture into the snap.

The applicable keys are:

  • organize moves and deletes the copied source files in the final payload. For example, you could use it to keep libraries but exclude binaries and headers from SDKs.

  • stage and prime specify which files and directories to copy into the snap.

    These keys take effect after organize. This means that any stage and prime entries should refer to the final paths of the files, and not their initials.

  • override-build, override-stage, and override-prime run custom shell scripts during the build process. For example, they can change the formats of files.

Example

The following example manipulates the files from a source tarball that contains directories named binaries, docs, etc, in addition to README and COPYRIGHT files.

The organize key moves the binaries directory and COPYRIGHT to usr/bin and usr/share/doc/my-app/COPYRIGHT, respectively. The stage key copies everything other than the docs directory and README into the snap.

parts:
    my-app-part:
        plugin: dump
        source: https://www.example.com/builds/latest-build.tar.gz
        organize:
            binaries: usr/bin
            COPYRIGHT: usr/share/doc/my-app/COPYRIGHT
        stage:
            - -README
            - -docs

See also

For more samples of the dump plugin, see Pre-built apps, or search GitHub for snaps that use it.


Last updated 2 days ago.