diff options
| author | Anton Gerasimov <anton.gerasimov@here.com> | 2018-09-04 16:56:01 +0200 |
|---|---|---|
| committer | Patrick Vacek <patrickvacek@gmail.com> | 2018-10-31 13:34:37 +0100 |
| commit | e65e6dd24d0114158a7eb02a36d31dab845bac3d (patch) | |
| tree | 07d1f4b6f3a48dd4736e94e7c3f7425f46b225f7 | |
| parent | fdbf88415985ac4543bdf8737cc4607e489fa04f (diff) | |
| download | meta-updater-e65e6dd24d0114158a7eb02a36d31dab845bac3d.tar.gz | |
Provide example for setting UPTANE target version automatically
| -rw-r--r-- | classes/image_types_ostree.bbclass | 4 | ||||
| -rw-r--r-- | classes/image_types_ota.bbclass | 2 | ||||
| -rw-r--r-- | classes/target_version_example.bbclass | 11 |
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 | ||
| 186 | IMAGE_TYPEDEP_garagesign = "ostreepush" | 186 | IMAGE_TYPEDEP_garagesign = "ostreepush" |
| 187 | do_image_garage_sign[depends] += "aktualizr-native:do_populate_sysroot" | 187 | do_image_garagesign[depends] += "aktualizr-native:do_populate_sysroot" |
| 188 | IMAGE_CMD_garagesign () { | 188 | IMAGE_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 | |||
| 4 | HOSTTOOLS += " git " | ||
| 5 | |||
| 6 | deploy_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 | |||
| 11 | IMAGE_PREPROCESS_COMMAND += "deploy_target_version;" | ||
