summaryrefslogtreecommitdiff
path: root/meta-phosphor/recipes-phosphor/logging/phosphor-hostlogger_git.bb
blob: b419db1c08e161f8dff1d4a3c841838614e15108 (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
61
62
63
64
65
66
67
68
69
SUMMARY = "Phosphor Host logger"
DESCRIPTION = "Save log messages from host's console to the persistent storage."
HOMEPAGE = "https://github.com/openbmc/phosphor-hostlogger"
PR = "r1"
PV = "1.0+git${SRCPV}"

inherit pkgconfig meson
inherit systemd

# License info
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"

# Dependencies
DEPENDS += " \
            phosphor-logging \
            zlib \
           "
RDEPENDS:${PN} += "obmc-console"
RRECOMMENDS:${PN} += "phosphor-debug-collector"

# Source code repository
S = "${WORKDIR}/git"
SRC_URI = "git://github.com/openbmc/phosphor-hostlogger"
SRCREV = "1ecbb996d9c88871db20c455db02ee055bff10f2"

# Disable unit tests
EXTRA_OEMESON:append = " -Dtests=disabled"

# Systemd service template
SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN} = "hostlogger@.service"

# Default service instance to install (single-host mode)
DEFAULT_INSTANCE = "ttyVUART0"
DEFAULT_SERVICE = "hostlogger@${DEFAULT_INSTANCE}.service"

# Multi-host mode setup - list of configuration files to install, can be added
# via SRC_URI in a bbappend. The file name is the name of the service instance,
# which should match the corresponding instance of the obmc-console service.
CUSTOM_CONFIGS = "${@custom_configs('${WORKDIR}')}"
CUSTOM_SERVICES = "${@custom_services('${CUSTOM_CONFIGS}')}"

# Preset systemd units
SYSTEMD_SERVICE:${PN} += "${@'${CUSTOM_SERVICES}' if len('${CUSTOM_SERVICES}') \
                                                  else '${DEFAULT_SERVICE}'}"

# Gets list of custom config files in a directory
def custom_configs(workdir):
    if os.path.exists(workdir):
        return ' '.join([f for f in os.listdir(workdir) if f.endswith('.conf')])

# Get list of custom service instances
def custom_services(configs):
    return ' '.join(['hostlogger@' + i.replace('.conf', '.service') \
                     for i in configs.split()])

do_install:append() {
  # Install config files
  if [ -n "${CUSTOM_CONFIGS}" ]; then
    for CONFIG_FILE in ${CUSTOM_CONFIGS}; do
        install -Dm 0644 ${WORKDIR}/${CONFIG_FILE} \
                     ${D}${sysconfdir}/hostlogger/${CONFIG_FILE}
    done
  else
    install -Dm 0644 ${S}/default.conf \
                     ${D}${sysconfdir}/hostlogger/${DEFAULT_INSTANCE}.conf
  fi
}