summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2020-04-28 16:28:14 +0000
committerLaurent Bonnans <laurent.bonnans@here.com>2020-06-02 15:28:09 +0200
commit4c6b5a1cae4195068c5751453611542a2e355669 (patch)
tree83e55fcc98885e24e30d7f86a24a91fcf799ab12
parent6ea2ffb1075d35f062acbfaa9d6b090dfcb152b4 (diff)
downloadmeta-updater-4c6b5a1cae4195068c5751453611542a2e355669.tar.gz
image_types_ostree/ota: use hash from ostree commit
Relying on a OSTree branch reference has been problematic in the past and addressed by adding more attributes to it in commit 202a8c70ba8c ("image_types_ostree: Add a unique ref to fix simultaneous bitbaking."). However, depening on what kind of OpenEmbedded builds are running in parallel, even more attributes would need to be taken into account. Instead of relying on a reference, store the exact ostree commit hash in a manifest file and reuse it in the do_image_ota deploy task. This guarantees that the correct reference gets picked even when two builds with the exact same machine/image name run in parallel. Note: This gets rid of the second branch name again. If the branch name with image name is preferred, the variable OSTREE_BRANCHNAME can be used: OSTREE_BRANCHNAME = "${SOTA_HARDWARE_ID}-${IMAGE_BASENAME}" Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
-rw-r--r--classes/image_types_ostree.bbclass18
-rw-r--r--classes/image_types_ota.bbclass2
2 files changed, 7 insertions, 13 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass
index 4b27f34..3e67043 100644
--- a/classes/image_types_ostree.bbclass
+++ b/classes/image_types_ostree.bbclass
@@ -169,25 +169,19 @@ IMAGE_CMD_ostreecommit () {
169 fi 169 fi
170 170
171 # Commit the result 171 # Commit the result
172 ostree --repo=${OSTREE_REPO} commit \ 172 ostree_target_hash=$(ostree --repo=${OSTREE_REPO} commit \
173 --tree=dir=${OSTREE_ROOTFS} \ 173 --tree=dir=${OSTREE_ROOTFS} \
174 --skip-if-unchanged \ 174 --skip-if-unchanged \
175 --branch=${OSTREE_BRANCHNAME} \ 175 --branch=${OSTREE_BRANCHNAME} \
176 --subject="${OSTREE_COMMIT_SUBJECT}" \ 176 --subject="${OSTREE_COMMIT_SUBJECT}" \
177 --body="${OSTREE_COMMIT_BODY}" \ 177 --body="${OSTREE_COMMIT_BODY}" \
178 --add-metadata-string=version="${OSTREE_COMMIT_VERSION}" \ 178 --add-metadata-string=version="${OSTREE_COMMIT_VERSION}")
179 --bind-ref="${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}" 179
180 echo $ostree_target_hash > ${WORKDIR}/ostree_manifest
180 181
181 if [ ${@ oe.types.boolean('${OSTREE_UPDATE_SUMMARY}')} = True ]; then 182 if [ ${@ oe.types.boolean('${OSTREE_UPDATE_SUMMARY}')} = True ]; then
182 ostree --repo=${OSTREE_REPO} summary -u 183 ostree --repo=${OSTREE_REPO} summary -u
183 fi 184 fi
184
185 # To enable simultaneous bitbaking of two images with the same branch name,
186 # create a new ref in the repo using the basename of the image. (This first
187 # requires deleting it if it already exists.) Fixes OTA-2211.
188 ostree --repo=${OSTREE_REPO} refs --delete ${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}
189 ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME})
190 ostree --repo=${OSTREE_REPO} refs --create=${OSTREE_BRANCHNAME}-${IMAGE_BASENAME} ${ostree_target_hash}
191} 185}
192 186
193IMAGE_TYPEDEP_ostreepush = "ostreecommit" 187IMAGE_TYPEDEP_ostreepush = "ostreecommit"
@@ -237,7 +231,7 @@ IMAGE_CMD_garagesign () {
237 --home-dir ${GARAGE_SIGN_REPO} \ 231 --home-dir ${GARAGE_SIGN_REPO} \
238 --credentials ${SOTA_PACKED_CREDENTIALS} 232 --credentials ${SOTA_PACKED_CREDENTIALS}
239 233
240 ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) 234 ostree_target_hash=$(cat ${WORKDIR}/ostree_manifest)
241 235
242 # Use OSTree target hash as version if none was provided by the user 236 # Use OSTree target hash as version if none was provided by the user
243 target_version=${ostree_target_hash} 237 target_version=${ostree_target_hash}
@@ -313,7 +307,7 @@ IMAGE_CMD_garagecheck () {
313 # if credentials are issued by a server that doesn't support offline signing, exit silently 307 # if credentials are issued by a server that doesn't support offline signing, exit silently
314 unzip -p ${SOTA_PACKED_CREDENTIALS} root.json targets.pub targets.sec tufrepo.url 2>&1 >/dev/null || exit 0 308 unzip -p ${SOTA_PACKED_CREDENTIALS} root.json targets.pub targets.sec tufrepo.url 2>&1 >/dev/null || exit 0
315 309
316 ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) 310 ostree_target_hash=$(cat ${WORKDIR}/ostree_manifest)
317 311
318 garage-check --ref=${ostree_target_hash} \ 312 garage-check --ref=${ostree_target_hash} \
319 --credentials=${SOTA_PACKED_CREDENTIALS} \ 313 --credentials=${SOTA_PACKED_CREDENTIALS} \
diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass
index 8f5a01a..17be0ee 100644
--- a/classes/image_types_ota.bbclass
+++ b/classes/image_types_ota.bbclass
@@ -64,7 +64,7 @@ IMAGE_CMD_ota () {
64 bbfatal "Invalid bootloader: ${OSTREE_BOOTLOADER}" 64 bbfatal "Invalid bootloader: ${OSTREE_BOOTLOADER}"
65 fi 65 fi
66 66
67 ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) 67 ostree_target_hash=$(cat ${WORKDIR}/ostree_manifest)
68 68
69 ostree --repo=${OTA_SYSROOT}/ostree/repo pull-local --remote=${OSTREE_OSNAME} ${OSTREE_REPO} ${ostree_target_hash} 69 ostree --repo=${OTA_SYSROOT}/ostree/repo pull-local --remote=${OSTREE_OSNAME} ${OSTREE_REPO} ${ostree_target_hash}
70 kargs_list="" 70 kargs_list=""