Packaging Guidelines for AppData Files

If a package contains a GUI application, then it SHOULD install a .metainfo.xml file into %{_metainfodir}. Installed .metainfo.xml files MUST follow the AppStream specification page.

If a package contains an add-on for GUI application, then it SHOULD install a .metainfo.xml file into %{_metainfodir}. Installed .metainfo.xml files MUST follow the AppStream add-ons specification.

The AppData files MUST correctly validate using appstream-util validate-relax.

appdata.xml files
For historical reasons, AppStream specification also allows using extension .appdata.xml for GUI applications. If upstream provides metadata with .appdata.xml extension, it MAY be used instead of .metainfo.xml.

.metainfo.xml file creation

If the package doesn’t already include and install its own .metainfo.xml file, you can make your own and send it upstream. Some benefits of sending the file upstream are that upstream can translate the file using the existing translation resources and can also modify the screenshots and descriptions as the application changes over time.

You may include an .metainfo.xml file you create as a Source: (e.g. Source3: %{name}.metainfo.xml) or generate it in the spec file.

Here are the contents of a sample application .metainfo.xml file (comical.metainfo.xml):

<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2014 Richard Hughes <richard@hughsie.com> -->
<component type="desktop">
  <id>comical.desktop</id>
  <metadata_license>CC0-1.0</metadata_license>
  <project_license>GPL-2.0+ and GFDL-1.3</project_license>
  <name>Comical</name>
  <summary>A Comic Archive Reader</summary>
  <summary xml:lang="fr">Un Comic Archive Lecteur</summary>
  <description>
    <p>
      Comical is an easy to use and cross-platform CBR and CBZ reader which
      prefetches and caches pages for speed.
    </p>
    <p xml:lang="fr">
      Comical est une CBR et CBZ lecteur facile à utiliser et
      multi-plateforme qui prélectures et caches pages pour la vitesse.
    </p>
    <p>
      Resized images are crisp, and you can view pages one or two at a time.
      Comical is open-source, so feel free to contribute new features!
    </p>
    <p xml:lang="fr">
      Images redimensionnées sont nettes, et vous pouvez voir une ou deux pages à la fois.
      Comical est open-source, alors n'hésitez pas à apporter de nouvelles fonctionnalités!
    </p>
  </description>
  <screenshots>
    <screenshot type="default">
      <image>http://comical.sourceforge.net/images/comical-0.5-linux.jpg</image>
    </screenshot>
    <screenshot>
      <image>http://comical.sourceforge.net/images/comical-0.6-win32.jpg</image>
    </screenshot>
  </screenshots>
  <url type="homepage">http://comical.sourceforge.net/</url>
  <update_contact>richard_at_hughsie.com</update_contact>
</component>

Application’s AppData file MUST be named with the same root as the .desktop file, so if the .desktop file is named org.gnome.SomeApp.desktop then the AppData file MUST be called org.gnome.SomeApp.metainfo.xml.

Here are the contents of a sample addon .metainfo.xml file (gedit-bookmarks.metainfo.xml):

<?xml version="1.0" encoding="UTF-8"?>
<component type="addon">
  <id>gedit-bookmarks</id>
  <extends>gedit.desktop</extends>
  <name>Bookmarks</name>
  <summary>Easy document navigation with bookmarks</summary>
  <url type="homepage">https://wiki.gnome.org/Apps/Gedit/ShippedPlugins</url>
  <url type="bugtracker">https://bugzilla.gnome.org/enter_bug.cgi?product=gedit&amp;component=Plugins</url>
  <metadata_license>CC0-1.0</metadata_license>
  <project_license>GPL-2.0+</project_license>
</component>

You can use anything as the <id> but it needs to be unique and sensible and also match the .metainfo.xml filename prefix.

app-data-validate usage

Although you can just include the .metainfo.xml file in the package, you MUST run appstream-util validate-relax (in %check or %install) and have BuildRequires: libappstream-glib, to help ensure the validity and safety of the appdata files you’re installing. An example:

appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/*.metainfo.xml