blob: 0cc0dc8c79cdf663f7c99864b8c3cda05e516340 [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
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08008SERIAL_CONSOLES ?= "115200;ttyS0"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009
10SRC_URI = "file://serial-getty@.service"
11
12S = "${WORKDIR}"
13
Brad Bishop316dfdd2018-06-25 12:45:53 -040014# As this package is tied to systemd, only build it when we're also building systemd.
Brad Bishop6dbb3162019-11-25 09:41:34 -050015inherit features_check
Brad Bishop316dfdd2018-06-25 12:45:53 -040016REQUIRED_DISTRO_FEATURES = "systemd"
17
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018do_install() {
19 if [ ! -z "${SERIAL_CONSOLES}" ] ; then
20 default_baudrate=`echo "${SERIAL_CONSOLES}" | sed 's/\;.*//'`
21 install -d ${D}${systemd_unitdir}/system/
22 install -d ${D}${sysconfdir}/systemd/system/getty.target.wants/
23 install -m 0644 ${WORKDIR}/serial-getty@.service ${D}${systemd_unitdir}/system/
Andrew Geisslerc9f78652020-09-18 14:11:35 -050024 sed -i -e "s/\@BAUDRATE\@/$default_baudrate/g" ${D}${systemd_unitdir}/system/serial-getty@.service
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025
26 tmp="${SERIAL_CONSOLES}"
27 for entry in $tmp ; do
28 baudrate=`echo $entry | sed 's/\;.*//'`
29 ttydev=`echo $entry | sed -e 's/^[0-9]*\;//' -e 's/\;.*//'`
30 if [ "$baudrate" = "$default_baudrate" ] ; then
31 # enable the service
32 ln -sf ${systemd_unitdir}/system/serial-getty@.service \
33 ${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty@$ttydev.service
34 else
35 # install custom service file for the non-default baudrate
36 install -m 0644 ${WORKDIR}/serial-getty@.service ${D}${systemd_unitdir}/system/serial-getty$baudrate@.service
Andrew Geisslerc9f78652020-09-18 14:11:35 -050037 sed -i -e "s/\@BAUDRATE\@/$baudrate/g" ${D}${systemd_unitdir}/system/serial-getty$baudrate@.service
Patrick Williamsc124f4f2015-09-15 14:41:29 -050038 # enable the service
39 ln -sf ${systemd_unitdir}/system/serial-getty$baudrate@.service \
40 ${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty$baudrate@$ttydev.service
41 fi
42 done
43 fi
44}
45
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046# This is a machine specific file
47FILES_${PN} = "${systemd_unitdir}/system/*.service ${sysconfdir}"
48PACKAGE_ARCH = "${MACHINE_ARCH}"
49
Brad Bishopd7bf8c12018-02-25 22:55:05 -050050ALLOW_EMPTY_${PN} = "1"