From patchwork Sun May 12 19:55:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiDFgXlzemN6ZWs=?= X-Patchwork-Id: 1098581 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.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bofc.pl 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 452F7p5m6Fz9sNk for ; Mon, 13 May 2019 05:56:22 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id D7B5B85EF9; Sun, 12 May 2019 19:56:15 +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 aJTBX96ckCuf; Sun, 12 May 2019 19:56:13 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id B48EF85CB4; Sun, 12 May 2019 19:56:13 +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 34A381BF271 for ; Sun, 12 May 2019 19:56:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id BAC9585359 for ; Sun, 12 May 2019 19:56:11 +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 xwNM4g_cCd7A for ; Sun, 12 May 2019 19:56:10 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from cache12.mydevil.net (cache12.mydevil.net [128.204.216.223]) by fraxinus.osuosl.org (Postfix) with ESMTPS id EDB9084DFF for ; Sun, 12 May 2019 19:56:09 +0000 (UTC) From: =?utf-8?b?TWljaGHFgiDFgXlzemN6ZWs=?= To: buildroot@buildroot.org Date: Sun, 12 May 2019 21:55:41 +0200 Message-Id: <20190512195550.24457-4-michal.lyszczek@bofc.pl> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20190512195550.24457-1-michal.lyszczek@bofc.pl> References: <20190512195550.24457-1-michal.lyszczek@bofc.pl> MIME-Version: 1.0 X-AV-Check: Passed X-System-Sender: michal.lyszczek@bofc.pl Subject: [Buildroot] [PATCH v2 04/13] 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: =?utf-8?b?TWljaGHFgiDFgXlzemN6ZWs=?= Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" * package/openrc/openrc.mk add code that monitors BR2_TARGET_GENERIC_GETTY and if set, creates configuration file (with SYSTEM_GETTY_*) for port in /etc/conf.d/getty.$(SYSTEM_GETTY_PORT) and links so openrc starts service. * package/skeleton-init-openrc/skeleton/etc/init.d/getty openrc service that spawns getty on configured port. * system/Config.in change dependency of BR2_TARGET_GENERIC_GETTY_TERM and BR2_TARGET_GENERIC_GETTY_OPTIONS so openrc can make use of these fields too. Signed-off-by: Michał Łyszczek --- Changes v1 -> v2 None --- package/openrc/openrc.mk | 13 ++++++++ .../skeleton/etc/conf.d/.empty | 0 .../skeleton/etc/init.d/getty | 31 +++++++++++++++++++ .../skeleton/etc/runlevels/default/.empty | 0 system/Config.in | 8 ++--- 5 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 package/skeleton-init-openrc/skeleton/etc/conf.d/.empty create mode 100755 package/skeleton-init-openrc/skeleton/etc/init.d/getty create mode 100644 package/skeleton-init-openrc/skeleton/etc/runlevels/default/.empty diff --git a/package/openrc/openrc.mk b/package/openrc/openrc.mk index 53f2947dcc..0feea22818 100644 --- a/package/openrc/openrc.mk +++ b/package/openrc/openrc.mk @@ -42,4 +42,17 @@ define OPENRC_REMOVE_UNNEEDED endef OPENRC_TARGET_FINALIZE_HOOKS += OPENRC_REMOVE_UNNEEDED +ifeq ($(BR2_TARGET_GENERIC_GETTY),y) +GETTY_SVCNAME = getty.$(SYSTEM_GETTY_PORT) +GETTY_CONF_D = $(TARGET_DIR)/etc/conf.d/$(GETTY_SVCNAME) +define OPENRC_SET_GETTY + echo "baud=\"$(SYSTEM_GETTY_BAUDRATE)\"" > $(GETTY_CONF_D) + echo "term_type=\"$(SYSTEM_GETTY_TERM)\"" >> $(GETTY_CONF_D) + echo "getty_options=\"-L $(SYSTEM_GETTY_OPTIONS)\"" >> $(GETTY_CONF_D) + ln -sf getty $(TARGET_DIR)/etc/init.d/$(GETTY_SVCNAME) + ln -sf /etc/init.d/$(GETTY_SVCNAME) $(TARGET_DIR)/etc/runlevels/default/$(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/init.d/getty b/package/skeleton-init-openrc/skeleton/etc/init.d/getty new file mode 100755 index 0000000000..acae1b218b --- /dev/null +++ b/package/skeleton-init-openrc/skeleton/etc/init.d/getty @@ -0,0 +1,31 @@ +#!/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() { + if [ -z "$port" ]; then + eerror "${RC_SVCNAME} cannot be started directly. You must create" + eerror "symbolic links to it for the ports you want to start" + eerror "agetty on and add those to the appropriate runlevels." + return 1 + else + export EINFO_QUIET="${quiet:-yes}" + fi +} + +stop_pre() { + export EINFO_QUIET="${quiet:-yes}" +} 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 808fc070f3..90aa0e52b9 100644 --- a/system/Config.in +++ b/system/Config.in @@ -343,16 +343,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.