Deprecated: This document has been superseded by Using external metadata
Some of the values required by the snapcraft.yaml file
might be already provided by other metadata sources available in the upstream
Instead of duplicating this information, you can declare that a snapcraft part
must parse the metadata file from the source, and adopt that parsed
information. For example, the following
snapcraft.yaml will parse the file
metadata-file and try to extract from it the
description for the snap.
name: my-snap-name adopt-info: part-with-metadata parts: part-with-metadata: plugin: dump parse-info: [metadata-file]
Currently, the only supported source of metadata is appstream.
Appstream is a standard
for metadata of software components. It can provide the
icon for the snap, and the
desktop files for the
Let’s say we have an upstream project with the following appstream file in
<?xml version="1.0" encoding="UTF-8"?> <component type="desktop-application"> <id>com.example.sampleapp</id> <summary>Single-line elevator pitch for your amazing application</summary> <description> This is applications's description. A paragraph or two to tell the most important story about it. </description> <icon type="local">assets/icon.png</icon> <launchable type="desktop-id"> com.example.sampleapp.desktop </launchable> </component>
Then you can adopt this info into your
snapcraft.yaml like this:
name: sampleapp-name adopt-info: sampleapp apps: sampleapp: command: sampleapp common-id: com.example.sampleapp parts: sampleapp: plugin: dump source: http://github.com/example/sampleapp.git parse-info: [sampleapp.metainfo.xml]
The resulting snap will take the summary and description from the appstream
file and it will use the referred icon and desktop files.
Note that appstream doesn’t use a path to declare the desktop file. It uses
a Desktop File ID.
To know which appstream
desktop-id corresponds to your app, you must declare
common-id of the app in the
snapcraft.yaml. snapcraft will search for a
parsed appstream file with the same component
id and extract the
Then it will search for the desktop file in the directories
usr/share relative to the part source, following the Desktop File ID