From patchwork Sat Dec 7 18:00:39 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: 1205494 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="urjgtElx"; 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 47VchP6tqsz9sNx for ; Sun, 8 Dec 2019 05:01:09 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 3A4B52048B; Sat, 7 Dec 2019 18:01: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 Mm4PRPz1JXek; Sat, 7 Dec 2019 18:01:01 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 1EE5F20468; Sat, 7 Dec 2019 18:01:01 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id DD1C71BF3BE for ; Sat, 7 Dec 2019 18:00:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id DA0E88784C for ; Sat, 7 Dec 2019 18:00:57 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nFjf-bTLlq1U for ; Sat, 7 Dec 2019 18:00:56 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by whitealder.osuosl.org (Postfix) with ESMTPS id 9DD3287832 for ; Sat, 7 Dec 2019 18:00:56 +0000 (UTC) Received: by mail-wr1-f47.google.com with SMTP id y17so11346955wrh.5 for ; Sat, 07 Dec 2019 10:00:56 -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=nXCHc1iQwRHg+24HnKQA77TKbeCsED/gppbIdkZ1nXo=; b=urjgtElxUI5y3cePwX58psoomWmhIIcdLEDkpjheh4t+V0G+dOuZeSopAFlNBc3hze JQ8hfZvnam66OWj291DcqWwel+u5Y49WMkdw0QGHGWgOf1aitop4faABqZBGNzTWYgAV J4thCwYr0bAK1kq7WeU2SntNlgkGFPRPr9AWjruxT6cVfNHHg44HB07TCw83JoC5O1/Y 1hi6t78oKzwzqgJFp99nc1lPOdQbVLh0xcK20qISm8G9xY+Q+E8nw9BmjAp94pOvvbqe 2rGC+vT90EQvRYdn+af2XgZDzaZAtOh86J9zrTlPnSLw6M0GevZj5P+C+Q+D0ueEJbco jEMQ== 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=nXCHc1iQwRHg+24HnKQA77TKbeCsED/gppbIdkZ1nXo=; b=M/HH9zH8sKLM2oYz8DP8lFt0eEwhA+iUUfrWERJzsoeaGgnZ1AZVxB4fQ8bMG+2Od2 ab+s2FkmEdpvESGvwj5a15PKirUUwvwQWuuc6dS9rcJpl+Q9LOAnTgEsqOvvgSr08+BV 0yueMxgNi5M4Kh4KxgIKts2WlwQdXWsPkAWZkIcbe91uu0WxRmMHIbwrVSx06GJVA/vE SXO2tmH4Q7V/HgDRPqOyL+fVF/6FI2eznsgUmvyJqUROz8XKA7gRaCD2Phy7dYZUQGii SXMc1koRh5zF7bNLcStjJOub8OlOAqv7ZIR17A9NK3BBywZ0psWARR5vEpMGa5LwCHWr BPlQ== X-Gm-Message-State: APjAAAXLloJ493h09c87BueO5LAmGzAWMMUGAy5N9gd6au2FcWp/iC1Q SWzfbjo6N3z6LB2+ednwidMKTc2DVw== X-Google-Smtp-Source: APXvYqxQv+bzVmCuceLqIw9koYiP6p0FILoY7+tHrWlMpD7wTt9TJ6ejD9E5Ll0DGXkJB+rKIzmKYA== X-Received: by 2002:adf:f052:: with SMTP id t18mr21476126wro.192.1575741654876; Sat, 07 Dec 2019 10:00:54 -0800 (PST) Received: from localhost.localdomain (2a02-8428-0351-c201-4ead-12d2-d337-cdfb.rev.sfr.net. [2a02:8428:351:c201:4ead:12d2:d337:cdfb]) by smtp.googlemail.com with ESMTPSA id z4sm7558964wme.17.2019.12.07.10.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Dec 2019 10:00:54 -0800 (PST) From: =?utf-8?b?SsOpcsOpbXkgUm9zZW4=?= To: buildroot@buildroot.org Date: Sat, 7 Dec 2019 19:00:39 +0100 Message-Id: <20191207180049.3245578-4-jeremy.rosen@smile.fr> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191207180049.3245578-1-jeremy.rosen@smile.fr> References: <20191207180049.3245578-1-jeremy.rosen@smile.fr> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v3 03/13] 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 --- package/systemd/80-buildroot.preset | 5 ++--- package/systemd/systemd.mk | 25 +++++++++++++++++-------- 2 files changed, 19 insertions(+), 11 deletions(-) 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 a51560df1d..9cf8bee3ac 100644 --- a/package/systemd/systemd.mk +++ b/package/systemd/systemd.mk @@ -428,22 +428,33 @@ 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 drop-in in /usr/lib +# * set a new DefaultInstance for getty@.service instead, 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 + mkdir $(TARGET_DIR)/usr/lib/systemd/system/getty@.service.d;\ + printf '[Install]\nDefaultInstance=\n' > $(TARGET_DIR)/usr/lib/systemd/system/getty@.service.d/buildroot-console.conf;\ if [ $(BR2_TARGET_GENERIC_GETTY_PORT) = "console" ]; \ then \ TARGET="console-getty.service"; \ - LINK_NAME="console-getty.service"; \ + printf 'enable console-getty.service\n' > $(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"; \ + printf '[Install]\nDefaultInstance=%s\n' $(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;\ + printf '[Install]\nDefaultInstance=%s\n' $(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}; \ @@ -451,7 +462,6 @@ define SYSTEMD_INSTALL_SERVICE_TTY endef endif - define SYSTEMD_INSTALL_PRESET $(INSTALL) -D -m 644 $(SYSTEMD_PKGDIR)/80-buildroot.preset $(TARGET_DIR)/usr/lib/systemd/system-preset/80-buildroot.preset endef @@ -467,7 +477,6 @@ define SYSTEMD_PRESET_ALL endef SYSTEMD_TARGET_FINALIZE_HOOKS += SYSTEMD_PRESET_ALL - SYSTEMD_CONF_ENV = $(HOST_UTF8_LOCALE_ENV) SYSTEMD_NINJA_ENV = $(HOST_UTF8_LOCALE_ENV)