systemd-serialgetty.bb 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. SUMMARY = "Serial terminal support for systemd"
  2. HOMEPAGE = "https://www.freedesktop.org/wiki/Software/systemd/"
  3. LICENSE = "GPL-2.0-or-later"
  4. LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6"
  5. SERIAL_CONSOLES ?= "115200;ttyS0"
  6. SERIAL_TERM ?= "linux"
  7. SRC_URI = "file://serial-getty@.service"
  8. S = "${WORKDIR}/sources"
  9. UNPACKDIR = "${S}"
  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. REQUIRED_DISTRO_FEATURES += "usrmerge"
  14. do_install() {
  15. if [ ! -z "${SERIAL_CONSOLES}" ] ; then
  16. default_baudrate=`echo "${SERIAL_CONSOLES}" | sed 's/\;.*//'`
  17. install -d ${D}${systemd_system_unitdir}/
  18. install -d ${D}${sysconfdir}/systemd/system/getty.target.wants/
  19. install -m 0644 ${S}/serial-getty@.service ${D}${systemd_system_unitdir}/
  20. sed -i -e "s/\@BAUDRATE\@/$default_baudrate/g" ${D}${systemd_system_unitdir}/serial-getty@.service
  21. sed -i -e "s/\@TERM\@/${SERIAL_TERM}/g" ${D}${systemd_system_unitdir}/serial-getty@.service
  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_system_unitdir}/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 ${S}/serial-getty@.service ${D}${systemd_system_unitdir}/serial-getty$baudrate@.service
  33. sed -i -e "s/\@BAUDRATE\@/$baudrate/g" ${D}${systemd_system_unitdir}/serial-getty$baudrate@.service
  34. # enable the service
  35. ln -sf ${systemd_system_unitdir}/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. # This is a machine specific file
  42. FILES:${PN} = "${systemd_system_unitdir}/*.service ${sysconfdir}"
  43. PACKAGE_ARCH = "${MACHINE_ARCH}"
  44. ALLOW_EMPTY:${PN} = "1"