summaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorAnton Gerasimov <anton.gerasimov@here.com>2018-09-04 16:56:01 +0200
committerAnton Gerasimov <anton.gerasimov@here.com>2018-10-09 16:11:04 +0200
commite2c03bd809ddefa9d164b5ba20f8d01957ce2f86 (patch)
tree5af6ddefbc57728185cd1a11226eb446262f80fb /classes
parent42972f0db05b4057a8c552cc10abfc8a634338be (diff)
downloadmeta-updater-e2c03bd809ddefa9d164b5ba20f8d01957ce2f86.tar.gz
Provide example for setting UPTANE target version automatically
Diffstat (limited to 'classes')
-rw-r--r--classes/image_types_ostree.bbclass4
-rw-r--r--classes/image_types_ota.bbclass2
-rw-r--r--classes/target_version_example.bbclass11
3 files changed, 16 insertions, 1 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass
index 95d1b59..1d43324 100644
--- a/classes/image_types_ostree.bbclass
+++ b/classes/image_types_ostree.bbclass
@@ -184,7 +184,7 @@ IMAGE_CMD_ostreepush () {
184} 184}
185 185
186IMAGE_TYPEDEP_garagesign = "ostreepush" 186IMAGE_TYPEDEP_garagesign = "ostreepush"
187do_image_garage_sign[depends] += "aktualizr-native:do_populate_sysroot" 187do_image_garagesign[depends] += "aktualizr-native:do_populate_sysroot"
188IMAGE_CMD_garagesign () { 188IMAGE_CMD_garagesign () {
189 if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then 189 if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then
190 # if credentials are issued by a server that doesn't support offline signing, exit silently 190 # if credentials are issued by a server that doesn't support offline signing, exit silently
@@ -210,6 +210,8 @@ IMAGE_CMD_garagesign () {
210 target_version=${ostree_target_hash} 210 target_version=${ostree_target_hash}
211 if [ -n "${GARAGE_TARGET_VERSION}" ]; then 211 if [ -n "${GARAGE_TARGET_VERSION}" ]; then
212 target_version=${GARAGE_TARGET_VERSION} 212 target_version=${GARAGE_TARGET_VERSION}
213 elif [ -e "${STAGING_DATADIR_NATIVE}/target_version" ]; then
214 target_version=$(cat "${STAGING_DATADIR_NATIVE}/target_version")
213 fi 215 fi
214 216
215 # Push may fail due to race condition when multiple build machines try to push simultaneously 217 # 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 4a51f24..df3bc7c 100644
--- a/classes/image_types_ota.bbclass
+++ b/classes/image_types_ota.bbclass
@@ -111,6 +111,8 @@ IMAGE_CMD_otaimg () {
111 target_version=${ostree_target_hash} 111 target_version=${ostree_target_hash}
112 if [ -n "${GARAGE_TARGET_VERSION}" ]; then 112 if [ -n "${GARAGE_TARGET_VERSION}" ]; then
113 target_version=${GARAGE_TARGET_VERSION} 113 target_version=${GARAGE_TARGET_VERSION}
114 elif [ -e "${STAGING_DATADIR_NATIVE}/target_version" ]; then
115 target_version=$(cat "${STAGING_DATADIR_NATIVE}/target_version")
114 fi 116 fi
115 mkdir -p ${PHYS_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota/import 117 mkdir -p ${PHYS_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota/import
116 echo "{\"${ostree_target_hash}\":\"${GARAGE_TARGET_NAME}-${target_version}\"}" > ${PHYS_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota/import/installed_versions 118 echo "{\"${ostree_target_hash}\":\"${GARAGE_TARGET_NAME}-${target_version}\"}" > ${PHYS_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 @@
1# Writes uses repo manifest version as a target version
2#
3
4HOSTTOOLS += " git "
5
6deploy_target_version () {
7 version=$(git --git-dir=${METADIR}/.repo/manifests/.git/ rev-parse HEAD)
8 echo -n ${version} > ${STAGING_DATADIR_NATIVE}/target_version
9}
10
11IMAGE_PREPROCESS_COMMAND += "deploy_target_version;"