summaryrefslogtreecommitdiffstats
path: root/recipes-sota/aktualizr/aktualizr_git.bb
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-sota/aktualizr/aktualizr_git.bb')
-rwxr-xr-xrecipes-sota/aktualizr/aktualizr_git.bb81
1 files changed, 68 insertions, 13 deletions
diff --git a/recipes-sota/aktualizr/aktualizr_git.bb b/recipes-sota/aktualizr/aktualizr_git.bb
index fef12b8..a49095a 100755
--- a/recipes-sota/aktualizr/aktualizr_git.bb
+++ b/recipes-sota/aktualizr/aktualizr_git.bb
@@ -5,40 +5,51 @@ SECTION = "base"
5LICENSE = "MPL-2.0" 5LICENSE = "MPL-2.0"
6LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=9741c346eef56131163e13b9db1241b3" 6LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=9741c346eef56131163e13b9db1241b3"
7 7
8require garage-sign-version.inc
9
10DEPENDS = "boost curl openssl libarchive libsodium sqlite3 asn1c-native" 8DEPENDS = "boost curl openssl libarchive libsodium sqlite3 asn1c-native"
11RDEPENDS_${PN}_class-target = "aktualizr-check-discovery aktualizr-configs lshw" 9DEPENDS_append = "${@bb.utils.contains('PTEST_ENABLED', '1', ' coreutils-native ostree-native aktualizr-native ', '', d)}"
12RDEPENDS_${PN}-secondary = "aktualizr-check-discovery" 10RDEPENDS_${PN}_class-target = "aktualizr-configs lshw"
13RDEPENDS_${PN}-host-tools = "aktualizr aktualizr-repo aktualizr-cert-provider ${@bb.utils.contains('PACKAGECONFIG', 'sota-tools', 'garage-deploy garage-push', '', d)}" 11RDEPENDS_${PN}-host-tools = "aktualizr aktualizr-repo aktualizr-cert-provider ${@bb.utils.contains('PACKAGECONFIG', 'sota-tools', 'garage-deploy garage-push', '', d)}"
14 12
13RDEPENDS_${PN}-ptest += "bash cmake curl python3-misc python3-modules sqlite3 valgrind"
14
15PV = "1.0+git${SRCPV}" 15PV = "1.0+git${SRCPV}"
16PR = "7" 16PR = "7"
17 17
18GARAGE_SIGN_PV = "0.6.0-18-g5b8b259"
19
18SRC_URI = " \ 20SRC_URI = " \
19 gitsm://github.com/advancedtelematic/aktualizr;branch=${BRANCH} \ 21 gitsm://github.com/advancedtelematic/aktualizr;branch=${BRANCH} \
22 file://run-ptest \
20 file://aktualizr.service \ 23 file://aktualizr.service \
21 file://aktualizr-secondary.service \ 24 file://aktualizr-secondary.service \
22 file://aktualizr-secondary.socket \ 25 file://aktualizr-secondary.socket \
23 file://aktualizr-serialcan.service \ 26 file://aktualizr-serialcan.service \
27 file://10-resource-control.conf \
28 ${@ d.expand("https://ats-tuf-cli-releases.s3-eu-central-1.amazonaws.com/cli-${GARAGE_SIGN_PV}.tgz;unpack=0") if d.getVar('GARAGE_SIGN_AUTOVERSION') != '1' else ''} \
24 " 29 "
25 30
26SRCREV = "c71ec0a320d85a3e75ba37bff7dc40ad02e9d655" 31# for garage-sign archive
32SRC_URI[md5sum] = "c5e9968dfe78a7264ab9a8338c11725d"
33SRC_URI[sha256sum] = "3a19258d7a1825a308aca0da82f7a337985bec05e8951355c4c95f0fcf2444f4"
34
35SRCREV = "c50feb37034eceb1254429d3e3ed38e5b8a0dc60"
27BRANCH ?= "master" 36BRANCH ?= "master"
28 37
29S = "${WORKDIR}/git" 38S = "${WORKDIR}/git"
30 39
31inherit pkgconfig cmake systemd 40inherit cmake pkgconfig ptest systemd
41
42# disable ptest by default as it slows down builds quite a lot
43# can be enabled manually by setting 'PTEST_ENABLED_pn-aktualizr' to '1' in local.conf
44PTEST_ENABLED = "0"
32 45
33SYSTEMD_PACKAGES = "${PN} ${PN}-secondary" 46SYSTEMD_PACKAGES = "${PN} ${PN}-secondary"
34SYSTEMD_SERVICE_${PN} = "aktualizr.service" 47SYSTEMD_SERVICE_${PN} = "aktualizr.service"
35SYSTEMD_SERVICE_${PN}-secondary = "aktualizr-secondary.socket" 48SYSTEMD_SERVICE_${PN}-secondary = "aktualizr-secondary.socket"
36 49
37EXTRA_OECMAKE = "-DCMAKE_BUILD_TYPE=Release -DAKTUALIZR_VERSION=${PV} -Dgtest_disable_pthreads=ON" 50EXTRA_OECMAKE = "-DCMAKE_BUILD_TYPE=Release -DAKTUALIZR_VERSION=${PV} -Dgtest_disable_pthreads=ON ${@bb.utils.contains('PTEST_ENABLED', '1', '-DTESTSUITE_VALGRIND=on', '', d)}"
38 51
39GARAGE_SIGN_OPS = "${@ '-DGARAGE_SIGN_VERSION=%s' % d.getVar('GARAGE_SIGN_VERSION') if d.getVar('GARAGE_SIGN_VERSION') is not None else ''} \ 52GARAGE_SIGN_OPS = "${@ d.expand('-DGARAGE_SIGN_ARCHIVE=${WORKDIR}/cli-${GARAGE_SIGN_PV}.tgz') if d.getVar('GARAGE_SIGN_AUTOVERSION') != '1' else ''}"
40 ${@ '-DGARAGE_SIGN_SHA256=%s' % d.getVar('GARAGE_SIGN_SHA256') if d.getVar('GARAGE_SIGN_SHA256') is not None else ''} \
41 "
42 53
43PACKAGECONFIG ?= "ostree ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} ${@bb.utils.filter('SOTA_CLIENT_FEATURES', 'hsm serialcan ubootenv', d)}" 54PACKAGECONFIG ?= "ostree ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} ${@bb.utils.filter('SOTA_CLIENT_FEATURES', 'hsm serialcan ubootenv', d)}"
44PACKAGECONFIG_class-native = "sota-tools" 55PACKAGECONFIG_class-native = "sota-tools"
@@ -51,6 +62,36 @@ PACKAGECONFIG[load-tests] = "-DBUILD_LOAD_TESTS=ON,-DBUILD_LOAD_TESTS=OFF,"
51PACKAGECONFIG[serialcan] = ",,,slcand-start" 62PACKAGECONFIG[serialcan] = ",,,slcand-start"
52PACKAGECONFIG[ubootenv] = ",,,u-boot-fw-utils aktualizr-uboot-env-rollback" 63PACKAGECONFIG[ubootenv] = ",,,u-boot-fw-utils aktualizr-uboot-env-rollback"
53 64
65# can be overriden in configuration with `RESOURCE_xxx_pn-aktualizr`
66# see `man systemd.resource-control` for details
67
68# can be used to lower aktualizr priority, default is 100
69RESOURCE_CPU_WEIGHT = "100"
70# will be slowed down when it reaches 'high', killed when it reaches 'max'
71RESOURCE_MEMORY_HIGH = "100M"
72RESOURCE_MEMORY_MAX = "80%"
73
74do_compile_ptest() {
75 bbnote VERBOSE=1 cmake --build '${B}' --target build_tests -- ${EXTRA_OECMAKE_BUILD} ${PARALLEL_MAKE}
76 VERBOSE=1 cmake --build '${B}' --target build_tests -- ${EXTRA_OECMAKE_BUILD} ${PARALLEL_MAKE}
77}
78
79do_install_ptest() {
80 # copy the complete source directory (contains build)
81 cp -r ${B}/ ${D}/${PTEST_PATH}/build
82 cp -r ${S}/ ${D}/${PTEST_PATH}/src
83
84 # remove huge external unused repository
85 rm -rf ${D}/${PTEST_PATH}/src/partial/extern/RIOT
86
87 # remove huge build artifacts
88 find ${D}/${PTEST_PATH}/build/src -name "*.a" -delete
89
90 # fix the absolute paths
91 find ${D}/${PTEST_PATH}/build -name "CMakeFiles" | xargs rm -rf
92 find ${D}/${PTEST_PATH}/build -name "*.cmake" -or -name "DartConfiguration.tcl" -or -name "run-valgrind" | xargs sed -e "s|${S}|${PTEST_PATH}/src|g" -e "s|${B}|${PTEST_PATH}/build|g" -e "s|\"--gtest_output[^\"]*\"||g" -i
93}
94
54do_install_append () { 95do_install_append () {
55 install -d ${D}${libdir}/sota 96 install -d ${D}${libdir}/sota
56 install -m 0644 ${S}/config/sota_autoprov.toml ${D}/${libdir}/sota/sota_autoprov.toml 97 install -m 0644 ${S}/config/sota_autoprov.toml ${D}/${libdir}/sota/sota_autoprov.toml
@@ -66,14 +107,14 @@ do_install_append () {
66 install -m 0700 -d ${D}${sysconfdir}/sota/conf.d 107 install -m 0700 -d ${D}${sysconfdir}/sota/conf.d
67 108
68 if [ -n "${SOTA_HARDWARE_ID}" ]; then 109 if [ -n "${SOTA_HARDWARE_ID}" ]; then
69 echo "[provision]\nprimary_ecu_hardware_id = ${SOTA_HARDWARE_ID}\n" > ${D}${libdir}/sota/conf.d/40-hardware-id.toml 110 printf "[provision]\nprimary_ecu_hardware_id = ${SOTA_HARDWARE_ID}\n" > ${D}${libdir}/sota/conf.d/40-hardware-id.toml
70 fi 111 fi
71 112
72 if [ -n "${SOTA_SECONDARY_CONFIG_DIR}" ]; then 113 if [ -n "${SOTA_SECONDARY_CONFIG_DIR}" ]; then
73 if [ -d "${SOTA_SECONDARY_CONFIG_DIR}" ]; then 114 if [ -d "${SOTA_SECONDARY_CONFIG_DIR}" ]; then
74 install -m 0700 -d ${D}${sysconfdir}/sota/ecus 115 install -m 0700 -d ${D}${sysconfdir}/sota/ecus
75 install -m 0644 "${SOTA_SECONDARY_CONFIG_DIR}"/* ${D}${sysconfdir}/sota/ecus/ 116 install -m 0644 "${SOTA_SECONDARY_CONFIG_DIR}"/* ${D}${sysconfdir}/sota/ecus/
76 echo "[uptane]\nsecondary_configs_dir = /etc/sota/ecus/\n" > ${D}${libdir}/sota/conf.d/30-secondary-configs-dir.toml 117 printf "[uptane]\nsecondary_configs_dir = /etc/sota/ecus/\n" > ${D}${libdir}/sota/conf.d/30-secondary-configs-dir.toml
77 else 118 else
78 bbwarn "SOTA_SECONDARY_CONFIG_DIR is set to an invalid directory (${SOTA_SECONDARY_CONFIG_DIR})" 119 bbwarn "SOTA_SECONDARY_CONFIG_DIR is set to an invalid directory (${SOTA_SECONDARY_CONFIG_DIR})"
79 fi 120 fi
@@ -87,6 +128,15 @@ do_install_append () {
87 install -m 0755 ${B}/src/sota_tools/garage-sign/bin/* ${D}${bindir} 128 install -m 0755 ${B}/src/sota_tools/garage-sign/bin/* ${D}${bindir}
88 install -m 0644 ${B}/src/sota_tools/garage-sign/lib/* ${D}${libdir} 129 install -m 0644 ${B}/src/sota_tools/garage-sign/lib/* ${D}${libdir}
89 fi 130 fi
131
132 # resource control
133 install -d ${D}/${systemd_system_unitdir}/aktualizr.service.d
134 install -m 0644 ${WORKDIR}/10-resource-control.conf ${D}/${systemd_system_unitdir}/aktualizr.service.d
135
136 sed -i -e 's|@CPU_WEIGHT@|${RESOURCE_CPU_WEIGHT}|g' \
137 -e 's|@MEMORY_HIGH@|${RESOURCE_MEMORY_HIGH}|g' \
138 -e 's|@MEMORY_MAX@|${RESOURCE_MEMORY_MAX}|g' \
139 ${D}${systemd_system_unitdir}/aktualizr.service.d/10-resource-control.conf
90} 140}
91 141
92PACKAGESPLITFUNCS_prepend = "split_hosttools_packages " 142PACKAGESPLITFUNCS_prepend = "split_hosttools_packages "
@@ -101,7 +151,7 @@ python split_hosttools_packages () {
101 151
102PACKAGES_DYNAMIC = "^aktualizr-.* ^garage-.*" 152PACKAGES_DYNAMIC = "^aktualizr-.* ^garage-.*"
103 153
104PACKAGES =+ "${PN}-examples ${PN}-secondary ${PN}-configs ${PN}-host-tools" 154PACKAGES =+ "${PN}-resource-control ${PN}-examples ${PN}-secondary ${PN}-configs ${PN}-host-tools"
105 155
106ALLOW_EMPTY_${PN}-host-tools = "1" 156ALLOW_EMPTY_${PN}-host-tools = "1"
107 157
@@ -111,6 +161,10 @@ FILES_${PN} = " \
111 ${systemd_unitdir}/system/aktualizr.service \ 161 ${systemd_unitdir}/system/aktualizr.service \
112 " 162 "
113 163
164FILES_${PN}-resource-control = " \
165 ${systemd_system_unitdir}/aktualizr.service.d/10-resource-control.conf \
166 "
167
114FILES_${PN}-configs = " \ 168FILES_${PN}-configs = " \
115 ${sysconfdir}/sota/* \ 169 ${sysconfdir}/sota/* \
116 ${libdir}/sota/* \ 170 ${libdir}/sota/* \
@@ -126,6 +180,7 @@ FILES_${PN}-secondary = " \
126 ${systemd_unitdir}/system/aktualizr-secondary.socket \ 180 ${systemd_unitdir}/system/aktualizr-secondary.socket \
127 ${systemd_unitdir}/system/aktualizr-secondary.service \ 181 ${systemd_unitdir}/system/aktualizr-secondary.service \
128 " 182 "
183
129BBCLASSEXTEND = "native" 184BBCLASSEXTEND = "native"
130 185
131# vim:set ts=4 sw=4 sts=4 expandtab: 186# vim:set ts=4 sw=4 sts=4 expandtab: