GoogleGit

blob: 4fbb462a25581844ce89db6eb109a812899aa89a [file] [log] [blame]
  1. # Copyright 2014 The Chromium OS Authors. All rights reserved.
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=4
  4. DESCRIPTION="Init script to run agetty on selected terminals."
  5. LICENSE="BSD-Google"
  6. SLOT="0"
  7. KEYWORDS="*"
  8. USE_PREFIX="tty_console_"
  9. ALL_PORTS=(
  10. ttyAMA{0..5}
  11. ttyHSL{0..5}
  12. ttyMSM{0..5}
  13. ttymxc{0..5}
  14. ttyO{0..5}
  15. ttyS{0..5}
  16. ttySAC{0..5}
  17. ttyUSB{0..5}
  18. tty{0..5}
  19. )
  20. IUSE_PORTS="${ALL_PORTS[@]/#/${USE_PREFIX}}"
  21. IUSE="${IUSE_PORTS}"
  22. RDEPEND="
  23. sys-apps/upstart
  24. !chromeos-base/tty1
  25. !chromeos-base/serial-tty
  26. "
  27. S="${WORKDIR}"
  28. src_compile() {
  29. # Generate a file for each activated tty console.
  30. local item
  31. for item in ${IUSE_PORTS}; do
  32. use ${item} && generate_init_script ${item}
  33. done
  34. }
  35. generate_init_script() {
  36. # Creates an init script per activated console by copying the base script and
  37. # changing the port number.
  38. local port="${1#${USE_PREFIX}}"
  39. sed -e "s|%PORT%|${port}|g" \
  40. "${FILESDIR}"/tty-base.conf \
  41. > console-${port}.conf || die "failed to generate ${port}"
  42. }
  43. src_install() {
  44. if [[ -n ${TTY_CONSOLE} ]]; then
  45. insinto /etc/init
  46. doins console-*.conf
  47. fi
  48. }