From patchwork Mon Nov 11 17:24:37 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: 1193041 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.138; helo=whitealder.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="viLbV/5n"; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47Bd716gxRz9sNT for ; Tue, 12 Nov 2019 04:25:17 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 080DE875AD; Mon, 11 Nov 2019 17:25:16 +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 pKLz3tBFMksl; Mon, 11 Nov 2019 17:25:09 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id B2CB584770; Mon, 11 Nov 2019 17:25:07 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 732851BF96A for ; Mon, 11 Nov 2019 17:25:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 6211C86709 for ; Mon, 11 Nov 2019 17:25:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EfUyrteN_vhx for ; Mon, 11 Nov 2019 17:25:01 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 3F10D866E5 for ; Mon, 11 Nov 2019 17:24:58 +0000 (UTC) Received: by mail-wm1-f44.google.com with SMTP id z26so112799wmi.4 for ; Mon, 11 Nov 2019 09:24:58 -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=FysdVqJN+4Lwt8o134hvkrafLpGeP1TvxQztpJwPyf8=; b=viLbV/5nykAZPev2e2hc6uHi4/GaKMKol5Xg2GDXT1eqcf9hzgTF+jz6xxj6fUy8Kj fD4YwogUKfMFyXauVPO9bE9H6MfcWzF+L4+kYEAFFQOQLNQejB1VYlcHAEwxV15DNY11 PyO2+nihRltyARTuSTjVTD0bgRgbBIyBIjjk4v9XF0gUZFvxjI+t6VmYtV9Txg3eGeBT nLxcSqlL3C15BdPIZW+959NMBXMLrrsl3zw7Jgv4hg6JP6q4FMbGHJqjb7hNRqDTZ+rj N/us2gxOTa/8nbGelT9xH2JTb2jNVND1NBqz+nStFfmZV5ai3rbJuH69S2TJDgwNYlrp hkZA== 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=FysdVqJN+4Lwt8o134hvkrafLpGeP1TvxQztpJwPyf8=; b=NLDGfFpCz8Ta7+YO+5xN70Uzc+5zsbussqUbiViXDtZ/0vayyzOrkTP73Z7Q14E2j4 RzPYDEWTsXe52hHQAnCnmHuWBCQtCHyqPukqG1Fflyp7K2xzc8h6uHz9veH7p4Sh7pJx peo4a0PDdlqeKCp7velLUO8HkTMSEsseq0BZe74XovsH5uJN7s5O2noL0n97QKaBYvjy cTiJq8/LkH+efAclqtj4fC0SACBd2qafebMQfB+gcU+5gR2xDWSih3eh1a5FZN7DkI6n iVPpkWsqA3RGCp5T1t52j1au867AelsPQQgMGJde/n6dLNbEspXQTHB0e5iWGMIeb3Jw v7BQ== X-Gm-Message-State: APjAAAULhvK0rIZ6C3kwhw/+4BQco68mc1WbFxHBtYTKg/+8TJXM0nNY auufTg7qt6QPRmETRlPhVm8Y3IXKAg== X-Google-Smtp-Source: APXvYqzW861aK4AZ+hXB6+XDW4okBQiJL5AkYZTcUDfeqFPYuyGx/atxNnEJ38QgGvNShbVV/M4cyQ== X-Received: by 2002:a7b:c4c8:: with SMTP id g8mr108927wmk.36.1573493096337; Mon, 11 Nov 2019 09:24:56 -0800 (PST) Received: from localhost.localdomain (2a02-8428-0351-c201-62d6-24fd-3fad-e4ae.rev.sfr.net. [2a02:8428:351:c201:62d6:24fd:3fad:e4ae]) by smtp.googlemail.com with ESMTPSA id h15sm13393905wrb.44.2019.11.11.09.24.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 09:24:55 -0800 (PST) From: =?utf-8?b?SsOpcsOpbXkgUm9zZW4=?= To: buildroot@buildroot.org Date: Mon, 11 Nov 2019 18:24:37 +0100 Message-Id: <20191111172443.6874-4-jeremy.rosen@smile.fr> X-Mailer: git-send-email 2.24.0.rc1 In-Reply-To: <20191111172443.6874-1-jeremy.rosen@smile.fr> References: <20191111172443.6874-1-jeremy.rosen@smile.fr> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v2 3/9] 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 --- .../0002-allow-an-empty-DefaultInstance.patch | 28 +++++++++++++++++++ package/systemd/80-buildroot.preset | 5 ++-- package/systemd/systemd.mk | 26 +++++++++++++---- 3 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 package/systemd/0002-allow-an-empty-DefaultInstance.patch diff --git a/package/systemd/0002-allow-an-empty-DefaultInstance.patch b/package/systemd/0002-allow-an-empty-DefaultInstance.patch new file mode 100644 index 0000000000..0cb4ffa985 --- /dev/null +++ b/package/systemd/0002-allow-an-empty-DefaultInstance.patch @@ -0,0 +1,28 @@ +From 087a91c29b9fd67bda9d4199789842263545cd12 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rosen?= +Date: Sat, 2 Nov 2019 00:03:54 +0100 +Subject: [PATCH] allow an empty DefaultInstance= in configuration files + +It is currently possible to override the DefaultInstance via drop-ins but +not remove it completely. Allow to do that by specifying an empty +DefaultInstance= +--- + src/shared/install.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/src/shared/install.c b/src/shared/install.c +index 0724dd96ee7..17f6f99f295 100644 +--- a/src/shared/install.c ++++ b/src/shared/install.c +@@ -1191,6 +1191,11 @@ static int config_parse_default_instance( + if (r < 0) + return r; + ++ if (isempty(printed)) { ++ i->default_instance = mfree(i->default_instance); ++ return 0; ++ } ++ + if (!unit_instance_is_valid(printed)) + return -EINVAL; + 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 dc2ed80e7d..fc782d0af7 100644 --- a/package/systemd/systemd.mk +++ b/package/systemd/systemd.mk @@ -429,22 +429,36 @@ 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;\ + echo [Install] > $(TARGET_DIR)/usr/lib/systemd/system/getty@.service.d/buildroot-console.conf;\ + echo DefaultInstance= >> $(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"; \ + 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"; \ + 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}; \