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 From 6c3f7564ea6fabdb6b882ef0a6f3d24af46979d0 Mon Sep 17 00:00:00 2001 From: Anton Gerasimov Date: Tue, 9 Oct 2018 16:09:19 +0200 Subject: Document version overriding and add warnings --- README.adoc | 10 ++++++++++ classes/image_types_ostree.bbclass | 2 ++ classes/target_version_example.bbclass | 3 +-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.adoc b/README.adoc index cccba9f..189a4d8 100644 --- a/README.adoc +++ b/README.adoc @@ -170,6 +170,16 @@ There are a few settings that can be controlled in `local.conf` to simplify the | `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. |====================== +=== Overriding target version +*Warning: overriding target version is a dangerous operation, make sure you understand this section completely before doing it.* + +Every 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: + +1. Set `GARAGE_TARGET_VERSION` variable in your `local.conf`. +2. 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`. + +Please 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 build one, the old package will be overwritten on the update server. It can have unpredictable effect on devices that have this version installed, 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 OSTree commit hash. + == QA with oe-selftest This 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 bcbb648..74282ef 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -219,8 +219,10 @@ IMAGE_CMD_garagesign () { target_version=${ostree_target_hash} if [ -n "${GARAGE_TARGET_VERSION}" ]; then target_version=${GARAGE_TARGET_VERSION} + 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" elif [ -e "${STAGING_DATADIR_NATIVE}/target_version" ]; then target_version=$(cat "${STAGING_DATADIR_NATIVE}/target_version") + 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" fi # Push may fail due to race condition when multiple build machines try to push simultaneously diff --git a/classes/target_version_example.bbclass b/classes/target_version_example.bbclass index 5adf159..ef119fb 100644 --- a/classes/target_version_example.bbclass +++ b/classes/target_version_example.bbclass @@ -1,5 +1,4 @@ -# Writes uses repo manifest version as a target version -# +# Writes target version to be used by garage-sign HOSTTOOLS += " git " -- cgit v1.2.3-54-g00ecf From c18824081b5d9d01337b3e33f5c78368b7fcf97b Mon Sep 17 00:00:00 2001 From: OYTIS Date: Fri, 12 Oct 2018 16:58:15 +0200 Subject: Fix typos/language --- README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index 189a4d8..e14d7bd 100644 --- a/README.adoc +++ b/README.adoc @@ -178,7 +178,7 @@ Every time you build an image with `SOTA_PACKED_CREDENTIALS` set, a new entry in 1. Set `GARAGE_TARGET_VERSION` variable in your `local.conf`. 2. 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`. -Please 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 build one, the old package will be overwritten on the update server. It can have unpredictable effect on devices that have this version installed, 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 OSTree commit hash. +Please 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. == QA with oe-selftest -- cgit v1.2.3-54-g00ecf From e9c39a028894b8ed2a38a922d5f905a42985aeb4 Mon Sep 17 00:00:00 2001 From: Patrick Vacek Date: Tue, 30 Oct 2018 11:48:49 +0100 Subject: Fix typos. --- CONTRIBUTING.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.adoc b/CONTRIBUTING.adoc index cd6e981..8f63245 100644 --- a/CONTRIBUTING.adoc +++ b/CONTRIBUTING.adoc @@ -14,7 +14,7 @@ If you are developing with meta-updater, it may be helpful to read the README an == Contributor checklist -* OTA-enabled build succeeds at least for one platform, the resulted image boots, and an update can be installed. This check is absolutely necessary for every pull request unless it only touches documentation. +* OTA-enabled build succeeds for at least one platform, the resulting image boots, and an update can be installed. This check is absolutely necessary for every pull request unless it only touches documentation. * If your change touches platform code (like `classes/sota_.bbclass`), please check building and updating on this particular platform. * oe-selftest succeeds. To test meta-updater, run `oe-selftest -r updater` from a build directory with `MACHINE` set to `qemux86-64`. * Updates are forwards- and backwards-compatible. You should be able to update an OTA-enabled build before the change is applied to the version with change applied and vice versa. One should pay double attention to the compatibility when bootloader code is affected. -- cgit v1.2.3-54-g00ecf