From 71da84906a4c5f6478aebf954f51dd53272d26ba Mon Sep 17 00:00:00 2001 From: bbhtt Date: Mon, 24 Jun 2024 06:39:46 +0530 Subject: [PATCH] Skip and don't add duplicate errors Extract `files/share` for screenshot check like everywhere elese and remove the "appstream-missing-appinfo" error. Instead raise an exception like we do everywhere else. --- flatpak_builder_lint/checks/desktop.py | 13 ------------ flatpak_builder_lint/checks/screenshots.py | 24 +++------------------- 2 files changed, 3 insertions(+), 34 deletions(-) diff --git a/flatpak_builder_lint/checks/desktop.py b/flatpak_builder_lint/checks/desktop.py index d0a40a4c..56065448 100644 --- a/flatpak_builder_lint/checks/desktop.py +++ b/flatpak_builder_lint/checks/desktop.py @@ -30,24 +30,11 @@ def _validate(self, path: str, appid: str) -> None: return None if not os.path.exists(appstream_path): - self.errors.add("appstream-missing-appinfo-file") - self.info.add( - "appstream-missing-appinfo-file: Appstream catalogue file is missing." - + " Perhaps no Metainfo file was installed with correct name" - ) return None if len(appstream.components(appstream_path)) != 1: - self.errors.add("appstream-multiple-components") return None - if not appstream.is_valid_component_type(appstream_path): - self.errors.add("appstream-unsupported-component-type") - self.info.add( - "appstream-unsupported-component-type: Component type must be one of" - + " addon, console-application, desktop, desktop-application or runtime" - ) - if appstream.component_type(appstream_path) not in ( "desktop", "desktop-application", diff --git a/flatpak_builder_lint/checks/screenshots.py b/flatpak_builder_lint/checks/screenshots.py index a511a66b..779c2910 100644 --- a/flatpak_builder_lint/checks/screenshots.py +++ b/flatpak_builder_lint/checks/screenshots.py @@ -22,35 +22,17 @@ def check_repo(self, path: str) -> None: refs = refs_cmd["stdout"].splitlines() with tempfile.TemporaryDirectory() as tmpdir: - ret = ostree.extract_subpath(path, ref, "files/share/app-info", tmpdir) + ret = ostree.extract_subpath(path, ref, "files/share", tmpdir) if ret["returncode"] != 0: - self.errors.add("appstream-missing-appinfo") - self.info.add( - "appstream-missing-appinfo: files/share/app-info directory is missing" - + " Perhaps no Metainfo file was supplied" - ) - return + raise RuntimeError("Failed to extract ostree repo") - appstream_path = f"{tmpdir}/xmls/{appid}.xml.gz" + appstream_path = f"{tmpdir}/app-info/xmls/{appid}.xml.gz" if not os.path.exists(appstream_path): - self.errors.add("appstream-missing-appinfo-file") - self.info.add( - "appstream-missing-appinfo-file: Appstream catalogue file is missing." - + " Perhaps no Metainfo file was installed with correct name" - ) return if len(appstream.components(appstream_path)) != 1: - self.errors.add("appstream-multiple-components") return - if not appstream.is_valid_component_type(appstream_path): - self.errors.add("appstream-unsupported-component-type") - self.info.add( - "appstream-unsupported-component-type: Component type must be one of" - + " addon, console-application, desktop, desktop-application or runtime" - ) - if appstream.component_type(appstream_path) not in ( "desktop", "desktop-application",