Skip to content

Commit 3182176

Browse files
committed
screenshots: Completely unhardcode architecture
Don't assume screenshots/x86_64 is present, validate what you have at hand instead. This should also catch issues if appstream ends up being different for each arch.
1 parent 3d8c7a7 commit 3182176

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

flatpak_builder_lint/checks/screenshots.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,6 @@ def check_repo(self, path: str) -> None:
5353
self.errors.add("appstream-missing-screenshots")
5454
return
5555

56-
arches = {ref.split("/")[2] for ref in refs if len(ref.split("/")) == 4}
57-
for arch in arches:
58-
if f"screenshots/{arch}" not in refs:
59-
self.errors.add("appstream-screenshots-not-mirrored-in-ostree")
60-
return
61-
62-
ostree_screenshots_cmd = ostree.cli(path, "ls", "-R", "screenshots/x86_64")
63-
if ostree_screenshots_cmd["returncode"] != 0:
64-
raise RuntimeError("Failed to list screenshots")
65-
66-
ostree_screenshots = []
67-
for ostree_screenshot in ostree_screenshots_cmd["stdout"].splitlines():
68-
mode, _, _, _, ostree_screenshot_filename = ostree_screenshot.split()
69-
if mode[0] != "-":
70-
continue
71-
ostree_screenshots.append(ostree_screenshot_filename[1:])
72-
7356
for screenshot in screenshots:
7457
if screenshot.attrib.get("type") != "source":
7558
if not screenshot.text.startswith(
@@ -78,9 +61,28 @@ def check_repo(self, path: str) -> None:
7861
self.errors.add("appstream-external-screenshot-url")
7962
return
8063

81-
screenshot_filename = "/".join(screenshot.text.split("/")[5:])
82-
if f"{screenshot_filename}" not in ostree_screenshots:
83-
self.warnings.add(
84-
"appstream-screenshots-files-not-found-in-ostree"
85-
)
86-
return
64+
arches = {ref.split("/")[2] for ref in refs if len(ref.split("/")) == 4}
65+
for arch in arches:
66+
if f"screenshots/{arch}" not in refs:
67+
self.errors.add("appstream-screenshots-not-mirrored-in-ostree")
68+
return
69+
70+
ostree_screenshots_cmd = ostree.cli(path, "ls", "-R", "screenshots/{arch}")
71+
if ostree_screenshots_cmd["returncode"] != 0:
72+
raise RuntimeError("Failed to list screenshots")
73+
74+
ostree_screenshots = []
75+
for ostree_screenshot in ostree_screenshots_cmd["stdout"].splitlines():
76+
mode, _, _, _, ostree_screenshot_filename = ostree_screenshot.split()
77+
if mode[0] != "-":
78+
continue
79+
ostree_screenshots.append(ostree_screenshot_filename[1:])
80+
81+
for screenshot in screenshots:
82+
if screenshot.attrib.get("type") != "source":
83+
screenshot_filename = "/".join(screenshot.text.split("/")[5:])
84+
if f"{screenshot_filename}" not in ostree_screenshots:
85+
self.warnings.add(
86+
"appstream-screenshots-files-not-found-in-ostree"
87+
)
88+
return

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "flatpak_builder_lint"
3-
version = "2.0.20"
3+
version = "2.0.21"
44
description = "A linter for flatpak-builder manifests"
55
authors = ["Bartłomiej Piotrowski <b@bpiotrowski.pl>"]
66
license = "MIT"

0 commit comments

Comments
 (0)