From fbabfa932a18332ea0e929f5ca733814bac84294 Mon Sep 17 00:00:00 2001 From: Patrick Vacek Date: Thu, 21 Feb 2019 16:27:44 +0100 Subject: image_types_ostree: Add a unique ref to fix simultaneous bitbaking. To enable simultaneous bitbaking of two images with the same branch name, create a new ref in the OSTree repo using the basename of the image. As @OYTIS has pointed out, this probably won't solve every problem that might come up with simultaneous bitbaking, such as if the two images use different bootloaders. However, it does solve the immediate problem that comes up with our primary-image + secondary-image example. Signed-off-by: Patrick Vacek --- classes/image_types_ostree.bbclass | 12 ++++++++++-- classes/image_types_ota.bbclass | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 29da78e..41327e1 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -148,6 +148,13 @@ IMAGE_CMD_ostreecommit () { if [ "${OSTREE_UPDATE_SUMMARY}" = "1" ]; then ostree --repo=${OSTREE_REPO} summary -u fi + + # To enable simultaneous bitbaking of two images with the same branch name, + # create a new ref in the repo using the basename of the image. (This first + # requires deleting it if it already exists.) Fixes OTA-2211. + ostree --repo=${OSTREE_REPO} refs --delete ${OSTREE_BRANCHNAME}-${IMAGE_BASENAME} + ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}) + ostree --repo=${OSTREE_REPO} refs --create=${OSTREE_BRANCHNAME}-${IMAGE_BASENAME} ${ostree_target_hash} } IMAGE_TYPEDEP_ostreepush = "ostreecommit" @@ -190,7 +197,7 @@ IMAGE_CMD_garagesign () { --home-dir ${GARAGE_SIGN_REPO} \ --credentials ${SOTA_PACKED_CREDENTIALS} - ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}) + ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) # Use OSTree target hash as version if none was provided by the user target_version=${ostree_target_hash} @@ -243,7 +250,8 @@ IMAGE_CMD_garagecheck () { if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then # if credentials are issued by a server that doesn't support offline signing, exit silently unzip -p ${SOTA_PACKED_CREDENTIALS} root.json targets.pub targets.sec tufrepo.url 2>&1 >/dev/null || exit 0 - ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}) + + ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) garage-check --ref=${ostree_target_hash} \ --credentials=${SOTA_PACKED_CREDENTIALS} \ diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass index a31cbd1..12375ec 100644 --- a/classes/image_types_ota.bbclass +++ b/classes/image_types_ota.bbclass @@ -59,7 +59,7 @@ IMAGE_CMD_ota () { bbfatal "Invalid bootloader: ${OSTREE_BOOTLOADER}" fi - ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}) + ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) ostree --repo=${OTA_SYSROOT}/ostree/repo pull-local --remote=${OSTREE_OSNAME} ${OSTREE_REPO} ${ostree_target_hash} kargs_list="" -- cgit v1.2.3-54-g00ecf