diff mbox series

systemd-serialgetty: Fix do_install for mixed baud rates

Message ID 20261120163326.6114-1-niko.mauno@vaisala.com
State New
Headers show
Series systemd-serialgetty: Fix do_install for mixed baud rates | expand

Commit Message

Niko Mauno Nov. 20, 2026, 4:33 p.m. UTC
Since commit b6a7617145c3 ("systemd-serialgetty: use existing unit
files in systemd") removed the recipe's own serial-getty@.service, any
SERIAL_CONSOLES entry whose baud rate differs from the first one fails
do_install, as the unit template it copies no longer exists:

  install: cannot stat '.../serial-getty@.service': No such file or directory

Enable systemd's serial-getty@.service for every console instead, as is
already done for the first one. That unit runs agetty with --keep-baud,
so a console's configured rate takes effect only where the kernel has
set it up, i.e. on a kernel console. Since b6a7617145c3 this has been
true of the first entry as well; say so in the recipe.

Tested on master and wrynose with mixed-rate SERIAL_CONSOLES: both
consoles get a getty, and on a qemux86-64 boot with "115200;ttyS0
38400;ttyS1", ttyS1, not a kernel console, runs at the 9600 default.

Fixes: b6a7617145c3 ("systemd-serialgetty: use existing unit files in systemd")
AI-Generated: Uses Claude Code (Claude Opus 5.5)
Signed-off-by: Niko Mauno <niko.mauno@vaisala.com>
---
 .../recipes-core/systemd/systemd-serialgetty.bb | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/meta/recipes-core/systemd/systemd-serialgetty.bb b/meta/recipes-core/systemd/systemd-serialgetty.bb
index c3fe9d5b6d..807dd8bb9f 100644
--- a/meta/recipes-core/systemd/systemd-serialgetty.bb
+++ b/meta/recipes-core/systemd/systemd-serialgetty.bb
@@ -8,6 +8,7 @@  LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0-only;m
 # will probe at boot and generate getty instances for any active consoles as
 # required.  This recipe (enabled via disabling serial-getty-generator in systemd)
 # should only be used if the generator is not appropriate.
+# Its gettys ignore SERIAL_CONSOLES baud rates and keep the rate the kernel set.
 
 # As this package is tied to systemd, only build it when we're also building systemd.
 inherit features_check
@@ -16,25 +17,13 @@  REQUIRED_DISTRO_FEATURES += "usrmerge"
 
 do_install() {
 	if [ ! -z "${SERIAL_CONSOLES}" ] ; then
-		default_baudrate=`echo "${SERIAL_CONSOLES}" | sed 's/\;.*//'`
 		install -d ${D}${sysconfdir}/systemd/system/getty.target.wants/
 
 		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_system_unitdir}/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 ${S}/serial-getty@.service ${D}${systemd_system_unitdir}/serial-getty$baudrate@.service
-				sed -i -e "s/\@BAUDRATE\@/$baudrate/g" ${D}${systemd_system_unitdir}/serial-getty$baudrate@.service
-				# enable the service
-				ln -sf ${systemd_system_unitdir}/serial-getty$baudrate@.service \
-					${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty$baudrate@$ttydev.service
-			fi
+			ln -sf ${systemd_system_unitdir}/serial-getty@.service \
+				${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty@$ttydev.service
 		done
 	fi
 }