diff options
| author | Zee314159 <252806294@qq.com> | 2019-11-18 14:43:30 +0100 |
|---|---|---|
| committer | Zee314159 <252806294@qq.com> | 2019-11-18 14:47:54 +0100 |
| commit | ce6b676f0ecc3d1245d4d14aaa20806d926144f8 (patch) | |
| tree | 5abef41b6cfe11d2f32f855afad406695cfb0b59 /classes/sota_sanity.bbclass | |
| parent | 3ecda64c56d1b254c2f01b05cbbe451024d1b59a (diff) | |
| download | meta-updater-ce6b676f0ecc3d1245d4d14aaa20806d926144f8.tar.gz | |
Add sanity checks for user-defined SOTA variables
Signed-off-by: Zee314159 <252806294@qq.com>
Diffstat (limited to 'classes/sota_sanity.bbclass')
| -rw-r--r-- | classes/sota_sanity.bbclass | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/classes/sota_sanity.bbclass b/classes/sota_sanity.bbclass index 8e80acb..c6665a2 100644 --- a/classes/sota_sanity.bbclass +++ b/classes/sota_sanity.bbclass | |||
| @@ -10,6 +10,32 @@ 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 | ||
| 13 | def sota_check_variables_validity(status, d): | ||
| 14 | var = d.getVar("OSTREE_BRANCHNAME") | ||
| 15 | if var != "": | ||
| 16 | for ch in var: | ||
| 17 | if not (ch >= 'a' and ch <= 'z' or ch >= 'A' and ch <= 'Z' or ch >= '0' and ch <= '9' or ch = '_' or ch == '-'): | ||
| 18 | status.addresult("OSTREE_BRANCHNAME Should only contain characters from the character set [a-zA-Z0-9_-].\n") | ||
| 19 | break | ||
| 20 | var = d.getVar("{SOTA_HARDWARE_ID") | ||
| 21 | if var != "": | ||
| 22 | for ch in var: | ||
| 23 | if not (ch >= 'a' and ch <= 'z' or ch >= 'A' and ch <= 'Z' or ch >= '0' and ch <= '9' or ch = '_' or ch == '-'): | ||
| 24 | status.addresult("SOTA_HARDWARE_ID Should only contain characters from the character set [a-zA-Z0-9_-].\n") | ||
| 25 | break | ||
| 26 | var = d.getVar("SOTA_CLIENT_FEATURES") | ||
| 27 | if var != "hsm" and var != "secondary-network" and var != "": | ||
| 28 | status.addresult("SOTA_CLIENT_FEATURES should be set to hsm or secondary-network.\n") | ||
| 29 | var = d.getVar("OSTREE_UPDATE_SUMMARY") | ||
| 30 | if var != "0" and var != "1" and var != "": | ||
| 31 | status.addresult("OSTREE_UPDATE_SUMMARY should be set to 0 or 1.\n") | ||
| 32 | var = d.getVar("OSTREE_DEPLOY_DEVICETREE") | ||
| 33 | if var != "0" and var != "1" and var != "": | ||
| 34 | status.addresult("OSTREE_DEPLOY_DEVICETREE should be set to 0 or 1.\n") | ||
| 35 | var = GARAGE_SIGN_AUTOVERSION | ||
| 36 | if var != "0" and var != "1" and var != "": | ||
| 37 | status.addresult("GARAGE_SIGN_AUTOVERSION should be set to 0 or 1.\n") | ||
| 38 | |||
| 13 | def sota_raise_sanity_error(msg, d): | 39 | def sota_raise_sanity_error(msg, d): |
| 14 | if d.getVar("SANITY_USE_EVENTS") == "1": | 40 | if d.getVar("SANITY_USE_EVENTS") == "1": |
| 15 | bb.event.fire(bb.event.SanityCheckFailed(msg), d) | 41 | bb.event.fire(bb.event.SanityCheckFailed(msg), d) |
| @@ -52,3 +78,19 @@ python sota_check_sanity_eventhandler() { | |||
| 52 | 78 | ||
| 53 | return | 79 | return |
| 54 | } | 80 | } |
| 81 | |||
| 82 | # Translate old provisioning recipe names into the new versions. | ||
| 83 | python () { | ||
| 84 | prov = d.getVar("SOTA_CLIENT_PROV") | ||
| 85 | if prov == "aktualizr-auto-prov": | ||
| 86 | bb.warn('aktualizr-auto-prov is deprecated. Please use aktualizr-shared-prov instead.') | ||
| 87 | d.setVar("SOTA_CLIENT_PROV", "aktualizr-shared-prov") | ||
| 88 | elif prov == "aktualizr-ca-implicit-prov": | ||
| 89 | bb.warn('aktualizr-ca-implicit-prov is deprecated. Please use aktualizr-device-prov instead.') | ||
| 90 | d.setVar("SOTA_CLIENT_PROV", "aktualizr-device-prov") | ||
| 91 | elif prov == "aktualizr-hsm-prov": | ||
| 92 | bb.warn('aktualizr-hsm-prov is deprecated. Please use aktualizr-device-prov-hsm instead.') | ||
| 93 | d.setVar("SOTA_CLIENT_PROV", "aktualizr-device-prov-hsm") | ||
| 94 | } | ||
| 95 | |||
| 96 | |||
