diff options
-rw-r--r-- | meta/recipes-core/systemd/systemd-serialgetty.bb | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/meta/recipes-core/systemd/systemd-serialgetty.bb b/meta/recipes-core/systemd/systemd-serialgetty.bb index 96cbf31470..37c49b12d7 100644 --- a/meta/recipes-core/systemd/systemd-serialgetty.bb +++ b/meta/recipes-core/systemd/systemd-serialgetty.bb | |||
@@ -8,37 +8,38 @@ SERIAL_CONSOLE ?= "115200 ttyS0" | |||
8 | 8 | ||
9 | SRC_URI = "file://serial-getty@.service" | 9 | SRC_URI = "file://serial-getty@.service" |
10 | 10 | ||
11 | def get_serial_console_value(d, index): | ||
12 | c = d.getVar('SERIAL_CONSOLE', True) | ||
13 | |||
14 | if len(c): | ||
15 | return c.split()[index] | ||
16 | |||
17 | return "" | ||
18 | |||
19 | def get_baudrate(d): | ||
20 | return get_serial_console_value(d, 0) | ||
21 | |||
22 | def get_console(d): | ||
23 | return get_serial_console_value(d, 1) | ||
24 | |||
25 | do_install() { | 11 | do_install() { |
26 | if [ ! ${@get_baudrate(d)} = "" ]; then | 12 | if [ ! -z "${SERIAL_CONSOLES}" ] ; then |
27 | sed -i -e s/\@BAUDRATE\@/${@get_baudrate(d)}/g ${WORKDIR}/serial-getty@.service | 13 | default_baudrate=`echo "${SERIAL_CONSOLES}" | sed 's/\;.*//'` |
28 | install -d ${D}${systemd_unitdir}/system/ | 14 | install -d ${D}${systemd_unitdir}/system/ |
29 | install -d ${D}${sysconfdir}/systemd/system/getty.target.wants/ | 15 | install -d ${D}${sysconfdir}/systemd/system/getty.target.wants/ |
30 | install ${WORKDIR}/serial-getty@.service ${D}${systemd_unitdir}/system/ | 16 | install -m 0644 ${WORKDIR}/serial-getty@.service ${D}${systemd_unitdir}/system/ |
31 | 17 | sed -i -e s/\@BAUDRATE\@/$default_baudrate/g ${D}${systemd_unitdir}/system/serial-getty@.service | |
32 | # enable the service | 18 | |
33 | ln -sf ${systemd_unitdir}/system/serial-getty@.service \ | 19 | tmp="${SERIAL_CONSOLES}" |
34 | ${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty@${@get_console(d)}.service | 20 | for entry in $tmp ; do |
21 | baudrate=`echo $entry | sed 's/\;.*//'` | ||
22 | ttydev=`echo $entry | sed -e 's/^[0-9]*\;//' -e 's/\;.*//'` | ||
23 | if [ "$baudrate" = "$default_baudrate" ] ; then | ||
24 | # enable the service | ||
25 | ln -sf ${systemd_unitdir}/system/serial-getty@.service \ | ||
26 | ${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty@$ttydev.service | ||
27 | else | ||
28 | # install custom service file for the non-default baudrate | ||
29 | install -m 0644 ${WORKDIR}/serial-getty@.service ${D}${systemd_unitdir}/system/serial-getty$baudrate@.service | ||
30 | sed -i -e s/\@BAUDRATE\@/$baudrate/g ${D}${systemd_unitdir}/system/serial-getty$baudrate@.service | ||
31 | # enable the service | ||
32 | ln -sf ${systemd_unitdir}/system/serial-getty$baudrate@.service \ | ||
33 | ${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty$baudrate@$ttydev.service | ||
34 | fi | ||
35 | done | ||
35 | fi | 36 | fi |
36 | } | 37 | } |
37 | 38 | ||
38 | RDEPENDS_${PN} = "systemd" | 39 | RDEPENDS_${PN} = "systemd" |
39 | 40 | ||
40 | # This is a machine specific file | 41 | # This is a machine specific file |
41 | FILES_${PN} = "${systemd_unitdir}/system/serial-getty@.service ${sysconfdir}" | 42 | FILES_${PN} = "${systemd_unitdir}/system/*.service ${sysconfdir}" |
42 | PACKAGE_ARCH = "${MACHINE_ARCH}" | 43 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
43 | 44 | ||
44 | # As this package is tied to systemd, only build it when we're also building systemd. | 45 | # As this package is tied to systemd, only build it when we're also building systemd. |