package/systemd: fix getty setup
authorAndré Erdmann <dywi@mailerd.de>
Thu, 9 Oct 2014 13:58:02 +0000 (15:58 +0200)
committerPeter Korsgaard <peter@korsgaard.com>
Sun, 12 Oct 2014 13:37:01 +0000 (15:37 +0200)
When trying to run a buildroot system configured with
BR2_TARGET_GENERIC_GETTY_PORT="tty1" (x86_64), the boot process hangs
with the following message:
  "A start job is running for dev-tty1.device (<time> / 1min 30s)"

Replacing /etc/systemd/system/getty.target.wants/serial-getty@tty1.service
(linking to serial-getty@) with getty@tty1.service (-> getty@) fixes the issue.

This patch adds a check that "detects" the tty type by removing digits at the
end of BR2_TARGET_GENERIC_GETTY_PORT and comparing the resulting base name.
An instance of getty@service gets created if the name matches "tty",
otherwise serial-getty@ gets instantiated (as before).

So, tty1,tty2,... are created as links getty@tty1.service -> getty@,
while ttyS0, ttyAMA0, ... are created as instances of serial-getty@.

[Peter: simplify logic]
Signed-off-by: André Erdmann <dywi@mailerd.de>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
package/systemd/systemd.mk

index face849136cc173624e6ba011713c302fcf3d4e7..dafc65ce21ecf0ffaa4b1ae995678931f7683e43 100644 (file)
@@ -183,12 +183,24 @@ define SYSTEMD_USERS
        systemd-network -1 systemd-network -1 * - - - Network Manager
 endef
 
-define SYSTEMD_INSTALL_SERVICE_TTY
+define SYSTEMD_DISABLE_SERVICE_TTY1
        rm -f $(TARGET_DIR)/etc/systemd/system/getty.target.wants/getty@tty1.service
-       ln -fs ../../../../lib/systemd/system/serial-getty@.service $(TARGET_DIR)/etc/systemd/system/getty.target.wants/serial-getty@$(BR2_TARGET_GENERIC_GETTY_PORT).service
+endef
+
+# systemd needs getty.service for VTs and serial-getty.service for serial ttys
+define SYSTEMD_INSTALL_SERVICE_TTY
+       if echo $(BR2_TARGET_GENERIC_GETTY_PORT) | egrep -q 'tty[0-9]*$$'; \
+       then \
+               SERVICE="getty"; \
+       else \
+               SERVICE="serial-getty"; \
+       fi; \
+       ln -fs ../../../../lib/systemd/system/$${SERVICE}@.service \
+               $(TARGET_DIR)/etc/systemd/system/getty.target.wants/$${SERVICE}@$(BR2_TARGET_GENERIC_GETTY_PORT).service
 endef
 
 define SYSTEMD_INSTALL_INIT_SYSTEMD
+       $(SYSTEMD_DISABLE_SERVICE_TTY1)
        $(SYSTEMD_INSTALL_SERVICE_TTY)
        $(SYSTEMD_INSTALL_SERVICE_NETWORK)
        $(SYSTEMD_INSTALL_SERVICE_TIMESYNC)