From 325fce6e4a87c035003f0ac810072ab0594567e1 Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Fri, 30 Aug 2019 15:39:25 +0800 Subject: image_type_tezi.bbclass: add OTA provisioning support Add two items into image json file: ota_provisioning and ota_credentials. ota_provisioning would be set 'True' if SOTA_PACKED_CREDENTIALS is being set, and ota_credentials would be set to the basename of SOTA_PACKED_CREDENTIALS. These two variables would be checked in Tezi installer to determine whether OTA provisioning is needed. This patch would not cause any functional change in Tezi installer while SOTA_PACKED_CREDENTIALS is not set. Signed-off-by: Ming Liu --- classes/image_type_tezi.bbclass | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/classes/image_type_tezi.bbclass b/classes/image_type_tezi.bbclass index 32eacb5..82458d2 100644 --- a/classes/image_type_tezi.bbclass +++ b/classes/image_type_tezi.bbclass @@ -151,6 +151,7 @@ def rootfs_tezi_emmc(d): "filesystem_type": d.getVar('TEZI_ROOT_FSTYPE'), "mkfs_options": "-E nodiscard", "filename": imagename + "." + imagetype_suffix, + "ota_provisioning": True if d.getVar('SOTA_PACKED_CREDENTIALS') else False, "uncompressed_size": get_uncompressed_size(d) / 1024 } } @@ -195,6 +196,7 @@ def rootfs_tezi_rawnand(d, distro=False): "content": { "filesystem_type": "ubifs", "filename": imagename + "." + imagetype_suffix, + "ota_provisioning": True if distro and d.getVar('SOTA_PACKED_CREDENTIALS') else False, "uncompressed_size": get_uncompressed_size(d) / 1024 } } @@ -254,11 +256,12 @@ def rootfs_tezi_rawnand(d, distro=False): return [uboot1, uboot2, ubi] def rootfs_tezi_json(d, flash_type, flash_data, json_file, uenv_file): - import json + import json, os from collections import OrderedDict from datetime import datetime deploydir = d.getVar('DEPLOY_DIR_IMAGE') + ota_credentials = d.getVar('SOTA_PACKED_CREDENTIALS') # Patched in IMAGE_CMD_teziimg() below release_date = "%release_date%" @@ -300,6 +303,11 @@ def rootfs_tezi_json(d, flash_type, flash_data, json_file, uenv_file): elif flash_type == "emmc": data["blockdevs"] = flash_data + if ota_credentials: + data["ota_credentials"] = os.path.basename(ota_credentials) + else: + data["ota_credentials"] = "" + with open(os.path.join(deploydir, json_file), 'w') as outfile: json.dump(data, outfile, indent=4) bb.note("Toradex Easy Installer metadata file {0} written.".format(json_file)) @@ -432,7 +440,7 @@ IMAGE_CMD_teziimg-distro () { -chf ${IMGDEPLOYDIR}/${IMAGE_NAME}-Tezi_${PV}${TDX_VERDATE}.tar \ ${TEZI_IMAGE_JSON_FILES} toradexlinux.png marketing.tar prepare.sh wrapup.sh \ ${TEZI_IMAGE_UBOOT_FILES} ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.bootfs.tar.xz \ - ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${TEZI_ROOT_SUFFIX} + ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${TEZI_ROOT_SUFFIX} ${SOTA_PACKED_CREDENTIALS} } IMAGE_TYPEDEP_teziimg-distro += "${TEZI_ROOT_SUFFIX}" -- cgit v1.2.3