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