<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "AppStream.ent">
%BOOK_ENTITIES;
]>

<section id="sect-Metadata-GenericComponent">
	<title>Generic Component</title>

	<section id="spec-component-introduction">
	<title>Introduction</title>
	<para>
		For a distribution, it is good to know more about the content of a package. Which public interfaces (libraries? Python modules?) does it provide? Does it contain codecs? Does it
		contain firmware? Fonts? An application?
		All of this information can be used to automatically install missing software or to offer users a choice on what they want to install from a software center.
	</para>
	<para>
		To provide this information, we created the <emphasis role="italic">metainfo</emphasis> files, which allow <emphasis role="bold">upstream projects</emphasis> to describe the content of their software package.
		If a metainfo file provides a <literal>&lt;provides/&gt;</literal> tag, distributors must also ensure that the package providing the file contain all items referenced
		by that statement, or is installed by a metapackage depending on packages which provide these items. This gives upstream projects a (very light) way to influence distributor packaging.
		More information about that can be found below.
	</para>
	<para>
		Several specialized component-metainfo files exist, for example for applications or fonts. These are all based on this generic component XML specification, and are described in the
		following chapters.
	</para>
	</section>

	<section id="spec-component-location">
	<title>Filesystem locations</title>

	<para>
		Upstream projects can ship one or more metainfo files in <filename>/usr/share/metainfo/%{id}.metainfo.xml</filename>, where <literal>id</literal> is a unique
		identifier of this specific component.
	</para>
	<note>
		<para>
			Applications are a special case here, because they are usually treated differently by software centers (and also for historical reasons).
			If your metainfo file covers only an application, as described in the AppData section, install it as
			<filename>/usr/share/metainfo/%{id}.appdata.xml</filename>.
		</para>
	</note>
	<important>
		<title>Legacy Path</title>
		<para>
			The <filename>/usr/share/appdata/</filename> path must be scanned by AppStream tools as well, to support legacy applications installing
			metadata there.
			For new software components, it is advised not to use this directory.
		</para>
	</important>

	</section>

	<section id="spec-component-filespec">
	<title>XML Specification</title>

	<para>
		The XML for a generic component definition starts with an <code><![CDATA[<component>]]></code> tag as root element.
		The <code><![CDATA[<component>]]></code> element must at least have an <literal>id</literal>, <literal>name</literal> and <literal>releases</literal> tag,
		a <literal>provides</literal> tag with appropriate children is highly recommended.
		All possible tags in the generic set are:
	</para>

	<variablelist>
		<varlistentry id="tag-id-generic">
		<term>&lt;id/&gt;</term>
		<listitem>
		<para>
			The <code language="XML"><![CDATA[<id>]]></code> tag is a short and unique identifier for this component. It must contain only ASCII characters, dots, hyphens and numbers, spaces are
			not allowed. Specialized metainfo types, such as application or fonts, may apply additional restrictions on the <literal>id</literal> tag value.
		</para>
		<para>
			A general pattern for a valid ID tag is to use a reverse URL scheme, consisting of <literal>&lt;tld&gt;.&lt;vendor&gt;.&lt;product&gt;.&lt;type&gt;</literal>, e.g. <code>org.kde.gwenview.desktop</code>
			or <code>com.hugski.ColorHug2.firmware</code>.
		</para>
		<para>
			Note that the value of this tag must be <emphasis>unique</emphasis> across all distributions. In case it is not, distributors are expected to reject the conflicting components
			from inclusion into their metadata.
		</para>
		</listitem>
		</varlistentry>

		<varlistentry id="tag-metadata_license">
		<term>&lt;metadata_license/&gt;</term>
		<listitem>
		<para>
			The <code>&lt;metadata_license/&gt;</code> tag indicates the content licence that you are releasing the one
			Metainfo XML file under. This is not typically the same as the project licence. Omitting the license value can result
			in your data not being incorporated into the distribution metadata (so this is a required tag).
		</para>
		<para>
			A permissive license ensures your data can be combined with arbitrary other data in one file.
			Primissive licence names include:
		</para>
		<itemizedlist>
			<listitem>
			<para>CC0-1.0</para>
			</listitem>
			<listitem>
			<para>CC-BY-3.0</para>
			</listitem>
			<listitem>
			<para>CC-BY-SA-3.0</para>
			</listitem>
			<listitem>
			<para>GFDL-1.3</para>
			</listitem>
			<listitem>
			<para>MIT</para>
			</listitem>
		</itemizedlist>
		<para>
			The licence codes correspond to the identifiers found at the <ulink url="http://spdx.org/licenses/">SPDX OpenSource License Registry</ulink>.
			For instance, CC-BY-SA-3.0 corresponds to the license at
			<ulink url="http://creativecommons.org/licenses/by-sa/3.0/">creativecommons.org/licenses/by-sa/3.0</ulink>.
		</para>
		</listitem>
		</varlistentry>

		<varlistentry id="tag-name">
		<term>&lt;name/&gt;</term>
		<listitem>
			<para>
			A human-readable name for this software component. For example, if the component id was "libc", its name might be "GNU Standard C Library".
			</para>
		</listitem>
		</varlistentry>

		<varlistentry id="tag-summary">
		<term>&lt;summary/&gt;</term>
		<listitem>
			<para>
			A short summary of what this component does. If the component is "PackageKit", the summary could be "Provides a package-management abstraction layer".
			</para>
		</listitem>
		</varlistentry>

		<varlistentry id="tag-description">
		<term>&lt;description/&gt;</term>
		<listitem>
		<para>
			A long description of this component. Some markup can be used.
		</para>
		<para>
			Do not assume the format is HTML. Only paragraph (p), ordered list (ol) and unordered list (ul) are supported at this time.
		</para>
		<para>
			In metainfo files, this tag should be translated by-paragraph, meaning that in a translated file, each translated <literal>&lt;p/&gt;</literal> child
			has a language property.
		</para>
		</listitem>
		</varlistentry>

		<varlistentry id="tag-url">
		<term>&lt;url/&gt;</term>
		<listitem>
			<para>
			Defines URLs for this component.There are several different URL types allowed:
			</para>
			<variablelist>
			<varlistentry>
				<term>homepage</term>
				<listitem>
				<para>Should be a link to the upstream homepage for the component.</para>
				</listitem>
			</varlistentry>

			<varlistentry>
				<term>bugtracker</term>
				<listitem>
				<para>Should point to the software's bug tracking system, for users to report new bugs.</para>
				</listitem>
			</varlistentry>

			<varlistentry>
				<term>faq</term>
				<listitem>
				<para>
					Should link a FAQ page for this software, to answer some of the most-asked questions in
					detail, something which you can not do in the component's description.
				</para>
				</listitem>
			</varlistentry>

			<varlistentry>
				<term>help</term>
				<listitem>
				<para>Should provide a link to an online user's reference, a software manual or help page.</para>
				</listitem>
			</varlistentry>

			<varlistentry>
				<term>donation</term>
				<listitem>
				<para>
					Links of this type should point to a webpage showing information on how to donate to
					the described software project.
				</para>
				</listitem>
			</varlistentry>
			</variablelist>
		</listitem>
		</varlistentry>

		<varlistentry id="tag-releases">
		<term>&lt;releases/&gt;</term>
		<listitem>
			<para>
				The <code><![CDATA[<releases>]]></code> tag contains <code>&lt;release/&gt;</code> child tags which
				describe some metainformation about the current release of the described software.
				The <code>&lt;release/&gt;</code> tag may be present multiple times (for older releases), but a tag for
				the current version must always be present.
			</para>
			<para>
				A <literal>release</literal> tag can have the properties <literal>version</literal>, <literal>date</literal> and <literal>timestamp</literal>.
				The <literal>date</literal> property can have any time in <ulink url="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</ulink> format as value and
				should be present for every release.
				The <literal>timestamp</literal> tag contains the release time in form of a UNIX epoch. This tag should not be used in metainfo files in newly
				written metadata, but will still be parsed in case it is present. The the <literal>timestamp</literal> property is mainly used in generated distro-meadata.
				In case both release-time tags are present, the <literal>timestamp</literal> tag will take precedence over <literal>date</literal>.
			</para>
			<para>
				Optionally, the <code>&lt;release/&gt;</code> tag may also have an <literal>urgency</literal> property, having one of the following values:
			</para>
			<itemizedlist>
				<listitem><para>low</para></listitem>
				<listitem><para>medium</para></listitem>
				<listitem><para>high</para></listitem>
				<listitem><para>critical</para></listitem>
			</itemizedlist>
			<para>
				The <literal>urgency</literal> defines how important it is to install the new release as an update. This is especially important for <literal>type=firmware</literal>
				components.
				If no urgency is defined, a <code>medium</code> urgency is implicitly assumed.
				The urgency defines how the update will be presented to the user, and sometimes if it will be installed automatically and immediately, or delayed.
			</para>
			<para>
				Each <literal>release</literal> tag may have a <literal>description</literal> tag as child, containing a brief description of what is new in the release.
				The <literal>description</literal> tag is structured as described in <xref linkend="tag-description"/>
			</para>
			<para>
				A <literal>release</literal> tag may also have one or multiple <literal>size</literal> tags as children, which define the installed and download size
				of this component release. This is useful in case the component does not have a corresponding native package in a distribution, for example if it is a Limba
				bundle or LVFS firmware.
				The size type is defined via a <literal>type</literal> property on the <literal>size</literal> tag, and may assume the value <code>download</code> or <code>installed</code>.
				The size itself is set as value and must be given in bytes.
			</para>
			<para>
			Examples for a valid releases tag:
			</para>
			<programlisting language="XML"><![CDATA[<releases>
  <release version="1.2" date="2014-04-12" urgency="high">
    <size type="download">12345678</size>
    <size type="installed">42424242</size>
  </release>
  <release version="1.0" date="2012-08-26" />
</releases>]]></programlisting>
		</listitem>
		</varlistentry>

		<varlistentry id="tag-provides">
		<term>&lt;provides/&gt;</term>
		<listitem>
			<para>
			The <literal>provides</literal> tag and it's children describe the public interfaces this application provides.
			A public interface can be anything which other applications, which are not part of the upstream project, can access or reference.
			This includes binaries and libraries. Private interfaces should never be added to a <literal>provides</literal> tag.
			</para>
			<para>
			A <literal>provides</literal> tag contain a number of children describing the type and name of the provided public interface items.
			It is suggested that the build-system auto-generates this tag and it's children.
			Currently allowed item types are listed below. If you miss something, file a bug against AppStream so we can add the new type.
			</para>

			<variablelist>
			<varlistentry>
				<term>&lt;library/&gt;</term>
				<listitem>
				<para>
					Contains the name of a shared library placed in a publicly accessible library path, such as <filename>/usr/lib</filename>, <filename>/usr/lib/&lt;triplet&gt;</filename>
					or <filename>/lib</filename>.
					For example, for the libappstream library, the value for <literal>library</literal> would be <userinput>libappstream.so.1</userinput>.
				</para>
				</listitem>
			</varlistentry>

			<varlistentry>
				<term>&lt;binary/&gt;</term>
				<listitem>
				<para>
					Name of a binary installed into a location in <envar>PATH</envar>.
				</para>
				</listitem>
			</varlistentry>

			<varlistentry>
				<term>&lt;font/&gt;</term>
				<listitem>
				<para>
					Name of a font provided by this component. For example <userinput>Linux Libertine O</userinput>.
					The tag must have a <literal>file</literal> property stating the filename of the referenced font.
				</para>
				<para>
					Example:
				</para>
				<programlisting language="XML"><![CDATA[<provides>
  <font file="LinLibertine_R.otf">Linux Libertine O</font>
</provides>]]></programlisting>
				</listitem>
			</varlistentry>

			<varlistentry>
				<term>&lt;modalias/&gt;</term>
				<listitem>
				<para>
					A modalias glob representing the hardware types (for example USB, PCI, ACPI, DMI) this component handles.
					Useful for installing printer drivers or other USB protocol drivers for smartphones, firmware, kernel drivers which
					are not merged upstream yet or whatever else.
				</para>
				</listitem>
			</varlistentry>

			<varlistentry>
				<term>&lt;firmware/&gt;</term>
				<listitem>
				<para>
					This provided element is described in details for the <literal>firmware</literal> component type, where it is mandatory.
					Please see <xref linkend="tag-firmware-provides"/> for more information.
				</para>
				</listitem>
			</varlistentry>

			<varlistentry>
				<term>&lt;python2/&gt;</term>
				<listitem>
				<para>
					Name of a Python2 module this component provides.
				</para>
				</listitem>
			</varlistentry>

			<varlistentry>
				<term>&lt;python3/&gt;</term>
				<listitem>
				<para>
					Name of a Python3 module this component provides.
				</para>
				</listitem>
			</varlistentry>

			<varlistentry>
				<term>&lt;dbus/&gt;</term>
				<listitem>
				<para>
					Contains the name of a DBus service as property. The type of the service must be specified using the <literal>type</literal> property
					of this tag. Allowed values are <code>user</code> and <code>system</code>.
				</para>
				<para>
					Example:
				</para>
				<programlisting language="XML"><![CDATA[<provides>
  <dbus type="system">org.freedesktop.PackageKit</dbus>
</provides>]]></programlisting>
				</listitem>
			</varlistentry>

			</variablelist>
		</listitem>

		</varlistentry>

		<varlistentry id="tag-mimetypes">
		<term>&lt;mimetypes/&gt;</term>
		<listitem>
			<para>
			This tag can contain one or more <code>&lt;mimetype/&gt;</code> children, describing the mime types this application supports.
			This tag is especially useful for generic components and addon-type components. For applications, the metadata will automatically
			be fetched from their .desktop files by the distribution's metadata generator.
			Example:
			</para>
			<programlisting language="XML">
