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 12:04:05 +0200
commit8d300f28c5e5d69022aee31c24bee36426b45f7d (patch)
tree97a6a81f9c345bc5c3c03e96ab9a2a602cfd14c8
parent4e5a1d0299378487602af80bedd29febe9ff9cfb (diff)
downloadmeta-updater-8d300f28c5e5d69022aee31c24bee36426b45f7d.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 31f8d40..0c076c8 100644
--- a/classes/image_types_ostree.bbclass
+++ b/classes/image_types_ostree.bbclass
@@ -167,25 +167,19 @@ IMAGE_CMD_ostreecommit () {
167 fi 167 fi
168 168
169 # Commit the result 169 # Commit the result
170 ostree --repo=${OSTREE_REPO} commit \ 170 ostree_target_hash=$(ostree --repo=${OSTREE_REPO} commit \
171 --tree=dir=${OSTREE_ROOTFS} \ 171 --tree=dir=${OSTREE_ROOTFS} \
172 --skip-if-unchanged \ 172 --skip-if-unchanged \
173 --branch=${OSTREE_BRANCHNAME} \ 173 --branch=${OSTREE_BRANCHNAME} \
174 --subject="${OSTREE_COMMIT_SUBJECT}" \ 174 --subject="${OSTREE_COMMIT_SUBJECT}" \
175 --body="${OSTREE_COMMIT_BODY}" \ 175 --body="${OSTREE_COMMIT_BODY}" \
176 --add-metadata-string=version="${OSTREE_COMMIT_VERSION}" \ 176 --add-metadata-string=version="${OSTREE_COMMIT_VERSION}")
177 --bind-ref="${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}" 177
178 echo $ostree_target_hash > ${WORKDIR}/ostree_manifest
178 179
179 if [ ${@ oe.types.boolean('${OSTREE_UPDATE_SUMMARY}')} = True ]; then 180 if [ ${@ oe.types.boolean('${OSTREE_UPDATE_SUMMARY}')} = True ]; then
180 ostree --repo=${OSTREE_REPO} summary -u 181 ostree --repo=${OSTREE_REPO} summary -u
181 fi 182 fi
182
183 # To enable simultaneous bitbaking of two images with the same branch name,
184 # create a new ref in the repo using the basename of the image. (This first
185 # requires deleting it if it already exists.) Fixes OTA-2211.
186 ostree --repo=${OSTREE_REPO} refs --delete ${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}
187 ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME})
188 ostree --repo=${OSTREE_REPO} refs --create=${OSTREE_BRANCHNAME}-${IMAGE_BASENAME} ${ostree_target_hash}
189} 183}
190 184
191IMAGE_TYPEDEP_ostreepush = "ostreecommit" 185IMAGE_TYPEDEP_ostreepush = "ostreecommit"
@@ -235,7 +229,7 @@ IMAGE_CMD_garagesign () {
235 --home-dir ${GARAGE_SIGN_REPO} \ 229 --home-dir ${GARAGE_SIGN_REPO} \
236 --credentials ${SOTA_PACKED_CREDENTIALS} 230 --credentials ${SOTA_PACKED_CREDENTIALS}
237 231
238 ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) 232 ostree_target_hash=$(cat ${WORKDIR}/ostree_manifest)
239 233
240 # Use OSTree target hash as version if none was provided by the user 234 # Use OSTree target hash as version if none was provided by the user
241 target_version=${ostree_target_hash} 235 target_version=${ostree_target_hash}
@@ -311,7 +305,7 @@ IMAGE_CMD_garagecheck () {
311 # if credentials are issued by a server that doesn't support offline signing, exit silently 305 # if credentials are issued by a server that doesn't support offline signing, exit silently
312 unzip -p ${SOTA_PACKED_CREDENTIALS} root.json targets.pub targets.sec tufrepo.url 2>&1 >/dev/null || exit 0 306 unzip -p ${SOTA_PACKED_CREDENTIALS} root.json targets.pub targets.sec tufrepo.url 2>&1 >/dev/null || exit 0
313 307
314 ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) 308 ostree_target_hash=$(cat ${WORKDIR}/ostree_manifest)
315 309
316 garage-check --ref=${ostree_target_hash} \ 310 garage-check --ref=${ostree_target_hash} \
317 --credentials=${SOTA_PACKED_CREDENTIALS} \ 311 --credentials=${SOTA_PACKED_CREDENTIALS} \
diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass
index 374ddc2..56c7794 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=""