[oe] [PATCH 05/15] meta-installer: add systemd/systemd-serialgetty bbappend

Hongxu Jia hongxu.jia at windriver.com
Thu Nov 23 12:09:05 UTC 2017


Use screen for text install, the serail console and tty1
will have the same input/output.

The bbappend works only if DISTRO = "anaconda".

Signed-off-by: Hongxu Jia <hongxu.jia at windriver.com>
---
 .../systemd/files/serial-getty at .service            | 40 ++++++++++++++++++++++
 .../systemd/files/serial-screen-anaconda.sh        |  5 +++
 .../systemd/systemd-serialgetty.bbappend           | 12 +++++++
 .../recipes-core/systemd/systemd_%.bbappend        |  6 ++++
 4 files changed, 63 insertions(+)
 create mode 100644 meta-installer/recipes-core/systemd/files/serial-getty at .service
 create mode 100644 meta-installer/recipes-core/systemd/files/serial-screen-anaconda.sh
 create mode 100644 meta-installer/recipes-core/systemd/systemd-serialgetty.bbappend
 create mode 100644 meta-installer/recipes-core/systemd/systemd_%.bbappend

diff --git a/meta-installer/recipes-core/systemd/files/serial-getty at .service b/meta-installer/recipes-core/systemd/files/serial-getty at .service
new file mode 100644
index 0000000..52530a3
--- /dev/null
+++ b/meta-installer/recipes-core/systemd/files/serial-getty at .service
@@ -0,0 +1,40 @@
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU Lesser General Public License as published by
+#  the Free Software Foundation; either version 2.1 of the License, or
+#  (at your option) any later version.
+
+[Unit]
+Description=Serial Getty on %I
+Documentation=man:agetty(8) man:systemd-getty-generator(8)
+Documentation=http://0pointer.de/blog/projects/serial-console.html
+BindsTo=dev-%i.device
+Requires=anaconda-init.service
+After=dev-%i.device systemd-user-sessions.service plymouth-quit-wait.service
+After=rc-local.service
+After=anaconda-init.target anaconda-init.service
+
+# If additional gettys are spawned during boot then we should make
+# sure that this is synchronized before getty.target, even though
+# getty.target didn't actually pull it in.
+Before=getty.target
+IgnoreOnIsolate=yes
+
+[Service]
+Environment=TERM=xterm HOME=@ROOT_HOME@ PATH=/usr/bin:/bin:/sbin:/usr/sbin LANG=en_US.UTF-8
+ExecStart=-/sbin/agetty -8 --keep-baud  -n -l /bin/bash -o '--login' %I @BAUDRATE@ $TERM
+WorkingDirectory=@ROOT_HOME@
+Type=idle
+Restart=always
+RestartSec=0
+UtmpIdentifier=%I
+TTYPath=/dev/%I
+TTYReset=yes
+TTYVHangup=yes
+KillMode=process
+IgnoreSIGPIPE=no
+SendSIGHUP=yes
+
+[Install]
+WantedBy=getty.target
diff --git a/meta-installer/recipes-core/systemd/files/serial-screen-anaconda.sh b/meta-installer/recipes-core/systemd/files/serial-screen-anaconda.sh
new file mode 100644
index 0000000..8ab9471
--- /dev/null
+++ b/meta-installer/recipes-core/systemd/files/serial-screen-anaconda.sh
@@ -0,0 +1,5 @@
+# Detect if it is serial tty, if yes, we need to invoke
+# screen to attach anaconda
+console=`/usr/bin/tty`
+[ "${console##/dev/ttyS}" != "${console}" ] && /usr/bin/screen -x anaconda-init
+
diff --git a/meta-installer/recipes-core/systemd/systemd-serialgetty.bbappend b/meta-installer/recipes-core/systemd/systemd-serialgetty.bbappend
new file mode 100644
index 0000000..afbd9b6
--- /dev/null
+++ b/meta-installer/recipes-core/systemd/systemd-serialgetty.bbappend
@@ -0,0 +1,12 @@
+FILESEXTRAPATHS_prepend_anaconda := "${THISDIR}/files:"
+
+SRC_URI_append_anaconda = " file://serial-getty@.service \
+           file://serial-screen-anaconda.sh \
+"
+
+do_install_append_anaconda() {
+	install -d ${D}${sysconfdir}/profile.d
+	install -m 644 ${WORKDIR}/serial-screen-anaconda.sh ${D}${sysconfdir}/profile.d/
+
+	sed -i -e 's, at ROOT_HOME@,${ROOT_HOME},g' ${D}${systemd_unitdir}/system/serial-getty at .service
+}
diff --git a/meta-installer/recipes-core/systemd/systemd_%.bbappend b/meta-installer/recipes-core/systemd/systemd_%.bbappend
new file mode 100644
index 0000000..3145f68
--- /dev/null
+++ b/meta-installer/recipes-core/systemd/systemd_%.bbappend
@@ -0,0 +1,6 @@
+FILESEXTRAPATHS_prepend_anaconda := "${THISDIR}/files:"
+
+do_install_append_anaconda() {
+	ln -nsf ${systemd_unitdir}/system/anaconda-init-screen at .service \
+		${D}${sysconfdir}/systemd/system/getty.target.wants/getty at tty1.service
+}
-- 
2.8.1




More information about the Openembedded-devel mailing list