diff options
author | Phil Wise <phil@advancedtelematic.com> | 2017-08-24 17:12:36 +0200 |
---|---|---|
committer | Phil Wise <phil@advancedtelematic.com> | 2017-08-24 17:12:36 +0200 |
commit | a130c026af9426eb657d04bfcd4402ad5be53cc7 (patch) | |
tree | f8be0daedcf1cbc34d62f2c3721400707b309268 /classes | |
parent | f9432682932fe6fcca59289e40bfca5ceacb137c (diff) | |
parent | 4e5064a1caae234a2ba755c246803d550234fd2b (diff) | |
download | meta-updater-a130c026af9426eb657d04bfcd4402ad5be53cc7.tar.gz |
Merge remote-tracking branch 'github/morty' into HEAD
Diffstat (limited to 'classes')
-rw-r--r-- | classes/image_types_ostree.bbclass | 83 |
1 files changed, 36 insertions, 47 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index a62ec84..110f88d 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass | |||
@@ -4,6 +4,7 @@ inherit image | |||
4 | 4 | ||
5 | IMAGE_DEPENDS_ostree = "ostree-native:do_populate_sysroot \ | 5 | IMAGE_DEPENDS_ostree = "ostree-native:do_populate_sysroot \ |
6 | openssl-native:do_populate_sysroot \ | 6 | openssl-native:do_populate_sysroot \ |
7 | zip-native:do_populate_sysroot \ | ||
7 | virtual/kernel:do_deploy \ | 8 | virtual/kernel:do_deploy \ |
8 | ${OSTREE_INITRAMFS_IMAGE}:do_image_complete \ | 9 | ${OSTREE_INITRAMFS_IMAGE}:do_image_complete \ |
9 | unzip-native" | 10 | unzip-native" |
@@ -18,36 +19,6 @@ OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}" | |||
18 | 19 | ||
19 | export SYSTEMD_USED = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', '', d)}" | 20 | export SYSTEMD_USED = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', '', d)}" |
20 | 21 | ||
21 | python () { | ||
22 | if d.getVar("SOTA_PACKED_CREDENTIALS", True): | ||
23 | if d.getVar("SOTA_AUTOPROVISION_CREDENTIALS", True): | ||
24 | bb.warn("SOTA_AUTOPROVISION_CREDENTIALS are overriden by those in SOTA_PACKED_CREDENTIALS") | ||
25 | if d.getVar("SOTA_AUTOPROVISION_URL", True): | ||
26 | bb.warn("SOTA_AUTOPROVISION_URL is overriden by the one in SOTA_PACKED_CREDENTIALS") | ||
27 | |||
28 | if d.getVar("SOTA_AUTOPROVISION_URL_FILE", True): | ||
29 | bb.warn("SOTA_AUTOPROVISION_URL_FILE is overriden by the one in SOTA_PACKED_CREDENTIALS") | ||
30 | |||
31 | if d.getVar("OSTREE_PUSH_CREDENTIALS", True): | ||
32 | bb.warn("OSTREE_PUSH_CREDENTIALS are overriden by those in SOTA_PACKED_CREDENTIALS") | ||
33 | |||
34 | d.setVar("SOTA_AUTOPROVISION_CREDENTIALS", "%s/sota_credentials/autoprov_credentials.p12" % d.getVar("DEPLOY_DIR_IMAGE", True)) | ||
35 | d.setVar("SOTA_AUTOPROVISION_URL_FILE", "%s/sota_credentials/autoprov.url" % d.getVar("DEPLOY_DIR_IMAGE", True)) | ||
36 | d.setVar("OSTREE_PUSH_CREDENTIALS", "%s/sota_credentials/treehub.json" % d.getVar("DEPLOY_DIR_IMAGE", True)) | ||
37 | } | ||
38 | |||
39 | IMAGE_DEPENDS_ostreecredunpack = "unzip-native:do_populate_sysroot" | ||
40 | |||
41 | IMAGE_CMD_ostreecredunpack () { | ||
42 | if [ ${SOTA_PACKED_CREDENTIALS} ]; then | ||
43 | rm -rf ${DEPLOY_DIR_IMAGE}/sota_credentials | ||
44 | |||
45 | unzip ${SOTA_PACKED_CREDENTIALS} -d ${DEPLOY_DIR_IMAGE}/sota_credentials | ||
46 | fi | ||
47 | } | ||
48 | |||
49 | IMAGE_TYPEDEP_ostree = "ostreecredunpack" | ||
50 | |||
51 | IMAGE_CMD_ostree () { | 22 | IMAGE_CMD_ostree () { |
52 | if [ -z "$OSTREE_REPO" ]; then | 23 | if [ -z "$OSTREE_REPO" ]; then |
53 | bbfatal "OSTREE_REPO should be set in your local.conf" | 24 | bbfatal "OSTREE_REPO should be set in your local.conf" |
@@ -146,22 +117,33 @@ IMAGE_CMD_ostree () { | |||
146 | ln -sf var/roothome root | 117 | ln -sf var/roothome root |
147 | fi | 118 | fi |
148 | 119 | ||
149 | # deploy SOTA credentials | 120 | mkdir -p var/sota |
150 | if [ -n "${SOTA_AUTOPROVISION_CREDENTIALS}" ]; then | ||
151 | EXPDATE=`openssl pkcs12 -in ${SOTA_AUTOPROVISION_CREDENTIALS} -password "pass:" -nodes 2>/dev/null | openssl x509 -noout -enddate | cut -f2 -d "="` | ||
152 | 121 | ||
153 | if [ `date +%s` -ge `date -d "${EXPDATE}" +%s` ]; then | 122 | if [ -n "${SOTA_AUTOPROVISION_CREDENTIALS}" ]; then |
154 | bberror "Certificate ${SOTA_AUTOPROVISION_CREDENTIALS} has expired on ${EXPDATE}" | 123 | bbwarn "SOTA_AUTOPROVISION_CREDENTIALS are ignored. Please use SOTA_PACKED_CREDENTIALS" |
155 | fi | 124 | fi |
125 | if [ -n "${SOTA_AUTOPROVISION_URL}" ]; then | ||
126 | bbwarn "SOTA_AUTOPROVISION_URL is ignored. Please use SOTA_PACKED_CREDENTIALS" | ||
127 | fi | ||
128 | if [ -n "${SOTA_AUTOPROVISION_URL_FILE}" ]; then | ||
129 | bbwarn "SOTA_AUTOPROVISION_URL_FILE is ignored. Please use SOTA_PACKED_CREDENTIALS" | ||
130 | fi | ||
131 | if [ -n "${OSTREE_PUSH_CREDENTIALS}" ]; then | ||
132 | bbwarn "OSTREE_PUSH_CREDENTIALS is ignored. Please use SOTA_PACKED_CREDENTIALS" | ||
133 | fi | ||
156 | 134 | ||
157 | mkdir -p var/sota | 135 | # deploy SOTA credentials |
158 | cp ${SOTA_AUTOPROVISION_CREDENTIALS} var/sota/sota_provisioning_credentials.p12 | 136 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then |
159 | if [ -n "${SOTA_AUTOPROVISION_URL_FILE}" ]; then | 137 | if [ -e ${SOTA_PACKED_CREDENTIALS} ]; then |
160 | export SOTA_AUTOPROVISION_URL=`cat ${SOTA_AUTOPROVISION_URL_FILE}` | 138 | cp ${SOTA_PACKED_CREDENTIALS} var/sota/sota_provisioning_credentials.zip |
161 | fi | 139 | # Device should not be able to push data to treehub |
162 | echo "SOTA_GATEWAY_URI=${SOTA_AUTOPROVISION_URL}" > var/sota/sota_provisioning_url.env | 140 | zip -d var/sota/sota_provisioning_credentials.zip treehub.json |
141 | fi | ||
163 | fi | 142 | fi |
164 | 143 | ||
144 | if [ -n "${SOTA_SECONDARY_ECUS}" ]; then | ||
145 | cp ${SOTA_SECONDARY_ECUS} var/sota/ecus | ||
146 | fi | ||
165 | 147 | ||
166 | # Creating boot directories is required for "ostree admin deploy" | 148 | # Creating boot directories is required for "ostree admin deploy" |
167 | 149 | ||
@@ -204,10 +186,17 @@ IMAGE_CMD_ostree () { | |||
204 | IMAGE_TYPEDEP_ostreepush = "ostree" | 186 | IMAGE_TYPEDEP_ostreepush = "ostree" |
205 | IMAGE_DEPENDS_ostreepush = "sota-tools-native:do_populate_sysroot" | 187 | IMAGE_DEPENDS_ostreepush = "sota-tools-native:do_populate_sysroot" |
206 | IMAGE_CMD_ostreepush () { | 188 | IMAGE_CMD_ostreepush () { |
207 | if [ -n "${OSTREE_PUSH_CREDENTIALS}" ]; then | 189 | # Print warnings if credetials are not set or if the file has not been found. |
208 | garage-push --repo=${OSTREE_REPO} \ | 190 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then |
209 | --ref=${OSTREE_BRANCHNAME} \ | 191 | if [ -e ${SOTA_PACKED_CREDENTIALS} ]; then |
210 | --credentials=${OSTREE_PUSH_CREDENTIALS} \ | 192 | garage-push --repo=${OSTREE_REPO} \ |
211 | --cacert=${STAGING_ETCDIR_NATIVE}/ssl/certs/ca-certificates.crt | 193 | --ref=${OSTREE_BRANCHNAME} \ |
194 | --credentials=${SOTA_PACKED_CREDENTIALS} \ | ||
195 | --cacert=${STAGING_ETCDIR_NATIVE}/ssl/certs/ca-certificates.crt | ||
196 | else | ||
197 | bbwarn "SOTA_PACKED_CREDENTIALS file does not exist." | ||
198 | fi | ||
199 | else | ||
200 | bbwarn "SOTA_PACKED_CREDENTIALS not set. Please add SOTA_PACKED_CREDENTIALS." | ||
212 | fi | 201 | fi |
213 | } | 202 | } |