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