summaryrefslogtreecommitdiffstats
path: root/classes/sota_sanity.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'classes/sota_sanity.bbclass')
-rw-r--r--classes/sota_sanity.bbclass47
1 files changed, 47 insertions, 0 deletions
diff --git a/classes/sota_sanity.bbclass b/classes/sota_sanity.bbclass
index 8e80acb..1339fb3 100644
--- a/classes/sota_sanity.bbclass
+++ b/classes/sota_sanity.bbclass
@@ -10,6 +10,52 @@ def sota_check_required_variables(status, d):
10 if not d.getVar(var): 10 if not d.getVar(var):
11 status.addresult("%s should be set in your local.conf.\n" % var) 11 status.addresult("%s should be set in your local.conf.\n" % var)
12 12
13def sota_check_variables_validity(status, d):
14 import re
15 import os.path
16
17 if d.getVar("OSTREE_BRANCHNAME") and re.match("^[a-zA-Z0-9_-]*$", d.getVar("OSTREE_BRANCHNAME")) is None:
18 status.addresult("OSTREE_BRANCHNAME Should only contain characters from the character set [a-zA-Z0-9_-].\n")
19 if d.getVar("SOTA_HARDWARE_ID") and re.match("^[a-zA-Z0-9_-]*$", d.getVar("SOTA_HARDWARE_ID")) is None:
20 status.addresult("SOTA_HARDWARE_ID Should only contain characters from the character set [a-zA-Z0-9_-].\n")
21 if d.getVar("SOTA_CLIENT_FEATURES") is not None:
22 for feat in d.getVar("SOTA_CLIENT_FEATURES").split(' '):
23 if feat not in ("hsm", "serialcan", "ubootenv", ""):
24 status.addresult("SOTA_CLIENT_FEATURES should only include hsm, serialcan and bootenv.\n")
25 break
26 if d.getVar("SOTA_CLIENT_PROV") is not None:
27 prov = d.getVar("SOTA_CLIENT_PROV").strip()
28 if prov not in ("aktualizr-shared-prov", "aktualizr-device-prov", "aktualizr-device-prov-hsm", ""):
29 status.addresult("Valid options for SOTA_CLIENT_PROV are aktualizr-shared-prov, aktualizr-device-prov and aktualizr-device-prov-hsm.\n")
30 if prov == "aktualizr-auto-prov":
31 bb.warn('aktualizr-auto-prov is deprecated. Please use aktualizr-shared-prov instead.')
32 elif prov == "aktualizr-ca-implicit-prov":
33 bb.warn('aktualizr-ca-implicit-prov is deprecated. Please use aktualizr-device-prov instead.')
34 elif prov == "aktualizr-hsm-prov":
35 bb.warn('aktualizr-hsm-prov is deprecated. Please use aktualizr-device-prov-hsm instead.')
36 if d.getVar("GARAGE_TARGET_URL") and re.match("^(https?|ftp|file)://.+$", d.getVar("GARAGE_TARGET_URL")) is None:
37 status.addresult("GARAGE_TARGET_URL is set to a bad url.\n")
38 if d.getVar("SOTA_POLLING_SEC") and re.match("^[1-9]\d*|0$", d.getVar("SOTA_POLLING_SEC")) is None:
39 status.addresult("SOTA_POLLING_SEC should be an integer.\n")
40 config = d.getVar("SOTA_SECONDARY_CONFIG")
41 if config is not None and config != "":
42 path = os.path.abspath(config)
43 if not os.path.exists(path):
44 status.addresult("SOTA_SECONDARY_CONFIG is not set correctly. The file containing JSON configuration for secondaries does not exist.\n")
45 credentials = d.getVar("SOTA_PACKED_CREDENTIALS")
46 if credentials is not None and credentials != "":
47 path = os.path.abspath(credentials)
48 if not os.path.exists(path):
49 status.addresult("SOTA_PACKED_CREDENTIALS is not set correctly. The zipped credentials file does not exist.\n")
50 if d.getVar("OSTREE_UPDATE_SUMMARY") and d.getVar("OSTREE_UPDATE_SUMMARY") not in ("0", "1", ""):
51 status.addresult("OSTREE_UPDATE_SUMMARY should be set to 0 or 1.\n")
52 if d.getVar("OSTREE_DEPLOY_DEVICETREE") and d.getVar("OSTREE_DEPLOY_DEVICETREE") not in ("0", "1", ""):
53 status.addresult("OSTREE_DEPLOY_DEVICETREE should be set to 0 or 1.\n")
54 if d.getVar("GARAGE_SIGN_AUTOVERSION") and d.getVar("GARAGE_SIGN_AUTOVERSION") not in ("0", "1", ""):
55 status.addresult("GARAGE_SIGN_AUTOVERSION should be set to 0 or 1.\n")
56 if d.getVar("SOTA_DEPLOY_CREDENTIALS") and d.getVar("SOTA_DEPLOY_CREDENTIALS") not in ("0", "1", ""):
57 status.addresult("SOTA_DEPLOY_CREDENTIALS should be set to 0 or 1.\n")
58
13def sota_raise_sanity_error(msg, d): 59def sota_raise_sanity_error(msg, d):
14 if d.getVar("SANITY_USE_EVENTS") == "1": 60 if d.getVar("SANITY_USE_EVENTS") == "1":
15 bb.event.fire(bb.event.SanityCheckFailed(msg), d) 61 bb.event.fire(bb.event.SanityCheckFailed(msg), d)
@@ -34,6 +80,7 @@ def sota_check_sanity(sanity_data):
34 80
35 sota_check_overrides(status, sanity_data) 81 sota_check_overrides(status, sanity_data)
36 sota_check_required_variables(status, sanity_data) 82 sota_check_required_variables(status, sanity_data)
83 sota_check_variables_validity(status, sanity_data)
37 84
38 if status.messages != "": 85 if status.messages != "":
39 sota_raise_sanity_error(sanity_data.expand(status.messages), sanity_data) 86 sota_raise_sanity_error(sanity_data.expand(status.messages), sanity_data)