From: Reza Arbab <arbab@linux.ibm.com>
To: buildroot@buildroot.org
Cc: Laurent Vivier <laurent@vivier.eu>, Joel Stanley <joel@jms.id.au>
Subject: [Buildroot] [PATCH v3 6/8] package/petitboot: run petitboot UI on consoles
Date: Mon, 9 Oct 2023 10:17:27 -0500 [thread overview]
Message-ID: <20231009151729.2223963-7-arbab@linux.ibm.com> (raw)
In-Reply-To: <20231009151729.2223963-1-arbab@linux.ibm.com>
Display the petitboot UI instead of a login prompt, allowing the
configuration of custom tty(s) as we do for the login prompt.
petitboot already depends on udev, so let's use it instead of rcS to
launch pb-console. This has the advantage of easily wildcarding the list
of ttys ("hvc*") and enables hotplug devices ("ttyUSB0").
Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
---
package/petitboot/Config.in | 8 ++++++++
package/petitboot/pb-console | 36 ++++++++++++++++++++++++++++++++++
package/petitboot/petitboot.mk | 10 ++++++++++
system/Config.in | 2 +-
4 files changed, 55 insertions(+), 1 deletion(-)
create mode 100644 package/petitboot/pb-console
diff --git a/package/petitboot/Config.in b/package/petitboot/Config.in
index 4981c165bf76..5f1d91e77ecb 100644
--- a/package/petitboot/Config.in
+++ b/package/petitboot/Config.in
@@ -28,3 +28,11 @@ comment "petitboot needs a uClibc or glibc toolchain w/ wchar, dynamic library,
!BR2_TOOLCHAIN_HAS_THREADS || \
!(BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC) || \
!BR2_PACKAGE_HAS_UDEV
+
+config BR2_PACKAGE_PETITBOOT_GETTY_PORT
+ string "TTY port(s)"
+ default "console"
+ depends on BR2_PACKAGE_PETITBOOT
+ help
+ Specify a space-separated list of ports to run the petitboot UI on.
+ Wildcards are allowed. Example: "hvc* ttys0 ttyS*"
diff --git a/package/petitboot/pb-console b/package/petitboot/pb-console
new file mode 100644
index 000000000000..407ff3b30232
--- /dev/null
+++ b/package/petitboot/pb-console
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+DAEMON="pb-console"
+
+PB_CONSOLE_PORT=${2:-"console"}
+PB_CONSOLE_ARGS="--getty --detach -- -n -i 0 $PB_CONSOLE_PORT linux"
+
+# shellcheck source=/dev/null
+[ -r "/etc/default/petitboot" ] && . "/etc/default/petitboot"
+
+start() {
+ printf 'Starting %s on %s: ' "$DAEMON" "$PB_CONSOLE_PORT"
+ mkdir -p /var/log/petitboot
+
+ # shellcheck disable=SC2086 # we need the word splitting
+ start-stop-daemon -S -q -x "/usr/libexec/petitboot/$DAEMON" \
+ -- $PB_CONSOLE_ARGS
+ status=$?
+ if [ "$status" -eq 0 ]; then
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
+ return "$status"
+}
+
+case "$1" in
+ start)
+ "$1";;
+ stop|restart|reload)
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|reload} [port]"
+ exit 1
+ ;;
+esac
diff --git a/package/petitboot/petitboot.mk b/package/petitboot/petitboot.mk
index 5c7913b560b1..ff87f3498734 100644
--- a/package/petitboot/petitboot.mk
+++ b/package/petitboot/petitboot.mk
@@ -56,6 +56,8 @@ else
PETITBOOT_CONF_OPTS += HOST_PROG_SHUTDOWN=/usr/sbin/kexec-restart
endif
+PETITBOOT_GETTY_PORT = $(patsubst %,'%',$(call qstrip,$(BR2_PACKAGE_PETITBOOT_GETTY_PORT)))
+
define PETITBOOT_POST_INSTALL
$(INSTALL) -D -m 0755 $(@D)/utils/bb-kexec-reboot \
$(TARGET_DIR)/usr/libexec/petitboot/bb-kexec-reboot
@@ -67,6 +69,14 @@ define PETITBOOT_POST_INSTALL
$(TARGET_DIR)/etc/init.d/S15pb-discover
$(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/kexec-restart \
$(TARGET_DIR)/usr/sbin/kexec-restart
+ $(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/pb-console \
+ $(TARGET_DIR)/etc/init.d/pb-console
+
+ mkdir -p $(TARGET_DIR)/etc/udev/rules.d
+ (for port in $(PETITBOOT_GETTY_PORT); do \
+ printf 'SUBSYSTEM=="tty", KERNEL=="%s", RUN+="/etc/init.d/pb-console start $$name"\n' "$$port"; \
+ done) > $(TARGET_DIR)/etc/udev/rules.d/petitboot-console-ui.rules
+
mkdir -p $(TARGET_DIR)/usr/share/udhcpc/default.script.d/
ln -sf /usr/sbin/pb-udhcpc \
$(TARGET_DIR)/usr/share/udhcpc/default.script.d/
diff --git a/system/Config.in b/system/Config.in
index 24798dc06803..9587dd9ce4db 100644
--- a/system/Config.in
+++ b/system/Config.in
@@ -375,7 +375,7 @@ config BR2_SYSTEM_BIN_SH
menuconfig BR2_TARGET_GENERIC_GETTY
bool "Run a getty (login prompt) after boot"
- default y
+ default y if !BR2_PACKAGE_PETITBOOT
if BR2_TARGET_GENERIC_GETTY
config BR2_TARGET_GENERIC_GETTY_PORT
--
2.39.3
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next prev parent reply other threads:[~2023-10-09 15:19 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-09 15:17 [Buildroot] [PATCH v3 0/8] package/petitboot: misc fixes/enhancement Reza Arbab
2023-10-09 15:17 ` [Buildroot] [PATCH v3 1/8] package/petitboot: fix menu comment Reza Arbab
2023-11-09 16:59 ` Peter Korsgaard
2023-10-09 15:17 ` [Buildroot] [PATCH v3 2/8] package/petitboot: fix pb-discover pidfile creation Reza Arbab
2023-10-09 15:17 ` [Buildroot] [PATCH v3 3/8] package/petitboot: use default logfile dir Reza Arbab
2023-11-09 16:59 ` Peter Korsgaard
2023-10-09 15:17 ` [Buildroot] [PATCH v3 4/8] package/petitboot: prefer kexec-lite on powerpc Reza Arbab
2023-11-05 17:40 ` Arnout Vandecappelle via buildroot
2023-10-09 15:17 ` [Buildroot] [PATCH v3 5/8] package/petitboot: fix shutdown Reza Arbab
2023-11-05 17:57 ` Arnout Vandecappelle via buildroot
2023-11-09 16:13 ` Reza Arbab
2023-10-09 15:17 ` Reza Arbab [this message]
2023-11-05 18:06 ` [Buildroot] [PATCH v3 6/8] package/petitboot: run petitboot UI on consoles Arnout Vandecappelle via buildroot
2023-10-09 15:17 ` [Buildroot] [PATCH v3 7/8] package/petitboot: enable user separation Reza Arbab
2023-11-05 18:26 ` Arnout Vandecappelle via buildroot
2023-11-09 16:16 ` Reza Arbab
2023-11-10 9:01 ` Arnout Vandecappelle via buildroot
2023-11-14 15:25 ` Reza Arbab
2023-10-09 15:17 ` [Buildroot] [PATCH v3 8/8] package/petitboot: prefer UTF-8 support Reza Arbab
2023-11-05 18:30 ` Arnout Vandecappelle via buildroot
2023-11-09 16:17 ` Reza Arbab
2023-11-05 18:31 ` [Buildroot] [PATCH v3 0/8] package/petitboot: misc fixes/enhancement Arnout Vandecappelle via buildroot
2023-11-09 16:19 ` Reza Arbab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231009151729.2223963-7-arbab@linux.ibm.com \
--to=arbab@linux.ibm.com \
--cc=buildroot@buildroot.org \
--cc=joel@jms.id.au \
--cc=laurent@vivier.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.