aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhang Nguyen <khang.nguyen.xw@renesas.com>2019-07-09 19:11:26 +0700
committerKhang Nguyen <khang.nguyen.xw@renesas.com>2019-07-11 14:24:42 +0700
commit7c7a92383e932a0ac4fc620370f61cdc5f1d3f3f (patch)
treec3e19efe983ae1ecd3e4f79bcf2c2de8b1eca84e
parent106115bfcde41da981f0c3863eee342c8249b628 (diff)
rcar-gen3: rauc-hawkbit: Run rauc-hawkbit-client after booting up
This adds the configuration variables to launch rauc-hawkbit-client after the board boots up: HAWKBIT_SERVER: The Hawkbit Server IP. HAWKBIT_TARGET: The "target_name" is defined in Hawkbit Server. HAWKBIT_TOKEN : The "auth_token" of target. HAWKBIT_MAC : The MAC address of target board. HAWKBIT_DL : The bundle download location in target board. These variables are mandatory, the setup will be skipped if any empty variables, wrong IP format or MAC address. Change-Id: I7282b4ef14b52f6f97a49ad8ba2ce82602c5e186 Signed-off-by: Khang Nguyen <khang.nguyen.xw@renesas.com>
-rw-r--r--meta-rcar-gen3/recipes-support/rauc-hawkbit/files/config.cfg8
-rw-r--r--meta-rcar-gen3/recipes-support/rauc-hawkbit/files/rauc_hawkbit.sh3
-rw-r--r--meta-rcar-gen3/recipes-support/rauc-hawkbit/rauc-hawkbit_git.bbappend61
3 files changed, 72 insertions, 0 deletions
diff --git a/meta-rcar-gen3/recipes-support/rauc-hawkbit/files/config.cfg b/meta-rcar-gen3/recipes-support/rauc-hawkbit/files/config.cfg
new file mode 100644
index 0000000..d3f7c24
--- /dev/null
+++ b/meta-rcar-gen3/recipes-support/rauc-hawkbit/files/config.cfg
@@ -0,0 +1,8 @@
+[client]
+hawkbit_server = @hawkbit_server@
+ssl = false
+tenant_id = DEFAULT
+target_name = @target@
+auth_token = @token@
+mac_address = @MAC@
+bundle_download_location = @location@
diff --git a/meta-rcar-gen3/recipes-support/rauc-hawkbit/files/rauc_hawkbit.sh b/meta-rcar-gen3/recipes-support/rauc-hawkbit/files/rauc_hawkbit.sh
new file mode 100644
index 0000000..bd2d5c0
--- /dev/null
+++ b/meta-rcar-gen3/recipes-support/rauc-hawkbit/files/rauc_hawkbit.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+rauc-hawkbit-client -c /etc/rauc/config.cfg &
diff --git a/meta-rcar-gen3/recipes-support/rauc-hawkbit/rauc-hawkbit_git.bbappend b/meta-rcar-gen3/recipes-support/rauc-hawkbit/rauc-hawkbit_git.bbappend
new file mode 100644
index 0000000..a1a44db
--- /dev/null
+++ b/meta-rcar-gen3/recipes-support/rauc-hawkbit/rauc-hawkbit_git.bbappend
@@ -0,0 +1,61 @@
+FILESEXTRAPATHS_prepend_rcar-gen3 := "${THISDIR}/files:"
+
+SRC_URI_append_rcar-gen3 = " \
+ file://config.cfg \
+ file://rauc_hawkbit.sh \
+"
+
+python __anonymous() {
+ hawkbit_items = [None] * 5
+ hawkbit_items[0] = d.getVar('HAWKBIT_SERVER')
+ hawkbit_items[1] = d.getVar('HAWKBIT_TARGET')
+ hawkbit_items[2] = d.getVar('HAWKBIT_TOKEN')
+ hawkbit_items[3] = d.getVar('HAWKBIT_MAC')
+ hawkbit_items[4] = d.getVar('HAWKBIT_DL')
+
+ import re
+
+ def check_valid_ip(ip):
+ if ':' in ip:
+ ip = ip.split(':')[0]
+ is_ip = re.match(r"^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$",ip)
+ return bool(is_ip)
+
+ def check_valid_mac(mac):
+ is_mac = re.match("[0-9a-f]{2}([-:]?)[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", mac.lower())
+ return bool(is_mac)
+
+ if not check_valid_ip(hawkbit_items[0]):
+ hawkbit_items[0] = None
+
+ if not check_valid_mac(hawkbit_items[3]):
+ hawkbit_items[3] = None
+
+ i = None
+
+ if all(i is not None for i in hawkbit_items):
+ d.setVar('ENABLE_HAWKBIT', '1')
+ else:
+ d.setVar('ENABLE_HAWKBIT', '0')
+}
+
+do_install_append_rcar-gen3 () {
+ if [ "${ENABLE_HAWKBIT}" = "1" ]; then
+ install -d ${D}${sysconfdir}/rauc
+ install -m 0644 ${WORKDIR}/config.cfg ${D}${sysconfdir}/rauc
+
+ sed "s|@hawkbit_server@|${HAWKBIT_SERVER}|g" -i ${D}${sysconfdir}/rauc/config.cfg
+ sed "s|@target@|${HAWKBIT_TARGET}|g" -i ${D}${sysconfdir}/rauc/config.cfg
+ sed "s|@token@|${HAWKBIT_TOKEN}|g" -i ${D}${sysconfdir}/rauc/config.cfg
+ sed "s|@MAC@|${HAWKBIT_MAC}|g" -i ${D}${sysconfdir}/rauc/config.cfg
+ sed "s|@location@|${HAWKBIT_DL}|g" -i ${D}${sysconfdir}/rauc/config.cfg
+
+ install -d ${D}${sysconfdir}/profile.d
+ install -m 0755 ${WORKDIR}/rauc_hawkbit.sh ${D}${sysconfdir}/profile.d
+ fi
+}
+
+FILES_${PN}_append_rcar-gen3 = " \
+ ${sysconfdir}/profile.d/rauc_hawkbit.sh \
+ ${sysconfdir}/rauc/config.cfg \
+"