From patchwork Mon Dec 16 10:30:42 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: 1210218 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.133; helo=hemlock.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="Vo+T/ouR"; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47byH75VzFz9sPn for ; Mon, 16 Dec 2019 21:31:15 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id CC1AF87C69; Mon, 16 Dec 2019 10:31:11 +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 2kGjxUbQONpM; Mon, 16 Dec 2019 10:31:09 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id B922287C14; Mon, 16 Dec 2019 10:31:09 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 197FB1BF2B5 for ; Mon, 16 Dec 2019 10:31:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 11BE5204C9 for ; Mon, 16 Dec 2019 10:31:05 +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 iHskmwO+myxA for ; Mon, 16 Dec 2019 10:31:02 +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 silver.osuosl.org (Postfix) with ESMTPS id 8C25520020 for ; Mon, 16 Dec 2019 10:31:02 +0000 (UTC) Received: by mail-wr1-f47.google.com with SMTP id g17so6589511wro.2 for ; Mon, 16 Dec 2019 02:31:02 -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=7zhgOyKBRdm0V5B6+7+WJse2x0EThFzUsejVmKZZgU4=; b=Vo+T/ouRh+SqO2E9gNKlgCkE2vlLO+GZrXofgilhgJssUL4aclJMMNb6mnebA5aqa0 9FmN/t3oUmkcChsPUQw/at+0WtIzTDXfz8h3sWOaYLqyfo40Zvyqy0YXofI1UTfOvNED dBHORFnvNc40iifkLMi6l7xM7st8KBUcekJPAWHjbBGqO51XM99VbmSXM+7j7D74asJf SzVa2iA2LfpASgIix+ioSq9INrLWkgbGh67GJoRrgdhaGrId1LzA4PRZkn356qmDc1bS Pn9iJeMbwX0xwF7K8AM5w5xs0Y5v1H3+AuYb4nEGQsw4RUSupnonCv6bQ9RbC5VGUbSX ppgQ== 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=7zhgOyKBRdm0V5B6+7+WJse2x0EThFzUsejVmKZZgU4=; b=qXY5fTENsqaFJvg/5jRXl2SqtZNBymXKup6/R1xzU6ZV8orfl/q/1oIoPbk8eyjCU/ z4YcM7Qq+RODDSeasCAfuiKGxVq68q0qR3rh3OXo49bWDPjGZ1qiX6j9/HiZcgVGymtl fLk4CqlGTy/TVywJhdvq6dr6RjAjtvLFDl+4ur2IrDozhnfHMNXPiZpgDzBGf6WZ5NTP jg3CxqmTa0ltH2DdGXUyStYNEGusFqlMotpuYoowddF/3/25teVQ2BfHv4pTQbYa8m9o b6JQJKDPCABy0eZgCVayTWmjdoLciakDisygILtwUroKQnM+PsxyjEEJjf+3OJ82Ajy1 XhoQ== X-Gm-Message-State: APjAAAUmsbCM7VcmISmYsjZ10+hbQsWO93hQrRSuj9FjN9m+loudhuL0 phj6jKXzSk8yKiEgSY67OfVuzBCaSA== X-Google-Smtp-Source: APXvYqyb7ym7qQDmgFODoybzaTNKgXzcPQjBGaR2pg3RFMI4ahzu06j2AuKLCb6Qfg02cyTsSaxOww== X-Received: by 2002:adf:e547:: with SMTP id z7mr29985758wrm.258.1576492260338; Mon, 16 Dec 2019 02:31:00 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:4f5:d4c0:c24e:c904:189d:5967]) by smtp.googlemail.com with ESMTPSA id h8sm22313643wrx.63.2019.12.16.02.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2019 02:30:59 -0800 (PST) From: =?utf-8?b?SsOpcsOpbXkgUm9zZW4=?= To: buildroot@buildroot.org Date: Mon, 16 Dec 2019 11:30:42 +0100 Message-Id: <20191216103052.35220-4-jeremy.rosen@smile.fr> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191216103052.35220-1-jeremy.rosen@smile.fr> References: <20191216103052.35220-1-jeremy.rosen@smile.fr> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v5 03/13] package/systemd: 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 057a4eb9e5..6adf3adca4 100644 --- a/package/systemd/systemd.mk +++ b/package/systemd/systemd.mk @@ -433,22 +433,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}; \ @@ -456,7 +467,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 @@ -472,7 +482,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)