Getting more of Barebox

Ahmad Fatoum ahmad at a3f.at
Fri Apr 1 09:45:58 PDT 2022


Finally, a no-frills way to join the currently relevant $supportgroup. Thx!

Please squash below for v2, so I don't need to carry patch for

  global.boot.default="$global.boot.default helpme"

around. Appreciated!

-------- 8< --------

 arch/arm/configs/ircbox_defconfig        |  1 +
 defaultenv/defaultenv-2-base/boot/helpme | 21 +++++++++++++++++++++
 net/irc.c                                | 13 +++++++++++--
 3 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100755 defaultenv/defaultenv-2-base/boot/helpme

diff --git a/arch/arm/configs/ircbox_defconfig b/arch/arm/configs/ircbox_defconfig
index 854a80775d79..0232156e624e 100644
--- a/arch/arm/configs/ircbox_defconfig
+++ b/arch/arm/configs/ircbox_defconfig
@@ -13,6 +13,7 @@ CONFIG_CONSOLE_ACTIVATE_NONE=y
 CONFIG_CONSOLE_ALLOW_COLOR=y
 CONFIG_PARTITION_DISK_EFI=y
 CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW_IKCONFIG=y
 CONFIG_STATE=y
 CONFIG_BOOTCHOOSER=y
 CONFIG_RESET_SOURCE=y
diff --git a/defaultenv/defaultenv-2-base/boot/helpme b/defaultenv/defaultenv-2-base/boot/helpme
new file mode 100755
index 000000000000..750445f297d7
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/boot/helpme
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+. /env/data/config
+
+if [ -n "$CONFIG_ARM" ]; then
+  supportgroup="armlinux"
+elif [ -n "$CONFIG_RISCV" ]; then
+  supportgroup="riscv"
+elif [ -n "$CONFIG_OPENRISC" ]; then
+  supportgroup="openrisc"
+fi
+
+if [ -n "$supportgroup" ]; then
+  readline "Want to ask for support on $supportgroup? [Y/n]  " linuxsupport
+fi
+
+if [ "$linuxsupport" != "Y" ]; then
+  supportgroup=barebox
+fi
+
+irc -n $global.user -c "/j $supportgroup" irc.libera.chat
diff --git a/net/irc.c b/net/irc.c
index 5ce2dbb4c8be..b42d4afc2c30 100644
--- a/net/irc.c
+++ b/net/irc.c
@@ -469,11 +469,15 @@ static int do_irc(int argc, char *argv[])
 {
 	int ret;
 	char *host, *p;
+	const char *command = NULL;
 	uint16_t port = 6667;
 	int opt;
 
-	while ((opt = getopt(argc, argv, "n:")) > 0) {
+	while ((opt = getopt(argc, argv, "c:n:")) > 0) {
 		switch (opt) {
+		case 'c':
+			command = optarg;
+			break;
 		case 'n':
 			strlcpy(nick, optarg, sizeof(nick));
 			break;
@@ -516,6 +520,10 @@ static int do_irc(int argc, char *argv[])
 	if (nick[0] == '\0')
 		strlcpy(nick, "barebox", sizeof(nick));
 	irc_login(host, "barebox");
+
+	if (command)
+		irc_input(command);
+
 	while (con->state == TCP_ESTABLISHED) {
 		int len;
 		len = irc_readline(input_line, sizeof(input_line) - 1);
@@ -541,11 +549,12 @@ out:
 BAREBOX_CMD_HELP_START(irc)
 BAREBOX_CMD_HELP_TEXT("Options:")
 BAREBOX_CMD_HELP_OPT ("-n NICK\t", "nick to use")
+BAREBOX_CMD_HELP_OPT ("-c COMMAND\t", "command to run after login")
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(irc)
 	.cmd		= do_irc,
 	BAREBOX_CMD_DESC("IRC client")
-	BAREBOX_CMD_OPTS("[-n] DESTINATION[[/]PORT]")
+	BAREBOX_CMD_OPTS("[-nc] DESTINATION[[/]PORT]")
 	BAREBOX_CMD_GROUP(CMD_GRP_NET)
 BAREBOX_CMD_END
-- 
2.34.1




More information about the barebox mailing list