Fix for user and group of /home/agl-driver
[AGL/meta-agl-demo.git] / recipes-connectivity / kuksa-val / kuksa-val_git.bb
1 SUMMARY = "KUKSA.val, the KUKSA Vehicle Abstraction Layer"
2 DESCRIPTION = "KUKSA.val provides a COVESA VSS data model describing data in a vehicle."
3 HOMEPAGE = "https://github.com/eclipse/kuksa.val"
4 BUGTRACKER = "https://github.com/eclipse/kuksa.val/issues"
5
6 LICENSE = "Apache-2.0 & BSL-1.0 & MIT"
7 LIC_FILES_CHKSUM = "file://../LICENSE;md5=2b42edef8fa55315f34f2370b4715ca9 \
8                     file://3rd-party-libs/jsoncons/LICENSE;md5=6ee7f7ed2001e4cde4679fdb8926f820 \
9                     file://3rd-party-libs/turtle/LICENSE_1_0.txt;md5=e4224ccaecb14d942c71d31bef20d78c \
10                     file://3rd-party-libs/jwt-cpp/LICENSE;md5=8325a5ce4414c65ffdda392e0d96a9ff"
11
12 DEPENDS = "boost openssl mosquitto nss protobuf-native grpc-native grpc"
13
14 require kuksa-val.inc
15
16 SRC_URI += "file://kuksa-val.service \
17             file://0001-Make-Boost-requirements-more-liberal.patch;striplevel=2 \
18             file://0002-Fix-gRPC-configuration-for-OE-cross-compiling.patch;striplevel=2 \
19             file://0003-Make-install-locations-configurable.patch;striplevel=2 \
20             file://0004-Disable-default-fetch-and-build-of-googletest.patch;striplevel=2 \
21             file://0005-kuksa-val-server-Add-missing-check_git-dependency.patch;striplevel=2 \
22             file://Server.key \
23             file://Server.pem \
24 "
25 # NOTE: Ideally this would be applied, but our S definition makes it problematic:
26 #   file://0001-genCerts.sh-add-Subject-Alt-Name-extension-to-server.patch;striplevel=?
27 #
28
29 S = "${WORKDIR}/git/kuksa-val-server"
30
31 inherit cmake pkgconfig systemd useradd
32
33 SYSTEMD_SERVICE:${PN} = "kuksa-val.service"
34
35 USERADD_PACKAGES = "${PN}"
36 USERADDEXTENSION = "useradd-staticids"
37 GROUPADD_PARAM:${PN} = "-g 900 kuksa ;"
38 USERADD_PARAM:${PN} = "--system -g 900 -u 900 -o -d / --shell /bin/nologin kuksa ;"
39
40 # Configure file locations more along the lines of FHS instead of kuksa.val's
41 # default locations.
42 EXTRA_OECMAKE = " \
43     -DKUKSA_INSTALL_BINDIR=${bindir} \
44     -DKUKSA_INSTALL_CERTDIR=${sysconfdir}/kuksa-val \
45     -DKUKSA_INSTALL_DATADIR=${datadir}/kuksa-val \
46     -DKUKSA_INSTALL_CONFIGDIR=${sysconfdir}/kuksa-val \
47 "
48
49 do_install:append() {
50     # Lower the logging level used in the installed config.ini from the upstream
51     # default of "ALL", which spams the logs.
52     sed -i 's/^log-level = .*/log-level = WARNING/' ${D}/${sysconfdir}/kuksa-val/config.ini
53
54     if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
55         install -d ${D}${systemd_system_unitdir}
56         install -m 0644 ${WORKDIR}/kuksa-val.service ${D}${systemd_system_unitdir}
57     fi
58
59     # Install replacement server key + certificate
60     # These are AGL specific versions generated using a tweaked
61     # genCerts.sh script from the source tree that adds the now
62     # required subjectAltName extension field to make python3-ssl
63     # happy.  This will be addressed with upstream and can hopefully
64     # be dropped in the future.
65     rm -f ${D}${sysconfdir}/kuksa-val/Server.key
66     install ${WORKDIR}/Server.key ${D}${sysconfdir}/kuksa-val/
67     rm -f ${D}${sysconfdir}/kuksa-val/Server.pem
68     install ${WORKDIR}/Server.pem ${D}${sysconfdir}/kuksa-val/
69
70     # Restrict server certificate access
71     # NOTE: The client certificates are left alone here for client
72     #       development convenience for now, but this will need to
73     #       be revisited.
74     chmod 640 ${D}${sysconfdir}/kuksa-val/Server.key
75     chgrp 900 ${D}${sysconfdir}/kuksa-val/Server.key
76     chmod 640 ${D}${sysconfdir}/kuksa-val/Server.pem
77     chgrp 900 ${D}${sysconfdir}/kuksa-val/Server.pem
78 }
79
80 pkg_postinst_ontarget:${PN}-client-certificates () {
81     certutil -A -d /home/agl-driver/.pki/nssdb -n "KuksaRootCA" -t "pC,," -i ${sysconfdir}/kuksa-val/CA.pem
82     chown agl-driver:agl-driver -R /home/agl-driver/
83 }
84
85 # Put client certificates into their own package so we can avoid
86 # duplicates of them for e.g. cluster clients.  Longer term this
87 # will need to be revisited.
88 PACKAGE_BEFORE_PN += "${PN}-client-certificates"
89
90 FILES:${PN}-client-certificates = " \
91     ${sysconfdir}/kuksa-val/Client.key \
92     ${sysconfdir}/kuksa-val/Client.pem \
93     ${sysconfdir}/kuksa-val/CA.pem \
94 "
95
96 FILES:${PN} += "${systemd_system_unitdir} ${datadir}"
97
98 RDEPENDS:${PN} += "${PN}-client-certificates nss-agl-driver-db"