From 824e5a7c9c4241d0f32ee777768b00249b47ad8a Mon Sep 17 00:00:00 2001 From: Anton Gerasimov Date: Tue, 4 Sep 2018 16:56:01 +0200 Subject: Provide example for setting UPTANE target version automatically --- classes/image_types_ostree.bbclass | 4 +++- classes/image_types_ota.bbclass | 2 ++ classes/target_version_example.bbclass | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 classes/target_version_example.bbclass diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 3bf2d0e..bcbb648 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -193,7 +193,7 @@ IMAGE_CMD_ostreepush () { } IMAGE_TYPEDEP_garagesign = "ostreepush" -do_image_garage_sign[depends] += "aktualizr-native:do_populate_sysroot" +do_image_garagesign[depends] += "aktualizr-native:do_populate_sysroot" IMAGE_CMD_garagesign () { if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then # if credentials are issued by a server that doesn't support offline signing, exit silently @@ -219,6 +219,8 @@ IMAGE_CMD_garagesign () { target_version=${ostree_target_hash} if [ -n "${GARAGE_TARGET_VERSION}" ]; then target_version=${GARAGE_TARGET_VERSION} + elif [ -e "${STAGING_DATADIR_NATIVE}/target_version" ]; then + target_version=$(cat "${STAGING_DATADIR_NATIVE}/target_version") fi # Push may fail due to race condition when multiple build machines try to push simultaneously diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass index ed1d579..03fe8d8 100644 --- a/classes/image_types_ota.bbclass +++ b/classes/image_types_ota.bbclass @@ -115,6 +115,8 @@ fakeroot do_otasetup () { target_version=${ostree_target_hash} if [ -n "${GARAGE_TARGET_VERSION}" ]; then target_version=${GARAGE_TARGET_VERSION} + elif [ -e "${STAGING_DATADIR_NATIVE}/target_version" ]; then + target_version=$(cat "${STAGING_DATADIR_NATIVE}/target_version") fi mkdir -p ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota/import echo "{\"${ostree_target_hash}\":\"${GARAGE_TARGET_NAME}-${target_version}\"}" > ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota/import/installed_versions diff --git a/classes/target_version_example.bbclass b/classes/target_version_example.bbclass new file mode 100644 index 0000000..5adf159 --- /dev/null +++ b/classes/target_version_example.bbclass @@ -0,0 +1,11 @@ +# Writes uses repo manifest version as a target version +# + +HOSTTOOLS += " git " + +deploy_target_version () { + version=$(git --git-dir=${METADIR}/.repo/manifests/.git/ rev-parse HEAD) + echo -n ${version} > ${STAGING_DATADIR_NATIVE}/target_version +} + +IMAGE_PREPROCESS_COMMAND += "deploy_target_version;" -- cgit v1.2.3-54-g00ecf