From patchwork Thu Dec 12 07:53:50 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: 1208189 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="FHJu+yws"; 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 47YQzr4vJ0z9sPf for ; Thu, 12 Dec 2019 18:54:16 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 001EC23C58; Thu, 12 Dec 2019 07:54:15 +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 92-AT5SAnDZb; Thu, 12 Dec 2019 07:54:12 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id CE50E23DB4; Thu, 12 Dec 2019 07:54:12 +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 EE2FD1BF293 for ; Thu, 12 Dec 2019 07:54:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id E8316886B1 for ; Thu, 12 Dec 2019 07:54:08 +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 fLsvIGA6Kc1k for ; Thu, 12 Dec 2019 07:54:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by hemlock.osuosl.org (Postfix) with ESMTPS id 83B9D88699 for ; Thu, 12 Dec 2019 07:54:07 +0000 (UTC) Received: by mail-wr1-f42.google.com with SMTP id c14so1590934wrn.7 for ; Wed, 11 Dec 2019 23:54:07 -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=3FIUsI4ciUFYthTbSaJfMcf+91x7YYdtPADkyRVEANA=; b=FHJu+ywsLwoR9l2ek3sZxMBfSoqkwD/UeI4L9jwx4I0VsecC+1BxYXAR4+khbTpsvu xOtbGn6ULDSjb92Sbq7sgOe7FAVByCLHIxVaaXNic6fSAh5ee8hZoHi/FtQbUMoYxYgp 74AMHS36jXEP4801D2U5E+CexQxYavbVrV9z2+nXUQ1I8JXu2azsLTM5USKZyq45YqKe 7qjKqgSYs8T7eJ+SnKF68337OxWIcGembafTcWepxtBbiKYKFDgOEOBspnWzVdKqjYln mc5BunSDYWx4e+qx7/flGgZY6ips6zlKsYGSc4c/3PUsnwRatQLWbsetvM2INvNwZGW5 WbTQ== 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=3FIUsI4ciUFYthTbSaJfMcf+91x7YYdtPADkyRVEANA=; b=DCEXp2GTjOYbnqqhSM6Ozm56U6xNbO7YyR1DNgQ2l4MT3YDBTWn5g7WRbhADGAscfg /4tsxZhr/8rIMZ/Qc1c31l3tuq15y2ekS+NL5Wt1LFLBEQk6kjDLTV3vhhULwoUVS4Iv aXilNJUbmq+FA0KiM4JSGbgBZ457v8E6DpHPBmpIV6lTE+YJp4V7OR057iL088F79K3S jkSbHCNZHeL9/EGr+GZU4NUEyLdRv8NJNXQGlRAmCRLI04eZCmGiA3z3oMrHyX8nMqHy LyAnRSsGtR8LtD4rDhyTBKV0FmczzG8ue/0agE9fvrl29vl6gyJHeL8FuiqMm9W2vakZ vRNA== X-Gm-Message-State: APjAAAVvznTkRvaMZ+H1PByvhXzrnUXyMIisZ0C45Y3PLXfH+1srJeKT xE9EjZM9iSF8TWrBR/Ku0cSUkwxI2Q== X-Google-Smtp-Source: APXvYqxVfXkLPFfgoNrbcUJk4JpowoyZL7ULnU4UkNjhOWkrXrArLwN8nMIMhxmpojjpLKc7bS1GCg== X-Received: by 2002:a5d:4752:: with SMTP id o18mr4457557wrs.330.1576137245538; Wed, 11 Dec 2019 23:54:05 -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 y20sm4909753wmi.25.2019.12.11.23.54.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 23:54:05 -0800 (PST) From: =?utf-8?b?SsOpcsOpbXkgUm9zZW4=?= To: buildroot@buildroot.org Date: Thu, 12 Dec 2019 08:53:50 +0100 Message-Id: <20191212075400.1499536-4-jeremy.rosen@smile.fr> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191212075400.1499536-1-jeremy.rosen@smile.fr> References: <20191212075400.1499536-1-jeremy.rosen@smile.fr> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v4 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 ca3fc7121f..33653a3b6b 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)