From patchwork Sun Nov 3 16:56:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsOpbXkgUk9TRU4=?= X-Patchwork-Id: 1188585 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=smile.fr Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=smile-fr.20150623.gappssmtp.com header.i=@smile-fr.20150623.gappssmtp.com header.b="ukUw9AsR"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 475htB1l13z9sP3 for ; Mon, 4 Nov 2019 03:57:06 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 5ADF120BF9; Sun, 3 Nov 2019 16:57:04 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TRasCm89d0nJ; Sun, 3 Nov 2019 16:57:02 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 8768020763; Sun, 3 Nov 2019 16:57:02 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id E641E1BF398 for ; Sun, 3 Nov 2019 16:57:00 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id E2E7587829 for ; Sun, 3 Nov 2019 16:57:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id N2zzHH6Oj-Lg for ; Sun, 3 Nov 2019 16:57:00 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by hemlock.osuosl.org (Postfix) with ESMTPS id C99DB8788B for ; Sun, 3 Nov 2019 16:56:59 +0000 (UTC) Received: by mail-wm1-f53.google.com with SMTP id m17so4918009wmi.5 for ; Sun, 03 Nov 2019 08:56:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile-fr.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TibwYXSYNDwPb+y370UXLZ/g8tgbvnsJXczGcgC54vY=; b=ukUw9AsRvAGN/LK4d0ePOeg9aY3xd+IVrKVpEB65P75/evLfI8EjWSeWxnSXABtE7N P+IgVikuaQ8UNQZ7JNxPgAxRxCfTnBPe+bwV1V1tM1s/BI5hd4uPcJwxedprogwAh7ro PVI3EZouD+ThrI1m9Dby5wM8VwzdlM+amu3J26txfTb2DW08+ikYWgwZ3MIEeIjsjXq7 J9zTerf4Nicot5XZCBW+ZUwF8DAUfMqm/t35xcDMQXWnpjN+MYcZlpX09oUEeyRbjCg8 lQMhF1Pb8kYUmT5zYD23kqmAH7/+dsGf6HjyL/6QyYkUEdXo0g3F5ViirkRcNfCZNm1x PrSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TibwYXSYNDwPb+y370UXLZ/g8tgbvnsJXczGcgC54vY=; b=BZOzYWDCZplwE7Ui9QL2TLn3HZvst2U6udKnx6WFVS2n5YX6I1yvPCZ6cPV93ZdnH2 S/+mhDxZYezKu4A1/57XFXozkq4BO9F+joY3B8cVf4Z2wCeYnfS22lk/Dc4yP8+qz1IA CRS0RZ9OIUvjo+X8lRENkhBelfx3msED3sBgsn9un8KWKeqpynB4+fGqnv6R5dxqFh8z 2vmKF6rpjipOYpZnFAZ1T3vxEggZaVDCqR3OavECz0Kc/4CZItU6QvtT6fmFO2d9SaQW WYK3RlxuGvuZRL3iCFkrt8/Rt4cYZ8xJiQYK4iuscv89w3xjrcJfdRf7zPNqL/qfDaNO yiQQ== X-Gm-Message-State: APjAAAXnQKoZcI8Cz3kSuUqWir3k6QVJbUYsUzsqqAxJ7flULvOiffJ7 udSutCD1mVCJ2LEE0h+4R7voIY0YCg== X-Google-Smtp-Source: APXvYqwKdFTdW/R2u/HlN99l8ffN65Asvh+HG1hiKboqWQs65IzHVCL3tN+Se77ROI6BNx0il3Kedg== X-Received: by 2002:a7b:c392:: with SMTP id s18mr9049333wmj.61.1572800218010; Sun, 03 Nov 2019 08:56:58 -0800 (PST) Received: from localhost.localdomain (221.86.207.77.rev.sfr.net. [77.207.86.221]) by smtp.googlemail.com with ESMTPSA id 14sm1850430wrc.65.2019.11.03.08.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2019 08:56:57 -0800 (PST) From: =?utf-8?b?SsOpcsOpbXkgUm9zZW4=?= To: buildroot@buildroot.org Date: Sun, 3 Nov 2019 17:56:28 +0100 Message-Id: <20191103165640.21819-4-jeremy.rosen@smile.fr> X-Mailer: git-send-email 2.24.0.rc1 In-Reply-To: <20191103165640.21819-1-jeremy.rosen@smile.fr> References: <20191103165640.21819-1-jeremy.rosen@smile.fr> MIME-Version: 1.0 Subject: [Buildroot] [PATCH 03/15] fix tty handling X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?b?SsOpcsOpbXkgUm9zZW4=?= Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Handling of tty is a bit tricky, we need to aggressively disable what systemd does with tty1 then update for what buildroot wants to do Rework the whole tty generation to work with presets Signed-off-by: Jérémy Rosen --- ...e-default-instance-of-getty-.service.patch | 27 +++++++++++++++++++ package/systemd/80-buildroot.preset | 5 ++-- package/systemd/systemd.mk | 25 ++++++++++++----- 3 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 package/systemd/0002-remove-default-instance-of-getty-.service.patch diff --git a/package/systemd/0002-remove-default-instance-of-getty-.service.patch b/package/systemd/0002-remove-default-instance-of-getty-.service.patch new file mode 100644 index 0000000000..b412620cbd --- /dev/null +++ b/package/systemd/0002-remove-default-instance-of-getty-.service.patch @@ -0,0 +1,27 @@ +From 77384f2f107ca99fef6a9c0b9d54a3f2147a0d18 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rosen?= +Date: Thu, 31 Oct 2019 16:24:02 +0100 +Subject: [PATCH] remove default instance of getty@.service + +upstream assumes that tty1 is always a valid tty, this generally makes +sense but might not be the case for embedded devices. Having it as a +DefaultInstance makes it enabled by "systemctl preset-all" + +it is simpler for us to remove the DefaultInstance entirely and manually +link as needed +--- + units/getty@.service.m4 | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/units/getty@.service.m4 b/units/getty@.service.m4 +index 80e793bb73..7060457cb1 100644 +--- a/units/getty@.service.m4 ++++ b/units/getty@.service.m4 +@@ -57,4 +57,3 @@ UnsetEnvironment=LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETAR + + [Install] + WantedBy=getty.target +-DefaultInstance=tty1 +-- +2.24.0.rc1 + diff --git a/package/systemd/80-buildroot.preset b/package/systemd/80-buildroot.preset index 4074901cbd..5dbae39173 100644 --- a/package/systemd/80-buildroot.preset +++ b/package/systemd/80-buildroot.preset @@ -1,5 +1,4 @@ # Higher priority than systemd presets -# by default systemd enables a getty on tty1 -# we don't want that because tty1 may not exist -disable getty@.service +# This file is currently empty, but is available for demonstration and future use + diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk index d4680cd225..ed039de82b 100644 --- a/package/systemd/systemd.mk +++ b/package/systemd/systemd.mk @@ -428,22 +428,35 @@ ifneq ($(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT)),) # systemd needs getty.service for VTs and serial-getty.service for serial ttys # note that console-getty.service should be used on /dev/console as it should not have dependencies # also patch the file to use the correct baud-rate, the default baudrate is 115200 so look for that +# +# systemd defaults to only have getty@tty.service enabled +# * DefaultInstance=tty1 in getty@service +# * no DefaultInstance in serial-getty@.service +# * WantedBy=getty.target in console-getty.service +# * console-getty is not enabled because of 90-systemd.preset +# We want "systemctl preset-all" to do the right thing, even when run on the target after boot +# * remove the default instance of getty@.service via a patch on systemd source +# drop-ins cannot override DefaultInstance with an empty string +# * set a new DefaultInstance for getty@.service, if needed +# * set a new DefaultInstance for serial-getty@.service, if needed +# * override the systemd-provided preset for console-getty.service if needed define SYSTEMD_INSTALL_SERVICE_TTY if [ $(BR2_TARGET_GENERIC_GETTY_PORT) = "console" ]; \ then \ TARGET="console-getty.service"; \ - LINK_NAME="console-getty.service"; \ + echo enable console-getty.service > $(TARGET_DIR)/usr/lib/systemd/system-preset/81-buildroot-tty.preset;\ elif echo $(BR2_TARGET_GENERIC_GETTY_PORT) | egrep -q 'tty[0-9]*$$'; \ then \ TARGET="getty@.service"; \ - LINK_NAME="getty@$(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT)).service"; \ + mkdir $(TARGET_DIR)/usr/lib/systemd/system/getty@.service.d;\ + echo [Install] > $(TARGET_DIR)/usr/lib/systemd/system/getty@.service.d/buildroot-console.conf;\ + echo DefaultInstance=$(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT)) >> $(TARGET_DIR)/usr/lib/systemd/system/getty@.service.d/buildroot-console.conf;\ else \ TARGET="serial-getty@.service"; \ - LINK_NAME="serial-getty@$(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT)).service"; \ + mkdir $(TARGET_DIR)/usr/lib/systemd/system/serial-getty@.service.d;\ + echo [Install] > $(TARGET_DIR)/usr/lib/systemd/system/serial-getty@.service.d/buildroot-console.conf;\ + echo DefaultInstance=$(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT)) >> $(TARGET_DIR)/usr/lib/systemd/system/serial-getty@.service.d/buildroot-console.conf;\ fi; \ - mkdir -p $(TARGET_DIR)/etc/systemd/system/getty.target.wants/; \ - ln -fs ../../../../lib/systemd/system/$${TARGET} \ - $(TARGET_DIR)/etc/systemd/system/getty.target.wants/$${LINK_NAME}; \ if [ $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE)) -gt 0 ] ; \ then \ $(SED) 's,115200,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE),' $(TARGET_DIR)/lib/systemd/system/$${TARGET}; \