summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Vacek <patrickvacek@gmail.com>2020-05-12 12:15:30 +0200
committerGitHub <noreply@github.com>2020-05-12 12:15:30 +0200
commit810cc045392088eb8365e4928f303f2140d1484d (patch)
tree35f5703a8b721e8d6726ac4e7eb17e9e4806fff5
parent82d7e04924f847bccba3136d1602d5646486a926 (diff)
parenta7189aae28cf3181daebc89c0bc609f4ef8ea5fb (diff)
downloadmeta-updater-810cc045392088eb8365e4928f303f2140d1484d.tar.gz
Merge pull request #724 from liuming50/fix-an-incomplete-sanity-checking
sota_sanity.bbclass: introduce sota_check_boolean_variable
-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 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
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 b1bee82..50f0c34 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)}"