summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMing Liu <ming.liu@toradex.com>2020-05-11 19:49:31 +0200
committerLaurent Bonnans <laurent.bonnans@here.com>2020-06-02 15:27:43 +0200
commit919ce317bd42659048154c25a13716f6fc9e0d2c (patch)
tree6b3b64bd8e8202d6a2896a99b0ef453c3a215599
parenta9a04e7d1d4b0b05a10a9f92bf980235a2a5bf38 (diff)
downloadmeta-updater-919ce317bd42659048154c25a13716f6fc9e0d2c.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>
-rw-r--r--classes/image_types_ostree.bbclass4
-rw-r--r--classes/sota_sanity.bbclass23
-rw-r--r--recipes-sota/aktualizr/aktualizr-shared-prov.bb2
-rw-r--r--recipes-sota/aktualizr/aktualizr_git.bb4
4 files changed, 20 insertions, 13 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass
index 95035e2..4b27f34 100644
--- a/classes/image_types_ostree.bbclass
+++ b/classes/image_types_ostree.bbclass
@@ -142,7 +142,7 @@ IMAGE_CMD_ostree () {
142 checksum=$(sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " ") 142 checksum=$(sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " ")
143 touch boot/initramfs-${checksum} 143 touch boot/initramfs-${checksum}
144 else 144 else
145 if [ "${OSTREE_DEPLOY_DEVICETREE}" = "1" ] && [ -n "${KERNEL_DEVICETREE}" ]; then 145 if [ ${@ oe.types.boolean('${OSTREE_DEPLOY_DEVICETREE}')} = True ] && [ -n "${KERNEL_DEVICETREE}" ]; then
146 checksum=$(cat ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} ${KERNEL_DEVICETREE} | sha256sum | cut -f 1 -d " ") 146 checksum=$(cat ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} ${KERNEL_DEVICETREE} | sha256sum | cut -f 1 -d " ")
147 for DTS_FILE in ${KERNEL_DEVICETREE}; do 147 for DTS_FILE in ${KERNEL_DEVICETREE}; do
148 DTS_FILE_BASENAME=$(basename ${DTS_FILE}) 148 DTS_FILE_BASENAME=$(basename ${DTS_FILE})
@@ -178,7 +178,7 @@ IMAGE_CMD_ostreecommit () {
178 --add-metadata-string=version="${OSTREE_COMMIT_VERSION}" \ 178 --add-metadata-string=version="${OSTREE_COMMIT_VERSION}" \
179 --bind-ref="${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}" 179 --bind-ref="${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}"
180 180
181 if [ "${OSTREE_UPDATE_SUMMARY}" = "1" ]; then 181 if [ ${@ oe.types.boolean('${OSTREE_UPDATE_SUMMARY}')} = True ]; then
182 ostree --repo=${OSTREE_REPO} summary -u 182 ostree --repo=${OSTREE_REPO} summary -u
183 fi 183 fi
184 184
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
3def sota_check_boolean_variable(var, d):
4 try:
5 oe.types.boolean(d.getVar(var))
6 except:
7 return False
8 return True
9
3def sota_check_overrides(status, d): 10def 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
59def sota_raise_sanity_error(msg, d): 66def sota_raise_sanity_error(msg, d):
60 if d.getVar("SANITY_USE_EVENTS") == "1": 67 if d.getVar("SANITY_USE_EVENTS") == "1":
diff --git a/recipes-sota/aktualizr/aktualizr-shared-prov.bb b/recipes-sota/aktualizr/aktualizr-shared-prov.bb
index 2ee47a1..0f712df 100644
--- a/recipes-sota/aktualizr/aktualizr-shared-prov.bb
+++ b/recipes-sota/aktualizr/aktualizr-shared-prov.bb
@@ -10,7 +10,7 @@ inherit allarch
10# We need to get the config files from the aktualizr-host-tools package built by 10# We need to get the config files from the aktualizr-host-tools package built by
11# the aktualizr (target) recipe. 11# the aktualizr (target) recipe.
12DEPENDS = "aktualizr" 12DEPENDS = "aktualizr"
13RDEPENDS_${PN}_append = "${@' aktualizr-shared-prov-creds' if d.getVar('SOTA_DEPLOY_CREDENTIALS') == '1' else ''}" 13RDEPENDS_${PN}_append = "${@' aktualizr-shared-prov-creds' if oe.types.boolean(d.getVar('SOTA_DEPLOY_CREDENTIALS')) else ''}"
14 14
15# If the config file from aktualizr used here is changed, you will need to bump 15# If the config file from aktualizr used here is changed, you will need to bump
16# the version here because of SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS! 16# the version here because of SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS!
diff --git a/recipes-sota/aktualizr/aktualizr_git.bb b/recipes-sota/aktualizr/aktualizr_git.bb
index a20d46b..667765a 100644
--- a/recipes-sota/aktualizr/aktualizr_git.bb
+++ b/recipes-sota/aktualizr/aktualizr_git.bb
@@ -26,7 +26,7 @@ SRC_URI = " \
26 file://aktualizr-secondary.service \ 26 file://aktualizr-secondary.service \
27 file://aktualizr-serialcan.service \ 27 file://aktualizr-serialcan.service \
28 file://10-resource-control.conf \ 28 file://10-resource-control.conf \
29 ${@ d.expand("https://tuf-cli-releases.ota.here.com/cli-${GARAGE_SIGN_PV}.tgz;unpack=0;name=garagesign") if d.getVar('GARAGE_SIGN_AUTOVERSION') != '1' else ''} \ 29 ${@ d.expand("https://tuf-cli-releases.ota.here.com/cli-${GARAGE_SIGN_PV}.tgz;unpack=0;name=garagesign") if not oe.types.boolean(d.getVar('GARAGE_SIGN_AUTOVERSION')) else ''} \
30 " 30 "
31 31
32SRC_URI[garagesign.md5sum] = "febc186527b324b23c5be3affcf90e54" 32SRC_URI[garagesign.md5sum] = "febc186527b324b23c5be3affcf90e54"
@@ -49,7 +49,7 @@ SYSTEMD_SERVICE_${PN}-secondary = "aktualizr-secondary.service"
49 49
50EXTRA_OECMAKE = "-DCMAKE_BUILD_TYPE=Release ${@bb.utils.contains('PTEST_ENABLED', '1', '-DTESTSUITE_VALGRIND=on', '', d)}" 50EXTRA_OECMAKE = "-DCMAKE_BUILD_TYPE=Release ${@bb.utils.contains('PTEST_ENABLED', '1', '-DTESTSUITE_VALGRIND=on', '', d)}"
51 51
52GARAGE_SIGN_OPS = "${@ d.expand('-DGARAGE_SIGN_ARCHIVE=${WORKDIR}/cli-${GARAGE_SIGN_PV}.tgz') if d.getVar('GARAGE_SIGN_AUTOVERSION') != '1' else ''}" 52GARAGE_SIGN_OPS = "${@ d.expand('-DGARAGE_SIGN_ARCHIVE=${WORKDIR}/cli-${GARAGE_SIGN_PV}.tgz') if not oe.types.boolean(d.getVar('GARAGE_SIGN_AUTOVERSION')) else ''}"
53PKCS11_ENGINE_PATH = "${libdir}/engines-1.1/pkcs11.so" 53PKCS11_ENGINE_PATH = "${libdir}/engines-1.1/pkcs11.so"
54 54
55PACKAGECONFIG ?= "ostree ${@bb.utils.filter('SOTA_CLIENT_FEATURES', 'hsm serialcan ubootenv', d)}" 55PACKAGECONFIG ?= "ostree ${@bb.utils.filter('SOTA_CLIENT_FEATURES', 'hsm serialcan ubootenv', d)}"