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