systemd-serialgetty.bb 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. SUMMARY = "Serial terminal support for systemd"
  2. HOMEPAGE = "https://www.freedesktop.org/wiki/Software/systemd/"
  3. LICENSE = "GPLv2+"
  4. LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
  5. PR = "r5"
  6. SERIAL_CONSOLES ?= "115200;ttyS0"
  7. SERIAL_TERM ?= "linux"
  8. SRC_URI = "file://serial-getty@.service"
  9. S = "${WORKDIR}"
  10. # As this package is tied to systemd, only build it when we're also building systemd.
  11. inherit features_check
  12. REQUIRED_DISTRO_FEATURES = "systemd"
  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. sed -i -e "s/\@TERM\@/${SERIAL_TERM}/g" ${D}${systemd_unitdir}/system/serial-getty@.service
  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. # This is a machine specific file
  41. FILES_${PN} = "${systemd_unitdir}/system/*.service ${sysconfdir}"
  42. PACKAGE_ARCH = "${MACHINE_ARCH}"
  43. ALLOW_EMPTY_${PN} = "1"