1SUMMARY = "OpenBMC console daemon"
2DESCRIPTION = "Daemon to handle UART console connections"
3HOMEPAGE = "http://github.com/openbmc/obmc-console"
4PR = "r1"
5LICENSE = "Apache-2.0"
6LIC_FILES_CHKSUM = "file://LICENSE;md5=fa818a259cbed7ce8bc2a22d35a464fc"
7
8inherit autotools pkgconfig
9inherit obmc-phosphor-discovery-service
10inherit systemd
11
12S = "${WORKDIR}/git"
13
14TARGET_CFLAGS += "-fpic -O2"
15
16PACKAGECONFIG ??= "udev ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
17PACKAGECONFIG[udev] = "--with-udevdir=`pkg-config --variable=udevdir udev`,\
18                       --without-udevdir,udev"
19PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_system_unitdir}, \
20                          --without-systemdsystemunitdir"
21
22DEPENDS += "autoconf-archive-native \
23            systemd \
24           "
25
26SRC_URI += "git://github.com/openbmc/obmc-console;branch=master;protocol=https"
27SRC_URI += "file://${BPN}.conf"
28
29SRCREV = "bbc95526c6b612ec42f45e3d554d01324477c4e7"
30PV = "1.0+git${SRCPV}"
31
32REGISTERED_SERVICES:${PN} += "obmc_console:tcp:2200:"
33
34SYSTEMD_SERVICE:${PN} += "obmc-console-ssh@.service \
35                obmc-console-ssh.socket \
36                obmc-console@.service \
37                "
38
39FILES:${PN} += "${systemd_system_unitdir}/obmc-console-ssh@.service.d/use-socket.conf"
40
41OBMC_CONSOLE_HOST_TTY ?= "ttyVUART0"
42
43# Support multiple TTY ports using space separated list.
44# Ex. OBMC_CONSOLE_TTYS = "ttyS1 ttyS2"
45OBMC_CONSOLE_TTYS ?= "${OBMC_CONSOLE_HOST_TTY}"
46
47do_install:append() {
48        # Install the server configuration
49        install -m 0755 -d ${D}${sysconfdir}/${BPN}
50
51        # If the OBMC_CONSOLE_TTYS variable is used without the default OBMC_CONSOLE_HOST_TTY
52        # the port specific config file should be provided. If it is just OBMC_CONSOLE_HOST_TTY,
53        # use the old style which supports both port specific or obmc-console.conf method.
54        if [ "${OBMC_CONSOLE_TTYS}" !=  "${OBMC_CONSOLE_HOST_TTY}" ]; then
55                rm -f ${D}${sysconfdir}/${BPN}/server.ttyVUART0.conf
56
57                for CONSOLE in ${OBMC_CONSOLE_TTYS}
58                do
59                        if test -f "${WORKDIR}/server.${CONSOLE}.conf" ; then
60                                install -m 0644 ${WORKDIR}/server.${CONSOLE}.conf ${D}${sysconfdir}/${BPN}/
61                        else
62                                bberror "Must provide port specific config files when using OBMC_CONSOLE_TTYS" \
63                                        "Missing server.${CONSOLE}.conf"
64                        fi
65                done
66        else
67                # Port specific config file is prioritized over generic conf file.
68                # If port specific config file is not present and generic "obmc-console.conf"
69                # exists, it will be used.
70                if test -f "${WORKDIR}/server.${OBMC_CONSOLE_TTYS}.conf" ; then
71                        # Remove the upstream-provided server configuration
72                        rm -f ${D}${sysconfdir}/${BPN}/server.ttyVUART0.conf
73                        # Install the package-provided new-style configuration
74                        install -m 0644 ${WORKDIR}/server.${OBMC_CONSOLE_TTYS}.conf ${D}${sysconfdir}/${BPN}/
75                elif test -f "${WORKDIR}/${BPN}.conf"; then
76                        # Remove the upstream-provided server configuration
77                        rm -f ${D}${sysconfdir}/${BPN}/server.ttyVUART0.conf
78                        # Install the old-style server configuration
79                        install -m 0644 ${WORKDIR}/${BPN}.conf ${D}${sysconfdir}/
80                        # Link the custom configuration to the required location
81                        ln -sr ${D}${sysconfdir}/${BPN}.conf ${D}${sysconfdir}/${BPN}/server.${OBMC_CONSOLE_TTYS}.conf
82                else
83                        # Otherwise, remove socket-id from the shipped configuration to
84                        # align with the lack of a client configuration file
85                        sed -ri '/^socket-id =/d' ${D}${sysconfdir}/${BPN}/server.${OBMC_CONSOLE_TTYS}.conf
86                fi
87        fi
88
89}
90