summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Vacek <patrickvacek@gmail.com>2019-06-13 16:59:21 +0200
committerGitHub <noreply@github.com>2019-06-13 16:59:21 +0200
commit1c049cbaec927971b0425e608b68551a4d2b898b (patch)
tree1b549011977622f2883bd13ac2c299f29609838c
parent9725c55078e6216437904aa63d5bb5c632f92302 (diff)
parent249254d0100eb19a2be5929cc14ee9f64bf0dd7c (diff)
downloadmeta-updater-1c049cbaec927971b0425e608b68551a4d2b898b.tar.gz
Merge pull request #526 from advancedtelematic/refactor/thud/renaming-secondaries-etc
Refactor/thud/renaming secondaries etc
-rw-r--r--README.adoc13
-rw-r--r--classes/sota.bbclass18
-rw-r--r--lib/oeqa/selftest/cases/testutils.py53
-rw-r--r--lib/oeqa/selftest/cases/updater_minnowboard.py2
-rw-r--r--lib/oeqa/selftest/cases/updater_qemux86_64.py189
-rw-r--r--lib/oeqa/selftest/cases/updater_raspberrypi.py3
-rw-r--r--recipes-sota/aktualizr/aktualizr-ca-implicit-prov.bb30
-rw-r--r--recipes-sota/aktualizr/aktualizr-device-prov-creds.bb (renamed from recipes-sota/aktualizr/aktualizr-ca-implicit-prov-creds.bb)13
-rw-r--r--recipes-sota/aktualizr/aktualizr-device-prov-hsm.bb30
-rw-r--r--recipes-sota/aktualizr/aktualizr-device-prov.bb29
-rw-r--r--recipes-sota/aktualizr/aktualizr-hsm-prov.bb30
-rw-r--r--recipes-sota/aktualizr/aktualizr-shared-prov-creds.bb (renamed from recipes-sota/aktualizr/aktualizr-auto-prov-creds.bb)3
-rw-r--r--recipes-sota/aktualizr/aktualizr-shared-prov.bb (renamed from recipes-sota/aktualizr/aktualizr-auto-prov.bb)14
-rw-r--r--recipes-sota/aktualizr/aktualizr-uboot-env-rollback.bb2
-rw-r--r--[-rwxr-xr-x]recipes-sota/aktualizr/aktualizr_git.bb26
-rw-r--r--recipes-sota/aktualizr/files/aktualizr-secondary.service6
-rw-r--r--recipes-sota/aktualizr/files/aktualizr-secondary.socket6
-rw-r--r--recipes-sota/config/aktualizr-polling-interval.bb29
-rw-r--r--recipes-sota/config/files/60-polling-interval.toml2
-rw-r--r--recipes-test/big-update/big-update_1.0.bb2
-rw-r--r--recipes-test/big-update/big-update_2.0.bb2
-rw-r--r--recipes-test/demo-config/files/30-fake-pacman.toml2
-rw-r--r--recipes-test/demo-config/files/30-secondary-config.toml2
-rw-r--r--recipes-test/demo-config/files/35-network-config.toml4
-rw-r--r--recipes-test/demo-config/files/45-id-config.toml3
-rw-r--r--recipes-test/demo-config/files/ip_secondary_config.json7
-rw-r--r--recipes-test/demo-config/primary-config.bb68
-rw-r--r--recipes-test/demo-config/secondary-config.bb41
-rw-r--r--recipes-test/demo-config/shared-conf.inc5
-rw-r--r--recipes-test/demo-network-config/files/26-static-client.network7
-rw-r--r--recipes-test/demo-network-config/primary-network-config.bb17
-rw-r--r--recipes-test/demo-network-config/secondary-network-config.bb17
-rw-r--r--recipes-test/demo-network-config/static-network-config.inc16
-rw-r--r--recipes-test/images/primary-image.bb6
-rw-r--r--recipes-test/images/secondary-image.bb15
-rwxr-xr-xscripts/find_aktualizr_dependencies.sh13
-rw-r--r--scripts/qemucommand.py4
37 files changed, 510 insertions, 219 deletions
diff --git a/README.adoc b/README.adoc
index a28d934..41d8e96 100644
--- a/README.adoc
+++ b/README.adoc
@@ -80,7 +80,7 @@ Your images will also need network connectivity to be able to reach an actual OT
80 80
81* `OSTREE_REPO` - path to your OSTree repository. Defaults to `$\{DEPLOY_DIR_IMAGE}/ostree_repo` 81* `OSTREE_REPO` - path to your OSTree repository. Defaults to `$\{DEPLOY_DIR_IMAGE}/ostree_repo`
82* `OSTREE_OSNAME` - OS deployment name on your target device. For more information about deployments and osnames see the https://ostree.readthedocs.io/en/latest/manual/deployment/[OSTree documentation]. Defaults to "poky". 82* `OSTREE_OSNAME` - OS deployment name on your target device. For more information about deployments and osnames see the https://ostree.readthedocs.io/en/latest/manual/deployment/[OSTree documentation]. Defaults to "poky".
83* `OSTREE_COMMIT_BODY` - Message attached to OSTree commit. Empty by default. 83* `OSTREE_COMMIT_BODY` - Message attached to OSTree commit. Empty by default.
84* `OSTREE_COMMIT_SUBJECT` - Commit subject used by OSTree. Defaults to `Commit-id: ${IMAGE_NAME}` 84* `OSTREE_COMMIT_SUBJECT` - Commit subject used by OSTree. Defaults to `Commit-id: ${IMAGE_NAME}`
85* `OSTREE_UPDATE_SUMMARY` - Set this to '1' to update summary of OSTree repository on each commit. '0' by default. 85* `OSTREE_UPDATE_SUMMARY` - Set this to '1' to update summary of OSTree repository on each commit. '0' by default.
86* `OSTREE_DEPLOY_DEVICETREE` - Set this to '1' to include devicetree(s) to boot 86* `OSTREE_DEPLOY_DEVICETREE` - Set this to '1' to include devicetree(s) to boot
@@ -88,7 +88,7 @@ Your images will also need network connectivity to be able to reach an actual OT
88* `INITRAMFS_IMAGE` - initramfs/initrd image that is used as a proxy while booting into OSTree deployment. Do not change this setting unless you are sure that your initramfs can serve as such a proxy. 88* `INITRAMFS_IMAGE` - initramfs/initrd image that is used as a proxy while booting into OSTree deployment. Do not change this setting unless you are sure that your initramfs can serve as such a proxy.
89* `SOTA_PACKED_CREDENTIALS` - when set, your ostree commit will be pushed to a remote repo as a bitbake step. This should be the path to a zipped credentials file in https://github.com/advancedtelematic/aktualizr/blob/master/docs/credentials.adoc[the format accepted by garage-push]. 89* `SOTA_PACKED_CREDENTIALS` - when set, your ostree commit will be pushed to a remote repo as a bitbake step. This should be the path to a zipped credentials file in https://github.com/advancedtelematic/aktualizr/blob/master/docs/credentials.adoc[the format accepted by garage-push].
90* `SOTA_DEPLOY_CREDENTIALS` - when set to '1' (default value), deploys credentials to the built image. Override it in `local.conf` to built a generic image that can be provisioned manually after the build. 90* `SOTA_DEPLOY_CREDENTIALS` - when set to '1' (default value), deploys credentials to the built image. Override it in `local.conf` to built a generic image that can be provisioned manually after the build.
91* `SOTA_CLIENT_PROV` - which provisioning method to use. Valid options are https://github.com/advancedtelematic/aktualizr/blob/master/docs/automatic-provisioning.adoc[`aktualizr-auto-prov`], https://github.com/advancedtelematic/aktualizr/blob/master/docs/implicit-provisioning.adoc[`aktualizr-ca-implicit-prov`], and https://github.com/advancedtelematic/aktualizr/blob/master/docs/hsm-provisioning.adoc[`aktualizr-hsm-prov`]. The default is `aktualizr-auto-prov`. This can also be set to an empty string to avoid using a provisioning recipe. 91* `SOTA_CLIENT_PROV` - which provisioning method to use. Valid options are `aktualizr-shared-prov`, `aktualizr-device-prov`, and `aktualizr-device-prov-hsm`. For more information on these provisioning methods, see the https://docs.ota.here.com/client-config/client-provisioning-methods.html[OTA Connect documentation]. The default is `aktualizr-shared-prov`. This can also be set to an empty string to avoid using a provisioning recipe.
92* `SOTA_CLIENT_FEATURES` - extensions to aktualizr. The only valid options are `hsm` (to build with HSM support) and `secondary-network` (to set up a simulated 'in-vehicle' network with support for a primary node with a DHCP server and a secondary node with a DHCP client). 92* `SOTA_CLIENT_FEATURES` - extensions to aktualizr. The only valid options are `hsm` (to build with HSM support) and `secondary-network` (to set up a simulated 'in-vehicle' network with support for a primary node with a DHCP server and a secondary node with a DHCP client).
93* `SOTA_SECONDARY_CONFIG_DIR` - a directory containing JSON configuration files for virtual secondaries on the host. These will be installed into `/etc/sota/ecus` on the device and automatically provided to aktualizr. 93* `SOTA_SECONDARY_CONFIG_DIR` - a directory containing JSON configuration files for virtual secondaries on the host. These will be installed into `/etc/sota/ecus` on the device and automatically provided to aktualizr.
94* `SOTA_HARDWARE_ID` - a custom hardware ID that will be written to the aktualizr config. Defaults to MACHINE if not set. 94* `SOTA_HARDWARE_ID` - a custom hardware ID that will be written to the aktualizr config. Defaults to MACHINE if not set.
@@ -96,6 +96,7 @@ Your images will also need network connectivity to be able to reach an actual OT
96* `SOTA_DT_OVERLAYS` - whitespace-separated list of used device tree overlays for FIT image. This list is OSTree-updateable as well. 96* `SOTA_DT_OVERLAYS` - whitespace-separated list of used device tree overlays for FIT image. This list is OSTree-updateable as well.
97* `SOTA_EXTRA_CONF_FRAGS` - extra https://lxr.missinglinkelectronics.com/uboot/doc/uImage.FIT/overlay-fdt-boot.txt[configuration fragments] for FIT image. 97* `SOTA_EXTRA_CONF_FRAGS` - extra https://lxr.missinglinkelectronics.com/uboot/doc/uImage.FIT/overlay-fdt-boot.txt[configuration fragments] for FIT image.
98* `RESOURCE_xxx_pn-aktualizr` - controls maximum resource usage of the aktualizr service, when `aktualizr-resource-control` is installed on the image. See <<aktualizr service resource control>> for details. 98* `RESOURCE_xxx_pn-aktualizr` - controls maximum resource usage of the aktualizr service, when `aktualizr-resource-control` is installed on the image. See <<aktualizr service resource control>> for details.
99* `SOTA_POLLING_SEC` - sets polling interval for aktualizr to check for updates if aktualizr-polling-sec is included in the image.
99 100
100== Usage 101== Usage
101 102
@@ -250,13 +251,13 @@ The aktualizr tests will now be part of the deployed ptest suite, which can be r
250 251
251As described in <<sota-related-variables-in-localconf,SOTA-related variables in local.conf>> section you can set `SOTA_DEPLOY_CREDENTIALS` to `0` to prevent deploying credentials to the built `wic` image. In this case you get a generic image that you can use e.g. on a production line to flash a series of devices. The cost of this approach is that this image is half-baked and should be provisioned before it can connect to the backend. 252As described in <<sota-related-variables-in-localconf,SOTA-related variables in local.conf>> section you can set `SOTA_DEPLOY_CREDENTIALS` to `0` to prevent deploying credentials to the built `wic` image. In this case you get a generic image that you can use e.g. on a production line to flash a series of devices. The cost of this approach is that this image is half-baked and should be provisioned before it can connect to the backend.
252 253
253Provisioning procedure depends on your provisioning recipe, i.e. the value of `SOTA_CLIENT_PROV` (equal to `aktualizr-auto-prov` by default): 254Provisioning procedure depends on your provisioning recipe, i.e. the value of `SOTA_CLIENT_PROV` (equal to `aktualizr-shared-prov` by default):
254 255
255* For `aktualizr-auto-prov` put your `credentials.zip` to `/var/sota/sota_provisioning_credentials.zip` on the filesystem of a running device. If you have the filesystem of our device mounted to your build machine, prefix all paths with `/ostree/deploy/poky` as in `/ostree/deploy/poky/var/sota/sota_provisioning_credentials.zip`. 256* For `aktualizr-shared-prov` put your `credentials.zip` to `/var/sota/sota_provisioning_credentials.zip` on the filesystem of a running device. If you have the filesystem of our device mounted to your build machine, prefix all paths with `/ostree/deploy/poky` as in `/ostree/deploy/poky/var/sota/sota_provisioning_credentials.zip`.
256* For `aktualizr-ca-implicit-prov` 257* For `aktualizr-device-prov`
257** put URL to the backend server (together with protocol prefix and port number) at `/var/sota/gateway.url`. If you're using HERE OTA Connect, you can find the URL in the `autoprov.url` file in your credentials archive. 258** put URL to the backend server (together with protocol prefix and port number) at `/var/sota/gateway.url`. If you're using HERE OTA Connect, you can find the URL in the `autoprov.url` file in your credentials archive.
258** put client certificate, private key and root CA certificate (for the *server*, not for the *device*) at `/var/sota/import/client.pem`, `/var/sota/import/pkey.pem` and `/var/sota/import/root.crt` respectively. 259** put client certificate, private key and root CA certificate (for the *server*, not for the *device*) at `/var/sota/import/client.pem`, `/var/sota/import/pkey.pem` and `/var/sota/import/root.crt` respectively.
259* For `aktualizr-hsm-prov` 260* For `aktualizr-device-prov-hsm`
260** put URL to the server backend (together with protocol prefix and port number) at `/var/sota/gateway.url`. If you're using HERE OTA Connect, you can find the URL in the `autoprov.url` file in your credentials archive. 261** put URL to the server backend (together with protocol prefix and port number) at `/var/sota/gateway.url`. If you're using HERE OTA Connect, you can find the URL in the `autoprov.url` file in your credentials archive.
261** put root CA certificate (for the *server*, not for the *device*) at `/var/sota/import/root.crt`. 262** put root CA certificate (for the *server*, not for the *device*) at `/var/sota/import/root.crt`.
262** put client certificate and private key to slots 1 and 2 of the PKCS#11-compatible device. 263** put client certificate and private key to slots 1 and 2 of the PKCS#11-compatible device.
diff --git a/classes/sota.bbclass b/classes/sota.bbclass
index 7ffcd23..bf27b6d 100644
--- a/classes/sota.bbclass
+++ b/classes/sota.bbclass
@@ -1,12 +1,26 @@
1OVERRIDES .= "${@bb.utils.contains('DISTRO_FEATURES', 'sota', ':sota', '', d)}" 1DISTROOVERRIDES .= "${@bb.utils.contains('DISTRO_FEATURES', 'sota', ':sota', '', d)}"
2 2
3HOSTTOOLS_NONFATAL += "java" 3HOSTTOOLS_NONFATAL += "java"
4 4
5SOTA_CLIENT ??= "aktualizr" 5SOTA_CLIENT ??= "aktualizr"
6SOTA_CLIENT_PROV ??= "aktualizr-auto-prov" 6SOTA_CLIENT_PROV ??= "aktualizr-shared-prov"
7SOTA_DEPLOY_CREDENTIALS ?= "1" 7SOTA_DEPLOY_CREDENTIALS ?= "1"
8SOTA_HARDWARE_ID ??= "${MACHINE}" 8SOTA_HARDWARE_ID ??= "${MACHINE}"
9 9
10# Translate old provisioning recipe names into the new versions.
11python () {
12 prov = d.getVar("SOTA_CLIENT_PROV")
13 if prov == "aktualizr-auto-prov":
14 bb.warn('aktualizr-auto-prov is deprecated. Please use aktualizr-shared-prov instead.')
15 d.setVar("SOTA_CLIENT_PROV", "aktualizr-shared-prov")
16 elif prov == "aktualizr-ca-implicit-prov":
17 bb.warn('aktualizr-ca-implicit-prov is deprecated. Please use aktualizr-device-prov instead.')
18 d.setVar("SOTA_CLIENT_PROV", "aktualizr-device-prov")
19 elif prov == "aktualizr-hsm-prov":
20 bb.warn('aktualizr-hsm-prov is deprecated. Please use aktualizr-device-prov-hsm instead.')
21 d.setVar("SOTA_CLIENT_PROV", "aktualizr-device-prov-hsm")
22}
23
10IMAGE_INSTALL_append_sota = " ostree os-release ${SOTA_CLIENT} ${SOTA_CLIENT_PROV}" 24IMAGE_INSTALL_append_sota = " ostree os-release ${SOTA_CLIENT} ${SOTA_CLIENT_PROV}"
11IMAGE_CLASSES += " image_types_ostree image_types_ota" 25IMAGE_CLASSES += " image_types_ostree image_types_ota"
12 26
diff --git a/lib/oeqa/selftest/cases/testutils.py b/lib/oeqa/selftest/cases/testutils.py
index 2ad99ad..f8b1904 100644
--- a/lib/oeqa/selftest/cases/testutils.py
+++ b/lib/oeqa/selftest/cases/testutils.py
@@ -7,49 +7,57 @@ from time import sleep
7from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars 7from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars
8from qemucommand import QemuCommand 8from qemucommand import QemuCommand
9 9
10logger = logging.getLogger("selftest")
10 11
11def qemu_launch(efi=False, machine=None, imagename=None): 12
12 logger = logging.getLogger("selftest") 13def qemu_launch(efi=False, machine=None, imagename='core-image-minimal', **kwargs):
13 if imagename is None: 14 qemu_bake_image(imagename)
14 imagename = 'core-image-minimal' 15 return qemu_boot_image(efi=efi, machine=machine, imagename=imagename, **kwargs)
15 logger.info('Running bitbake to build {}'.format(imagename)) 16
16 bitbake(imagename) 17
18def qemu_terminate(s):
19 try:
20 s.terminate()
21 s.wait(timeout=10)
22 except KeyboardInterrupt:
23 pass
24
25
26def qemu_boot_image(imagename, **kwargs):
17 # Create empty object. 27 # Create empty object.
18 args = type('', (), {})() 28 args = type('', (), {})()
19 args.imagename = imagename 29 args.imagename = imagename
20 args.mac = None 30 args.mac = kwargs.get('mac', None)
21 # Could use DEPLOY_DIR_IMAGE here but it's already in the machine 31 # Could use DEPLOY_DIR_IMAGE here but it's already in the machine
22 # subdirectory. 32 # subdirectory.
23 args.dir = 'tmp/deploy/images' 33 args.dir = 'tmp/deploy/images'
24 args.efi = efi 34 args.efi = kwargs.get('efi', False)
25 args.machine = machine 35 args.machine = kwargs.get('machine', None)
26 qemu_use_kvm = get_bb_var("QEMU_USE_KVM") 36 qemu_use_kvm = get_bb_var("QEMU_USE_KVM")
27 if qemu_use_kvm and \ 37 if qemu_use_kvm and \
28 (qemu_use_kvm == 'True' and 'x86' in machine or 38 (qemu_use_kvm == 'True' and 'x86' in args.machine or
29 get_bb_var('MACHINE') in qemu_use_kvm.split()): 39 get_bb_var('MACHINE') in qemu_use_kvm.split()):
30 args.kvm = True 40 args.kvm = True
31 else: 41 else:
32 args.kvm = None # Autodetect 42 args.kvm = None # Autodetect
33 args.no_gui = True 43 args.no_gui = kwargs.get('no_gui', True)
34 args.gdb = False 44 args.gdb = kwargs.get('gdb', False)
35 args.pcap = None 45 args.pcap = kwargs.get('pcap', None)
36 args.overlay = None 46 args.overlay = kwargs.get('overlay', None)
37 args.dry_run = False 47 args.dry_run = kwargs.get('dry_run', False)
38 args.secondary_network = False 48 args.secondary_network = kwargs.get('secondary_network', False)
39 49
40 qemu = QemuCommand(args) 50 qemu = QemuCommand(args)
41 cmdline = qemu.command_line() 51 cmdline = qemu.command_line()
42 print('Booting image with run-qemu-ota...') 52 print('Booting image with run-qemu-ota...')
43 s = subprocess.Popen(cmdline) 53 s = subprocess.Popen(cmdline)
44 sleep(10) 54 sleep(kwargs.get('wait_for_boot_time', 10))
45 return qemu, s 55 return qemu, s
46 56
47 57
48def qemu_terminate(s): 58def qemu_bake_image(imagename):
49 try: 59 logger.info('Running bitbake to build {}'.format(imagename))
50 s.terminate() 60 bitbake(imagename)
51 except KeyboardInterrupt:
52 pass
53 61
54 62
55def qemu_send_command(port, command, timeout=60): 63def qemu_send_command(port, command, timeout=60):
@@ -122,7 +130,6 @@ def verifyProvisioned(testInst, machine):
122 m = p.search(stdout.decode()) 130 m = p.search(stdout.decode())
123 testInst.assertTrue(m, 'Device ID could not be read: ' + stderr.decode() + stdout.decode()) 131 testInst.assertTrue(m, 'Device ID could not be read: ' + stderr.decode() + stdout.decode())
124 testInst.assertGreater(m.lastindex, 0, 'Device ID could not be read: ' + stderr.decode() + stdout.decode()) 132 testInst.assertGreater(m.lastindex, 0, 'Device ID could not be read: ' + stderr.decode() + stdout.decode())
125 logger = logging.getLogger("selftest")
126 logger.info('Device successfully provisioned with ID: ' + m.group(1)) 133 logger.info('Device successfully provisioned with ID: ' + m.group(1))
127 134
128# vim:set ts=4 sw=4 sts=4 expandtab: 135# vim:set ts=4 sw=4 sts=4 expandtab:
diff --git a/lib/oeqa/selftest/cases/updater_minnowboard.py b/lib/oeqa/selftest/cases/updater_minnowboard.py
index f5df584..267445b 100644
--- a/lib/oeqa/selftest/cases/updater_minnowboard.py
+++ b/lib/oeqa/selftest/cases/updater_minnowboard.py
@@ -29,7 +29,7 @@ class MinnowTests(OESelftestTestCase):
29 self.meta_minnow = None 29 self.meta_minnow = None
30 self.append_config('MACHINE = "intel-corei7-64"') 30 self.append_config('MACHINE = "intel-corei7-64"')
31 self.append_config('OSTREE_BOOTLOADER = "grub"') 31 self.append_config('OSTREE_BOOTLOADER = "grub"')
32 self.append_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "') 32 self.append_config('SOTA_CLIENT_PROV = " aktualizr-shared-prov "')
33 self.qemu, self.s = qemu_launch(efi=True, machine='intel-corei7-64') 33 self.qemu, self.s = qemu_launch(efi=True, machine='intel-corei7-64')
34 34
35 def tearDownLocal(self): 35 def tearDownLocal(self):
diff --git a/lib/oeqa/selftest/cases/updater_qemux86_64.py b/lib/oeqa/selftest/cases/updater_qemux86_64.py
index 9f32bcf..e26a022 100644
--- a/lib/oeqa/selftest/cases/updater_qemux86_64.py
+++ b/lib/oeqa/selftest/cases/updater_qemux86_64.py
@@ -4,18 +4,19 @@ import logging
4import re 4import re
5import unittest 5import unittest
6from time import sleep 6from time import sleep
7from uuid import uuid4
7 8
8from oeqa.selftest.case import OESelftestTestCase 9from oeqa.selftest.case import OESelftestTestCase
9from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars 10from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars
10from testutils import qemu_launch, qemu_send_command, qemu_terminate, \ 11from testutils import qemu_launch, qemu_send_command, qemu_terminate, \
11 akt_native_run, verifyNotProvisioned, verifyProvisioned 12 akt_native_run, verifyNotProvisioned, verifyProvisioned, qemu_bake_image, qemu_boot_image
12 13
13 14
14class GeneralTests(OESelftestTestCase): 15class GeneralTests(OESelftestTestCase):
15 def test_credentials(self): 16 def test_credentials(self):
16 logger = logging.getLogger("selftest") 17 logger = logging.getLogger("selftest")
17 logger.info('Running bitbake to build core-image-minimal') 18 logger.info('Running bitbake to build core-image-minimal')
18 self.append_config('SOTA_CLIENT_PROV = "aktualizr-auto-prov"') 19 self.append_config('SOTA_CLIENT_PROV = "aktualizr-shared-prov"')
19 bitbake('core-image-minimal') 20 bitbake('core-image-minimal')
20 credentials = get_bb_var('SOTA_PACKED_CREDENTIALS') 21 credentials = get_bb_var('SOTA_PACKED_CREDENTIALS')
21 # skip the test if the variable SOTA_PACKED_CREDENTIALS is not set 22 # skip the test if the variable SOTA_PACKED_CREDENTIALS is not set
@@ -45,13 +46,13 @@ class AktualizrToolsTests(OESelftestTestCase):
45 46
46 def test_cert_provider_local_output(self): 47 def test_cert_provider_local_output(self):
47 logger = logging.getLogger("selftest") 48 logger = logging.getLogger("selftest")
48 logger.info('Running bitbake to build aktualizr-ca-implicit-prov') 49 logger.info('Running bitbake to build aktualizr-device-prov')
49 bitbake('aktualizr-ca-implicit-prov') 50 bitbake('aktualizr-device-prov')
50 bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS', 'T'], 'aktualizr-native') 51 bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS', 'T'], 'aktualizr-native')
51 creds = bb_vars['SOTA_PACKED_CREDENTIALS'] 52 creds = bb_vars['SOTA_PACKED_CREDENTIALS']
52 temp_dir = bb_vars['T'] 53 temp_dir = bb_vars['T']
53 bb_vars_prov = get_bb_vars(['STAGING_DIR_HOST', 'libdir'], 'aktualizr-ca-implicit-prov') 54 bb_vars_prov = get_bb_vars(['STAGING_DIR_HOST', 'libdir'], 'aktualizr-device-prov')
54 config = bb_vars_prov['STAGING_DIR_HOST'] + bb_vars_prov['libdir'] + '/sota/sota_implicit_prov_ca.toml' 55 config = bb_vars_prov['STAGING_DIR_HOST'] + bb_vars_prov['libdir'] + '/sota/sota-device-cred.toml'
55 56
56 akt_native_run(self, 'aktualizr-cert-provider -c {creds} -r -l {temp} -g {config}' 57 akt_native_run(self, 'aktualizr-cert-provider -c {creds} -r -l {temp} -g {config}'
57 .format(creds=creds, temp=temp_dir, config=config)) 58 .format(creds=creds, temp=temp_dir, config=config))
@@ -68,7 +69,7 @@ class AktualizrToolsTests(OESelftestTestCase):
68 self.assertTrue(os.path.getsize(ca_path) > 0, "Client certificate at %s is empty." % ca_path) 69 self.assertTrue(os.path.getsize(ca_path) > 0, "Client certificate at %s is empty." % ca_path)
69 70
70 71
71class AutoProvTests(OESelftestTestCase): 72class SharedCredProvTests(OESelftestTestCase):
72 73
73 def setUpLocal(self): 74 def setUpLocal(self):
74 layer = "meta-updater-qemux86-64" 75 layer = "meta-updater-qemux86-64"
@@ -84,7 +85,7 @@ class AutoProvTests(OESelftestTestCase):
84 else: 85 else:
85 self.meta_qemu = None 86 self.meta_qemu = None
86 self.append_config('MACHINE = "qemux86-64"') 87 self.append_config('MACHINE = "qemux86-64"')
87 self.append_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "') 88 self.append_config('SOTA_CLIENT_PROV = " aktualizr-shared-prov "')
88 self.qemu, self.s = qemu_launch(machine='qemux86-64') 89 self.qemu, self.s = qemu_launch(machine='qemux86-64')
89 90
90 def tearDownLocal(self): 91 def tearDownLocal(self):
@@ -126,7 +127,7 @@ class ManualControlTests(OESelftestTestCase):
126 else: 127 else:
127 self.meta_qemu = None 128 self.meta_qemu = None
128 self.append_config('MACHINE = "qemux86-64"') 129 self.append_config('MACHINE = "qemux86-64"')
129 self.append_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "') 130 self.append_config('SOTA_CLIENT_PROV = " aktualizr-shared-prov "')
130 self.append_config('SYSTEMD_AUTO_ENABLE_aktualizr = "disable"') 131 self.append_config('SYSTEMD_AUTO_ENABLE_aktualizr = "disable"')
131 self.qemu, self.s = qemu_launch(machine='qemux86-64') 132 self.qemu, self.s = qemu_launch(machine='qemux86-64')
132 133
@@ -154,7 +155,7 @@ class ManualControlTests(OESelftestTestCase):
154 'Aktualizr should have run' + stderr.decode() + stdout.decode()) 155 'Aktualizr should have run' + stderr.decode() + stdout.decode())
155 156
156 157
157class ImplProvTests(OESelftestTestCase): 158class DeviceCredProvTests(OESelftestTestCase):
158 159
159 def setUpLocal(self): 160 def setUpLocal(self):
160 layer = "meta-updater-qemux86-64" 161 layer = "meta-updater-qemux86-64"
@@ -170,9 +171,9 @@ class ImplProvTests(OESelftestTestCase):
170 else: 171 else:
171 self.meta_qemu = None 172 self.meta_qemu = None
172 self.append_config('MACHINE = "qemux86-64"') 173 self.append_config('MACHINE = "qemux86-64"')
173 self.append_config('SOTA_CLIENT_PROV = " aktualizr-ca-implicit-prov "') 174 self.append_config('SOTA_CLIENT_PROV = " aktualizr-device-prov "')
174 self.append_config('SOTA_DEPLOY_CREDENTIALS = "0"') 175 self.append_config('SOTA_DEPLOY_CREDENTIALS = "0"')
175 runCmd('bitbake -c cleanall aktualizr aktualizr-ca-implicit-prov') 176 runCmd('bitbake -c cleanall aktualizr aktualizr-device-prov')
176 self.qemu, self.s = qemu_launch(machine='qemux86-64') 177 self.qemu, self.s = qemu_launch(machine='qemux86-64')
177 178
178 def tearDownLocal(self): 179 def tearDownLocal(self):
@@ -200,8 +201,8 @@ class ImplProvTests(OESelftestTestCase):
200 # Run aktualizr-cert-provider. 201 # Run aktualizr-cert-provider.
201 bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS'], 'aktualizr-native') 202 bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS'], 'aktualizr-native')
202 creds = bb_vars['SOTA_PACKED_CREDENTIALS'] 203 creds = bb_vars['SOTA_PACKED_CREDENTIALS']
203 bb_vars_prov = get_bb_vars(['STAGING_DIR_HOST', 'libdir'], 'aktualizr-ca-implicit-prov') 204 bb_vars_prov = get_bb_vars(['STAGING_DIR_HOST', 'libdir'], 'aktualizr-device-prov')
204 config = bb_vars_prov['STAGING_DIR_HOST'] + bb_vars_prov['libdir'] + '/sota/sota_implicit_prov_ca.toml' 205 config = bb_vars_prov['STAGING_DIR_HOST'] + bb_vars_prov['libdir'] + '/sota/sota-device-cred.toml'
205 206
206 print('Provisining at root@localhost:%d' % self.qemu.ssh_port) 207 print('Provisining at root@localhost:%d' % self.qemu.ssh_port)
207 akt_native_run(self, 'aktualizr-cert-provider -c {creds} -t root@localhost -p {port} -s -u -r -g {config}' 208 akt_native_run(self, 'aktualizr-cert-provider -c {creds} -t root@localhost -p {port} -s -u -r -g {config}'
@@ -210,7 +211,7 @@ class ImplProvTests(OESelftestTestCase):
210 verifyProvisioned(self, machine) 211 verifyProvisioned(self, machine)
211 212
212 213
213class HsmTests(OESelftestTestCase): 214class DeviceCredProvHsmTests(OESelftestTestCase):
214 215
215 def setUpLocal(self): 216 def setUpLocal(self):
216 layer = "meta-updater-qemux86-64" 217 layer = "meta-updater-qemux86-64"
@@ -226,11 +227,11 @@ class HsmTests(OESelftestTestCase):
226 else: 227 else:
227 self.meta_qemu = None 228 self.meta_qemu = None
228 self.append_config('MACHINE = "qemux86-64"') 229 self.append_config('MACHINE = "qemux86-64"')
229 self.append_config('SOTA_CLIENT_PROV = "aktualizr-hsm-prov"') 230 self.append_config('SOTA_CLIENT_PROV = "aktualizr-device-prov-hsm"')
230 self.append_config('SOTA_DEPLOY_CREDENTIALS = "0"') 231 self.append_config('SOTA_DEPLOY_CREDENTIALS = "0"')
231 self.append_config('SOTA_CLIENT_FEATURES = "hsm"') 232 self.append_config('SOTA_CLIENT_FEATURES = "hsm"')
232 self.append_config('IMAGE_INSTALL_append = " softhsm-testtoken"') 233 self.append_config('IMAGE_INSTALL_append = " softhsm-testtoken"')
233 runCmd('bitbake -c cleanall aktualizr aktualizr-hsm-prov') 234 runCmd('bitbake -c cleanall aktualizr aktualizr-device-prov-hsm')
234 self.qemu, self.s = qemu_launch(machine='qemux86-64') 235 self.qemu, self.s = qemu_launch(machine='qemux86-64')
235 236
236 def tearDownLocal(self): 237 def tearDownLocal(self):
@@ -268,8 +269,8 @@ class HsmTests(OESelftestTestCase):
268 # Run aktualizr-cert-provider. 269 # Run aktualizr-cert-provider.
269 bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS'], 'aktualizr-native') 270 bb_vars = get_bb_vars(['SOTA_PACKED_CREDENTIALS'], 'aktualizr-native')
270 creds = bb_vars['SOTA_PACKED_CREDENTIALS'] 271 creds = bb_vars['SOTA_PACKED_CREDENTIALS']
271 bb_vars_prov = get_bb_vars(['STAGING_DIR_HOST', 'libdir'], 'aktualizr-hsm-prov') 272 bb_vars_prov = get_bb_vars(['STAGING_DIR_HOST', 'libdir'], 'aktualizr-device-prov-hsm')
272 config = bb_vars_prov['STAGING_DIR_HOST'] + bb_vars_prov['libdir'] + '/sota/sota_hsm_prov.toml' 273 config = bb_vars_prov['STAGING_DIR_HOST'] + bb_vars_prov['libdir'] + '/sota/sota-device-cred-hsm.toml'
273 274
274 akt_native_run(self, 'aktualizr-cert-provider -c {creds} -t root@localhost -p {port} -r -s -u -g {config}' 275 akt_native_run(self, 'aktualizr-cert-provider -c {creds} -t root@localhost -p {port} -r -s -u -g {config}'
275 .format(creds=creds, port=self.qemu.ssh_port, config=config)) 276 .format(creds=creds, port=self.qemu.ssh_port, config=config))
@@ -309,7 +310,91 @@ class HsmTests(OESelftestTestCase):
309 verifyProvisioned(self, machine) 310 verifyProvisioned(self, machine)
310 311
311 312
312class SecondaryTests(OESelftestTestCase): 313class IpSecondaryTests(OESelftestTestCase):
314
315 class Image:
316 def __init__(self, imagename, binaryname, machine='qemux86-64', bake=True, **kwargs):
317 self.machine = machine
318 self.imagename = imagename
319 self.boot_kwargs = kwargs
320 self.binaryname = binaryname
321 self.stdout = ''
322 self.stderr = ''
323 self.retcode = 0
324 if bake:
325 self.bake()
326
327 def bake(self):
328 self.configure()
329 qemu_bake_image(self.imagename)
330
331 def send_command(self, cmd):
332 stdout, stderr, retcode = qemu_send_command(self.qemu.ssh_port, cmd, timeout=60)
333 return str(stdout), str(stderr), retcode
334
335 def __enter__(self):
336 self.qemu, self.process = qemu_boot_image(machine=self.machine, imagename=self.imagename,
337 wait_for_boot_time=1, **self.boot_kwargs)
338 # wait until the VM is booted and is SSHable
339 self.wait_till_sshable()
340
341 def __exit__(self, exc_type, exc_val, exc_tb):
342 qemu_terminate(self.process)
343
344 def wait_till_sshable(self):
345 # qemu_send_command tries to ssh into the qemu VM and blocks until it gets there or timeout happens
346 # so it helps us to block q control flow until the VM is booted and a target binary/daemon is running there
347 self.stdout, self.stderr, self.retcode = self.send_command(self.binaryname + ' --help')
348
349 def was_successfully_booted(self):
350 return self.retcode == 0
351
352 class Secondary(Image):
353 def __init__(self, test_ctx):
354 self._test_ctx = test_ctx
355 self.sndry_serial = str(uuid4())
356 self.sndry_hw_id = 'qemux86-64-oeselftest-sndry'
357 self.id = (self.sndry_hw_id, self.sndry_serial)
358 super(IpSecondaryTests.Secondary, self).__init__('secondary-image', 'aktualizr-secondary',
359 secondary_network=True)
360
361 def configure(self):
362 self._test_ctx.append_config('SECONDARY_SERIAL_ID = "{}"'.format(self.sndry_serial))
363 self._test_ctx.append_config('SECONDARY_HARDWARE_ID = "{}"'.format(self.sndry_hw_id))
364
365 class Primary(Image):
366 def __init__(self, test_ctx):
367 self._test_ctx = test_ctx
368 super(IpSecondaryTests.Primary, self).__init__('primary-image', 'aktualizr', secondary_network=True)
369
370 def configure(self):
371 self._test_ctx.append_config('MACHINE = "qemux86-64"')
372 self._test_ctx.append_config('SOTA_CLIENT_PROV = " aktualizr-shared-prov "')
373
374 def is_ecu_registered(self, ecu_id):
375 max_number_of_tries = 20
376 try_counter = 0
377
378 # aktualizr-info is not always able to load ECU serials from DB
379 # so, let's run it a few times until it actually succeeds
380 while try_counter < max_number_of_tries:
381 device_status = self.get_info()
382 try_counter += 1
383 if device_status.find("load ECU serials") == -1:
384 break
385 sleep(1)
386
387 if not ((device_status.find(ecu_id[0]) != -1) and (device_status.find(ecu_id[1]) != -1)):
388 return False
389 not_registered_field = "Removed or not registered ecus:"
390 not_reg_start = device_status.find(not_registered_field)
391 return not_reg_start == -1 or (device_status.find(ecu_id[1], not_reg_start) == -1)
392
393 def get_info(self):
394 stdout, stderr, retcode = self.send_command('aktualizr-info')
395 self._test_ctx.assertEqual(retcode, 0, 'Unable to run aktualizr-info: {}'.format(stderr))
396 return stdout
397
313 def setUpLocal(self): 398 def setUpLocal(self):
314 layer = "meta-updater-qemux86-64" 399 layer = "meta-updater-qemux86-64"
315 result = runCmd('bitbake-layers show-layers') 400 result = runCmd('bitbake-layers show-layers')
@@ -323,57 +408,37 @@ class SecondaryTests(OESelftestTestCase):
323 runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) 408 runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu)
324 else: 409 else:
325 self.meta_qemu = None 410 self.meta_qemu = None
326 self.append_config('MACHINE = "qemux86-64"') 411
327 self.append_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "') 412 self.primary = IpSecondaryTests.Primary(self)
328 self.qemu, self.s = qemu_launch(machine='qemux86-64', imagename='secondary-image') 413 self.secondary = IpSecondaryTests.Secondary(self)
329 414
330 def tearDownLocal(self): 415 def tearDownLocal(self):
331 qemu_terminate(self.s)
332 if self.meta_qemu: 416 if self.meta_qemu:
333 runCmd('bitbake-layers remove-layer "%s"' % self.meta_qemu, ignore_status=True) 417 runCmd('bitbake-layers remove-layer "%s"' % self.meta_qemu, ignore_status=True)
334 418
335 def qemu_command(self, command): 419 def test_ip_secondary_registration_if_secondary_starts_first(self):
336 return qemu_send_command(self.qemu.ssh_port, command) 420 with self.secondary:
421 self.assertTrue(self.secondary.was_successfully_booted(),
422 'The secondary failed to boot: {}'.format(self.secondary.stderr))
337 423
338 def test_secondary_present(self): 424 with self.primary:
339 print('Checking aktualizr-secondary is present') 425 self.assertTrue(self.primary.was_successfully_booted(),
340 stdout, stderr, retcode = self.qemu_command('aktualizr-secondary --help') 426 'The primary failed to boot: {}'.format(self.primary.stderr))
341 self.assertEqual(retcode, 0, "Unable to run aktualizr-secondary --help")
342 self.assertEqual(stderr, b'', 'Error: ' + stderr.decode())
343 427
428 self.assertTrue(self.primary.is_ecu_registered(self.secondary.id),
429 "The secondary wasn't registered at the primary: {}".format(self.primary.get_info()))
344 430
345class PrimaryTests(OESelftestTestCase): 431 def test_ip_secondary_registration_if_primary_starts_first(self):
346 def setUpLocal(self): 432 with self.primary:
347 layer = "meta-updater-qemux86-64" 433 self.assertTrue(self.primary.was_successfully_booted(),
348 result = runCmd('bitbake-layers show-layers') 434 'The primary failed to boot: {}'.format(self.primary.stderr))
349 if re.search(layer, result.output) is None:
350 # Assume the directory layout for finding other layers. We could also
351 # make assumptions by using 'show-layers', but either way, if the
352 # layers we need aren't where we expect them, we are out of luck.
353 path = os.path.abspath(os.path.dirname(__file__))
354 metadir = path + "/../../../../../"
355 self.meta_qemu = metadir + layer
356 runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu)
357 else:
358 self.meta_qemu = None
359 self.append_config('MACHINE = "qemux86-64"')
360 self.append_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "')
361 self.append_config('SOTA_CLIENT_FEATURES = "secondary-network"')
362 self.qemu, self.s = qemu_launch(machine='qemux86-64', imagename='primary-image')
363
364 def tearDownLocal(self):
365 qemu_terminate(self.s)
366 if self.meta_qemu:
367 runCmd('bitbake-layers remove-layer "%s"' % self.meta_qemu, ignore_status=True)
368 435
369 def qemu_command(self, command): 436 with self.secondary:
370 return qemu_send_command(self.qemu.ssh_port, command) 437 self.assertTrue(self.secondary.was_successfully_booted(),
438 'The secondary failed to boot: {}'.format(self.secondary.stderr))
371 439
372 def test_aktualizr_present(self): 440 self.assertTrue(self.primary.is_ecu_registered(self.secondary.id),
373 print('Checking aktualizr is present') 441 "The secondary wasn't registered at the primary: {}".format(self.primary.get_info()))
374 stdout, stderr, retcode = self.qemu_command('aktualizr --help')
375 self.assertEqual(retcode, 0, "Unable to run aktualizr --help")
376 self.assertEqual(stderr, b'', 'Error: ' + stderr.decode())
377 442
378 443
379class ResourceControlTests(OESelftestTestCase): 444class ResourceControlTests(OESelftestTestCase):
@@ -391,7 +456,7 @@ class ResourceControlTests(OESelftestTestCase):
391 else: 456 else:
392 self.meta_qemu = None 457 self.meta_qemu = None
393 self.append_config('MACHINE = "qemux86-64"') 458 self.append_config('MACHINE = "qemux86-64"')
394 self.append_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "') 459 self.append_config('SOTA_CLIENT_PROV = " aktualizr-shared-prov "')
395 self.append_config('IMAGE_INSTALL_append += " aktualizr-resource-control "') 460 self.append_config('IMAGE_INSTALL_append += " aktualizr-resource-control "')
396 self.append_config('RESOURCE_CPU_WEIGHT_pn-aktualizr = "1000"') 461 self.append_config('RESOURCE_CPU_WEIGHT_pn-aktualizr = "1000"')
397 self.append_config('RESOURCE_MEMORY_HIGH_pn-aktualizr = "50M"') 462 self.append_config('RESOURCE_MEMORY_HIGH_pn-aktualizr = "50M"')
diff --git a/lib/oeqa/selftest/cases/updater_raspberrypi.py b/lib/oeqa/selftest/cases/updater_raspberrypi.py
index 785d703..f6ae903 100644
--- a/lib/oeqa/selftest/cases/updater_raspberrypi.py
+++ b/lib/oeqa/selftest/cases/updater_raspberrypi.py
@@ -53,7 +53,7 @@ class RpiTests(OESelftestTestCase):
53 self.meta_qemu = None 53 self.meta_qemu = None
54 54
55 self.append_config('MACHINE = "raspberrypi3"') 55 self.append_config('MACHINE = "raspberrypi3"')
56 self.append_config('SOTA_CLIENT_PROV = " aktualizr-auto-prov "') 56 self.append_config('SOTA_CLIENT_PROV = " aktualizr-shared-prov "')
57 57
58 def tearDownLocal(self): 58 def tearDownLocal(self):
59 if self.meta_qemu: 59 if self.meta_qemu:
@@ -68,7 +68,6 @@ class RpiTests(OESelftestTestCase):
68 def test_build(self): 68 def test_build(self):
69 logger = logging.getLogger("selftest") 69 logger = logging.getLogger("selftest")
70 logger.info('Running bitbake to build core-image-minimal') 70 logger.info('Running bitbake to build core-image-minimal')
71 self.append_config('SOTA_CLIENT_PROV = "aktualizr-auto-prov"')
72 bitbake('core-image-minimal') 71 bitbake('core-image-minimal')
73 credentials = get_bb_var('SOTA_PACKED_CREDENTIALS') 72 credentials = get_bb_var('SOTA_PACKED_CREDENTIALS')
74 # Skip the test if the variable SOTA_PACKED_CREDENTIALS is not set. 73 # Skip the test if the variable SOTA_PACKED_CREDENTIALS is not set.
diff --git a/recipes-sota/aktualizr/aktualizr-ca-implicit-prov.bb b/recipes-sota/aktualizr/aktualizr-ca-implicit-prov.bb
deleted file mode 100644
index 414cb5e..0000000
--- a/recipes-sota/aktualizr/aktualizr-ca-implicit-prov.bb
+++ /dev/null
@@ -1,30 +0,0 @@
1SUMMARY = "Aktualizr configuration for implicit provisioning with CA"
2DESCRIPTION = "Configuration for implicitly provisioning Aktualizr using externally provided or generated CA"
3
4HOMEPAGE = "https://github.com/advancedtelematic/aktualizr"
5SECTION = "base"
6LICENSE = "MPL-2.0"
7LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad"
8
9inherit allarch
10
11DEPENDS = "aktualizr aktualizr-native openssl-native"
12RDEPENDS_${PN}_append = "${@' aktualizr-ca-implicit-prov-creds' if d.getVar('SOTA_DEPLOY_CREDENTIALS') == '1' else ''}"
13
14PV = "1.0"
15PR = "1"
16
17require credentials.inc
18
19do_install() {
20 install -m 0700 -d ${D}${libdir}/sota/conf.d
21
22 install -m 0644 ${STAGING_DIR_HOST}${libdir}/sota/sota_implicit_prov_ca.toml \
23 ${D}${libdir}/sota/conf.d/20-sota_implicit_prov_ca.toml
24}
25
26FILES_${PN} = " \
27 ${libdir}/sota/conf.d/20-sota_implicit_prov_ca.toml \
28 "
29
30# vim:set ts=4 sw=4 sts=4 expandtab:
diff --git a/recipes-sota/aktualizr/aktualizr-ca-implicit-prov-creds.bb b/recipes-sota/aktualizr/aktualizr-device-prov-creds.bb
index da17d77..6e02a50 100644
--- a/recipes-sota/aktualizr/aktualizr-ca-implicit-prov-creds.bb
+++ b/recipes-sota/aktualizr/aktualizr-device-prov-creds.bb
@@ -1,4 +1,5 @@
1SUMMARY = "Credentials for implicit provisioning with CA certificate" 1SUMMARY = "Credentials for device provisioning with fleet CA certificate"
2HOMEPAGE = "https://github.com/advancedtelematic/aktualizr"
2SECTION = "base" 3SECTION = "base"
3LICENSE = "MPL-2.0" 4LICENSE = "MPL-2.0"
4LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad" 5LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad"
@@ -13,8 +14,8 @@ DEPENDS = "aktualizr aktualizr-native"
13ALLOW_EMPTY_${PN} = "1" 14ALLOW_EMPTY_${PN} = "1"
14 15
15SRC_URI = " \ 16SRC_URI = " \
16 file://ca.cnf \ 17 file://ca.cnf \
17 " 18 "
18 19
19require credentials.inc 20require credentials.inc
20 21
@@ -39,7 +40,7 @@ do_install() {
39 fi 40 fi
40 41
41 if [ -z ${SOTA_CAKEY_PATH} ]; then 42 if [ -z ${SOTA_CAKEY_PATH} ]; then
42 bbfatal "SOTA_CAKEY_PATH should be set when using implicit provisioning" 43 bbfatal "SOTA_CAKEY_PATH should be set when using device credential provisioning"
43 fi 44 fi
44 45
45 install -m 0700 -d ${D}${localstatedir}/sota 46 install -m 0700 -d ${D}${localstatedir}/sota
@@ -49,9 +50,11 @@ do_install() {
49 --root-ca \ 50 --root-ca \
50 --server-url \ 51 --server-url \
51 --local ${D} \ 52 --local ${D} \
52 --config ${STAGING_DIR_HOST}${libdir}/sota/sota_implicit_prov_ca.toml 53 --config ${STAGING_DIR_HOST}${libdir}/sota/sota-device-cred.toml
53 fi 54 fi
54} 55}
55 56
56FILES_${PN} = " \ 57FILES_${PN} = " \
57 ${localstatedir}/sota/*" 58 ${localstatedir}/sota/*"
59
60# vim:set ts=4 sw=4 sts=4 expandtab:
diff --git a/recipes-sota/aktualizr/aktualizr-device-prov-hsm.bb b/recipes-sota/aktualizr/aktualizr-device-prov-hsm.bb
new file mode 100644
index 0000000..c3cd593
--- /dev/null
+++ b/recipes-sota/aktualizr/aktualizr-device-prov-hsm.bb
@@ -0,0 +1,30 @@
1SUMMARY = "Aktualizr configuration for device credential provisioning with HSM support"
2DESCRIPTION = "Configuration for provisioning Aktualizr with device credentials using externally provided or generated CA with HSM support"
3HOMEPAGE = "https://github.com/advancedtelematic/aktualizr"
4SECTION = "base"
5LICENSE = "MPL-2.0"
6LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad"
7
8inherit allarch
9
10DEPENDS = "aktualizr aktualizr-native"
11RDEPENDS_${PN}_append = "${@' aktualizr-device-prov-creds softhsm-testtoken' if d.getVar('SOTA_DEPLOY_CREDENTIALS') == '1' else ''}"
12
13SRC_URI = ""
14PV = "1.0"
15PR = "6"
16
17require credentials.inc
18
19do_install() {
20 install -m 0700 -d ${D}${libdir}/sota/conf.d
21 install -m 0644 ${STAGING_DIR_HOST}${libdir}/sota/sota-device-cred-hsm.toml \
22 ${D}${libdir}/sota/conf.d/20-sota-device-cred-hsm.toml
23}
24
25FILES_${PN} = " \
26 ${libdir}/sota/conf.d \
27 ${libdir}/sota/conf.d/20-sota-device-cred-hsm.toml \
28 "
29
30# vim:set ts=4 sw=4 sts=4 expandtab:
diff --git a/recipes-sota/aktualizr/aktualizr-device-prov.bb b/recipes-sota/aktualizr/aktualizr-device-prov.bb
new file mode 100644
index 0000000..d579532
--- /dev/null
+++ b/recipes-sota/aktualizr/aktualizr-device-prov.bb
@@ -0,0 +1,29 @@
1SUMMARY = "Aktualizr configuration for device credential provisioning"
2DESCRIPTION = "Configuration for provisioning Aktualizr with device credentials using externally provided or generated CA"
3HOMEPAGE = "https://github.com/advancedtelematic/aktualizr"
4SECTION = "base"
5LICENSE = "MPL-2.0"
6LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad"
7
8inherit allarch
9
10DEPENDS = "aktualizr aktualizr-native openssl-native"
11RDEPENDS_${PN}_append = "${@' aktualizr-device-prov-creds' if d.getVar('SOTA_DEPLOY_CREDENTIALS') == '1' else ''}"
12
13PV = "1.0"
14PR = "1"
15
16require credentials.inc
17
18do_install() {
19 install -m 0700 -d ${D}${libdir}/sota/conf.d
20 install -m 0644 ${STAGING_DIR_HOST}${libdir}/sota/sota-device-cred.toml \
21 ${D}${libdir}/sota/conf.d/20-sota-device-cred.toml
22}
23
24FILES_${PN} = " \
25 ${libdir}/sota/conf.d \
26 ${libdir}/sota/conf.d/20-sota-device-cred.toml \
27 "
28
29# vim:set ts=4 sw=4 sts=4 expandtab:
diff --git a/recipes-sota/aktualizr/aktualizr-hsm-prov.bb b/recipes-sota/aktualizr/aktualizr-hsm-prov.bb
deleted file mode 100644
index 77c6720..0000000
--- a/recipes-sota/aktualizr/aktualizr-hsm-prov.bb
+++ /dev/null
@@ -1,30 +0,0 @@
1SUMMARY = "Aktualizr configuration with HSM support"
2DESCRIPTION = "Configuration for HSM provisioning with Aktualizr, the SOTA Client application written in C++"
3HOMEPAGE = "https://github.com/advancedtelematic/aktualizr"
4SECTION = "base"
5LICENSE = "MPL-2.0"
6LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad"
7
8inherit allarch
9
10DEPENDS = "aktualizr aktualizr-native"
11RDEPENDS_${PN}_append = "${@' aktualizr-ca-implicit-prov-creds softhsm-testtoken' if d.getVar('SOTA_DEPLOY_CREDENTIALS') == '1' else ''}"
12
13SRC_URI = ""
14PV = "1.0"
15PR = "6"
16
17require credentials.inc
18
19do_install() {
20 install -m 0700 -d ${D}${libdir}/sota/conf.d
21 install -m 0644 ${STAGING_DIR_HOST}${libdir}/sota/sota_hsm_prov.toml \
22 ${D}${libdir}/sota/conf.d/20-sota_hsm_prov.toml
23}
24
25FILES_${PN} = " \
26 ${libdir}/sota/conf.d \
27 ${libdir}/sota/conf.d/20-sota_hsm_prov.toml \
28 "
29
30# vim:set ts=4 sw=4 sts=4 expandtab:
diff --git a/recipes-sota/aktualizr/aktualizr-auto-prov-creds.bb b/recipes-sota/aktualizr/aktualizr-shared-prov-creds.bb
index 6b2dd27..dbb5fde 100644
--- a/recipes-sota/aktualizr/aktualizr-auto-prov-creds.bb
+++ b/recipes-sota/aktualizr/aktualizr-shared-prov-creds.bb
@@ -1,4 +1,5 @@
1SUMMARY = "Credentials for autoprovisioning scenario" 1SUMMARY = "Credentials for shared provisioning"
2HOMEPAGE = "https://github.com/advancedtelematic/aktualizr"
2SECTION = "base" 3SECTION = "base"
3LICENSE = "MPL-2.0" 4LICENSE = "MPL-2.0"
4LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad" 5LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad"
diff --git a/recipes-sota/aktualizr/aktualizr-auto-prov.bb b/recipes-sota/aktualizr/aktualizr-shared-prov.bb
index 4b68491..d3d6f16 100644
--- a/recipes-sota/aktualizr/aktualizr-auto-prov.bb
+++ b/recipes-sota/aktualizr/aktualizr-shared-prov.bb
@@ -1,5 +1,5 @@
1SUMMARY = "Aktualizr configuration for autoprovisioning" 1SUMMARY = "Aktualizr configuration for shared credential provisioning"
2DESCRIPTION = "Configuration for automatically provisioning Aktualizr, the SOTA Client application written in C++" 2DESCRIPTION = "Configuration for provisioning Aktualizr with shared credentials"
3HOMEPAGE = "https://github.com/advancedtelematic/aktualizr" 3HOMEPAGE = "https://github.com/advancedtelematic/aktualizr"
4SECTION = "base" 4SECTION = "base"
5LICENSE = "MPL-2.0" 5LICENSE = "MPL-2.0"
@@ -8,7 +8,7 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7
8inherit allarch 8inherit allarch
9 9
10DEPENDS = "aktualizr-native zip-native" 10DEPENDS = "aktualizr-native zip-native"
11RDEPENDS_${PN}_append = "${@' aktualizr-auto-prov-creds' if d.getVar('SOTA_DEPLOY_CREDENTIALS') == '1' else ''}" 11RDEPENDS_${PN}_append = "${@' aktualizr-shared-prov-creds' if d.getVar('SOTA_DEPLOY_CREDENTIALS') == '1' else ''}"
12PV = "1.0" 12PV = "1.0"
13PR = "6" 13PR = "6"
14 14
@@ -31,15 +31,13 @@ do_install() {
31 fi 31 fi
32 32
33 install -m 0700 -d ${D}${libdir}/sota/conf.d 33 install -m 0700 -d ${D}${libdir}/sota/conf.d
34 aktualizr_toml=${@bb.utils.contains('SOTA_CLIENT_FEATURES', 'secondary-network', 'sota_autoprov_primary.toml', 'sota_autoprov.toml', d)} 34 install -m 0644 ${STAGING_DIR_NATIVE}${libdir}/sota/sota-shared-cred.toml \
35 35 ${D}${libdir}/sota/conf.d/20-sota-shared-cred.toml
36 install -m 0644 ${STAGING_DIR_NATIVE}${libdir}/sota/${aktualizr_toml} \
37 ${D}${libdir}/sota/conf.d/20-${aktualizr_toml}
38} 36}
39 37
40FILES_${PN} = " \ 38FILES_${PN} = " \
41 ${libdir}/sota/conf.d \ 39 ${libdir}/sota/conf.d \
42 ${libdir}/sota/conf.d/20-${aktualizr_toml} \ 40 ${libdir}/sota/conf.d/20-sota-shared-cred.toml \
43 " 41 "
44 42
45# vim:set ts=4 sw=4 sts=4 expandtab: 43# vim:set ts=4 sw=4 sts=4 expandtab:
diff --git a/recipes-sota/aktualizr/aktualizr-uboot-env-rollback.bb b/recipes-sota/aktualizr/aktualizr-uboot-env-rollback.bb
index d962876..860f225 100644
--- a/recipes-sota/aktualizr/aktualizr-uboot-env-rollback.bb
+++ b/recipes-sota/aktualizr/aktualizr-uboot-env-rollback.bb
@@ -13,7 +13,7 @@ SRC_URI = ""
13 13
14do_install() { 14do_install() {
15 install -m 0700 -d ${D}${libdir}/sota/conf.d 15 install -m 0700 -d ${D}${libdir}/sota/conf.d
16 install -m 0644 ${STAGING_DIR_NATIVE}${libdir}/sota/sota_uboot_env.toml ${D}${libdir}/sota/conf.d/30-rollback.toml 16 install -m 0644 ${STAGING_DIR_NATIVE}${libdir}/sota/sota-uboot-env.toml ${D}${libdir}/sota/conf.d/30-rollback.toml
17} 17}
18 18
19FILES_${PN} = " \ 19FILES_${PN} = " \
diff --git a/recipes-sota/aktualizr/aktualizr_git.bb b/recipes-sota/aktualizr/aktualizr_git.bb
index 903f2de..75d5bd9 100755..100644
--- a/recipes-sota/aktualizr/aktualizr_git.bb
+++ b/recipes-sota/aktualizr/aktualizr_git.bb
@@ -15,24 +15,23 @@ RDEPENDS_${PN}-ptest += "bash cmake curl python3-misc python3-modules openssl-bi
15PV = "1.0+git${SRCPV}" 15PV = "1.0+git${SRCPV}"
16PR = "7" 16PR = "7"
17 17
18GARAGE_SIGN_PV = "0.6.0-18-g5b8b259" 18GARAGE_SIGN_PV = "0.7.0-3-gf5ba640"
19 19
20SRC_URI = " \ 20SRC_URI = " \
21 gitsm://github.com/advancedtelematic/aktualizr;branch=${BRANCH} \ 21 gitsm://github.com/advancedtelematic/aktualizr;branch=${BRANCH} \
22 file://run-ptest \ 22 file://run-ptest \
23 file://aktualizr.service \ 23 file://aktualizr.service \
24 file://aktualizr-secondary.service \ 24 file://aktualizr-secondary.service \
25 file://aktualizr-secondary.socket \
26 file://aktualizr-serialcan.service \ 25 file://aktualizr-serialcan.service \
27 file://10-resource-control.conf \ 26 file://10-resource-control.conf \
28 ${@ d.expand("https://ats-tuf-cli-releases.s3-eu-central-1.amazonaws.com/cli-${GARAGE_SIGN_PV}.tgz;unpack=0") if d.getVar('GARAGE_SIGN_AUTOVERSION') != '1' else ''} \ 27 ${@ d.expand("https://ats-tuf-cli-releases.s3-eu-central-1.amazonaws.com/cli-${GARAGE_SIGN_PV}.tgz;unpack=0") if d.getVar('GARAGE_SIGN_AUTOVERSION') != '1' else ''} \
29 " 28 "
30 29
31# for garage-sign archive 30# for garage-sign archive
32SRC_URI[md5sum] = "c5e9968dfe78a7264ab9a8338c11725d" 31SRC_URI[md5sum] = "e104ccd4f32e52571a5fc0e5042db050"
33SRC_URI[sha256sum] = "3a19258d7a1825a308aca0da82f7a337985bec05e8951355c4c95f0fcf2444f4" 32SRC_URI[sha256sum] = "c590be1a57523bfe097af82279eda5c97cf40ae47fb27162cf33c469702c8a9b"
34 33
35SRCREV = "c50feb37034eceb1254429d3e3ed38e5b8a0dc60" 34SRCREV = "fce5854ff10e7efd52d69bbaf68dc2af990d5746"
36BRANCH ?= "master" 35BRANCH ?= "master"
37 36
38S = "${WORKDIR}/git" 37S = "${WORKDIR}/git"
@@ -45,7 +44,7 @@ PTEST_ENABLED = "0"
45 44
46SYSTEMD_PACKAGES = "${PN} ${PN}-secondary" 45SYSTEMD_PACKAGES = "${PN} ${PN}-secondary"
47SYSTEMD_SERVICE_${PN} = "aktualizr.service" 46SYSTEMD_SERVICE_${PN} = "aktualizr.service"
48SYSTEMD_SERVICE_${PN}-secondary = "aktualizr-secondary.socket" 47SYSTEMD_SERVICE_${PN}-secondary = "aktualizr-secondary.service"
49 48
50EXTRA_OECMAKE = "-DCMAKE_BUILD_TYPE=Release -DAKTUALIZR_VERSION=${PV} ${@bb.utils.contains('PTEST_ENABLED', '1', '-DTESTSUITE_VALGRIND=on', '', d)}" 49EXTRA_OECMAKE = "-DCMAKE_BUILD_TYPE=Release -DAKTUALIZR_VERSION=${PV} ${@bb.utils.contains('PTEST_ENABLED', '1', '-DTESTSUITE_VALGRIND=on', '', d)}"
51 50
@@ -93,14 +92,12 @@ do_install_ptest() {
93 92
94do_install_append () { 93do_install_append () {
95 install -d ${D}${libdir}/sota 94 install -d ${D}${libdir}/sota
96 install -m 0644 ${S}/config/sota_autoprov.toml ${D}/${libdir}/sota/sota_autoprov.toml 95 install -m 0644 ${S}/config/sota-shared-cred.toml ${D}/${libdir}/sota/sota-shared-cred.toml
97 install -m 0644 ${S}/config/sota_autoprov_primary.toml ${D}/${libdir}/sota/sota_autoprov_primary.toml 96 install -m 0644 ${S}/config/sota-device-cred-hsm.toml ${D}/${libdir}/sota/sota-device-cred-hsm.toml
98 install -m 0644 ${S}/config/sota_hsm_prov.toml ${D}/${libdir}/sota/sota_hsm_prov.toml 97 install -m 0644 ${S}/config/sota-device-cred.toml ${D}/${libdir}/sota/sota-device-cred.toml
99 install -m 0644 ${S}/config/sota_implicit_prov_ca.toml ${D}/${libdir}/sota/sota_implicit_prov_ca.toml 98 install -m 0644 ${S}/config/sota-secondary.toml ${D}/${libdir}/sota/sota-secondary.toml
100 install -m 0644 ${S}/config/sota_secondary.toml ${D}/${libdir}/sota/sota_secondary.toml 99 install -m 0644 ${S}/config/sota-uboot-env.toml ${D}/${libdir}/sota/sota-uboot-env.toml
101 install -m 0644 ${S}/config/sota_uboot_env.toml ${D}/${libdir}/sota/sota_uboot_env.toml
102 install -d ${D}${systemd_unitdir}/system 100 install -d ${D}${systemd_unitdir}/system
103 install -m 0644 ${WORKDIR}/aktualizr-secondary.socket ${D}${systemd_unitdir}/system/aktualizr-secondary.socket
104 install -m 0644 ${WORKDIR}/aktualizr-secondary.service ${D}${systemd_unitdir}/system/aktualizr-secondary.service 101 install -m 0644 ${WORKDIR}/aktualizr-secondary.service ${D}${systemd_unitdir}/system/aktualizr-secondary.service
105 install -m 0700 -d ${D}${libdir}/sota/conf.d 102 install -m 0700 -d ${D}${libdir}/sota/conf.d
106 install -m 0700 -d ${D}${sysconfdir}/sota/conf.d 103 install -m 0700 -d ${D}${sysconfdir}/sota/conf.d
@@ -175,8 +172,7 @@ FILES_${PN}-examples = " \
175 172
176FILES_${PN}-secondary = " \ 173FILES_${PN}-secondary = " \
177 ${bindir}/aktualizr-secondary \ 174 ${bindir}/aktualizr-secondary \
178 ${libdir}/sota/sota_secondary.toml \ 175 ${libdir}/sota/sota-secondary.toml \
179 ${systemd_unitdir}/system/aktualizr-secondary.socket \
180 ${systemd_unitdir}/system/aktualizr-secondary.service \ 176 ${systemd_unitdir}/system/aktualizr-secondary.service \
181 " 177 "
182 178
diff --git a/recipes-sota/aktualizr/files/aktualizr-secondary.service b/recipes-sota/aktualizr/files/aktualizr-secondary.service
index 9628ee3..b577ae8 100644
--- a/recipes-sota/aktualizr/files/aktualizr-secondary.service
+++ b/recipes-sota/aktualizr/files/aktualizr-secondary.service
@@ -1,8 +1,12 @@
1[Unit] 1[Unit]
2Description=Aktualizr SOTA Client (UPTANE Secondary) 2Description=Aktualizr SOTA Client (UPTANE Secondary)
3After=network.target
3 4
4[Service] 5[Service]
5RestartSec=10 6RestartSec=10
6Restart=always 7Restart=always
7ExecStart=/usr/bin/aktualizr-secondary --config /usr/lib/sota/sota_secondary.toml 8ExecStart=/usr/bin/aktualizr-secondary
9
10[Install]
11WantedBy=multi-user.target
8 12
diff --git a/recipes-sota/aktualizr/files/aktualizr-secondary.socket b/recipes-sota/aktualizr/files/aktualizr-secondary.socket
deleted file mode 100644
index da0ee44..0000000
--- a/recipes-sota/aktualizr/files/aktualizr-secondary.socket
+++ /dev/null
@@ -1,6 +0,0 @@
1[Socket]
2ListenStream=9030
3ListenDatagram=9031
4
5[Install]
6WantedBy=sockets.target \ No newline at end of file
diff --git a/recipes-sota/config/aktualizr-polling-interval.bb b/recipes-sota/config/aktualizr-polling-interval.bb
new file mode 100644
index 0000000..53c008a
--- /dev/null
+++ b/recipes-sota/config/aktualizr-polling-interval.bb
@@ -0,0 +1,29 @@
1SUMMARY = "Set polling interval in Aktualizr"
2DESCRIPTION = "Configures aktualizr to poll at a custom frequency (suitable for testing or other purposes)"
3HOMEPAGE = "https://github.com/advancedtelematic/aktualizr"
4SECTION = "base"
5LICENSE = "MPL-2.0"
6LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad"
7
8inherit allarch
9
10SRC_URI = " \
11 file://60-polling-interval.toml \
12 "
13
14SOTA_POLLING_SEC ?= "30"
15
16do_install_append () {
17 install -m 0700 -d ${D}${libdir}/sota/conf.d
18 install -m 0644 ${WORKDIR}/60-polling-interval.toml ${D}${libdir}/sota/conf.d/60-polling-interval.toml
19
20 sed -i -e 's|@POLLING_SEC@|${SOTA_POLLING_SEC}|g' \
21 ${D}${libdir}/sota/conf.d/60-polling-interval.toml
22}
23
24FILES_${PN} = " \
25 ${libdir}/sota/conf.d/60-polling-interval.toml \
26 "
27
28# vim:set ts=4 sw=4 sts=4 expandtab:
29
diff --git a/recipes-sota/config/files/60-polling-interval.toml b/recipes-sota/config/files/60-polling-interval.toml
new file mode 100644
index 0000000..7d25d05
--- /dev/null
+++ b/recipes-sota/config/files/60-polling-interval.toml
@@ -0,0 +1,2 @@
1[uptane]
2polling_sec = @POLLING_SEC@
diff --git a/recipes-test/big-update/big-update_1.0.bb b/recipes-test/big-update/big-update_1.0.bb
index 68b9746..3b1d652 100644
--- a/recipes-test/big-update/big-update_1.0.bb
+++ b/recipes-test/big-update/big-update_1.0.bb
@@ -1,5 +1,5 @@
1DESCRIPTION = "Example Package with 10MB of random, seeded content" 1DESCRIPTION = "Example Package with 10MB of random, seeded content"
2LICENSE = "CLOSED" 2LICENSE = "MPL-2.0"
3 3
4SRC_URI = "file://rand_file.py" 4SRC_URI = "file://rand_file.py"
5 5
diff --git a/recipes-test/big-update/big-update_2.0.bb b/recipes-test/big-update/big-update_2.0.bb
index 20c8138..7cb6e94 100644
--- a/recipes-test/big-update/big-update_2.0.bb
+++ b/recipes-test/big-update/big-update_2.0.bb
@@ -1,5 +1,5 @@
1DESCRIPTION = "Example Package with 12MB of random, seeded content" 1DESCRIPTION = "Example Package with 12MB of random, seeded content"
2LICENSE = "CLOSED" 2LICENSE = "MPL-2.0"
3 3
4SRC_URI = "file://rand_file.py" 4SRC_URI = "file://rand_file.py"
5 5
diff --git a/recipes-test/demo-config/files/30-fake-pacman.toml b/recipes-test/demo-config/files/30-fake-pacman.toml
new file mode 100644
index 0000000..3fb5cf2
--- /dev/null
+++ b/recipes-test/demo-config/files/30-fake-pacman.toml
@@ -0,0 +1,2 @@
1[pacman]
2type = "fake"
diff --git a/recipes-test/demo-config/files/30-secondary-config.toml b/recipes-test/demo-config/files/30-secondary-config.toml
new file mode 100644
index 0000000..7714240
--- /dev/null
+++ b/recipes-test/demo-config/files/30-secondary-config.toml
@@ -0,0 +1,2 @@
1[uptane]
2secondary_config_file = "@CFG_FILEPATH@"
diff --git a/recipes-test/demo-config/files/35-network-config.toml b/recipes-test/demo-config/files/35-network-config.toml
new file mode 100644
index 0000000..db7a1bb
--- /dev/null
+++ b/recipes-test/demo-config/files/35-network-config.toml
@@ -0,0 +1,4 @@
1[network]
2port = @PORT@
3primary_ip = @PRIMARY_IP@
4primary_port = @PRIMARY_PORT@
diff --git a/recipes-test/demo-config/files/45-id-config.toml b/recipes-test/demo-config/files/45-id-config.toml
new file mode 100644
index 0000000..6cbd77f
--- /dev/null
+++ b/recipes-test/demo-config/files/45-id-config.toml
@@ -0,0 +1,3 @@
1[uptane]
2ecu_serial = @SERIAL@
3ecu_hardware_id = @HWID@
diff --git a/recipes-test/demo-config/files/ip_secondary_config.json b/recipes-test/demo-config/files/ip_secondary_config.json
new file mode 100644
index 0000000..690cf2e
--- /dev/null
+++ b/recipes-test/demo-config/files/ip_secondary_config.json
@@ -0,0 +1,7 @@
1{
2 "IP": {
3 "secondaries_wait_port": @PORT@,
4 "secondaries_wait_timeout": @TIMEOUT@,
5 "secondaries": @ADDR_ARRAY@
6 }
7}
diff --git a/recipes-test/demo-config/primary-config.bb b/recipes-test/demo-config/primary-config.bb
new file mode 100644
index 0000000..27cb553
--- /dev/null
+++ b/recipes-test/demo-config/primary-config.bb
@@ -0,0 +1,68 @@
1DESCRIPTION = "Sample configuration for an Uptane Primary to support IP/Posix Secondary"
2LICENSE = "MPL-2.0"
3LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad"
4
5require shared-conf.inc
6
7PRIMARY_SECONDARIES ?= "${SECONDARY_IP}:${SECONDARY_PORT}"
8
9SRC_URI = "\
10 file://30-secondary-config.toml \
11 file://ip_secondary_config.json \
12 "
13
14def get_secondary_addrs(d):
15 import json
16
17 secondaries = d.getVar('PRIMARY_SECONDARIES')
18 sec_array = []
19 for secondary in secondaries.split():
20 sec_array.append({"addr": secondary})
21
22 return json.dumps(sec_array)
23
24do_install () {
25
26 if [ ! -n "${SOTA_SECONDARY_CONFIG}" ]; then
27 bbwarn "SOTA_SECONDARY_CONFIG hasn't been specified in the local config, generate a default one"
28
29 IP_SECONDARY_CONFIG_FILE=${WORKDIR}/ip_secondary_config.json
30 IP_SECONDARY_ADDRS='${@get_secondary_addrs(d)}'
31 else
32 bbwarn "SOTA_SECONDARY_CONFIG has been specified in the local config: ${SOTA_SECONDARY_CONFIG}"
33
34 IP_SECONDARY_CONFIG_FILE=${SOTA_SECONDARY_CONFIG}
35 fi
36
37 if [ ! -f $IP_SECONDARY_CONFIG_FILE ]; then
38 bbfatal "Secondary config file does not exist: $IP_SECONDARY_CONFIG_FILE"
39 fi
40
41 SECONDARY_CONFIG_DEST_DIR="${D}${sysconfdir}/sota/ecus"
42 SECONDARY_CONFIG_DEST_FILEPATH=$SECONDARY_CONFIG_DEST_DIR/$(basename -- $IP_SECONDARY_CONFIG_FILE)
43 SECONDARY_CONFIG_FILEPATH_ON_IMAGE="${sysconfdir}/sota/ecus/$(basename -- $IP_SECONDARY_CONFIG_FILE)"
44
45 # install the secondary configuration file (json)
46 install -m 0700 -d $SECONDARY_CONFIG_DEST_DIR
47 install -m 0644 $IP_SECONDARY_CONFIG_FILE $SECONDARY_CONFIG_DEST_DIR
48
49 # if SOTA_SECONDARY_CONFIG/secondary config file is not defined in the local conf
50 # then a default template is used and filled with corresponding configuration variable values
51 if [ ! -n "${SOTA_SECONDARY_CONFIG}" ]; then
52 sed -i -e "s|@PORT@|${PRIMARY_PORT}|g" \
53 -e "s|@TIMEOUT@|${PRIMARY_WAIT_TIMEOUT}|g" \
54 -e "s|@ADDR_ARRAY@|$IP_SECONDARY_ADDRS|g" $SECONDARY_CONFIG_DEST_FILEPATH
55 fi
56
57 # install aktualizr config file (toml) that points to the secondary config file, so aktualizr is aware about it
58 install -m 0700 -d ${D}${libdir}/sota/conf.d
59 install -m 0644 ${WORKDIR}/30-secondary-config.toml ${D}${libdir}/sota/conf.d
60 sed -i "s|@CFG_FILEPATH@|$SECONDARY_CONFIG_FILEPATH_ON_IMAGE|g" ${D}${libdir}/sota/conf.d/30-secondary-config.toml
61}
62
63FILES_${PN} = " \
64 ${libdir}/sota/conf.d/* \
65 ${sysconfdir}/sota/ecus/* \
66 "
67
68# vim:set ts=4 sw=4 sts=4 expandtab:
diff --git a/recipes-test/demo-config/secondary-config.bb b/recipes-test/demo-config/secondary-config.bb
new file mode 100644
index 0000000..9411646
--- /dev/null
+++ b/recipes-test/demo-config/secondary-config.bb
@@ -0,0 +1,41 @@
1DESCRIPTION = "Sample configuration for an Uptane Secondary"
2LICENSE = "MPL-2.0"
3LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad"
4
5require shared-conf.inc
6
7SECONDARY_SERIAL_ID ?= ""
8SOTA_HARDWARE_ID ?= "${MACHINE}-sndry"
9SECONDARY_HARDWARE_ID ?= "${SOTA_HARDWARE_ID}"
10
11SRC_URI = "\
12 file://30-fake-pacman.toml \
13 file://35-network-config.toml \
14 file://45-id-config.toml \
15 "
16
17do_install () {
18 install -m 0700 -d ${D}${libdir}/sota/conf.d
19 install -m 0644 ${WORKDIR}/30-fake-pacman.toml ${D}/${libdir}/sota/conf.d/30-fake-pacman.toml
20
21 install -m 0644 ${WORKDIR}/35-network-config.toml ${D}/${libdir}/sota/conf.d/35-network-config.toml
22 sed -i -e 's|@PORT@|${SECONDARY_PORT}|g' \
23 -e 's|@PRIMARY_IP@|${PRIMARY_IP}|g' \
24 -e 's|@PRIMARY_PORT@|${PRIMARY_PORT}|g' \
25 ${D}/${libdir}/sota/conf.d/35-network-config.toml
26
27 install -m 0644 ${WORKDIR}/45-id-config.toml ${D}/${libdir}/sota/conf.d/45-id-config.toml
28 sed -i -e 's|@SERIAL@|${SECONDARY_SERIAL_ID}|g' \
29 -e 's|@HWID@|${SECONDARY_HARDWARE_ID}|g' \
30 ${D}/${libdir}/sota/conf.d/45-id-config.toml
31
32}
33
34FILES_${PN} = " \
35 ${libdir}/sota/conf.d \
36 ${libdir}/sota/conf.d/30-fake-pacman.toml \
37 ${libdir}/sota/conf.d/35-network-config.toml \
38 ${libdir}/sota/conf.d/45-id-config.toml \
39 "
40
41# vim:set ts=4 sw=4 sts=4 expandtab:
diff --git a/recipes-test/demo-config/shared-conf.inc b/recipes-test/demo-config/shared-conf.inc
new file mode 100644
index 0000000..ce2bb44
--- /dev/null
+++ b/recipes-test/demo-config/shared-conf.inc
@@ -0,0 +1,5 @@
1SECONDARY_IP ?= "10.0.3.2"
2SECONDARY_PORT ?= "9050"
3PRIMARY_IP ?= "10.0.3.1"
4PRIMARY_PORT ?= "9040"
5PRIMARY_WAIT_TIMEOUT ?= "120"
diff --git a/recipes-test/demo-network-config/files/26-static-client.network b/recipes-test/demo-network-config/files/26-static-client.network
new file mode 100644
index 0000000..19a6b83
--- /dev/null
+++ b/recipes-test/demo-network-config/files/26-static-client.network
@@ -0,0 +1,7 @@
1[Match]
2Name=@IFNAME@
3
4[Network]
5Description=Private internal network between aktualizr Primary and Secondary nodes
6Address=@ADDR@
7DHCP=no
diff --git a/recipes-test/demo-network-config/primary-network-config.bb b/recipes-test/demo-network-config/primary-network-config.bb
index 78678a2..c7daa15 100644
--- a/recipes-test/demo-network-config/primary-network-config.bb
+++ b/recipes-test/demo-network-config/primary-network-config.bb
@@ -1,10 +1,12 @@
1DESCRIPTION = "Sample network configuration for an Uptane Primary" 1DESCRIPTION = "Sample network configuration for an Uptane Primary"
2LICENSE = "CLOSED" 2LICENSE = "MPL-2.0"
3LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad"
3 4
4inherit allarch 5inherit allarch
5 6
6SRC_URI = "file://25-dhcp-server.network" 7SRC_URI = "\
7 8 file://27-dhcp-client-external.network \
9 "
8 10
9FILES_${PN} = "/usr/lib/systemd/network" 11FILES_${PN} = "/usr/lib/systemd/network"
10 12
@@ -12,5 +14,12 @@ PR = "1"
12 14
13do_install() { 15do_install() {
14 install -d ${D}/usr/lib/systemd/network 16 install -d ${D}/usr/lib/systemd/network
15 install -m 0644 ${WORKDIR}/25-dhcp-server.network ${D}/usr/lib/systemd/network/ 17 install -m 0644 ${WORKDIR}/27-dhcp-client-external.network ${D}/usr/lib/systemd/network/
16} 18}
19
20PRIMARY_IP ?= "10.0.3.1"
21IP_ADDR = "${PRIMARY_IP}"
22
23require static-network-config.inc
24
25# vim:set ts=4 sw=4 sts=4 expandtab:
diff --git a/recipes-test/demo-network-config/secondary-network-config.bb b/recipes-test/demo-network-config/secondary-network-config.bb
index 9091c65..c70d88a 100644
--- a/recipes-test/demo-network-config/secondary-network-config.bb
+++ b/recipes-test/demo-network-config/secondary-network-config.bb
@@ -1,20 +1,29 @@
1DESCRIPTION = "Sample network configuration for an Uptane Secondary" 1DESCRIPTION = "Sample network configuration for an Uptane Secondary"
2LICENSE = "CLOSED" 2LICENSE = "MPL-2.0"
3LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad"
3 4
4inherit allarch 5inherit allarch
5 6
7# TODO: It configures the 'user' interface in NAT mode and provides an access to public Inet via it
8# which is not desired for Secondary. It cannot be just removed since we get SSH access to Secondary
9# VM via this interface. So, the task is to configure the interface in such way that it does provide access
10# via SSH from a host machine and forbids an access to Inet
6SRC_URI = "\ 11SRC_URI = "\
7 file://26-dhcp-client.network \
8 file://27-dhcp-client-external.network \ 12 file://27-dhcp-client-external.network \
9 " 13 "
10 14
11
12FILES_${PN} = "/usr/lib/systemd/network" 15FILES_${PN} = "/usr/lib/systemd/network"
13 16
14PR = "1" 17PR = "1"
15 18
16do_install() { 19do_install() {
17 install -d ${D}/usr/lib/systemd/network 20 install -d ${D}/usr/lib/systemd/network
18 install -m 0644 ${WORKDIR}/26-dhcp-client.network ${D}/usr/lib/systemd/network/
19 install -m 0644 ${WORKDIR}/27-dhcp-client-external.network ${D}/usr/lib/systemd/network/ 21 install -m 0644 ${WORKDIR}/27-dhcp-client-external.network ${D}/usr/lib/systemd/network/
20} 22}
23
24SECONDARY_IP ?= "10.0.3.2"
25IP_ADDR = "${SECONDARY_IP}"
26
27require static-network-config.inc
28
29# vim:set ts=4 sw=4 sts=4 expandtab:
diff --git a/recipes-test/demo-network-config/static-network-config.inc b/recipes-test/demo-network-config/static-network-config.inc
new file mode 100644
index 0000000..e64675e
--- /dev/null
+++ b/recipes-test/demo-network-config/static-network-config.inc
@@ -0,0 +1,16 @@
1SRC_URI_append = "\
2 file://26-static-client.network \
3 "
4
5SECONDARY_INTERFACE ?= "enp0s5"
6
7do_install_append() {
8 install -d ${D}/usr/lib/systemd/network
9 install -m 0644 ${WORKDIR}/26-static-client.network ${D}/usr/lib/systemd/network/
10 sed -i -e 's|@ADDR@|${IP_ADDR}|g' \
11 -e 's|@IFNAME@|${SECONDARY_INTERFACE}|g' \
12 ${D}/usr/lib/systemd/network/26-static-client.network
13
14}
15
16# vim:set ts=4 sw=4 sts=4 expandtab:
diff --git a/recipes-test/images/primary-image.bb b/recipes-test/images/primary-image.bb
index 6d2df94..ba1dc1f 100644
--- a/recipes-test/images/primary-image.bb
+++ b/recipes-test/images/primary-image.bb
@@ -2,13 +2,15 @@ include recipes-core/images/core-image-minimal.bb
2 2
3SUMMARY = "A minimal Uptane Primary image running aktualizr, for testing with a Linux secondary" 3SUMMARY = "A minimal Uptane Primary image running aktualizr, for testing with a Linux secondary"
4 4
5LICENSE = "MIT" 5LICENSE = "MPL-2.0"
6 6
7IMAGE_INSTALL_remove = " \ 7IMAGE_INSTALL_remove = " \
8 virtual/network-configuration \
8 " 9 "
9 10
10IMAGE_INSTALL_append = " \ 11IMAGE_INSTALL_append = " \
11 primary-network-config \ 12 primary-network-config \
13 primary-config \
12 " 14 "
13 15
14# vim:set ts=4 sw=4 sts=4 expandtab: 16# vim:set ts=4 sw=4 sts=4 expandtab:
diff --git a/recipes-test/images/secondary-image.bb b/recipes-test/images/secondary-image.bb
index 61df85b..27d1e3f 100644
--- a/recipes-test/images/secondary-image.bb
+++ b/recipes-test/images/secondary-image.bb
@@ -2,18 +2,20 @@ include recipes-core/images/core-image-minimal.bb
2 2
3SUMMARY = "A minimal Uptane Secondary image running aktualizr-secondary" 3SUMMARY = "A minimal Uptane Secondary image running aktualizr-secondary"
4 4
5LICENSE = "MIT" 5LICENSE = "MPL-2.0"
6 6
7SECONDARY_SERIAL_ID ?= ""
8SOTA_HARDWARE_ID ?= "${MACHINE}-sndry"
7 9
8# Remove default aktualizr primary, and the provisioning configuration (which 10# Remove default aktualizr primary, and the provisioning configuration (which
9# RDEPENDS on aktualizr) 11# RDEPENDS on aktualizr)
10IMAGE_INSTALL_remove = " \ 12IMAGE_INSTALL_remove = " \
11 aktualizr \ 13 aktualizr \
12 aktualizr-auto-prov \ 14 aktualizr-shared-prov \
13 aktualizr-auto-prov-creds \ 15 aktualizr-shared-prov-creds \
14 aktualizr-ca-implicit-prov \ 16 aktualizr-device-prov \
15 aktualizr-ca-implicit-prov-creds \ 17 aktualizr-device-prov-creds \
16 aktualizr-hsm-prov \ 18 aktualizr-device-prov-hsm \
17 aktualizr-uboot-env-rollback \ 19 aktualizr-uboot-env-rollback \
18 virtual/network-configuration \ 20 virtual/network-configuration \
19 " 21 "
@@ -21,6 +23,7 @@ IMAGE_INSTALL_remove = " \
21IMAGE_INSTALL_append = " \ 23IMAGE_INSTALL_append = " \
22 aktualizr-secondary \ 24 aktualizr-secondary \
23 secondary-network-config \ 25 secondary-network-config \
26 secondary-config \
24 " 27 "
25 28
26# vim:set ts=4 sw=4 sts=4 expandtab: 29# vim:set ts=4 sw=4 sts=4 expandtab:
diff --git a/scripts/find_aktualizr_dependencies.sh b/scripts/find_aktualizr_dependencies.sh
index 986b541..493df80 100755
--- a/scripts/find_aktualizr_dependencies.sh
+++ b/scripts/find_aktualizr_dependencies.sh
@@ -10,14 +10,15 @@ parentdir="$(dirname "$0")"
10# (jsoncpp, open62541, picojson). Also check libp11, dpkg, and systemd since 10# (jsoncpp, open62541, picojson). Also check libp11, dpkg, and systemd since
11# those are common dependencies not enabled by default. 11# those are common dependencies not enabled by default.
12${parentdir}/find_dependencies.py aktualizr 12${parentdir}/find_dependencies.py aktualizr
13${parentdir}/find_dependencies.py aktualizr-auto-prov 13${parentdir}/find_dependencies.py aktualizr-shared-prov
14${parentdir}/find_dependencies.py aktualizr-auto-prov-creds 14${parentdir}/find_dependencies.py aktualizr-shared-prov-creds
15${parentdir}/find_dependencies.py aktualizr-ca-implicit-prov 15${parentdir}/find_dependencies.py aktualizr-device-prov
16${parentdir}/find_dependencies.py aktualizr-ca-implicit-prov-creds 16${parentdir}/find_dependencies.py aktualizr-device-prov-creds
17${parentdir}/find_dependencies.py aktualizr-hsm-prov 17${parentdir}/find_dependencies.py aktualizr-device-prov-hsm
18${parentdir}/find_dependencies.py aktualizr-hsm-prov-creds 18${parentdir}/find_dependencies.py aktualizr-auto-reboot
19${parentdir}/find_dependencies.py aktualizr-disable-send-ip 19${parentdir}/find_dependencies.py aktualizr-disable-send-ip
20${parentdir}/find_dependencies.py aktualizr-log-debug 20${parentdir}/find_dependencies.py aktualizr-log-debug
21${parentdir}/find_dependencies.py aktualizr-polling-interval
21${parentdir}/find_dependencies.py libp11 22${parentdir}/find_dependencies.py libp11
22${parentdir}/find_dependencies.py dpkg 23${parentdir}/find_dependencies.py dpkg
23${parentdir}/find_dependencies.py systemd 24${parentdir}/find_dependencies.py systemd
diff --git a/scripts/qemucommand.py b/scripts/qemucommand.py
index cafab6d..1049d7c 100644
--- a/scripts/qemucommand.py
+++ b/scripts/qemucommand.py
@@ -109,8 +109,8 @@ class QemuCommand(object):
109 cmdline += ['-net', 'dump,file=' + self.pcap] 109 cmdline += ['-net', 'dump,file=' + self.pcap]
110 if self.secondary_network: 110 if self.secondary_network:
111 cmdline += [ 111 cmdline += [
112 '-net', 'nic,vlan=1,macaddr='+random_mac(), 112 '-netdev', 'socket,id=vlan1,mcast=230.0.0.1:1234,localaddr=127.0.0.1',
113 '-net', 'socket,vlan=1,mcast=230.0.0.1:1234,localaddr=127.0.0.1', 113 '-device', 'e1000,netdev=vlan1,mac='+random_mac(),
114 ] 114 ]
115 if self.gui: 115 if self.gui:
116 cmdline += ["-serial", "stdio"] 116 cmdline += ["-serial", "stdio"]