Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame^] | 1 | SUMMARY = "Serial terminal support for systemd" |
| 2 | LICENSE = "GPLv2+" |
| 3 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" |
| 4 | |
| 5 | PR = "r5" |
| 6 | |
| 7 | SERIAL_CONSOLE ?= "115200 ttyS0" |
| 8 | |
| 9 | SRC_URI = "file://serial-getty@.service" |
| 10 | |
| 11 | S = "${WORKDIR}" |
| 12 | |
| 13 | do_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 | |
| 41 | RDEPENDS_${PN} = "systemd" |
| 42 | |
| 43 | # This is a machine specific file |
| 44 | FILES_${PN} = "${systemd_unitdir}/system/*.service ${sysconfdir}" |
| 45 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 46 | |
| 47 | # As this package is tied to systemd, only build it when we're also building systemd. |
| 48 | python () { |
| 49 | if not bb.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d): |
| 50 | raise bb.parse.SkipPackage("'systemd' not in DISTRO_FEATURES") |
| 51 | } |