Patchwork [meta-oe,1/3] systemd-serialgetty: support machines without serial console

login
register
mail settings
Submitter Otavio Salvador
Date Jan. 31, 2012, 5:38 p.m.
Message ID <cb6176771f9766892fb60c8f2a48490b1b060b36.1328031500.git.otavio@ossystems.com.br>
Download mbox | patch
Permalink /patch/20435/
State Accepted
Commit 0d20039cfd748cb0d91d3f878f2256550c9feb3e
Headers show

Comments

Otavio Salvador - Jan. 31, 2012, 5:38 p.m.
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---
 .../recipes-core/systemd/systemd-serialgetty.bb    |   24 +++++++++++++------
 1 files changed, 16 insertions(+), 8 deletions(-)

Patch

diff --git a/meta-oe/recipes-core/systemd/systemd-serialgetty.bb b/meta-oe/recipes-core/systemd/systemd-serialgetty.bb
index 2b88d0c..5b903a0 100644
--- a/meta-oe/recipes-core/systemd/systemd-serialgetty.bb
+++ b/meta-oe/recipes-core/systemd/systemd-serialgetty.bb
@@ -2,29 +2,37 @@  DESCRIPTION = "Systemd serial config"
 LICENSE = "GPLv2+"
 LIC_FILES_CHKSUM = "file://${WORKDIR}/LICENSE;md5=751419260aa954499f7abaabaa882bbe"
 
-PR = "r1"
+PR = "r2"
 
 SERIAL_CONSOLE ?= "115200 ttyS0"
 
 SRC_URI = "file://LICENSE \
            file://serial-getty@.service"
 
-def get_baudrate(bb, d):
-    return bb.data.getVar('SERIAL_CONSOLE', d, 1).split()[0]
+def get_serial_console_value(d, index):
+    c = d.getVar('SERIAL_CONSOLE', True)
 
-def get_console(bb, d):
-    return bb.data.getVar('SERIAL_CONSOLE', d, 1).split()[1]
+    if len(c):
+        return c.split()[index]
+
+    return ""
+
+def get_baudrate(d):
+    return get_serial_console_value(d, 0)
+
+def get_console(d):
+    return get_serial_console_value(d, 1)
 
 do_install() {
-	if [ ! ${@get_baudrate(bb, d)} = "" ]; then
-		sed -i -e s/\@BAUDRATE\@/${@get_baudrate(bb, d)}/g ${WORKDIR}/serial-getty@.service
+	if [ ! ${@get_baudrate(d)} = "" ]; then
+		sed -i -e s/\@BAUDRATE\@/${@get_baudrate(d)}/g ${WORKDIR}/serial-getty@.service
 		install -d ${D}${base_libdir}/systemd/system/
 		install -d ${D}${sysconfdir}/systemd/system/getty.target.wants/
 		install ${WORKDIR}/serial-getty@.service ${D}${base_libdir}/systemd/system/
 
 		# enable the service
 		ln -sf ${base_libdir}/systemd/system/serial-getty@.service \
-			${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty@${@get_console(bb, d)}.service
+			${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty@${@get_console(d)}.service
 	fi
 }