summaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorPatrick Vacek <patrickvacek@gmail.com>2017-07-19 14:05:48 +0200
committerPatrick Vacek <patrickvacek@gmail.com>2017-08-07 17:01:39 +0200
commit53307024e1845c4717be7eb8b8735e493ec4535d (patch)
treee1baf988680d73c92635756b2c35f8b1a78e3dd3 /classes
parent34d5f757a86a7e8e1db3e19f2fb33e90e3f33584 (diff)
downloadmeta-updater-53307024e1845c4717be7eb8b8735e493ec4535d.tar.gz
Call garage-push directly with zip file instead of sending unzipped contents.
Warn if older credential environment variables are set. They are now ignored since the credentials aren't unpacked during building.
Diffstat (limited to 'classes')
-rw-r--r--classes/image_types_ostree.bbclass59
1 files changed, 16 insertions, 43 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass
index ac7cb60..d01cb9f 100644
--- a/classes/image_types_ostree.bbclass
+++ b/classes/image_types_ostree.bbclass
@@ -17,36 +17,6 @@ OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}"
17 17
18export SYSTEMD_USED = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', '', d)}" 18export SYSTEMD_USED = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', '', d)}"
19 19
20python () {
21 if d.getVar("SOTA_PACKED_CREDENTIALS", True):
22 if d.getVar("SOTA_AUTOPROVISION_CREDENTIALS", True):
23 bb.warn("SOTA_AUTOPROVISION_CREDENTIALS are overriden by those in SOTA_PACKED_CREDENTIALS")
24 if d.getVar("SOTA_AUTOPROVISION_URL", True):
25 bb.warn("SOTA_AUTOPROVISION_URL is overriden by the one in SOTA_PACKED_CREDENTIALS")
26
27 if d.getVar("SOTA_AUTOPROVISION_URL_FILE", True):
28 bb.warn("SOTA_AUTOPROVISION_URL_FILE is overriden by the one in SOTA_PACKED_CREDENTIALS")
29
30 if d.getVar("OSTREE_PUSH_CREDENTIALS", True):
31 bb.warn("OSTREE_PUSH_CREDENTIALS are overriden by those in SOTA_PACKED_CREDENTIALS")
32
33 d.setVar("SOTA_AUTOPROVISION_CREDENTIALS", "%s/sota_credentials/autoprov_credentials.p12" % d.getVar("DEPLOY_DIR_IMAGE", True))
34 d.setVar("SOTA_AUTOPROVISION_URL_FILE", "%s/sota_credentials/autoprov.url" % d.getVar("DEPLOY_DIR_IMAGE", True))
35 d.setVar("OSTREE_PUSH_CREDENTIALS", "%s/sota_credentials/treehub.json" % d.getVar("DEPLOY_DIR_IMAGE", True))
36}
37
38IMAGE_DEPENDS_ostreecredunpack = "unzip-native:do_populate_sysroot"
39
40IMAGE_CMD_ostreecredunpack () {
41 if [ ${SOTA_PACKED_CREDENTIALS} ]; then
42 rm -rf ${DEPLOY_DIR_IMAGE}/sota_credentials
43
44 unzip ${SOTA_PACKED_CREDENTIALS} -d ${DEPLOY_DIR_IMAGE}/sota_credentials
45 fi
46}
47
48IMAGE_TYPEDEP_ostree = "ostreecredunpack"
49
50IMAGE_CMD_ostree () { 20IMAGE_CMD_ostree () {
51 if [ -z "$OSTREE_REPO" ]; then 21 if [ -z "$OSTREE_REPO" ]; then
52 bbfatal "OSTREE_REPO should be set in your local.conf" 22 bbfatal "OSTREE_REPO should be set in your local.conf"
@@ -145,21 +115,24 @@ IMAGE_CMD_ostree () {
145 ln -sf var/roothome root 115 ln -sf var/roothome root
146 fi 116 fi
147 117
148 # deploy SOTA credentials
149 mkdir -p var/sota 118 mkdir -p var/sota
150 119
151 if [ -n "${SOTA_AUTOPROVISION_CREDENTIALS}" ]; then 120 if [ -n "${SOTA_AUTOPROVISION_CREDENTIALS}" ]; then
152 EXPDATE=`openssl pkcs12 -in ${SOTA_AUTOPROVISION_CREDENTIALS} -password "pass:" -nodes 2>/dev/null | openssl x509 -noout -enddate | cut -f2 -d "="` 121 bbwarn "SOTA_AUTOPROVISION_CREDENTIALS are ignored. Please use SOTA_PACKED_CREDENTIALS"
153 122 fi
154 if [ `date +%s` -ge `date -d "${EXPDATE}" +%s` ]; then 123 if [ -n "${SOTA_AUTOPROVISION_URL}" ]; then
155 bberror "Certificate ${SOTA_AUTOPROVISION_CREDENTIALS} has expired on ${EXPDATE}" 124 bbwarn "SOTA_AUTOPROVISION_URL is ignored. Please use SOTA_PACKED_CREDENTIALS"
156 fi 125 fi
126 if [ -n "${SOTA_AUTOPROVISION_URL_FILE}" ]; then
127 bbwarn "SOTA_AUTOPROVISION_URL_FILE is ignored. Please use SOTA_PACKED_CREDENTIALS"
128 fi
129 if [ -n "${OSTREE_PUSH_CREDENTIALS}" ]; then
130 bbwarn "OSTREE_PUSH_CREDENTIALS is ignored. Please use SOTA_PACKED_CREDENTIALS"
131 fi
157 132
158 cp ${SOTA_AUTOPROVISION_CREDENTIALS} var/sota/sota_provisioning_credentials.p12 133 # deploy SOTA credentials
159 if [ -n "${SOTA_AUTOPROVISION_URL_FILE}" ]; then 134 if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then
160 export SOTA_AUTOPROVISION_URL=`cat ${SOTA_AUTOPROVISION_URL_FILE}` 135 cp ${SOTA_PACKED_CREDENTIALS} var/sota/sota_provisioning_credentials.zip
161 fi
162 echo "SOTA_GATEWAY_URI=${SOTA_AUTOPROVISION_URL}" > var/sota/sota_provisioning_url.env
163 fi 136 fi
164 137
165 if [ -n "${SOTA_SECONDARY_ECUS}" ]; then 138 if [ -n "${SOTA_SECONDARY_ECUS}" ]; then
@@ -207,10 +180,10 @@ IMAGE_CMD_ostree () {
207IMAGE_TYPEDEP_ostreepush = "ostree" 180IMAGE_TYPEDEP_ostreepush = "ostree"
208IMAGE_DEPENDS_ostreepush = "sota-tools-native:do_populate_sysroot" 181IMAGE_DEPENDS_ostreepush = "sota-tools-native:do_populate_sysroot"
209IMAGE_CMD_ostreepush () { 182IMAGE_CMD_ostreepush () {
210 if [ -n "${OSTREE_PUSH_CREDENTIALS}" ]; then 183 if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then
211 garage-push --repo=${OSTREE_REPO} \ 184 garage-push --repo=${OSTREE_REPO} \
212 --ref=${OSTREE_BRANCHNAME} \ 185 --ref=${OSTREE_BRANCHNAME} \
213 --credentials=${OSTREE_PUSH_CREDENTIALS} \ 186 --credentials=${SOTA_PACKED_CREDENTIALS} \
214 --cacert=${STAGING_ETCDIR_NATIVE}/ssl/certs/ca-certificates.crt 187 --cacert=${STAGING_ETCDIR_NATIVE}/ssl/certs/ca-certificates.crt
215 fi 188 fi
216} 189}