Skip to content

Commit

Permalink
appstream: Add a check for missing timestamps in catalogue data
Browse files Browse the repository at this point in the history
  • Loading branch information
bbhtt committed Jan 24, 2025
1 parent 2bddff7 commit efb1efb
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 0 deletions.
4 changes: 4 additions & 0 deletions flatpak_builder_lint/appstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,7 @@ def get_icon_filename(path: str) -> str | None:
if icons := parse_xml(path).xpath("/components/component[1]/icon[@type='cached']"):
return str(icons[0].text)
return None


def all_release_has_timestamp(path: str) -> bool:
return not parse_xml(path).xpath("//releases/release[not(@timestamp)]")
7 changes: 7 additions & 0 deletions flatpak_builder_lint/checks/metainfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ def _validate(self, path: str, appid: str) -> None:
+ f" does not match the FLATPAK_ID: {appid}. Please see the docs for more details"
)

if not appstream.all_release_has_timestamp(appstream_path):
self.errors.add("appstream-release-tag-missing-timestamp")
self.info.add(
"appstream-release-tag-missing-timestamp: A release tag is missing timestamp."
+ " This is autogenerated and indicates an issue in Metainfo release tags"
)

if appstream.component_type(appstream_path) not in (
"desktop",
"desktop-application",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>org.flathub.appstream_no_timestamp</id>
<provides>
<id>org.flathub.appstream_no_timestamp.desktop</id>
</provides>
<launchable type="desktop-id">org.flathub.appstream_no_timestamp.desktop</launchable>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0+</project_license>
<name>Foo Bar</name>
<developer_name>Flathub</developer_name>
<summary>Foo foo foo foo</summary>
<url type="homepage">https://flathub.org</url>
<description>
<p>An example desktop application</p>
</description>
<screenshots>
<screenshot type="default">
<caption>Tux</caption>
<image>https://upload.wikimedia.org/wikipedia/commons/a/af/Tux.png</image>
<caption>foofoo</caption>
</screenshot>
</screenshots>
<url type="bugtracker">https://flathub.org</url>
<content_rating type="oars-1.1"/>
<releases>
<release version="0.0.1" date="2020-08-28"/>
</releases>
</component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Desktop Entry]
Name=Example
GenericName=Example
Comment=Example
Exec=Example %U
Icon=org.flathub.appstream_no_timestamp
Type=Application
Categories=Network;
Version=1.1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions tests/builddir/appstream-missing-timestamp/metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Application]
name=org.flathub.appstream_no_timestamp
runtime=org.gnome.Platform/x86_64/45
sdk=org.gnome.Sdk/x86_64/45
command=foo

[Context]
filesystems=xdg-download;
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/test_builddir.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,9 @@ def test_builddir_xdg_dir_access() -> None:
}
for e in errors:
assert e in found_errors


def test_builddir_appstream_missing_timestamp() -> None:
ret = run_checks("tests/builddir/appstream-missing-timestamp")
found_errors = set(ret["errors"])
assert "appstream-release-tag-missing-timestamp" in found_errors

0 comments on commit efb1efb

Please sign in to comment.