From adf8c2b90ce1be5567fe9e774183c9cc455a15e8 Mon Sep 17 00:00:00 2001 From: Stoyan Zoubev Date: Tue, 25 Jul 2023 14:32:28 +0300 Subject: [PATCH] Yocto recipe for Kanto Update Manager [#60] Yocto recipe for Kanto Update Manager Signed-off-by: Stoyan Zoubev --- .github/workflows/validation.yml | 4 ++ .../update-manager/files/config.json | 13 ++++ .../update-manager/files/service.template | 14 ++++ .../update-manager/update-manager.inc | 10 +++ .../update-manager/update-manager_git.bb | 66 +++++++++++++++++++ 5 files changed, 107 insertions(+) create mode 100644 recipes-management/update-manager/files/config.json create mode 100644 recipes-management/update-manager/files/service.template create mode 100644 recipes-management/update-manager/update-manager.inc create mode 100644 recipes-management/update-manager/update-manager_git.bb diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index d386737..ad81c7f 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -90,6 +90,10 @@ jobs: run: | source poky/oe-init-build-env build bitbake software-update + - name: Build update manager + run: | + source poky/oe-init-build-env build + bitbake update-manager - name: Build system metrics run: | source poky/oe-init-build-env build diff --git a/recipes-management/update-manager/files/config.json b/recipes-management/update-manager/files/config.json new file mode 100644 index 0000000..7a1a93a --- /dev/null +++ b/recipes-management/update-manager/files/config.json @@ -0,0 +1,13 @@ +{ + "log": { + "logFile": "@UM_LOG_DD@/update-manager/update-manager.log" + }, + "domain": "device", + "agents": { + "containers": { + "name": "containers", + "rebootRequired": false, + "readTimeout": "30s" + } + } +} diff --git a/recipes-management/update-manager/files/service.template b/recipes-management/update-manager/files/service.template new file mode 100644 index 0000000..6453e67 --- /dev/null +++ b/recipes-management/update-manager/files/service.template @@ -0,0 +1,14 @@ +[Unit] +Description=Eclipse Kanto - Update Manager +Documentation=https://eclipse.org/kanto/docs/ +After=network.target mosquitto.service +Requires=network.target +Requires=mosquitto.service + +[Service] +Type=simple +ExecStart=@UM_BIN_DD@/update-manager -configFile @UM_CFG_DD@/update-manager/config.json +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/recipes-management/update-manager/update-manager.inc b/recipes-management/update-manager/update-manager.inc new file mode 100644 index 0000000..80bccd6 --- /dev/null +++ b/recipes-management/update-manager/update-manager.inc @@ -0,0 +1,10 @@ +# Common configuration variables to set the binaries and resources allocation directories for Eclipse Kanto update manager component +# The destination directory where the required configuration files for the proper connectivity establishment of the update manager will be placed +UM_CFG_DD ?= "${sysconfdir}" +# The destination directory where the generated service file will be placed +UM_SYSUNIT_DD ?= "${systemd_unitdir}/system" +# The destination directory where the update manager binaries will be placed +UM_BIN_DD ?= "${bindir}" +# The destination directory where the update manager logs will be placed +UM_LOG_DD ?= "${localstatedir}/log" + diff --git a/recipes-management/update-manager/update-manager_git.bb b/recipes-management/update-manager/update-manager_git.bb new file mode 100644 index 0000000..b918e7b --- /dev/null +++ b/recipes-management/update-manager/update-manager_git.bb @@ -0,0 +1,66 @@ +DESCRIPTION = "Eclipse Kanto - Update Manager" + +LICENSE = "EPL-2.0 | Apache-2.0" +LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=54cd967551e55d39f55006d3344c22fc" + +SRC_URI = "git://github.com/eclipse-kanto/update-manager;protocol=https;branch=main \ + file://config.json \ + file://service.template \ + " + +SRCREV = "${AUTOREV}" + +PV = "0.1.0-git${SRCPV}" + +GO_IMPORT = "github.com/eclipse-kanto/update-manager" +GO_INSTALL = "${GO_IMPORT}/cmd/update-manager" + +require update-manager.inc + +inherit go-mod +inherit systemd + +SYSTEMD_AUTO_ENABLE = "enable" +SYSTEMD_PACKAGES = "${@bb.utils.contains('DISTRO_FEATURES','systemd','${PN}','',d)}" +SYSTEMD_SERVICE:${PN} = "${@bb.utils.contains('DISTRO_FEATURES','systemd','update-manager.service','',d)}" + +# workaround for network issue +do_compile[network] = "1" + +FILES:${PN} += "${UM_SYSUNIT_DD}/update-manager.service" +FILES:${PN} += "${UM_BIN_DD}/update-manager" +# ensure all additional resources are properly packed in the resulting package if provided +FILES:${PN} += "${UM_CFG_DD}/update-manager/config.json" + +RDEPENDS:${PN} += "mosquitto" + +PROVIDES:${PN} += "kanto/update-manager" +RPROVIDES:${PN} += "kanto/update-manager" + +do_install() { + install -d "${D}/${UM_BIN_DD}" + + install -m 0755 "${GO_BUILD_BINDIR}/update-manager" "${D}${UM_BIN_DD}/update-manager" + + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then + install -d ${D}${UM_SYSUNIT_DD} + + # update-manager + install -d ${D}${UM_CFG_DD}/update-manager + + # config.json + install -m 0644 ${WORKDIR}/config.json ${D}${UM_CFG_DD}/update-manager + + # service.template as service + install -m 0644 ${WORKDIR}/service.template ${D}${UM_SYSUNIT_DD}/update-manager.service + + # fill in the update-manager systemd service template with the custom configs provided + sed -e 's,@UM_BIN_DD@,${UM_BIN_DD},g' \ + -e 's,@UM_CFG_DD@,${UM_CFG_DD},g' \ + -i ${D}${UM_SYSUNIT_DD}/update-manager.service + + # fill in the config.json template with the custom configs provided + sed -e 's,@UM_LOG_DD@,${UM_LOG_DD},g' \ + -i ${D}${UM_CFG_DD}/update-manager/config.json + fi +}