← Back to issue list

appstream: extract title and version

View original Github issue

Metadata

Project
snapcraft
Number
#2762
Type
pull request
State
merged
Author
merlijn-sebrechts
Labels
Created
Updated
Closed

Current evaluation

Merged changes extract title and version from AppStream metadata by parsing the name tag and first release tag. Adds 105 lines across three files, passes CI, and enables adopt-info functionality for Snapcraft without external dependencies.

Suggested action:

No scores available.

Issue body

- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)? - [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? - [x] Have you successfully run `./runtests.sh static`? - [x] Have you successfully run `./runtests.sh tests/unit`? ----- This PR extracts `title` and `version` from AppStream's `name` tag and from the `version` property of the first `release` tag. According to the AppStream docs: > `<name/>`: A human-readable name for this software component. > Each release of the software component should have a `<release/>` > tag describing it, but at least one release child must be present > for the current release of the software. **The release children > should be sorted in a latest-to-oldest order to simplify reading > the metadata file.** [source](https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-releases) This PR assumes the AppStream follows the spec in that the first `<release>` element describes the latest release. It's possible to check the `date` and `timestamp` properties of each release to find the latest, however, parsing the dates is non-trivial: > The date property can have any time in ISO 8601 format as its value and should be present for every release. At least day-level granularity is required, which means that the ISO 8601 string must contain at least a full date (e.g. 2019-08-12). As a result, we can't simply use `strptime` because we don't know what the granularity of the date is beforehand. `python-dateutil` could be used to parse this date, however, I didn't want to add another dependency just to support AppStream files who don't follow the spec. I looked at a bunch of AppStream files in the wild and they all seem to follow the spec. * [GNOME Calculator](https://gitlab.gnome.org/GNOME/gnome-calculator/blob/master/data/org.gnome.Calculator.appdata.xml.in) * [Foliate](https://github.com/johnfactotum/foliate/blob/master/data/com.github.johnfactotum.Foliate.appdata.xml.in) * [Krita](https://invent.kde.org/kde/krita/blob/master/krita/org.kde.krita.appdata.xml) * [Nautilus](https://github.com/GNOME/nautilus/blob/mainline/data/org.gnome.Nautilus.appdata.xml.in.in) I also tested this PR manually with the Foliate snaps: https://github.com/snapcrafters/foliate/pull/4

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Merged changes extract title and version from AppStream metadata by parsing the name tag and first release tag. Adds 105 lines across three files, passes CI, and enables adopt-info functionality for Snapcraft without external dependencies.
qwen3.6-35b-a3b-mtp-q6 Merged. Extracts title from AppStream's name tag and version from the first release tag, relying on spec-compliant ordering. Integrates with Snapcraft's adopt-info and validated against the Foliate snap.
qwen3.6-35b-a3b-mtp-q6 Merged. Extracts title and version from AppStream metadata files using the name tag and first release tag, assuming spec compliance. Validated with Foliate snap without adding dependencies.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#3695 meta: add appstream metadata extractor snapcraft merged Merged after reviewer approval and passing CI. Adds an appstream metadata extractor to parse application metadata from appstream files, modifying 9 files with a net addition of 1192 lines.
73%
#2831 appstream extractor: add support for code snapcraft merged Merged a pull request adding XSLT support to preserve code tags during Appstream to Markdown transformation. Approved by a reviewer, passed CI checks, and added 63 lines across two files to prevent code content from being stripped.
71%