From: Paul Eggleton <paul.eggleton@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 5/5] systemd-serialgetty: change to handle SERIAL_CONSOLES
Date: Tue, 30 Apr 2013 17:53:01 +0100 [thread overview]
Message-ID: <3ea5089011e316a994deffa881981ad855914998.1367340369.git.paul.eggleton@linux.intel.com> (raw)
In-Reply-To: <cover.1367340369.git.paul.eggleton@linux.intel.com>
In-Reply-To: <cover.1367340369.git.paul.eggleton@linux.intel.com>
SERIAL_CONSOLES is now set from SERIAL_CONSOLE if not already set.
This is a little bit gnarly because we have to create a separate service
file for each different baud rate; assume that the first baud rate is
the default, thus preserving the previous behaviour in the event there
is only one baud rate in use.
This change also installs the service file before modifying it in place,
allowing do_install to re-execute properly; additionally the service
file now has the correct permissions (i.e. no execute bit set).
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
meta/recipes-core/systemd/systemd-serialgetty.bb | 45 ++++++++++++------------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/meta/recipes-core/systemd/systemd-serialgetty.bb b/meta/recipes-core/systemd/systemd-serialgetty.bb
index 96cbf31..37c49b1 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"
SRC_URI = "file://serial-getty@.service"
-def get_serial_console_value(d, index):
- c = d.getVar('SERIAL_CONSOLE', True)
-
- 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(d)} = "" ]; then
- sed -i -e s/\@BAUDRATE\@/${@get_baudrate(d)}/g ${WORKDIR}/serial-getty@.service
+ if [ ! -z "${SERIAL_CONSOLES}" ] ; then
+ default_baudrate=`echo "${SERIAL_CONSOLES}" | sed 's/\;.*//'`
install -d ${D}${systemd_unitdir}/system/
install -d ${D}${sysconfdir}/systemd/system/getty.target.wants/
- install ${WORKDIR}/serial-getty@.service ${D}${systemd_unitdir}/system/
-
- # enable the service
- ln -sf ${systemd_unitdir}/system/serial-getty@.service \
- ${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty@${@get_console(d)}.service
+ install -m 0644 ${WORKDIR}/serial-getty@.service ${D}${systemd_unitdir}/system/
+ sed -i -e s/\@BAUDRATE\@/$default_baudrate/g ${D}${systemd_unitdir}/system/serial-getty@.service
+
+ tmp="${SERIAL_CONSOLES}"
+ for entry in $tmp ; do
+ baudrate=`echo $entry | sed 's/\;.*//'`
+ ttydev=`echo $entry | sed -e 's/^[0-9]*\;//' -e 's/\;.*//'`
+ if [ "$baudrate" = "$default_baudrate" ] ; then
+ # enable the service
+ ln -sf ${systemd_unitdir}/system/serial-getty@.service \
+ ${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty@$ttydev.service
+ else
+ # install custom service file for the non-default baudrate
+ install -m 0644 ${WORKDIR}/serial-getty@.service ${D}${systemd_unitdir}/system/serial-getty$baudrate@.service
+ sed -i -e s/\@BAUDRATE\@/$baudrate/g ${D}${systemd_unitdir}/system/serial-getty$baudrate@.service
+ # enable the service
+ ln -sf ${systemd_unitdir}/system/serial-getty$baudrate@.service \
+ ${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty$baudrate@$ttydev.service
+ fi
+ done
fi
}
RDEPENDS_${PN} = "systemd"
# This is a machine specific file
-FILES_${PN} = "${systemd_unitdir}/system/serial-getty@.service ${sysconfdir}"
+FILES_${PN} = "${systemd_unitdir}/system/*.service ${sysconfdir}"
PACKAGE_ARCH = "${MACHINE_ARCH}"
# As this package is tied to systemd, only build it when we're also building systemd.
--
1.8.1.2
next prev parent reply other threads:[~2013-04-30 17:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-30 16:52 [PATCH 0/5] SERIAL_CONSOLES improvements Paul Eggleton
2013-04-30 16:52 ` [PATCH 1/5] sysvinit-inittab: ensure unique label for SERIAL_CONSOLES entries Paul Eggleton
2013-04-30 16:52 ` [PATCH 2/5] bitbake.conf: set SERIAL_CONSOLES from SERIAL_CONSOLE by default Paul Eggleton
2013-04-30 21:42 ` Khem Raj
2013-05-01 6:51 ` Paul Eggleton
2013-05-01 17:07 ` Khem Raj
2013-04-30 16:52 ` [PATCH 3/5] sysvinit-inittab: remove specific handling of SERIAL_CONSOLE Paul Eggleton
2013-04-30 16:53 ` [PATCH 4/5] shadow-securetty: change to handle SERIAL_CONSOLES Paul Eggleton
2013-04-30 16:53 ` Paul Eggleton [this message]
2013-05-01 7:14 ` [PATCH 0/5] SERIAL_CONSOLES improvements Koen Kooi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3ea5089011e316a994deffa881981ad855914998.1367340369.git.paul.eggleton@linux.intel.com \
--to=paul.eggleton@linux.intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox