-
Notifications
You must be signed in to change notification settings - Fork 118
/
flathub_json.py
65 lines (52 loc) · 2.66 KB
/
flathub_json.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from . import ARCHES, Check
class FlathubJsonCheck(Check):
type = "manifest"
def _check_if_extra_data(self, modules: list) -> bool:
for module in modules:
if sources := module.get("sources"):
for source in sources:
if source.get("type") == "extra-data":
return True
if nested_modules := module.get("modules"):
return self._check_if_extra_data(nested_modules)
return False
def check(self, manifest: dict) -> None:
flathub_json = manifest.get("x-flathub")
if not flathub_json:
return
appid = manifest.get("id", "")
if flathub_json.get("skip-appstream-check"):
is_baseapp = appid.endswith(".BaseApp")
if not (manifest.get("build-extension") or is_baseapp):
self.errors.add("flathub-json-skip-appstream-check")
eol = flathub_json.get("end-of-life")
eol_rebase = flathub_json.get("end-of-life-rebase")
if eol_rebase and not eol:
self.errors.add("flathub-json-eol-rebase-without-message")
if eol and eol_rebase:
if eol_rebase not in eol:
self.errors.add("flathub-json-eol-rebase-misses-new-id")
publish_delay = flathub_json.get("publish-delay-hours")
if isinstance(publish_delay, int):
if publish_delay < 3:
if modules := manifest.get("modules"):
if not self._check_if_extra_data(modules):
self.errors.add("flathub-json-modified-publish-delay")
if only_arches := flathub_json.get("only-arches"):
if "arm" in only_arches:
self.warnings.add("flathub-json-deprecated-arm-arch-included")
if "i386" in only_arches:
self.warnings.add("flathub-json-deprecated-i386-arch-included")
if len(only_arches) == 0:
self.errors.add("flathub-json-only-arches-empty")
if len(ARCHES.intersection(only_arches)) == len(ARCHES):
self.warnings.add("flathub-json-redundant-only-arches")
if exclude_arches := flathub_json.get("exclude-arches"):
if "arm" in exclude_arches:
self.warnings.add("flathub-json-deprecated-arm-arch-excluded")
if "i386" in exclude_arches:
self.warnings.add("flathub-json-deprecated-i386-arch-excluded")
if len(exclude_arches) == 0:
self.warnings.add("flathub-json-exclude-arches-empty")
if len(ARCHES.intersection(exclude_arches)) == len(ARCHES):
self.errors.add("flathub-json-excluded-all-arches")