summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Luck <ben+qa@advancedtelematic.com>2018-10-30 11:37:15 +0100
committerGitHub <noreply@github.com>2018-10-30 11:37:15 +0100
commit405c54c8effd39f8bd8a6a77d3ecd298b5196f25 (patch)
treea7482e76a04cc32d19bbcaec52e26a963936ab46
parenta8ed681a86972b1dcd7fb61934a237163908af8a (diff)
parent145d2288dc1433002092673dd23291eb94acee04 (diff)
downloadmeta-updater-405c54c8effd39f8bd8a6a77d3ecd298b5196f25.tar.gz
Merge pull request #382 from advancedtelematic/feat/OTA-627/targetversion
Provide example for setting UPTANE target version automatically
-rw-r--r--README.adoc10
-rw-r--r--classes/image_types_ostree.bbclass6
-rw-r--r--classes/image_types_ota.bbclass2
-rw-r--r--classes/target_version_example.bbclass10
4 files changed, 27 insertions, 1 deletions
diff --git a/README.adoc b/README.adoc
index 703ea23..d648774 100644
--- a/README.adoc
+++ b/README.adoc
@@ -167,6 +167,16 @@ There are a few settings that can be controlled in `local.conf` to simplify the
167| `TOOLCHAIN_HOST_TASK_append = " nativesdk-cmake "` | Use with `bitbake -c populate_sdk core-image-minimal` to build an SDK. See the https://github.com/advancedtelematic/aktualizr#developing-against-an-openembedded-system[aktualizr repo] for more information. 167| `TOOLCHAIN_HOST_TASK_append = " nativesdk-cmake "` | Use with `bitbake -c populate_sdk core-image-minimal` to build an SDK. See the https://github.com/advancedtelematic/aktualizr#developing-against-an-openembedded-system[aktualizr repo] for more information.
168|====================== 168|======================
169 169
170=== Overriding target version
171*Warning: overriding target version is a dangerous operation, make sure you understand this section completely before doing it.*
172
173Every time you build an image with `SOTA_PACKED_CREDENTIALS` set, a new entry in your Uptane metadata is created and you can see it in the OTA Garage UI if you're using one. Normally this version will be equal to OSTree hash of your root file system. If you want it to be different though you can override is using one of two methods:
174
1751. Set `GARAGE_TARGET_VERSION` variable in your `local.conf`.
1762. Write a recipe or a bbclass to write the desired version to `${STAGING_DATADIR_NATIVE}/target_version`. An example of such bbclass can be found in `classes/target_version_example.bbclass`.
177
178Please note that [target name, target version] pairs are expected to be unique in the system. If you build a new target with the same target version as a previously built one, the old package will be overwritten on the update server. It can have unpredictable effect on devices that have this version installed, and it is not guaranteed that information will be reported correctly for such devices or that you will be able to update them (we're doing our best though). The easiest way to avoid problems is to make sure that your overriding version is as unique as an OSTree commit hash.
179
170== QA with oe-selftest 180== QA with oe-selftest
171 181
172This layer relies on the test framework oe-selftest for quality assurance. Follow the steps below to run the tests: 182This layer relies on the test framework oe-selftest for quality assurance. Follow the steps below to run the tests:
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass
index 95d1b59..5a17096 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,10 @@ 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 bbwarn "Target version is overriden with GARAGE_TARGET_VERSION variable. It is a dangerous operation, make sure you've read the respective secion in meta-updater/README.adoc"
214 elif [ -e "${STAGING_DATADIR_NATIVE}/target_version" ]; then
215 target_version=$(cat "${STAGING_DATADIR_NATIVE}/target_version")
216 bbwarn "Target version is overriden with target_version file. It is a dangerous operation, make sure you've read the respective secion in meta-updater/README.adoc"
213 fi 217 fi
214 218
215 # Push may fail due to race condition when multiple build machines try to push simultaneously 219 # 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..ef119fb
--- /dev/null
+++ b/classes/target_version_example.bbclass
@@ -0,0 +1,10 @@
1# Writes target version to be used by garage-sign
2
3HOSTTOOLS += " git "
4
5deploy_target_version () {
6 version=$(git --git-dir=${METADIR}/.repo/manifests/.git/ rev-parse HEAD)
7 echo -n ${version} > ${STAGING_DATADIR_NATIVE}/target_version
8}
9
10IMAGE_PREPROCESS_COMMAND += "deploy_target_version;"