From patchwork Sun Aug 4 12:14:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 1141731 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) 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=free.fr Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="J5BFxH4Z"; 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 461fwW22Qtz9sNy for ; Sun, 4 Aug 2019 22:14:51 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 3281420406; Sun, 4 Aug 2019 12:14:49 +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 lj2Xngi6nEk1; Sun, 4 Aug 2019 12:14:38 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 88BB62040E; Sun, 4 Aug 2019 12:14:33 +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 847721BF868 for ; Sun, 4 Aug 2019 12:14:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 52A6E85A00 for ; Sun, 4 Aug 2019 12:14:27 +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 b2PMA3oWhj1M for ; Sun, 4 Aug 2019 12:14:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 617368592F for ; Sun, 4 Aug 2019 12:14:24 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id s3so72218668wms.2 for ; Sun, 04 Aug 2019 05:14:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3LnQFv15PWxSEJq1cXPvIBh6TdyOly9kZccOpsn/gAE=; b=J5BFxH4ZZlBmRbf61u2Ll+7iRo1aIDktXsFpf3K39mWi1gn5Y7VCBZHlNbu57QJbPj yG6NFp326Cos8dMShTop661HUNqpdTI3rD2u9JfJl98etPbjso2xCxzi8CM5uL0sC+P6 O5sb9cGK5DX6N8ZSpVKIsOLWMBHXAYJ/1XcmZcS7eTh3ihGFFHuTIbQwc7I9tYMxUs9O t5xTRNqekFEEKWIypPANrvr5UbH2R6TFAcAzgeGakbEMw3Tu2F7ouy7eLGz8yjnR2NuS RoKW4PL/9wEzwMMRVxfkYnmHy1aN87GL2ibFKQUQlohLVU1H4LF8fXgbV7lCmgLtG7w2 JH+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=3LnQFv15PWxSEJq1cXPvIBh6TdyOly9kZccOpsn/gAE=; b=gpWqNUpyDXR50UI7WSJbRibaj5sUAtDNdMUcQeB3+U7dinKoyMcq0e5yx7qPYTAi3b gVpXZz2LXxUsxNYHRKBMSFgUUvAk+POqVZgOV+bdfwHLheDlXqHTeblAA0F6k1l7Cxor Pw7ccffU79lCzNJRsFmwGuFoNVhg0W6TYUs9DET4sh9tDJKrv8shty9xE1sz5oDq7kJz +U1o9yUPNosEmRlCt47LeeNFsTlJv1QKpHyJ3LDLuvjuai3nYTxipnG+/B+kXmVj2GyB //NU/HGArTDLhIopYpsWAE/hMC02cBxfCymyImvsNyQFWhKjO1h9Vo9GNPRbm9Proq2b Wcbw== X-Gm-Message-State: APjAAAWrfUNdZ2GhZoK1KycCkqmxmJRuvbevbNnI6chWBNhjOOb8PoPr 4bkaGiVgjdoMy+fAeKMINXQSJ8lg X-Google-Smtp-Source: APXvYqyidrocHDgJrULVI2NCYcWjC5yK43lYiC8ZlakDa/hIMNBulgmax2aIfZ1QvLJjWkoketrjNQ== X-Received: by 2002:a1c:3142:: with SMTP id x63mr13966467wmx.169.1564920862628; Sun, 04 Aug 2019 05:14:22 -0700 (PDT) Received: from scaer.home (ns304657.ip-46-105-103.eu. [46.105.103.66]) by smtp.gmail.com with ESMTPSA id u1sm76939800wml.14.2019.08.04.05.14.21 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 04 Aug 2019 05:14:22 -0700 (PDT) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Sun, 4 Aug 2019 14:14:17 +0200 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Buildroot] [PATCH 3/5 v3] package/openrc: add support for spawning getty 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: Thomas Petazzoni , "Yann E . MORIN" , =?utf-8?b?TWljaGHFgiDFgXlzemN6ZWs=?= Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Michał Łyszczek We install a template getty service, and we 'instanciate' it in the default runlevel, using the configured tty. Ideally, packages that provide a getty program would be responsible for installing the corresponding service file. However, to keep consistency with the existing init systems (busybox, systemd, and sysv), we do do provide it from the openrc package itself. OpenrRC only acts on the files in a runlevel sub-directory, but the documentation [0] actually suggests that the instance symlink be done in init.d, and then again symlinked into the actual runlevel sub-directory. So, we abide by the rules. Also, to be noted, the getty service file is installed without ensuring that a getty command is available. This again is not unlike other init systems, sysvinit and busybox, which behave the same. [0] https://wiki.gentoo.org/wiki/OpenRC Signed-off-by: Michał Łyszczek [yann.morin.1998@free.fr: - move getty template to openrc package (Thomas) - fix namespace of the vaiables (Thomas) - simplify creation of the defaults file - rewrite commit log ] Signed-off-by: Yann E. MORIN Cc: Thomas Petazzoni --- package/openrc/getty | 24 +++++++++++++++++++ package/openrc/openrc.mk | 18 ++++++++++++++ .../skeleton/etc/conf.d/.empty | 0 .../skeleton/etc/runlevels/default/.empty | 0 system/Config.in | 8 +++---- 5 files changed, 46 insertions(+), 4 deletions(-) create mode 100755 package/openrc/getty create mode 100644 package/skeleton-init-openrc/skeleton/etc/conf.d/.empty create mode 100644 package/skeleton-init-openrc/skeleton/etc/runlevels/default/.empty diff --git a/package/openrc/getty b/package/openrc/getty new file mode 100755 index 0000000000..8fcb071f8a --- /dev/null +++ b/package/openrc/getty @@ -0,0 +1,24 @@ +#!/sbin/openrc-run +# based on agetty service from OpenRC package + +description="start getty on terminal" +supervisor=supervise-daemon +port="${RC_SVCNAME#*.}" +term_type="${term_type:-linux}" +command=/sbin/getty +command_args_foreground="${getty_options} ${baud} ${port} ${term_type}" +pidfile="/run/${RC_SVCNAME}.pid" + +depend() { + # start getty at the very end of init + after * + keyword -prefix +} + +start_pre() { + export EINFO_QUIET="${quiet:-yes}" +} + +stop_pre() { + export EINFO_QUIET="${quiet:-yes}" +} diff --git a/package/openrc/openrc.mk b/package/openrc/openrc.mk index 53f2947dcc..5978b6de5d 100644 --- a/package/openrc/openrc.mk +++ b/package/openrc/openrc.mk @@ -42,4 +42,22 @@ define OPENRC_REMOVE_UNNEEDED endef OPENRC_TARGET_FINALIZE_HOOKS += OPENRC_REMOVE_UNNEEDED +ifeq ($(BR2_TARGET_GENERIC_GETTY),y) +OPENRC_GETTY_SVCNAME = getty.$(SYSTEM_GETTY_PORT) +OPENRC_GETTY_CONF_D = $(TARGET_DIR)/etc/conf.d/$(OPENRC_GETTY_SVCNAME) +define OPENRC_SET_GETTY + { \ + echo "baud=\"$(SYSTEM_GETTY_BAUDRATE)\""; \ + echo "term_type=\"$(SYSTEM_GETTY_TERM)\"" ; \ + echo "getty_options=\"-L $(SYSTEM_GETTY_OPTIONS)\""; \ + } > $(OPENRC_GETTY_CONF_D) + $(INSTALL) -D -m 0755 $(OPENRC_PKGDIR)/getty \ + $(TARGET_DIR)/etc/init.d/getty + ln -sf getty $(TARGET_DIR)/etc/init.d/$(OPENRC_GETTY_SVCNAME) + ln -sf /etc/init.d/$(OPENRC_GETTY_SVCNAME) \ + $(TARGET_DIR)/etc/runlevels/default/$(OPENRC_GETTY_SVCNAME) +endef +OPENRC_TARGET_FINALIZE_HOOKS += OPENRC_SET_GETTY +endif # BR2_TARGET_GENERIC_GETTY + $(eval $(generic-package)) diff --git a/package/skeleton-init-openrc/skeleton/etc/conf.d/.empty b/package/skeleton-init-openrc/skeleton/etc/conf.d/.empty new file mode 100644 index 0000000000..e69de29bb2 diff --git a/package/skeleton-init-openrc/skeleton/etc/runlevels/default/.empty b/package/skeleton-init-openrc/skeleton/etc/runlevels/default/.empty new file mode 100644 index 0000000000..e69de29bb2 diff --git a/system/Config.in b/system/Config.in index af7d8566d3..1bfe069b2e 100644 --- a/system/Config.in +++ b/system/Config.in @@ -348,16 +348,16 @@ config BR2_TARGET_GENERIC_GETTY_BAUDRATE config BR2_TARGET_GENERIC_GETTY_TERM string "TERM environment variable" default "vt100" - # currently observed only by busybox and sysvinit - depends on BR2_INIT_BUSYBOX || BR2_INIT_SYSV + # currently observed by all but systemd + depends on !BR2_INIT_SYSTEMD help Specify a TERM type. config BR2_TARGET_GENERIC_GETTY_OPTIONS string "other options to pass to getty" default "" - # currently observed only by busybox and sysvinit - depends on BR2_INIT_BUSYBOX || BR2_INIT_SYSV + # currently observed by all but systemd + depends on !BR2_INIT_SYSTEMD help Any other flags you want to pass to getty, Refer to getty --help for details.