<![CDATA[<mimetypes>
    <mimetype>text/html</mimetype>
    <mimetype>image/jpeg</mimetype>
    <mimetype>application/rss+xml</mimetype>
 </mimetypes>]]></programlisting>
		</listitem>
		</varlistentry>

		<varlistentry id="tag-project_group">
		<term>&lt;project_group/&gt;</term>
		<listitem>
		<para>
			If you include the <code>&lt;project_group/&gt;</code> tag then this identifies your project with a specific upstream umbrella project.
			Known values include GNOME, KDE, XFCE, MATE and LXDE, although other umbrella projects like Yorba or Mozilla make sense too.
		</para>
		<note>
			<para>
			You should only identify with an umbrella project if you use all their infrastructure and policies, for instance string freezes dates, bugtracker and source control instance.
			</para>
		</note>
		</listitem>
		</varlistentry>

		<varlistentry id="tag-project_license">
		<term>&lt;project_license/&gt;</term>
		<listitem>
			<para>
			The <code>&lt;project_license/&gt;</code> tag is indicating the license of the component (application/library/addon/font/etc.) described in the metadata document.
			It should be a string in SPDX format. Licenses may be combined using <emphasis>and</emphasis> and <emphasis>or</emphasis> logic.
			Possible values include:
			<itemizedlist>
				<listitem><para>GPL-2.0</para></listitem>
				<listitem><para>LGPL-3.0+ and GPL-3.0+</para></listitem>
				<listitem><para>MIT</para></listitem>
				<listitem><para>CC-BY-SA-2.0</para></listitem>
				<listitem><para>...</para></listitem>
			</itemizedlist>
			A full list of recognized licenses and their identifiers can be found at the
			<ulink url="http://spdx.org/licenses/">SPDX OpenSource License Registry</ulink>.
			</para>
			<para>
			Although the <literal>project_license</literal> tag is not mandatory, it is recommended to include it.
			</para>
		</listitem>
		</varlistentry>

		<varlistentry id="tag-developer_name">
		<term>&lt;developer_name/&gt;</term>
		<listitem>
		<para>
			The <code>&lt;developer_name/&gt;</code> tag is designed to represent the developers or project responsible for development of the project described in the metadata.
		</para>
		<para>
			Values might be for example "The GNOME Foundation" or "The KDE Community".
			You must not include hyperlinks or emails in this field, if you want to link to the developer's homepage, use the <xref linkend="tag-url"/>-tag instead.
		</para>
		<para>
			This tag is translatable.
		</para>
		</listitem>
		</varlistentry>

		<varlistentry id="tag-screenshots">
		<term>&lt;screenshots/&gt;</term>
		<listitem>
		<para>
			Visual components (like fonts or graphical applications) may choose to add one or multiple screenshots to their metadata.
		</para>
		<para>
			The <code>&lt;screenshots/&gt;</code> tag contains multiple <code>&lt;screenshot/&gt;</code> children, where at least one of them must have the property
			<code>type="default"</code> to indicate the application's primary screenshot. Every <code>&lt;screenshot/&gt;</code> tag must have at least
			one <code>&lt;image/&gt;</code> child, which should define the width and height of the referenced image in it's properties.
			The value of the <code>&lt;image/&gt;</code> tag is a direct URL to a screenshot uploaded to a public location on the web.
		</para>
		<para>
			Optionally, a <code>&lt;screenshot/&gt;</code> tag may have a <code>&lt;caption/&gt;</code> child, defining a short (not more then 255 characters!)
			description of what the user can see on the referenced screenshot.
		</para>
		<para>
			Ideally, all screenshots should have a 16:9 aspect ratio, and should have a width that is no smaller than 620px.
			They should also be in be in PNG or JPEG format. PNG is the preferred format; JPEG should only be used when screenshots include large photographs or other
			images where a lossy format like JPEG may compress better.
		</para>
		</listitem>
		</varlistentry>

		<varlistentry id="tag-update_contact">
		<term>&lt;update_contact/&gt;</term>
		<listitem>
		<para>
			The <code>&lt;update_contact/&gt;</code> tag is an optional tag which can be added to provide an email address distributors can use to contact the project
			about invalid or incomplete metadata, or in case the specification has changed, about old metadata. It can also be used to ask general questions in case of
			an update of the component described in the metadata file.
		</para>
		<para>
			The <code>&lt;update_contact/&gt;</code> tag must <emphasis>only be used by distributors</emphasis>. It is not included in the distribution-provided
			AppStream XML file, and therefore not exposed to the end user via any kind of UI.
		</para>
		<para>
			Upstream authors might decide to add an email address in cleartext, but spam protection using <code>_AT_</code> is also valid.
		</para>
		<para>
			Example:
		</para>
		<programlisting language="XML"><![CDATA[<update_contact>developer_AT_example.com</update_contact>]]></programlisting>
		</listitem>
		</varlistentry>

		<varlistentry id="tag-translation">
		<term>&lt;translation/&gt;</term>
		<listitem>
		<para>
			The <code>&lt;translation/&gt;</code> tag is an optional tag which can be added to specify the translation domain used for this software component.
			It may be used by the AppStream distro metadata generator to determine the translation status of the respective software.
		</para>
		<para>
			The tag must have a <literal>type</literal> property, assuming the value of the translation system which is used. Right now, allowed trabslation systems and
			values for <literal>type</literal> are:
			<itemizedlist>
				<listitem><para>gettext</para></listitem>
				<listitem><para>qt</para></listitem>
			</itemizedlist>
			In case a software components gets its translation from multiple translation domains, the <code>&lt;translation/&gt;</code> tag may be defined more
			than once.
		</para>
		<para>
			Example:
		</para>
		<programlisting language="XML"><![CDATA[<translation type="gettext">foobar</translation>]]></programlisting>
		</listitem>
		</varlistentry>

	</variablelist>

	<para>
		An example for a very basic component file could look like this:
	</para>
	<programlisting language="XML">
<![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<component>
  <id>foobar</id>
  <name>Foo Bar</name>
  <summary>A foo-ish bar</summary>
  <url type="homepage">http://www.example.org</url>
  <metadata_license>CC0-1.0</metadata_license>

  <provides>
    <library>libfoobar.so.2</library>
    <font>foo.ttf</font>
    <binary>foobar</binary>
  </provides>
  <releases>
    <release version="1.2" date="2015-02-16" />
  </releases>
  <developer_name>FooBar Team</developer_name>
</component>]]>
	</programlisting>

	<para>
		For a component of type <literal>generic</literal>, the minimal amount of required tags is: <xref linkend="tag-id-generic"/>, <xref linkend="tag-name"/>,
		<xref linkend="tag-summary"/>, <xref linkend="tag-metadata_license"/>.
	</para>

	</section>
</section>
