From d0b6547fde5038cb7ab9837681ea370af24de855 Mon Sep 17 00:00:00 2001 From: Mike Sul Date: Tue, 21 May 2019 08:04:44 +0300 Subject: OTA-2541: Add suffix '-sndry' to a default HW_ID for Secondary. Ability to define IP and Port in local.conf Signed-off-by: Mike Sul --- .../demo-network-config/primary-network-config.bb | 3 ++- .../secondary-network-config.bb | 3 ++- .../demo-network-config/static-network-config.inc | 6 ++--- .../files/35-network_config.toml | 4 ++++ .../demo-secondary-config/files/45-id_config.toml | 3 +++ .../demo-secondary-config/secondary-config.bb | 26 ++++++++++++++++++++-- recipes-test/images/secondary-image.bb | 2 ++ 7 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 recipes-test/demo-secondary-config/files/35-network_config.toml create mode 100644 recipes-test/demo-secondary-config/files/45-id_config.toml diff --git a/recipes-test/demo-network-config/primary-network-config.bb b/recipes-test/demo-network-config/primary-network-config.bb index ce19f07..9725898 100644 --- a/recipes-test/demo-network-config/primary-network-config.bb +++ b/recipes-test/demo-network-config/primary-network-config.bb @@ -16,7 +16,8 @@ do_install() { install -m 0644 ${WORKDIR}/27-dhcp-client-external.network ${D}/usr/lib/systemd/network/ } -SECONDARY_NETWORK_IP_ADDR ?= "10.0.3.1" +PRIMARY_IP ?= "10.0.3.1" +IP_ADDR = "${PRIMARY_IP}" require static-network-config.inc diff --git a/recipes-test/demo-network-config/secondary-network-config.bb b/recipes-test/demo-network-config/secondary-network-config.bb index 6473e05..e33229d 100644 --- a/recipes-test/demo-network-config/secondary-network-config.bb +++ b/recipes-test/demo-network-config/secondary-network-config.bb @@ -20,7 +20,8 @@ do_install() { install -m 0644 ${WORKDIR}/27-dhcp-client-external.network ${D}/usr/lib/systemd/network/ } -SECONDARY_NETWORK_IP_ADDR ?= "10.0.3.2" +SECONDARY_IP ?= "10.0.3.2" +IP_ADDR = "${SECONDARY_IP}" require static-network-config.inc diff --git a/recipes-test/demo-network-config/static-network-config.inc b/recipes-test/demo-network-config/static-network-config.inc index 27d2a20..e64675e 100644 --- a/recipes-test/demo-network-config/static-network-config.inc +++ b/recipes-test/demo-network-config/static-network-config.inc @@ -2,13 +2,13 @@ SRC_URI_append = "\ file://26-static-client.network \ " -SECONDARY_NETWORK_INTERFACE_NAME ?= "enp0s5" +SECONDARY_INTERFACE ?= "enp0s5" do_install_append() { install -d ${D}/usr/lib/systemd/network install -m 0644 ${WORKDIR}/26-static-client.network ${D}/usr/lib/systemd/network/ - sed -i -e 's|@ADDR@|${SECONDARY_NETWORK_IP_ADDR}|g' \ - -e 's|@IFNAME@|${SECONDARY_NETWORK_INTERFACE_NAME}|g' \ + sed -i -e 's|@ADDR@|${IP_ADDR}|g' \ + -e 's|@IFNAME@|${SECONDARY_INTERFACE}|g' \ ${D}/usr/lib/systemd/network/26-static-client.network } diff --git a/recipes-test/demo-secondary-config/files/35-network_config.toml b/recipes-test/demo-secondary-config/files/35-network_config.toml new file mode 100644 index 0000000..db7a1bb --- /dev/null +++ b/recipes-test/demo-secondary-config/files/35-network_config.toml @@ -0,0 +1,4 @@ +[network] +port = @PORT@ +primary_ip = @PRIMARY_IP@ +primary_port = @PRIMARY_PORT@ diff --git a/recipes-test/demo-secondary-config/files/45-id_config.toml b/recipes-test/demo-secondary-config/files/45-id_config.toml new file mode 100644 index 0000000..6cbd77f --- /dev/null +++ b/recipes-test/demo-secondary-config/files/45-id_config.toml @@ -0,0 +1,3 @@ +[uptane] +ecu_serial = @SERIAL@ +ecu_hardware_id = @HWID@ diff --git a/recipes-test/demo-secondary-config/secondary-config.bb b/recipes-test/demo-secondary-config/secondary-config.bb index 3187ff0..b05ab8e 100644 --- a/recipes-test/demo-secondary-config/secondary-config.bb +++ b/recipes-test/demo-secondary-config/secondary-config.bb @@ -1,20 +1,42 @@ DESCRIPTION = "Sample configuration for an Uptane Secondary" LICENSE = "CLOSED" -inherit allarch +SECONDARY_SERIAL_ID ?= "" +SOTA_HARDWARE_ID ?= "${MACHINE}-sndry" +SECONDARY_HARDWARE_ID ?= "${SOTA_HARDWARE_ID}" + +SECONDARY_PORT ?= "9050" +PRIMARY_IP ?= "10.0.3.1" +PRIMARY_PORT ?= "9040" SRC_URI = "\ file://30-fake_pacman.toml \ + file://35-network_config.toml \ + file://45-id_config.toml \ " do_install () { - install -m 0700 -d ${D}${libdir}/sota/conf.d + install -m 0700 -d ${D}${libdir}/sota/conf.d install -m 0644 ${WORKDIR}/30-fake_pacman.toml ${D}/${libdir}/sota/conf.d/30-fake_pacman.toml + + install -m 0644 ${WORKDIR}/35-network_config.toml ${D}/${libdir}/sota/conf.d/35-network_config.toml + sed -i -e 's|@PORT@|${SECONDARY_PORT}|g' \ + -e 's|@PRIMARY_IP@|${PRIMARY_IP}|g' \ + -e 's|@PRIMARY_PORT@|${PRIMARY_PORT}|g' \ + ${D}/${libdir}/sota/conf.d/35-network_config.toml + + install -m 0644 ${WORKDIR}/45-id_config.toml ${D}/${libdir}/sota/conf.d/45-id_config.toml + sed -i -e 's|@SERIAL@|${SECONDARY_SERIAL_ID}|g' \ + -e 's|@HWID@|${SECONDARY_HARDWARE_ID}|g' \ + ${D}/${libdir}/sota/conf.d/45-id_config.toml + } FILES_${PN} = " \ ${libdir}/sota/conf.d \ ${libdir}/sota/conf.d/30-fake_pacman.toml \ + ${libdir}/sota/conf.d/35-network_config.toml \ + ${libdir}/sota/conf.d/45-id_config.toml \ " # 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 46be3d1..a688bbd 100644 --- a/recipes-test/images/secondary-image.bb +++ b/recipes-test/images/secondary-image.bb @@ -4,6 +4,8 @@ SUMMARY = "A minimal Uptane Secondary image running aktualizr-secondary" LICENSE = "MIT" +SECONDARY_SERIAL_ID ?= "" +SOTA_HARDWARE_ID ?= "${MACHINE}-sndry" # Remove default aktualizr primary, and the provisioning configuration (which # RDEPENDS on aktualizr) -- cgit v1.2.3-54-g00ecf