summaryrefslogtreecommitdiffstats
path: root/recipes-sota/aktualizr/aktualizr-auto-prov.bb
blob: f05bf7510ebcf34c10d4821d2fcc180bece3e743 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
SUMMARY = "Aktualizr systemd service and configurations"
DESCRIPTION = "Systemd service and configurations for autoprovisioning Aktualizr, the SOTA Client application written in C++"
HOMEPAGE = "https://github.com/advancedtelematic/aktualizr"
SECTION = "base"
LICENSE = "MPL-2.0"
LIC_FILES_CHKSUM = "file://${WORKDIR}/LICENSE;md5=9741c346eef56131163e13b9db1241b3"
DEPENDS = "aktualizr-native zip-native"
RDEPENDS_${PN} = "aktualizr"
PV = "1.0"
PR = "6"

SRC_URI = " \
  file://LICENSE \
  file://aktualizr.service \
  "

SYSTEMD_SERVICE_${PN} = "aktualizr.service"

inherit systemd

require environment.inc

export SOTA_PACKED_CREDENTIALS

do_install() {
    if [ -n "${SOTA_AUTOPROVISION_CREDENTIALS}" ]; then
        bbwarn "SOTA_AUTOPROVISION_CREDENTIALS are ignored. Please use SOTA_PACKED_CREDENTIALS"
    fi
    if [ -n "${SOTA_AUTOPROVISION_URL}" ]; then
        bbwarn "SOTA_AUTOPROVISION_URL is ignored. Please use SOTA_PACKED_CREDENTIALS"
    fi
    if [ -n "${SOTA_AUTOPROVISION_URL_FILE}" ]; then
        bbwarn "SOTA_AUTOPROVISION_URL_FILE is ignored. Please use SOTA_PACKED_CREDENTIALS"
    fi
    if [ -n "${OSTREE_PUSH_CREDENTIALS}" ]; then
        bbwarn "OSTREE_PUSH_CREDENTIALS is ignored. Please use SOTA_PACKED_CREDENTIALS"
    fi

    install -d ${D}${libdir}/sota
    install -d ${D}${localstatedir}/sota
    if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then
      install -m 0644 ${STAGING_DIR_NATIVE}/${libdir}/sota/sota_autoprov.toml ${D}${libdir}/sota/sota.toml

      # deploy SOTA credentials
      if [ -e ${SOTA_PACKED_CREDENTIALS} ]; then
          cp ${SOTA_PACKED_CREDENTIALS} ${D}${localstatedir}/sota/sota_provisioning_credentials.zip
          # Device should not be able to push data to treehub
          zip -d ${D}${localstatedir}/sota/sota_provisioning_credentials.zip treehub.json
      fi
    fi
    install -d ${D}${systemd_unitdir}/system
    install -m 0644 ${WORKDIR}/aktualizr.service ${D}${systemd_unitdir}/system/aktualizr.service
}

FILES_${PN} = " \
                ${systemd_unitdir}/system/aktualizr.service \
                ${libdir}/sota/sota.toml \
                ${localstatedir}/sota \
                ${localstatedir}/sota/sota_provisioning_credentials.zip \
                "