diff options
author | ToshikazuOhiwa <toshikazu_ohiwa@mail.toyota.co.jp> | 2020-03-30 09:24:26 +0900 |
---|---|---|
committer | ToshikazuOhiwa <toshikazu_ohiwa@mail.toyota.co.jp> | 2020-03-30 09:24:26 +0900 |
commit | 5b80bfd7bffd4c20d80b7c70a7130529e9a755dd (patch) | |
tree | b4bb18dcd1487dbf1ea8127e5671b7bb2eded033 /external/meta-updater/recipes-test | |
parent | 706ad73eb02caf8532deaf5d38995bd258725cb8 (diff) |
agl-basesystem
Diffstat (limited to 'external/meta-updater/recipes-test')
21 files changed, 333 insertions, 0 deletions
diff --git a/external/meta-updater/recipes-test/big-update/big-update_1.0.bb b/external/meta-updater/recipes-test/big-update/big-update_1.0.bb new file mode 100644 index 00000000..3b1d6523 --- /dev/null +++ b/external/meta-updater/recipes-test/big-update/big-update_1.0.bb @@ -0,0 +1,13 @@ +DESCRIPTION = "Example Package with 10MB of random, seeded content" +LICENSE = "MPL-2.0" + +SRC_URI = "file://rand_file.py" + +FILES_${PN} = "/usr/lib/big-update" + +DEPENDS = "coreutils-native" + +do_install() { + install -d ${D}/usr/lib/big-update + python ${S}/../rand_file.py ${D}/usr/lib/big-update/a-big-file $(numfmt --from=iec 10M) +} diff --git a/external/meta-updater/recipes-test/big-update/big-update_2.0.bb b/external/meta-updater/recipes-test/big-update/big-update_2.0.bb new file mode 100644 index 00000000..7cb6e949 --- /dev/null +++ b/external/meta-updater/recipes-test/big-update/big-update_2.0.bb @@ -0,0 +1,13 @@ +DESCRIPTION = "Example Package with 12MB of random, seeded content" +LICENSE = "MPL-2.0" + +SRC_URI = "file://rand_file.py" + +FILES_${PN} = "/usr/lib/big-update" + +DEPENDS = "coreutils-native" + +do_install() { + install -d ${D}/usr/lib/big-update + python ${S}/../rand_file.py ${D}/usr/lib/big-update/a-big-file $(numfmt --from=iec 12M) +} diff --git a/external/meta-updater/recipes-test/big-update/files/rand_file.py b/external/meta-updater/recipes-test/big-update/files/rand_file.py new file mode 100644 index 00000000..0f4f16e4 --- /dev/null +++ b/external/meta-updater/recipes-test/big-update/files/rand_file.py @@ -0,0 +1,16 @@ +import sys +from random import seed, randint + +def main(): + n = int(sys.argv[2]) + ba = bytearray(n) + + seed(42) + for i in range(0, n): + ba[i] = randint(0, 255) + + with open(sys.argv[1], 'wb') as f: + f.write(bytes(ba)) + +if __name__ == "__main__": + main() diff --git a/external/meta-updater/recipes-test/demo-config/files/30-fake-pacman.toml b/external/meta-updater/recipes-test/demo-config/files/30-fake-pacman.toml new file mode 100644 index 00000000..3fb5cf2c --- /dev/null +++ b/external/meta-updater/recipes-test/demo-config/files/30-fake-pacman.toml @@ -0,0 +1,2 @@ +[pacman] +type = "fake" diff --git a/external/meta-updater/recipes-test/demo-config/files/30-secondary-config.toml b/external/meta-updater/recipes-test/demo-config/files/30-secondary-config.toml new file mode 100644 index 00000000..77142408 --- /dev/null +++ b/external/meta-updater/recipes-test/demo-config/files/30-secondary-config.toml @@ -0,0 +1,2 @@ +[uptane] +secondary_config_file = "@CFG_FILEPATH@" diff --git a/external/meta-updater/recipes-test/demo-config/files/35-network-config.toml b/external/meta-updater/recipes-test/demo-config/files/35-network-config.toml new file mode 100644 index 00000000..db7a1bb0 --- /dev/null +++ b/external/meta-updater/recipes-test/demo-config/files/35-network-config.toml @@ -0,0 +1,4 @@ +[network] +port = @PORT@ +primary_ip = @PRIMARY_IP@ +primary_port = @PRIMARY_PORT@ diff --git a/external/meta-updater/recipes-test/demo-config/files/45-id-config.toml b/external/meta-updater/recipes-test/demo-config/files/45-id-config.toml new file mode 100644 index 00000000..6cbd77f9 --- /dev/null +++ b/external/meta-updater/recipes-test/demo-config/files/45-id-config.toml @@ -0,0 +1,3 @@ +[uptane] +ecu_serial = @SERIAL@ +ecu_hardware_id = @HWID@ diff --git a/external/meta-updater/recipes-test/demo-config/files/ip_secondary_config.json b/external/meta-updater/recipes-test/demo-config/files/ip_secondary_config.json new file mode 100644 index 00000000..690cf2eb --- /dev/null +++ b/external/meta-updater/recipes-test/demo-config/files/ip_secondary_config.json @@ -0,0 +1,7 @@ +{ + "IP": { + "secondaries_wait_port": @PORT@, + "secondaries_wait_timeout": @TIMEOUT@, + "secondaries": @ADDR_ARRAY@ + } +} diff --git a/external/meta-updater/recipes-test/demo-config/primary-config.bb b/external/meta-updater/recipes-test/demo-config/primary-config.bb new file mode 100644 index 00000000..27cb553e --- /dev/null +++ b/external/meta-updater/recipes-test/demo-config/primary-config.bb @@ -0,0 +1,68 @@ +DESCRIPTION = "Sample configuration for an Uptane Primary to support IP/Posix Secondary" +LICENSE = "MPL-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad" + +require shared-conf.inc + +PRIMARY_SECONDARIES ?= "${SECONDARY_IP}:${SECONDARY_PORT}" + +SRC_URI = "\ + file://30-secondary-config.toml \ + file://ip_secondary_config.json \ + " + +def get_secondary_addrs(d): + import json + + secondaries = d.getVar('PRIMARY_SECONDARIES') + sec_array = [] + for secondary in secondaries.split(): + sec_array.append({"addr": secondary}) + + return json.dumps(sec_array) + +do_install () { + + if [ ! -n "${SOTA_SECONDARY_CONFIG}" ]; then + bbwarn "SOTA_SECONDARY_CONFIG hasn't been specified in the local config, generate a default one" + + IP_SECONDARY_CONFIG_FILE=${WORKDIR}/ip_secondary_config.json + IP_SECONDARY_ADDRS='${@get_secondary_addrs(d)}' + else + bbwarn "SOTA_SECONDARY_CONFIG has been specified in the local config: ${SOTA_SECONDARY_CONFIG}" + + IP_SECONDARY_CONFIG_FILE=${SOTA_SECONDARY_CONFIG} + fi + + if [ ! -f $IP_SECONDARY_CONFIG_FILE ]; then + bbfatal "Secondary config file does not exist: $IP_SECONDARY_CONFIG_FILE" + fi + + SECONDARY_CONFIG_DEST_DIR="${D}${sysconfdir}/sota/ecus" + SECONDARY_CONFIG_DEST_FILEPATH=$SECONDARY_CONFIG_DEST_DIR/$(basename -- $IP_SECONDARY_CONFIG_FILE) + SECONDARY_CONFIG_FILEPATH_ON_IMAGE="${sysconfdir}/sota/ecus/$(basename -- $IP_SECONDARY_CONFIG_FILE)" + + # install the secondary configuration file (json) + install -m 0700 -d $SECONDARY_CONFIG_DEST_DIR + install -m 0644 $IP_SECONDARY_CONFIG_FILE $SECONDARY_CONFIG_DEST_DIR + + # if SOTA_SECONDARY_CONFIG/secondary config file is not defined in the local conf + # then a default template is used and filled with corresponding configuration variable values + if [ ! -n "${SOTA_SECONDARY_CONFIG}" ]; then + sed -i -e "s|@PORT@|${PRIMARY_PORT}|g" \ + -e "s|@TIMEOUT@|${PRIMARY_WAIT_TIMEOUT}|g" \ + -e "s|@ADDR_ARRAY@|$IP_SECONDARY_ADDRS|g" $SECONDARY_CONFIG_DEST_FILEPATH + fi + + # install aktualizr config file (toml) that points to the secondary config file, so aktualizr is aware about it + install -m 0700 -d ${D}${libdir}/sota/conf.d + install -m 0644 ${WORKDIR}/30-secondary-config.toml ${D}${libdir}/sota/conf.d + sed -i "s|@CFG_FILEPATH@|$SECONDARY_CONFIG_FILEPATH_ON_IMAGE|g" ${D}${libdir}/sota/conf.d/30-secondary-config.toml +} + +FILES_${PN} = " \ + ${libdir}/sota/conf.d/* \ + ${sysconfdir}/sota/ecus/* \ + " + +# vim:set ts=4 sw=4 sts=4 expandtab: diff --git a/external/meta-updater/recipes-test/demo-config/secondary-config.bb b/external/meta-updater/recipes-test/demo-config/secondary-config.bb new file mode 100644 index 00000000..9411646b --- /dev/null +++ b/external/meta-updater/recipes-test/demo-config/secondary-config.bb @@ -0,0 +1,41 @@ +DESCRIPTION = "Sample configuration for an Uptane Secondary" +LICENSE = "MPL-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad" + +require shared-conf.inc + +SECONDARY_SERIAL_ID ?= "" +SOTA_HARDWARE_ID ?= "${MACHINE}-sndry" +SECONDARY_HARDWARE_ID ?= "${SOTA_HARDWARE_ID}" + +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 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/external/meta-updater/recipes-test/demo-config/shared-conf.inc b/external/meta-updater/recipes-test/demo-config/shared-conf.inc new file mode 100644 index 00000000..c5ab5987 --- /dev/null +++ b/external/meta-updater/recipes-test/demo-config/shared-conf.inc @@ -0,0 +1,5 @@ +SECONDARY_IP ?= "10.0.3.2" +SECONDARY_PORT ?= "9050" +PRIMARY_IP ?= "10.0.3.1" +PRIMARY_PORT ?= "9040" +PRIMARY_WAIT_TIMEOUT ?= "240" diff --git a/external/meta-updater/recipes-test/demo-network-config/files/25-dhcp-server.network b/external/meta-updater/recipes-test/demo-network-config/files/25-dhcp-server.network new file mode 100644 index 00000000..4766f9ae --- /dev/null +++ b/external/meta-updater/recipes-test/demo-network-config/files/25-dhcp-server.network @@ -0,0 +1,12 @@ +[Match] +Name=enp0s4 + +[Network] +Description=Private internal network between aktualizr Primary and Secondary nodes +DHCPServer=yes +Address=10.0.3.1/24 +IPForward=yes +IPMasquerade=yes + +[DHCPServer] +PoolOffset=10
\ No newline at end of file diff --git a/external/meta-updater/recipes-test/demo-network-config/files/26-dhcp-client.network b/external/meta-updater/recipes-test/demo-network-config/files/26-dhcp-client.network new file mode 100644 index 00000000..319664f8 --- /dev/null +++ b/external/meta-updater/recipes-test/demo-network-config/files/26-dhcp-client.network @@ -0,0 +1,6 @@ +[Match] +Name=enp0s4 + +[Network] +Description=Private internal network between aktualizr Primary and Secondary nodes +DHCP=yes diff --git a/external/meta-updater/recipes-test/demo-network-config/files/26-multihomed-client.network b/external/meta-updater/recipes-test/demo-network-config/files/26-multihomed-client.network new file mode 100644 index 00000000..f1e6cc63 --- /dev/null +++ b/external/meta-updater/recipes-test/demo-network-config/files/26-multihomed-client.network @@ -0,0 +1,9 @@ +[Match] +Name=@IFNAME@ + +[Network] +Description=Multihomed network. DHCP-assigned IP for Primary<->Backend. Statically assigned IP for Primary<->Secondary +DHCP=yes + +[Address] +Address=@ADDR@ diff --git a/external/meta-updater/recipes-test/demo-network-config/files/26-static-client.network b/external/meta-updater/recipes-test/demo-network-config/files/26-static-client.network new file mode 100644 index 00000000..19a6b83f --- /dev/null +++ b/external/meta-updater/recipes-test/demo-network-config/files/26-static-client.network @@ -0,0 +1,7 @@ +[Match] +Name=@IFNAME@ + +[Network] +Description=Private internal network between aktualizr Primary and Secondary nodes +Address=@ADDR@ +DHCP=no diff --git a/external/meta-updater/recipes-test/demo-network-config/files/27-dhcp-client-external.network b/external/meta-updater/recipes-test/demo-network-config/files/27-dhcp-client-external.network new file mode 100644 index 00000000..ba495939 --- /dev/null +++ b/external/meta-updater/recipes-test/demo-network-config/files/27-dhcp-client-external.network @@ -0,0 +1,6 @@ +[Match] +Name=enp0s3 + +[Network] +Description=External network for secondary +DHCP=yes diff --git a/external/meta-updater/recipes-test/demo-network-config/network-config.inc b/external/meta-updater/recipes-test/demo-network-config/network-config.inc new file mode 100644 index 00000000..ed623d46 --- /dev/null +++ b/external/meta-updater/recipes-test/demo-network-config/network-config.inc @@ -0,0 +1,17 @@ +SRC_URI_append = "\ + file://26-${CONF_TYPE}-client.network \ + " + +SECONDARY_INTERFACE ?= "${@ 'eth0' if d.getVar('MACHINE') == 'raspberrypi3' else 'enp0s5'}" + +do_install_append() { + bbnote "Network configuration type to be applied: ${CONF_TYPE}" + install -d ${D}/usr/lib/systemd/network + install -m 0644 ${WORKDIR}/26-${CONF_TYPE}-client.network ${D}/usr/lib/systemd/network/ + sed -i -e 's|@ADDR@|${IP_ADDR}|g' \ + -e 's|@IFNAME@|${SECONDARY_INTERFACE}|g' \ + ${D}/usr/lib/systemd/network/26-${CONF_TYPE}-client.network + +} + +# vim:set ts=4 sw=4 sts=4 expandtab: diff --git a/external/meta-updater/recipes-test/demo-network-config/primary-network-config.bb b/external/meta-updater/recipes-test/demo-network-config/primary-network-config.bb new file mode 100644 index 00000000..d840a951 --- /dev/null +++ b/external/meta-updater/recipes-test/demo-network-config/primary-network-config.bb @@ -0,0 +1,27 @@ +DESCRIPTION = "Sample network configuration for an Uptane Primary" +LICENSE = "MPL-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad" + +inherit allarch + +SRC_URI = "\ + file://27-dhcp-client-external.network \ + " + +FILES_${PN} = "/usr/lib/systemd/network" + +PR = "1" + +do_install() { + install -d ${D}/usr/lib/systemd/network + install -m 0644 ${WORKDIR}/27-dhcp-client-external.network ${D}/usr/lib/systemd/network/ +} + +PRIMARY_IP ?= "10.0.3.1" + +IP_ADDR = "${PRIMARY_IP}" +CONF_TYPE ?= "${@ 'multihomed' if d.getVar('MACHINE') == 'raspberrypi3' and d.getVar('RPI_WIFI_ENABLE') != '1' else 'static'}" + +require network-config.inc + +# vim:set ts=4 sw=4 sts=4 expandtab: diff --git a/external/meta-updater/recipes-test/demo-network-config/secondary-network-config.bb b/external/meta-updater/recipes-test/demo-network-config/secondary-network-config.bb new file mode 100644 index 00000000..b1d70f1f --- /dev/null +++ b/external/meta-updater/recipes-test/demo-network-config/secondary-network-config.bb @@ -0,0 +1,30 @@ +DESCRIPTION = "Sample network configuration for an Uptane Secondary" +LICENSE = "MPL-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad" + +inherit allarch + +# TODO: It configures the 'user' interface in NAT mode and provides an access to public Inet via it +# which is not desired for Secondary. It cannot be just removed since we get SSH access to Secondary +# VM via this interface. So, the task is to configure the interface in such way that it does provide access +# via SSH from a host machine and forbids an access to Inet +SRC_URI = "\ + file://27-dhcp-client-external.network \ + " + +FILES_${PN} = "/usr/lib/systemd/network" + +PR = "1" + +do_install() { + install -d ${D}/usr/lib/systemd/network + install -m 0644 ${WORKDIR}/27-dhcp-client-external.network ${D}/usr/lib/systemd/network/ +} + +SECONDARY_IP ?= "10.0.3.2" +IP_ADDR = "${SECONDARY_IP}" +CONF_TYPE = "static" + +require network-config.inc + +# vim:set ts=4 sw=4 sts=4 expandtab: diff --git a/external/meta-updater/recipes-test/images/primary-image.bb b/external/meta-updater/recipes-test/images/primary-image.bb new file mode 100644 index 00000000..ba1dc1fa --- /dev/null +++ b/external/meta-updater/recipes-test/images/primary-image.bb @@ -0,0 +1,16 @@ +include recipes-core/images/core-image-minimal.bb + +SUMMARY = "A minimal Uptane Primary image running aktualizr, for testing with a Linux secondary" + +LICENSE = "MPL-2.0" + +IMAGE_INSTALL_remove = " \ + virtual/network-configuration \ + " + +IMAGE_INSTALL_append = " \ + primary-network-config \ + primary-config \ + " + +# vim:set ts=4 sw=4 sts=4 expandtab: diff --git a/external/meta-updater/recipes-test/images/secondary-image.bb b/external/meta-updater/recipes-test/images/secondary-image.bb new file mode 100644 index 00000000..27d1e3f9 --- /dev/null +++ b/external/meta-updater/recipes-test/images/secondary-image.bb @@ -0,0 +1,29 @@ +include recipes-core/images/core-image-minimal.bb + +SUMMARY = "A minimal Uptane Secondary image running aktualizr-secondary" + +LICENSE = "MPL-2.0" + +SECONDARY_SERIAL_ID ?= "" +SOTA_HARDWARE_ID ?= "${MACHINE}-sndry" + +# Remove default aktualizr primary, and the provisioning configuration (which +# RDEPENDS on aktualizr) +IMAGE_INSTALL_remove = " \ + aktualizr \ + aktualizr-shared-prov \ + aktualizr-shared-prov-creds \ + aktualizr-device-prov \ + aktualizr-device-prov-creds \ + aktualizr-device-prov-hsm \ + aktualizr-uboot-env-rollback \ + virtual/network-configuration \ + " + +IMAGE_INSTALL_append = " \ + aktualizr-secondary \ + secondary-network-config \ + secondary-config \ + " + +# vim:set ts=4 sw=4 sts=4 expandtab: |