summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Sul <ext-mykhaylo.sul@here.com>2019-05-22 17:02:24 +0300
committerMike Sul <ext-mykhaylo.sul@here.com>2019-05-27 10:40:00 +0300
commit0b89fa5f5505891d8b358f8ef829b0200d238705 (patch)
tree189a5006c02ef9a053fe154c8505ddb037ed95b9
parentf14d0017d221f93b51d57484619aff28cb23f9bd (diff)
downloadmeta-updater-0b89fa5f5505891d8b358f8ef829b0200d238705.tar.gz
OTA-2541: Use local.conf's variables to configure Primary with Secondary(ies) and vice versa
Signed-off-by: Mike Sul <ext-mykhaylo.sul@here.com>
-rwxr-xr-xrecipes-sota/aktualizr/aktualizr_git.bb8
-rw-r--r--recipes-test/demo-config/files/30-fake_pacman.toml (renamed from recipes-test/demo-secondary-config/files/30-fake_pacman.toml)0
-rw-r--r--recipes-test/demo-config/files/30-secondary_config.toml2
-rw-r--r--recipes-test/demo-config/files/35-network_config.toml (renamed from recipes-test/demo-secondary-config/files/35-network_config.toml)0
-rw-r--r--recipes-test/demo-config/files/45-id_config.toml (renamed from recipes-test/demo-secondary-config/files/45-id_config.toml)0
-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.bb (renamed from recipes-test/demo-secondary-config/secondary-config.bb)6
-rw-r--r--recipes-test/demo-config/shared-conf.inc5
-rw-r--r--recipes-test/images/primary-image.bb3
10 files changed, 86 insertions, 13 deletions
diff --git a/recipes-sota/aktualizr/aktualizr_git.bb b/recipes-sota/aktualizr/aktualizr_git.bb
index d61b597..f4c9946 100755
--- a/recipes-sota/aktualizr/aktualizr_git.bb
+++ b/recipes-sota/aktualizr/aktualizr_git.bb
@@ -117,14 +117,6 @@ do_install_append () {
117 fi 117 fi
118 fi 118 fi
119 119
120 if [ -n "${SOTA_SECONDARY_NETWORK_CONFIG}" ]; then
121 if [ -f "${SOTA_SECONDARY_NETWORK_CONFIG}" ]; then
122 install -m 0644 ${SOTA_SECONDARY_NETWORK_CONFIG} ${D}/${libdir}/sota/conf.d/35-secondary-network-config.toml
123 else
124 bbwarn "SOTA_SECONDARY_NETWORK_CONFIG is set to a non-existent file (${SOTA_SECONDARY_NETWORK_CONFIG})"
125 fi
126 fi
127
128 install -m 0755 -d ${D}${systemd_unitdir}/system 120 install -m 0755 -d ${D}${systemd_unitdir}/system
129 aktualizr_service=${@bb.utils.contains('SOTA_CLIENT_FEATURES', 'serialcan', '${WORKDIR}/aktualizr-serialcan.service', '${WORKDIR}/aktualizr.service', d)} 121 aktualizr_service=${@bb.utils.contains('SOTA_CLIENT_FEATURES', 'serialcan', '${WORKDIR}/aktualizr-serialcan.service', '${WORKDIR}/aktualizr.service', d)}
130 install -m 0644 ${aktualizr_service} ${D}${systemd_unitdir}/system/aktualizr.service 122 install -m 0644 ${aktualizr_service} ${D}${systemd_unitdir}/system/aktualizr.service
diff --git a/recipes-test/demo-secondary-config/files/30-fake_pacman.toml b/recipes-test/demo-config/files/30-fake_pacman.toml
index 3fb5cf2..3fb5cf2 100644
--- a/recipes-test/demo-secondary-config/files/30-fake_pacman.toml
+++ b/recipes-test/demo-config/files/30-fake_pacman.toml
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-secondary-config/files/35-network_config.toml b/recipes-test/demo-config/files/35-network_config.toml
index db7a1bb..db7a1bb 100644
--- a/recipes-test/demo-secondary-config/files/35-network_config.toml
+++ b/recipes-test/demo-config/files/35-network_config.toml
diff --git a/recipes-test/demo-secondary-config/files/45-id_config.toml b/recipes-test/demo-config/files/45-id_config.toml
index 6cbd77f..6cbd77f 100644
--- a/recipes-test/demo-secondary-config/files/45-id_config.toml
+++ b/recipes-test/demo-config/files/45-id_config.toml
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..0cd9180
--- /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-secondary-config/secondary-config.bb b/recipes-test/demo-config/secondary-config.bb
index 25972d4..5b213d1 100644
--- a/recipes-test/demo-secondary-config/secondary-config.bb
+++ b/recipes-test/demo-config/secondary-config.bb
@@ -2,14 +2,12 @@ DESCRIPTION = "Sample configuration for an Uptane Secondary"
2LICENSE = "MPL-2.0" 2LICENSE = "MPL-2.0"
3LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad" 3LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad"
4 4
5require shared-conf.inc
6
5SECONDARY_SERIAL_ID ?= "" 7SECONDARY_SERIAL_ID ?= ""
6SOTA_HARDWARE_ID ?= "${MACHINE}-sndry" 8SOTA_HARDWARE_ID ?= "${MACHINE}-sndry"
7SECONDARY_HARDWARE_ID ?= "${SOTA_HARDWARE_ID}" 9SECONDARY_HARDWARE_ID ?= "${SOTA_HARDWARE_ID}"
8 10
9SECONDARY_PORT ?= "9050"
10PRIMARY_IP ?= "10.0.3.1"
11PRIMARY_PORT ?= "9040"
12
13SRC_URI = "\ 11SRC_URI = "\
14 file://30-fake_pacman.toml \ 12 file://30-fake_pacman.toml \
15 file://35-network_config.toml \ 13 file://35-network_config.toml \
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/images/primary-image.bb b/recipes-test/images/primary-image.bb
index 935f7ac..ba1dc1f 100644
--- a/recipes-test/images/primary-image.bb
+++ b/recipes-test/images/primary-image.bb
@@ -9,7 +9,8 @@ IMAGE_INSTALL_remove = " \
9 " 9 "
10 10
11IMAGE_INSTALL_append = " \ 11IMAGE_INSTALL_append = " \
12 primary-network-config \ 12 primary-network-config \
13 primary-config \
13 " 14 "
14 15
15# vim:set ts=4 sw=4 sts=4 expandtab: 16# vim:set ts=4 sw=4 sts=4 expandtab: