Skip to contentSkip to conversation

systemd: if getty generator is disabled remove the generator, not the units

PATCH In review Ross Burton 2 participants 5 messages Feb 13, 2025 – Feb 14, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 systemd: if getty generator is disabled remove the generator, not the units

If the getty generator is disabled then it's neater to remove just the generator tool instead of the unit files as the unit files are still useful.

---
 meta/recipes-core/systemd/systemd_257.1.bb | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
meta/recipes-core/systemd/systemd_257.1.bb +5 -3
index cdf72a50157..b9f17849671 100644
@@ -287,9 +287,11 @@ do_install() {
 		fi
 	fi
 	install -d ${D}/${base_sbindir}
-	if ${@bb.utils.contains('PACKAGECONFIG', 'serial-getty-generator', 'false', 'true', d)}; then
-		# Provided by a separate recipe
-		rm ${D}${systemd_system_unitdir}/serial-getty* -f
+
+	if ! ${@bb.utils.contains('PACKAGECONFIG', 'serial-getty-generator', 'true', 'false', d)}; then
+		# Remove the serial-getty generator and instead use explicit services
+		# created by the systemd-serialgetty recipe
+		find ${D} -name \*getty-generator\* -delete
 	fi
 
 	# Provide support for initramfs
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/4 systemd-serialgetty: use existing unit files in systemd

Now that systemd isn't deleting the [email protected] unit template files, we can simply symlink to the files provided by systemd instead of shipping a copy of them in this recipe.

---
 .../systemd/systemd-serialgetty.bb            | 12 +----
 .../systemd-serialgetty/[email protected] | 45 -------------------
 2 files changed, 1 insertion(+), 56 deletions(-)
 delete mode 100644 meta/recipes-core/systemd/systemd-serialgetty/[email protected]
meta/recipes-core/systemd/systemd-serialgetty.bb +1 -11
index 7b525b10f0c..3798b07b1a8 100644
@@ -10,12 +10,6 @@ LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0-only;m
 # should only be used if the generator is not appropriate.
 
 SERIAL_CONSOLES ?= "115200;ttyS0"
-SERIAL_TERM ?= "linux"
-
-SRC_URI = "file://[email protected]"
-
-S = "${WORKDIR}/sources"
-UNPACKDIR = "${S}"
 
 # As this package is tied to systemd, only build it when we're also building systemd.
 inherit features_check
@@ -25,11 +19,7 @@ REQUIRED_DISTRO_FEATURES += "usrmerge"
 do_install() {
 	if [ ! -z "${SERIAL_CONSOLES}" ] ; then
 		default_baudrate=`echo "${SERIAL_CONSOLES}" | sed 's/\;.*//'`
-		install -d ${D}${systemd_system_unitdir}/
 		install -d ${D}${sysconfdir}/systemd/system/getty.target.wants/
-		install -m 0644 ${S}/[email protected] ${D}${systemd_system_unitdir}/
-		sed -i -e "s/\@BAUDRATE\@/$default_baudrate/g" ${D}${systemd_system_unitdir}/[email protected]
-		sed -i -e "s/\@TERM\@/${SERIAL_TERM}/g" ${D}${systemd_system_unitdir}/[email protected]
 
 		tmp="${SERIAL_CONSOLES}"
 		for entry in $tmp ; do
@@ -52,7 +42,7 @@ do_install() {
 }
 
 # This is a machine specific file
-FILES:${PN} = "${systemd_system_unitdir}/*.service ${sysconfdir}"
 PACKAGE_ARCH = "${MACHINE_ARCH}"
+FILES:${PN} = "${sysconfdir}"
 
 ALLOW_EMPTY:${PN} = "1"
meta/recipes-core/systemd/systemd-serialgetty/[email protected] deleted +0 -45

45 lines not on this page · raw message

Signature · 1 line
2.43.0
#2 lore raw

PATCH 3/4 systemd-serialgetty: don't set a default SERIAL_CONSOLES

In reply to Ross Burton

bitbake.conf defines a default value, so there's no value in setting another default here that doesn't match the rest of the system.

---
 meta/recipes-core/systemd/systemd-serialgetty.bb | 2 --
 1 file changed, 2 deletions(-)
meta/recipes-core/systemd/systemd-serialgetty.bb +0 -2
index 3798b07b1a8..c3fe9d5b6d4 100644
@@ -9,8 +9,6 @@ LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0-only;m
 # required.  This recipe (enabled via disabling serial-getty-generator in systemd)
 # should only be used if the generator is not appropriate.
 
-SERIAL_CONSOLES ?= "115200;ttyS0"
-
 # As this package is tied to systemd, only build it when we're also building systemd.
 inherit features_check
 REQUIRED_DISTRO_FEATURES += "systemd"
Signature · 1 line
2.43.0
#3 lore raw

PATCH 4/4 sysvinit-inittab: exec getty from the wrapper

In reply to Ross Burton

Instead of forking, the start_getty wrapper can use exec to replace itself. This results in one less process in ps per getty.

---
 meta/recipes-core/sysvinit/sysvinit-inittab/start_getty | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/sysvinit/sysvinit-inittab/start_getty +1 -1
index f5671ee53d2..f6a41428f76 100644
@@ -17,4 +17,4 @@ case $(readlink -f "${getty}") in
         ;;
 esac
 
-${setsid:-} ${getty} ${options:-} -L $SPEED $DEVICE $TERM
+exec ${setsid:-} ${getty} ${options:-} -L $SPEED $DEVICE $TERM
Signature · 1 line
2.43.0
#4 lore raw
In reply to Ross Burton
Quoted 6 lines · Ross Burton via lists.openembedded.org

If the getty generator is disabled then it's neater to remove just the generator tool instead of the unit files as the unit files are still useful.

---

Hi Ross,

Sorry, but I believe one patch in this series is again triggering a strange behaviour on the autobuilder:

QMP released QEMU at 02/14/25 09:37:43 and took 0.12 seconds from connect
WARNING: core-image-full-cmdline-1.0-r0 do_testimage: Couldn't login into serial console as root using blank password
WARNING: core-image-full-cmdline-1.0-r0 do_testimage: The output:
root
qemux86-64 login: <<< run_serial(): command timed out after 120 seconds without output >>>

https://autobuilder.yoctoproject.org/valkyrie/#/builders/26/builds/1003/steps/35/logs/stdio
https://autobuilder.yoctoproject.org/valkyrie/#/builders/6/builds/1019/steps/13/logs/stdio
https://autobuilder.yoctoproject.org/valkyrie/#/builders/68/builds/1042/steps/13/logs/stdio
https://autobuilder.yoctoproject.org/valkyrie/#/builders/73/builds/947/steps/13/logs/stdio

Can you have a look at this please?

Signature · 3 lines
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com