1SUMMARY = "Phosphor Host logger"
2DESCRIPTION = "Save log messages from host's console to the persistent storage."
3HOMEPAGE = "https://github.com/openbmc/phosphor-hostlogger"
4PR = "r1"
5PV = "1.0+git${SRCPV}"
6
7inherit meson
8inherit systemd
9
10# License info
11LICENSE = "Apache-2.0"
12LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
13
14# Dependencies
15DEPENDS += " \
16            phosphor-logging \
17            zlib \
18           "
19RDEPENDS:${PN} += "obmc-console"
20RRECOMMENDS:${PN} += "phosphor-debug-collector"
21
22# Source code repository
23S = "${WORKDIR}/git"
24SRC_URI = "git://github.com/openbmc/phosphor-hostlogger"
25SRCREV = "042b5ba8438d1423f807feb5ef739cda063ea8d2"
26
27# Disable unit tests
28EXTRA_OEMESON:append = " -Dtests=disabled"
29
30# Systemd service template
31SYSTEMD_PACKAGES = "${PN}"
32SYSTEMD_SERVICE:${PN} = "hostlogger@.service"
33
34# Default service instance to install (single-host mode)
35DEFAULT_INSTANCE = "ttyVUART0"
36DEFAULT_SERVICE = "hostlogger@${DEFAULT_INSTANCE}.service"
37
38# Multi-host mode setup - list of configuration files to install, can be added
39# via SRC_URI in a bbappend. The file name is the name of the service instance,
40# which should match the corresponding instance of the obmc-console service.
41CUSTOM_CONFIGS = "${@custom_configs('${WORKDIR}')}"
42CUSTOM_SERVICES = "${@custom_services('${CUSTOM_CONFIGS}')}"
43
44# Preset systemd units
45SYSTEMD_SERVICE:${PN} += "${@'${CUSTOM_SERVICES}' if len('${CUSTOM_SERVICES}') \
46                                                  else '${DEFAULT_SERVICE}'}"
47
48# Gets list of custom config files in a directory
49def custom_configs(workdir):
50    if os.path.exists(workdir):
51        return ' '.join([f for f in os.listdir(workdir) if f.endswith('.conf')])
52
53# Get list of custom service instances
54def custom_services(configs):
55    return ' '.join(['hostlogger@' + i.replace('.conf', '.service') \
56                     for i in configs.split()])
57
58do_install:append() {
59  # Install config files
60  if [ -n "${CUSTOM_CONFIGS}" ]; then
61    for CONFIG_FILE in ${CUSTOM_CONFIGS}; do
62        install -Dm 0644 ${WORKDIR}/${CONFIG_FILE} \
63                     ${D}${sysconfdir}/hostlogger/${CONFIG_FILE}
64    done
65  else
66    install -Dm 0644 ${S}/default.conf \
67                     ${D}${sysconfdir}/hostlogger/${DEFAULT_INSTANCE}.conf
68  fi
69}
70