diff --git a/flatpak_builder_lint/appstream.py b/flatpak_builder_lint/appstream.py index 6d41198c..2a838054 100644 --- a/flatpak_builder_lint/appstream.py +++ b/flatpak_builder_lint/appstream.py @@ -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)]") diff --git a/flatpak_builder_lint/checks/metainfo.py b/flatpak_builder_lint/checks/metainfo.py index 3733e811..a5473823 100644 --- a/flatpak_builder_lint/checks/metainfo.py +++ b/flatpak_builder_lint/checks/metainfo.py @@ -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", diff --git a/tests/builddir/appstream-missing-timestamp/files/share/app-info/icons/flatpak/128x128/org.flathub.appstream_no_timestamp.png b/tests/builddir/appstream-missing-timestamp/files/share/app-info/icons/flatpak/128x128/org.flathub.appstream_no_timestamp.png new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/tests/builddir/appstream-missing-timestamp/files/share/app-info/icons/flatpak/128x128/org.flathub.appstream_no_timestamp.png @@ -0,0 +1 @@ + diff --git a/tests/builddir/appstream-missing-timestamp/files/share/app-info/xmls/org.flathub.appstream_no_timestamp.xml.gz b/tests/builddir/appstream-missing-timestamp/files/share/app-info/xmls/org.flathub.appstream_no_timestamp.xml.gz new file mode 100644 index 00000000..794044fa Binary files /dev/null and b/tests/builddir/appstream-missing-timestamp/files/share/app-info/xmls/org.flathub.appstream_no_timestamp.xml.gz differ diff --git a/tests/builddir/appstream-missing-timestamp/files/share/appdata/org.flathub.appstream_no_timestamp.appdata.xml b/tests/builddir/appstream-missing-timestamp/files/share/appdata/org.flathub.appstream_no_timestamp.appdata.xml new file mode 100644 index 00000000..8d86a9a2 --- /dev/null +++ b/tests/builddir/appstream-missing-timestamp/files/share/appdata/org.flathub.appstream_no_timestamp.appdata.xml @@ -0,0 +1,29 @@ + + + org.flathub.appstream_no_timestamp + + org.flathub.appstream_no_timestamp.desktop + + org.flathub.appstream_no_timestamp.desktop + CC0-1.0 + GPL-2.0+ + Foo Bar + Flathub + Foo foo foo foo + https://flathub.org + +

An example desktop application

+
+ + + Tux + https://upload.wikimedia.org/wikipedia/commons/a/af/Tux.png + foofoo + + + https://flathub.org + + + + +
diff --git a/tests/builddir/appstream-missing-timestamp/files/share/applications/org.flathub.appstream_no_timestamp.desktop b/tests/builddir/appstream-missing-timestamp/files/share/applications/org.flathub.appstream_no_timestamp.desktop new file mode 100644 index 00000000..faa6b153 --- /dev/null +++ b/tests/builddir/appstream-missing-timestamp/files/share/applications/org.flathub.appstream_no_timestamp.desktop @@ -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 diff --git a/tests/builddir/appstream-missing-timestamp/files/share/icons/hicolor/128x128/apps/org.flathub.appstream_no_timestamp.png b/tests/builddir/appstream-missing-timestamp/files/share/icons/hicolor/128x128/apps/org.flathub.appstream_no_timestamp.png new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/tests/builddir/appstream-missing-timestamp/files/share/icons/hicolor/128x128/apps/org.flathub.appstream_no_timestamp.png @@ -0,0 +1 @@ + diff --git a/tests/builddir/appstream-missing-timestamp/metadata b/tests/builddir/appstream-missing-timestamp/metadata new file mode 100644 index 00000000..08796c24 --- /dev/null +++ b/tests/builddir/appstream-missing-timestamp/metadata @@ -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; diff --git a/tests/builddir/console/files/share/app-info/xmls/org.flathub.example.console.xml.gz b/tests/builddir/console/files/share/app-info/xmls/org.flathub.example.console.xml.gz index 17e5391a..a863b2cb 100644 Binary files a/tests/builddir/console/files/share/app-info/xmls/org.flathub.example.console.xml.gz and b/tests/builddir/console/files/share/app-info/xmls/org.flathub.example.console.xml.gz differ diff --git a/tests/test_builddir.py b/tests/test_builddir.py index cedd1faf..40d70f5f 100644 --- a/tests/test_builddir.py +++ b/tests/test_builddir.py @@ -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