blob: 768b1308f23fa2a827854a13bf3c5f89ceb66e8a [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "Serial terminal support for systemd"
2LICENSE = "GPLv2+"
3LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
4
5PR = "r5"
6
7SERIAL_CONSOLE ?= "115200 ttyS0"
8
9SRC_URI = "file://serial-getty@.service"
10
11S = "${WORKDIR}"
12
13do_install() {
14 if [ ! -z "${SERIAL_CONSOLES}" ] ; then
15 default_baudrate=`echo "${SERIAL_CONSOLES}" | sed 's/\;.*//'`
16 install -d ${D}${systemd_unitdir}/system/
17 install -d ${D}${sysconfdir}/systemd/system/getty.target.wants/
18 install -m 0644 ${WORKDIR}/serial-getty@.service ${D}${systemd_unitdir}/system/
19 sed -i -e s/\@BAUDRATE\@/$default_baudrate/g ${D}${systemd_unitdir}/system/serial-getty@.service
20
21 tmp="${SERIAL_CONSOLES}"
22 for entry in $tmp ; do
23 baudrate=`echo $entry | sed 's/\;.*//'`
24 ttydev=`echo $entry | sed -e 's/^[0-9]*\;//' -e 's/\;.*//'`
25 if [ "$baudrate" = "$default_baudrate" ] ; then
26 # enable the service
27 ln -sf ${systemd_unitdir}/system/serial-getty@.service \
28 ${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty@$ttydev.service
29 else
30 # install custom service file for the non-default baudrate
31 install -m 0644 ${WORKDIR}/serial-getty@.service ${D}${systemd_unitdir}/system/serial-getty$baudrate@.service
32 sed -i -e s/\@BAUDRATE\@/$baudrate/g ${D}${systemd_unitdir}/system/serial-getty$baudrate@.service
33 # enable the service
34 ln -sf ${systemd_unitdir}/system/serial-getty$baudrate@.service \
35 ${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty$baudrate@$ttydev.service
36 fi
37 done
38 fi
39}
40
41RDEPENDS_${PN} = "systemd"
42
43# This is a machine specific file
44FILES_${PN} = "${systemd_unitdir}/system/*.service ${sysconfdir}"
45PACKAGE_ARCH = "${MACHINE_ARCH}"
46
47# As this package is tied to systemd, only build it when we're also building systemd.
48python () {
49 if not bb.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d):
50 raise bb.parse.SkipPackage("'systemd' not in DISTRO_FEATURES")
51}