Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | SUMMARY = "Serial terminal support for systemd" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2 | HOMEPAGE = "https://www.freedesktop.org/wiki/Software/systemd/" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3 | LICENSE = "GPLv2+" |
| 4 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" |
| 5 | |
| 6 | PR = "r5" |
| 7 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 8 | SERIAL_CONSOLES ?= "115200;ttyS0" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9 | |
| 10 | SRC_URI = "file://serial-getty@.service" |
| 11 | |
| 12 | S = "${WORKDIR}" |
| 13 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14 | # As this package is tied to systemd, only build it when we're also building systemd. |
| 15 | inherit distro_features_check |
| 16 | REQUIRED_DISTRO_FEATURES = "systemd" |
| 17 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 18 | do_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/ |
| 24 | sed -i -e s/\@BAUDRATE\@/$default_baudrate/g ${D}${systemd_unitdir}/system/serial-getty@.service |
| 25 | |
| 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 |
| 37 | sed -i -e s/\@BAUDRATE\@/$baudrate/g ${D}${systemd_unitdir}/system/serial-getty$baudrate@.service |
| 38 | # 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 46 | # This is a machine specific file |
| 47 | FILES_${PN} = "${systemd_unitdir}/system/*.service ${sysconfdir}" |
| 48 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 49 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 50 | ALLOW_EMPTY_${PN} = "1" |