aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/runit/runit-serialgetty.bb
blob: cd9715bfc60dda437d9515af5cb35fe879fd68fe (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
# Copyright (C) 2017 Khem Raj <raj.khem@gmail.com>
# Released under the MIT license (see COPYING.MIT for the terms)

DESCRIPTION = "Serial terminal support for runit"

SECTION = "base utils"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"

INHIBIT_DEFAULT_DEPS = "1"

SRC_URI = "\
           file://run \
           file://finish \
"

S = "${WORKDIR}"

SERIAL_CONSOLES ?= "115200;ttyS0"

do_install() {
	install -d ${D}${sysconfdir}/service ${D}${sysconfdir}/runit/runsvdir/default
	tmp="${SERIAL_CONSOLES}"
	for i in $tmp
	do
		baudrate=`echo $i | sed 's/\;.*//'`
		ttydev=`echo $i | sed -e 's/^[0-9]*\;//' -e 's/\;.*//'`
		install -d ${D}${sysconfdir}/sv/getty-${ttydev}
		install -m 755 ${WORKDIR}/run ${D}${sysconfdir}/sv/getty-${ttydev}
		install -m 755 ${WORKDIR}/finish ${D}${sysconfdir}/sv/getty-${ttydev}
		sed -i -e s/\@BAUDRATE\@/$baudrate/g ${D}${sysconfdir}/sv/getty-${ttydev}/run
		sed -i -e s/\@BAUDRATE\@/$baudrate/g ${D}${sysconfdir}/sv/getty-${ttydev}/finish
		sed -i -e s/\@TTY\@/$ttydev/g ${D}${sysconfdir}/sv/getty-${ttydev}/run
		sed -i -e s/\@TTY\@/$ttydev/g ${D}${sysconfdir}/sv/getty-${ttydev}/finish
		ln -s ${localstatedir}/run/sv.getty-${ttydev} ${D}${sysconfdir}/sv/getty-${ttydev}/supervise
		ln -s ${sysconfdir}/sv/getty-${ttydev} ${D}${sysconfdir}/service/getty-${ttydev}
		ln -s ${sysconfdir}/sv/getty-${ttydev} ${D}${sysconfdir}/runit/runsvdir/default/getty-${ttydev}
	done
}
# Since SERIAL_CONSOLES is likely to be set from the machine configuration
PACKAGE_ARCH = "${MACHINE_ARCH}"

FILES_${PN} = "${sysconfdir}"