diff options
author | Ming Liu <ming.liu@toradex.com> | 2020-05-11 19:49:31 +0200 |
---|---|---|
committer | Ming Liu <ming.liu@toradex.com> | 2020-05-11 19:53:55 +0200 |
commit | a7189aae28cf3181daebc89c0bc609f4ef8ea5fb (patch) | |
tree | 35f5703a8b721e8d6726ac4e7eb17e9e4806fff5 /classes | |
parent | 82d7e04924f847bccba3136d1602d5646486a926 (diff) | |
download | meta-updater-a7189aae28cf3181daebc89c0bc609f4ef8ea5fb.tar.gz |
sota_sanity.bbclass: introduce sota_check_boolean_variable
The current sanity check are too strict for some boolean variables,
introduce sota_check_boolean_variable to allow a boolean value to be
set like yes/y/true/t/1 or no/n/false/f/0.
Also change to use oe.types.boolean to check their values.
Signed-off-by: Ming Liu <ming.liu@toradex.com>
Diffstat (limited to 'classes')
-rw-r--r-- | classes/image_types_ostree.bbclass | 4 | ||||
-rw-r--r-- | classes/sota_sanity.bbclass | 23 |
2 files changed, 17 insertions, 10 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index a8a6c39..0614dd3 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass | |||
@@ -141,7 +141,7 @@ IMAGE_CMD_ostree () { | |||
141 | checksum=$(sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " ") | 141 | checksum=$(sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " ") |
142 | touch boot/initramfs-${checksum} | 142 | touch boot/initramfs-${checksum} |
143 | else | 143 | else |
144 | if [ "${OSTREE_DEPLOY_DEVICETREE}" = "1" ] && [ -n "${KERNEL_DEVICETREE}" ]; then | 144 | if [ ${@ oe.types.boolean('${OSTREE_DEPLOY_DEVICETREE}')} = True ] && [ -n "${KERNEL_DEVICETREE}" ]; then |
145 | checksum=$(cat ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} ${KERNEL_DEVICETREE} | sha256sum | cut -f 1 -d " ") | 145 | checksum=$(cat ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} ${KERNEL_DEVICETREE} | sha256sum | cut -f 1 -d " ") |
146 | for DTS_FILE in ${KERNEL_DEVICETREE}; do | 146 | for DTS_FILE in ${KERNEL_DEVICETREE}; do |
147 | DTS_FILE_BASENAME=$(basename ${DTS_FILE}) | 147 | DTS_FILE_BASENAME=$(basename ${DTS_FILE}) |
@@ -177,7 +177,7 @@ IMAGE_CMD_ostreecommit () { | |||
177 | --add-metadata-string=version="${OSTREE_COMMIT_VERSION}" \ | 177 | --add-metadata-string=version="${OSTREE_COMMIT_VERSION}" \ |
178 | --bind-ref="${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}" | 178 | --bind-ref="${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}" |
179 | 179 | ||
180 | if [ "${OSTREE_UPDATE_SUMMARY}" = "1" ]; then | 180 | if [ ${@ oe.types.boolean('${OSTREE_UPDATE_SUMMARY}')} = True ]; then |
181 | ostree --repo=${OSTREE_REPO} summary -u | 181 | ostree --repo=${OSTREE_REPO} summary -u |
182 | fi | 182 | fi |
183 | 183 | ||
diff --git a/classes/sota_sanity.bbclass b/classes/sota_sanity.bbclass index 74973eb..02ca2e7 100644 --- a/classes/sota_sanity.bbclass +++ b/classes/sota_sanity.bbclass | |||
@@ -1,5 +1,12 @@ | |||
1 | # Sanity check the sota setup for common misconfigurations | 1 | # Sanity check the sota setup for common misconfigurations |
2 | 2 | ||
3 | def sota_check_boolean_variable(var, d): | ||
4 | try: | ||
5 | oe.types.boolean(d.getVar(var)) | ||
6 | except: | ||
7 | return False | ||
8 | return True | ||
9 | |||
3 | def sota_check_overrides(status, d): | 10 | def sota_check_overrides(status, d): |
4 | for var in (d.getVar('SOTA_OVERRIDES_BLACKLIST') or "").split(): | 11 | for var in (d.getVar('SOTA_OVERRIDES_BLACKLIST') or "").split(): |
5 | if var in d.getVar('OVERRIDES').split(':'): | 12 | if var in d.getVar('OVERRIDES').split(':'): |
@@ -47,14 +54,14 @@ def sota_check_variables_validity(status, d): | |||
47 | path = os.path.abspath(credentials) | 54 | path = os.path.abspath(credentials) |
48 | if not os.path.exists(path): | 55 | if not os.path.exists(path): |
49 | status.addresult("SOTA_PACKED_CREDENTIALS is not set correctly. The zipped credentials file does not exist.\n") | 56 | 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", ""): | 57 | if not sota_check_boolean_variable("OSTREE_UPDATE_SUMMARY", d): |
51 | status.addresult("OSTREE_UPDATE_SUMMARY should be set to 0 or 1.\n") | 58 | status.addresult("OSTREE_UPDATE_SUMMARY (=%s) should be set to yes/y/true/t/1 or no/n/false/f/0.\n" % d.getVar("OSTREE_UPDATE_SUMMARY")) |
52 | if d.getVar("OSTREE_DEPLOY_DEVICETREE") and d.getVar("OSTREE_DEPLOY_DEVICETREE") not in ("0", "1", ""): | 59 | if not sota_check_boolean_variable("OSTREE_DEPLOY_DEVICETREE", d): |
53 | status.addresult("OSTREE_DEPLOY_DEVICETREE should be set to 0 or 1.\n") | 60 | status.addresult("OSTREE_DEPLOY_DEVICETREE (=%s) should be set to yes/y/true/t/1 or no/n/false/f/0.\n" % d.getVar("OSTREE_DEPLOY_DEVICETREE")) |
54 | if d.getVar("GARAGE_SIGN_AUTOVERSION") and d.getVar("GARAGE_SIGN_AUTOVERSION") not in ("0", "1", ""): | 61 | if not sota_check_boolean_variable("GARAGE_SIGN_AUTOVERSION", d): |
55 | status.addresult("GARAGE_SIGN_AUTOVERSION should be set to 0 or 1.\n") | 62 | status.addresult("GARAGE_SIGN_AUTOVERSION (=%s) should be set to yes/y/true/t/1 or no/n/false/f/0.\n" % d.getVar("GARAGE_SIGN_AUTOVERSION")) |
56 | if d.getVar("SOTA_DEPLOY_CREDENTIALS") and d.getVar("SOTA_DEPLOY_CREDENTIALS") not in ("0", "1", ""): | 63 | if not sota_check_boolean_variable("SOTA_DEPLOY_CREDENTIALS", d): |
57 | status.addresult("SOTA_DEPLOY_CREDENTIALS should be set to 0 or 1.\n") | 64 | status.addresult("SOTA_DEPLOY_CREDENTIALS (=%s) should be set to yes/y/true/t/1 or no/n/false/f/0.\n" % d.getVar("SOTA_DEPLOY_CREDENTIALS")) |
58 | 65 | ||
59 | def sota_raise_sanity_error(msg, d): | 66 | def sota_raise_sanity_error(msg, d): |
60 | if d.getVar("SANITY_USE_EVENTS") == "1": | 67 | if d.getVar("SANITY_USE_EVENTS") == "1": |