From e56b232da52f1ca98a28ff67eed9e324dd1e487a Mon Sep 17 00:00:00 2001 From: Mike Sul Date: Tue, 19 Feb 2019 16:33:09 +0200 Subject: OTA-2135: Aktualizr's config and recipe to auto reboot just after update Signed-off-by: Mike Sul --- recipes-sota/config/aktualizr-auto-reboot.bb | 21 +++++++++++++++++++++ .../config/files/35-enable-auto-reboot.toml | 2 ++ 2 files changed, 23 insertions(+) create mode 100644 recipes-sota/config/aktualizr-auto-reboot.bb create mode 100644 recipes-sota/config/files/35-enable-auto-reboot.toml diff --git a/recipes-sota/config/aktualizr-auto-reboot.bb b/recipes-sota/config/aktualizr-auto-reboot.bb new file mode 100644 index 0000000..1317fd4 --- /dev/null +++ b/recipes-sota/config/aktualizr-auto-reboot.bb @@ -0,0 +1,21 @@ +SUMMARY = "Enable auto reboot to apply updates" +DESCRIPTION = "Configures aktualizr to auto reboot just after new updates installation in order to apply them" +HOMEPAGE = "https://github.com/advancedtelematic/aktualizr" +SECTION = "base" +LICENSE = "MPL-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad" + +SRC_URI = " \ + file://35-enable-auto-reboot.toml \ + " + +do_install_append () { + install -m 0700 -d ${D}${libdir}/sota/conf.d + install -m 0644 ${WORKDIR}/35-enable-auto-reboot.toml ${D}${libdir}/sota/conf.d/35-enable-auto-reboot.toml +} + +FILES_${PN} = " \ + ${libdir}/sota/conf.d/35-enable-auto-reboot.toml \ + " + +# vim:set ts=4 sw=4 sts=4 expandtab: diff --git a/recipes-sota/config/files/35-enable-auto-reboot.toml b/recipes-sota/config/files/35-enable-auto-reboot.toml new file mode 100644 index 0000000..f83810e --- /dev/null +++ b/recipes-sota/config/files/35-enable-auto-reboot.toml @@ -0,0 +1,2 @@ +[uptane] +force_install_completion = true -- cgit v1.2.3-54-g00ecf From 161c2da71b85e85f79bab8c54a02ee9587094b63 Mon Sep 17 00:00:00 2001 From: Patrick Vacek Date: Thu, 21 Feb 2019 16:27:44 +0100 Subject: image_types_ostree: Add a unique ref to fix simultaneous bitbaking. To enable simultaneous bitbaking of two images with the same branch name, create a new ref in the OSTree repo using the basename of the image. As @OYTIS has pointed out, this probably won't solve every problem that might come up with simultaneous bitbaking, such as if the two images use different bootloaders. However, it does solve the immediate problem that comes up with our primary-image + secondary-image example. Signed-off-by: Patrick Vacek --- classes/image_types_ostree.bbclass | 12 ++++++++++-- classes/image_types_ota.bbclass | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 97290ac..f3b1b33 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -159,6 +159,13 @@ IMAGE_CMD_ostree () { ostree --repo=${OSTREE_REPO} summary -u fi + # To enable simultaneous bitbaking of two images with the same branch name, + # create a new ref in the repo using the basename of the image. (This first + # requires deleting it if it already exists.) Fixes OTA-2211. + ostree --repo=${OSTREE_REPO} refs --delete ${OSTREE_BRANCHNAME}-${IMAGE_BASENAME} + ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}) + ostree --repo=${OSTREE_REPO} refs --create=${OSTREE_BRANCHNAME}-${IMAGE_BASENAME} ${ostree_target_hash} + rm -rf ${OSTREE_ROOTFS} } @@ -202,7 +209,7 @@ IMAGE_CMD_garagesign () { --home-dir ${GARAGE_SIGN_REPO} \ --credentials ${SOTA_PACKED_CREDENTIALS} - ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}) + ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) # Use OSTree target hash as version if none was provided by the user target_version=${ostree_target_hash} @@ -255,7 +262,8 @@ IMAGE_CMD_garagecheck () { if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then # if credentials are issued by a server that doesn't support offline signing, exit silently unzip -p ${SOTA_PACKED_CREDENTIALS} root.json targets.pub targets.sec tufrepo.url 2>&1 >/dev/null || exit 0 - ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}) + + ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) garage-check --ref=${ostree_target_hash} \ --credentials=${SOTA_PACKED_CREDENTIALS} \ diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass index 88f5b2c..068d43e 100644 --- a/classes/image_types_ota.bbclass +++ b/classes/image_types_ota.bbclass @@ -77,7 +77,7 @@ IMAGE_CMD_otaimg () { bbfatal "Invalid bootloader: ${OSTREE_BOOTLOADER}" fi - ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}) + ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) ostree --repo=${PHYS_SYSROOT}/ostree/repo pull-local --remote=${OSTREE_OSNAME} ${OSTREE_REPO} ${ostree_target_hash} kargs_list="" -- cgit v1.2.3-54-g00ecf From 350be04fa412a0770f67e0ab75807094fe531a9e Mon Sep 17 00:00:00 2001 From: Patrick Vacek Date: Thu, 21 Feb 2019 17:22:50 +0100 Subject: aktualizr-auto-prov-creds: remove API Gateway URL if it exists. It will only be used by garage-sign. Signed-off-by: Patrick Vacek --- recipes-sota/aktualizr/aktualizr-auto-prov-creds.bb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/recipes-sota/aktualizr/aktualizr-auto-prov-creds.bb b/recipes-sota/aktualizr/aktualizr-auto-prov-creds.bb index 34460af..0628a61 100644 --- a/recipes-sota/aktualizr/aktualizr-auto-prov-creds.bb +++ b/recipes-sota/aktualizr/aktualizr-auto-prov-creds.bb @@ -11,9 +11,14 @@ require credentials.inc do_install() { if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then install -m 0700 -d ${D}${localstatedir}/sota - cp ${SOTA_PACKED_CREDENTIALS} ${D}${localstatedir}/sota/sota_provisioning_credentials.zip + cp "${SOTA_PACKED_CREDENTIALS}" ${D}${localstatedir}/sota/sota_provisioning_credentials.zip # Device should not be able to push data to treehub zip -d ${D}${localstatedir}/sota/sota_provisioning_credentials.zip treehub.json + # Device has no use for the API Gateway. Remove if present. See: + # https://github.com/advancedtelematic/ota-plus-server/pull/1913/ + if unzip -l ${D}${localstatedir}/sota/sota_provisioning_credentials.zip api_gateway.url > /dev/null; then + zip -d ${D}${localstatedir}/sota/sota_provisioning_credentials.zip api_gateway.url + fi fi } -- cgit v1.2.3-54-g00ecf From 2884654ede6cbfeb82eddb472e71a05f823eb8f9 Mon Sep 17 00:00:00 2001 From: Mike Sul Date: Tue, 26 Feb 2019 11:16:36 +0200 Subject: Switch to the aktualizr's master head Signed-off-by: Mike Sul --- recipes-sota/aktualizr/aktualizr_git.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes-sota/aktualizr/aktualizr_git.bb b/recipes-sota/aktualizr/aktualizr_git.bb index ed6a760..fef12b8 100755 --- a/recipes-sota/aktualizr/aktualizr_git.bb +++ b/recipes-sota/aktualizr/aktualizr_git.bb @@ -23,7 +23,7 @@ SRC_URI = " \ file://aktualizr-serialcan.service \ " -SRCREV = "2aa9d93ccea09ec327789eecf858de561ef632da" +SRCREV = "c71ec0a320d85a3e75ba37bff7dc40ad02e9d655" BRANCH ?= "master" S = "${WORKDIR}/git" -- cgit v1.2.3-54-g00ecf From 9df740e77427adbed6e7156b01cc475962936063 Mon Sep 17 00:00:00 2001 From: Patrick Vacek Date: Tue, 26 Feb 2019 11:19:15 +0100 Subject: Reformat default bblayers. Put each item on its own line to make versioning and manual modififcation easier going forward. Signed-off-by: Patrick Vacek --- conf/include/bblayers/sota_am335x-evm.inc | 3 +-- conf/include/bblayers/sota_intel-corei7-64.inc | 4 ++-- conf/include/bblayers/sota_m3ulcb.inc | 5 +++-- conf/include/bblayers/sota_porter.inc | 6 ++++-- conf/include/bblayers/sota_qemux86-64.inc | 2 +- conf/include/bblayers/sota_raspberrypi2.inc | 6 +++--- conf/include/bblayers/sota_raspberrypi3.inc | 6 +++--- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/conf/include/bblayers/sota_am335x-evm.inc b/conf/include/bblayers/sota_am335x-evm.inc index f2d485d..909a7a4 100644 --- a/conf/include/bblayers/sota_am335x-evm.inc +++ b/conf/include/bblayers/sota_am335x-evm.inc @@ -1,2 +1 @@ - -BBLAYERS += " ${METADIR}/meta-ti " +BBLAYERS += "${METADIR}/meta-ti" diff --git a/conf/include/bblayers/sota_intel-corei7-64.inc b/conf/include/bblayers/sota_intel-corei7-64.inc index 1771e6c..8e85a6c 100644 --- a/conf/include/bblayers/sota_intel-corei7-64.inc +++ b/conf/include/bblayers/sota_intel-corei7-64.inc @@ -1,2 +1,2 @@ - -BBLAYERS += " ${METADIR}/meta-updater-minnowboard ${METADIR}/meta-intel " +BBLAYERS += "${METADIR}/meta-updater-minnowboard" +BBLAYERS += "${METADIR}/meta-intel" diff --git a/conf/include/bblayers/sota_m3ulcb.inc b/conf/include/bblayers/sota_m3ulcb.inc index 04f78e4..4f2e0a9 100644 --- a/conf/include/bblayers/sota_m3ulcb.inc +++ b/conf/include/bblayers/sota_m3ulcb.inc @@ -1,2 +1,3 @@ - -BBLAYERS += " ${METADIR}/meta-renesas ${METADIR}/meta-renesas-rcar-gen3 ${METADIR}/meta-openembedded/meta-multimedia" +BBLAYERS += "${METADIR}/meta-renesas" +BBLAYERS += "${METADIR}/meta-renesas-rcar-gen3" +BBLAYERS += "${METADIR}/meta-openembedded/meta-multimedia" diff --git a/conf/include/bblayers/sota_porter.inc b/conf/include/bblayers/sota_porter.inc index 6964ef0..a50b71c 100644 --- a/conf/include/bblayers/sota_porter.inc +++ b/conf/include/bblayers/sota_porter.inc @@ -1,2 +1,4 @@ - -BBLAYERS += " ${METADIR}/meta-renesas ${METADIR}/meta-renesas/meta-rcar-gen2 ${METADIR}/meta-openembedded/meta-multimedia ${METADIR}/meta-updater-porter" +BBLAYERS += "${METADIR}/meta-renesas" +BBLAYERS += "${METADIR}/meta-renesas/meta-rcar-gen2" +BBLAYERS += "${METADIR}/meta-openembedded/meta-multimedia" +BBLAYERS += "${METADIR}/meta-updater-porter" diff --git a/conf/include/bblayers/sota_qemux86-64.inc b/conf/include/bblayers/sota_qemux86-64.inc index 12d32ff..9ccbfa6 100644 --- a/conf/include/bblayers/sota_qemux86-64.inc +++ b/conf/include/bblayers/sota_qemux86-64.inc @@ -1 +1 @@ -BBLAYERS += " ${METADIR}/meta-updater-qemux86-64 " +BBLAYERS += "${METADIR}/meta-updater-qemux86-64" diff --git a/conf/include/bblayers/sota_raspberrypi2.inc b/conf/include/bblayers/sota_raspberrypi2.inc index cc26679..03f8f44 100644 --- a/conf/include/bblayers/sota_raspberrypi2.inc +++ b/conf/include/bblayers/sota_raspberrypi2.inc @@ -1,3 +1,3 @@ -BBLAYERS += " ${METADIR}/meta-openembedded/meta-python " - -BBLAYERS += " ${METADIR}/meta-updater-raspberrypi ${METADIR}/meta-raspberrypi " +BBLAYERS += "${METADIR}/meta-openembedded/meta-python" +BBLAYERS += "${METADIR}/meta-updater-raspberrypi" +BBLAYERS += "${METADIR}/meta-raspberrypi" diff --git a/conf/include/bblayers/sota_raspberrypi3.inc b/conf/include/bblayers/sota_raspberrypi3.inc index cc26679..03f8f44 100644 --- a/conf/include/bblayers/sota_raspberrypi3.inc +++ b/conf/include/bblayers/sota_raspberrypi3.inc @@ -1,3 +1,3 @@ -BBLAYERS += " ${METADIR}/meta-openembedded/meta-python " - -BBLAYERS += " ${METADIR}/meta-updater-raspberrypi ${METADIR}/meta-raspberrypi " +BBLAYERS += "${METADIR}/meta-openembedded/meta-python" +BBLAYERS += "${METADIR}/meta-updater-raspberrypi" +BBLAYERS += "${METADIR}/meta-raspberrypi" -- cgit v1.2.3-54-g00ecf From 0d0eb4bd090cbb76b3cd61d1ff44cfb9759d6634 Mon Sep 17 00:00:00 2001 From: Patrick Vacek Date: Tue, 26 Feb 2019 11:13:14 +0100 Subject: updater.py: remove test_add_package. It was a nice idea when we were less confident about bitbaking and oe-selftest, but at this point, it is redundant and provides no useful information while adding extraneous time to the already long test suite. Signed-off-by: Patrick Vacek --- lib/oeqa/selftest/cases/updater.py | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/lib/oeqa/selftest/cases/updater.py b/lib/oeqa/selftest/cases/updater.py index 4813b2e..07232d7 100644 --- a/lib/oeqa/selftest/cases/updater.py +++ b/lib/oeqa/selftest/cases/updater.py @@ -63,35 +63,6 @@ class GeneralTests(OESelftestTestCase): self.assertEqual(result.status, 0, "Java not found. Do you have a JDK installed on your host machine?") - def test_add_package(self): - deploydir = get_bb_var('DEPLOY_DIR_IMAGE') - imagename = get_bb_var('IMAGE_LINK_NAME', 'core-image-minimal') - image_path = deploydir + '/' + imagename + '.otaimg' - logger = logging.getLogger("selftest") - - logger.info('Running bitbake with man in the image package list') - self.append_config('IMAGE_INSTALL_append = " man "') - bitbake('-c cleanall man') - bitbake('core-image-minimal') - result = runCmd('oe-pkgdata-util find-path /usr/bin/man') - self.assertEqual(result.output, 'man: /usr/bin/man') - path1 = os.path.realpath(image_path) - size1 = os.path.getsize(path1) - logger.info('First image %s has size %i' % (path1, size1)) - - logger.info('Running bitbake without man in the image package list') - self.append_config('IMAGE_INSTALL_remove = " man "') - bitbake('-c cleanall man') - bitbake('core-image-minimal') - result = runCmd('oe-pkgdata-util find-path /usr/bin/man', ignore_status=True) - self.assertEqual(result.status, 1, "Status different than 1. output: %s" % result.output) - self.assertEqual(result.output, 'ERROR: Unable to find any package producing path /usr/bin/man') - path2 = os.path.realpath(image_path) - size2 = os.path.getsize(path2) - logger.info('Second image %s has size %i', path2, size2) - self.assertNotEqual(path1, path2, "Image paths are identical; image was not rebuilt.") - self.assertNotEqual(size1, size2, "Image sizes are identical; image was not rebuilt.") - class AktualizrToolsTests(OESelftestTestCase): -- cgit v1.2.3-54-g00ecf From cfd16dc98ad78a724372b42056b3a94583743d36 Mon Sep 17 00:00:00 2001 From: Patrick Vacek Date: Wed, 27 Feb 2019 12:08:59 +0100 Subject: README: document auto-reboot config feature. Signed-off-by: Patrick Vacek Suggested-by: Ben Luck --- README.adoc | 1 + recipes-sota/config/aktualizr-auto-reboot.bb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index 6ca20d8..9f7d485 100644 --- a/README.adoc +++ b/README.adoc @@ -147,6 +147,7 @@ First, you can set `SOTA_CLIENT_PROV` to control which provisioning recipe is us Second, you can write recipes to install additional config files with customized options. A few recipes already exist to address common needs and provide an example: +* link:recipes-sota/config/aktualizr-auto-reboot.bb[aktualizr-auto-reboot.bb] configures aktualizr to automatically reboot after new updates are installed in order to apply the updates immediately. This is only relevant for package managers (such as OSTree) that require a reboot to complete the installation process. If this is not enabled, you will need to reboot the system through other means. * link:recipes-sota/config/aktualizr-disable-send-ip.bb[aktualizr-disable-send-ip.bb] disables the reporting of networking information to the server. This is enabled by default and supported by https://connect.ota.here.com/[HERE OTA Connect]. However, if you are using a different server that does not support this feature, you may want to disable it in aktualizr. * link:recipes-sota/config/aktualizr-log-debug.bb[aktualizr-log-debug.bb] sets the log level of aktualizr to 0 (trace). The default is 2 (info). This recipe is intended for development and debugging purposes. diff --git a/recipes-sota/config/aktualizr-auto-reboot.bb b/recipes-sota/config/aktualizr-auto-reboot.bb index 1317fd4..ad4d17c 100644 --- a/recipes-sota/config/aktualizr-auto-reboot.bb +++ b/recipes-sota/config/aktualizr-auto-reboot.bb @@ -1,5 +1,5 @@ SUMMARY = "Enable auto reboot to apply updates" -DESCRIPTION = "Configures aktualizr to auto reboot just after new updates installation in order to apply them" +DESCRIPTION = "Configures aktualizr to automatically reboot after new updates are installed in order to apply the updates immediately" HOMEPAGE = "https://github.com/advancedtelematic/aktualizr" SECTION = "base" LICENSE = "MPL-2.0" -- cgit v1.2.3-54-g00ecf