diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index ad81c7f..5c69bf6 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -66,6 +66,10 @@ jobs: bitbake-layers add-layer ../meta-openembedded/meta-filesystems bitbake-layers add-layer ../meta-virtualization bitbake-layers add-layer ../meta-kanto + - name: Build aws connector + run: | + source poky/oe-init-build-env build + bitbake aws-connector - name: Build suite connector run: | source poky/oe-init-build-env build diff --git a/recipes-connectivity/aws-connector/aws-connector.inc b/recipes-connectivity/aws-connector/aws-connector.inc new file mode 100644 index 0000000..1a1f180 --- /dev/null +++ b/recipes-connectivity/aws-connector/aws-connector.inc @@ -0,0 +1,9 @@ +# Common configuration variables to set the binaries and resources allocation directories for Eclipse Kanto AWS connector component +# The destination directory where the required configuration files for the proper connectivity establishment of the AWS connector will be placed +SC_CFG_DD ?= "${sysconfdir}" +# The destination directory where the generated service file will be placed +SC_SYSUNIT_DD ?= "${systemd_unitdir}/system" +# The destination directory where the aws connector binaries will be placed +SC_BIN_DD ?= "${bindir}" +# The destination directory where the aws connector logs will be placed +SC_LOG_DD ?= "${localstatedir}/log" diff --git a/recipes-connectivity/aws-connector/aws-connector_git.bb b/recipes-connectivity/aws-connector/aws-connector_git.bb new file mode 100644 index 0000000..dff3ee1 --- /dev/null +++ b/recipes-connectivity/aws-connector/aws-connector_git.bb @@ -0,0 +1,72 @@ +DESCRIPTION = "Eclipse Kanto - AWS Connector" + +LICENSE = "EPL-2.0 | Apache-2.0" +LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=54cd967551e55d39f55006d3344c22fc" + +SRC_URI = "git://github.com/eclipse-kanto/aws-connector;protocol=https;branch=main \ + file://config.json \ + file://service.template \ + " + +SRCREV = "${AUTOREV}" + +PV = "0.1.0-git${SRCPV}" + +GO_IMPORT = "github.com/eclipse-kanto/aws-connector" +GO_INSTALL = "${GO_IMPORT}/cmd/aws-connector" + +require aws-connector.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','aws-connector.service','',d)}" + +# workaround for network issue +do_compile[network] = "1" + +FILES:${PN} += "${SC_SYSUNIT_DD}/aws-connector.service" +FILES:${PN} += "${SC_BIN_DD}/aws-connector" +# ensure all additional resources are properly packed in the resulting package if provided +FILES:${PN} += "${SC_CFG_DD}/aws-connector/config.json" +FILES:${PN} += "${SC_CFG_DD}/aws-connector/aws.crt" + + +RDEPENDS:${PN} += "mosquitto" + +PROVIDES:${PN} += "kanto/aws-connector" +RPROVIDES:${PN} += "kanto/aws-connector" + +do_install() { + install -d "${D}/${SC_BIN_DD}" + + install -m 0755 "${GO_BUILD_BINDIR}/aws-connector" "${D}${SC_BIN_DD}/aws-connector" + + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then + install -d ${D}${SC_SYSUNIT_DD} + + # aws-connector + install -d ${D}${SC_CFG_DD}/aws-connector + + # iothub.crt + install -m 0644 ${S}/src/${GO_IMPORT}/cmd/aws-connector/aws.crt ${D}${SC_CFG_DD}/aws-connector + + # config.json + install -m 0644 ${WORKDIR}/config.json ${D}${SC_CFG_DD}/aws-connector + + # service.template as service + install -m 0644 ${WORKDIR}/service.template ${D}${SC_SYSUNIT_DD}/aws-connector.service + + # fill in the aws-connector systemd service template with the custom configs provided + sed -e 's,@SC_BIN_DD@,${SC_BIN_DD},g' \ + -e 's,@SC_CFG_DD@,${SC_CFG_DD},g' \ + -i ${D}${SC_SYSUNIT_DD}/aws-connector.service + + # fill in the config.json template with the custom configs provided + sed -e 's,@SC_CFG_DD@,${SC_CFG_DD},g' \ + -e 's,@SC_LOG_DD@,${SC_LOG_DD},g' \ + -i ${D}${SC_CFG_DD}/aws-connector/config.json + fi +} diff --git a/recipes-connectivity/aws-connector/files/config.json b/recipes-connectivity/aws-connector/files/config.json new file mode 100644 index 0000000..9553d3c --- /dev/null +++ b/recipes-connectivity/aws-connector/files/config.json @@ -0,0 +1,4 @@ +{ + "caCert": "@SC_CFG_DD@/aws-connector/aws.crt", + "logFile": "@SC_LOG_DD@/aws-connector/aws-connector.log" +} diff --git a/recipes-connectivity/aws-connector/files/service.template b/recipes-connectivity/aws-connector/files/service.template new file mode 100644 index 0000000..0698554 --- /dev/null +++ b/recipes-connectivity/aws-connector/files/service.template @@ -0,0 +1,15 @@ +[Unit] +Description=Eclipse Kanto - AWS Connector +Documentation=https://eclipse.org/kanto/docs/ +After=network.target mosquitto.service +Requires=network.target +Requires=mosquitto.service + +[Service] +Type=simple +ExecStart=@SC_BIN_DD@/aws-connector -configFile @SC_CFG_DD@/aws-connector/config.json +Restart=always + +[Install] +WantedBy=multi-user.target +