Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yocto recipe for Kanto Update Manager #61

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions recipes-management/update-manager/files/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"log": {
"logFile": "@UM_LOG_DD@/update-manager/update-manager.log"
},
"domain": "device",
"agents": {
"containers": {
"name": "containers",
"rebootRequired": false,
"readTimeout": "30s"
}
}
}
14 changes: 14 additions & 0 deletions recipes-management/update-manager/files/service.template
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions recipes-management/update-manager/update-manager.inc
Original file line number Diff line number Diff line change
@@ -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"

66 changes: 66 additions & 0 deletions recipes-management/update-manager/update-manager_git.bb
Original file line number Diff line number Diff line change
@@ -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
}