Found out about "make change" and decided to run it to see which commands
break. The "make ipaddr" issue addressed in a previous thread is present on
ping6, nc, halt, poweroff, and prlimit ('[' also experiences this but didn't 
fix it
in this patch). The solution is the same too, different
USE_ macros and more config symbols.

An exception to this is wget, which fails for a different reason I've yet to 
diagnose properly:

wget:generated/{Config.in,newtoys.h,flags.h,tags.h,help.h}
Compile change/wget
........Assembler messages:
Fatal error: can't create generated/obj/lib_env.o: No such file or directory
Assembler messages:
Fatal error: can't create generated/obj/lib_hash.o: No such file or directory
Assembler messages:
Fatal error: can't create generated/obj/lib_lib.o: No such file or directory

-   Oliver Webb <[email protected]>
From 6c7779c8f31633c7b5991af180f905ce538eb5ac Mon Sep 17 00:00:00 2001
From: Oliver Webb <[email protected]>
Date: Thu, 11 Apr 2024 00:52:22 -0500
Subject: [PATCH] Fix single command builds for nc, ping6, halt, poweroff, and
 prlimit by adding config symbols

---
 toys/net/netcat.c   |  8 +++++++-
 toys/net/ping.c     |  7 ++++++-
 toys/other/reboot.c | 15 +++++++++++++--
 toys/posix/ulimit.c |  8 +++++++-
 4 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/toys/net/netcat.c b/toys/net/netcat.c
index 4e76fa7f..db196eef 100644
--- a/toys/net/netcat.c
+++ b/toys/net/netcat.c
@@ -5,7 +5,7 @@
  * TODO: genericize for telnet/microcom/tail-f, fix -t
 
 USE_NETCAT(NEWTOY(netcat, "^tElLw#<1W#<1p#<1>65535q#<1s:f:46uUnvz[!tlL][!Lw][!Lu][!46U]", TOYFLAG_BIN))
-USE_NETCAT(OLDTOY(nc, netcat, TOYFLAG_USR|TOYFLAG_BIN))
+USE_NC(OLDTOY(nc, netcat, TOYFLAG_USR|TOYFLAG_BIN))
 
 config NETCAT
   bool "netcat"
@@ -43,6 +43,12 @@ config NETCAT
 
     Or use "stty 115200 -F /dev/ttyS0 && stty raw -echo -ctlecho" with
     netcat -f to connect to a serial port.
+
+config NC
+  bool
+  default y
+  depends on NETCAT
+
 */
 
 #define FOR_netcat
diff --git a/toys/net/ping.c b/toys/net/ping.c
index 3c00e0c2..70a380ce 100644
--- a/toys/net/ping.c
+++ b/toys/net/ping.c
@@ -12,7 +12,7 @@
 
 // -s > 4064 = sizeof(toybuf)-sizeof(struct icmphdr)-CMSG_SPACE(sizeof(uint8_t)), then kernel adds 20 bytes
 USE_PING(NEWTOY(ping, "<1>1m#t#<0>255=64c#<0=3s#<0>4064=56i%W#<0=3w#<0qf46I:[-46]", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_LINEBUF))
-USE_PING(OLDTOY(ping6, ping, TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_LINEBUF))
+USE_PING6(OLDTOY(ping6, ping, TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_LINEBUF))
 
 config PING
   bool "ping"
@@ -38,6 +38,11 @@ config PING
     -t TTL		Set Time To Live (number of hops)
     -W SEC		Seconds to wait for response after last -c packet (default 3)
     -w SEC		Exit after this many seconds
+
+config PING6
+  bool
+  default y
+  depends on PING
 */
 
 #define FOR_ping
diff --git a/toys/other/reboot.c b/toys/other/reboot.c
index 4770d1f1..178b95cb 100644
--- a/toys/other/reboot.c
+++ b/toys/other/reboot.c
@@ -3,8 +3,8 @@
  * Copyright 2013 Elie De Brauwer <[email protected]>
 
 USE_REBOOT(NEWTOY(reboot, "d:fn", TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
-USE_REBOOT(OLDTOY(halt, reboot, TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
-USE_REBOOT(OLDTOY(poweroff, reboot, TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
+USE_HALT(OLDTOY(halt, reboot, TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
+USE_POWEROFF(OLDTOY(poweroff, reboot, TOYFLAG_SBIN|TOYFLAG_NEEDROOT))
 
 config REBOOT
   bool "reboot"
@@ -17,6 +17,17 @@ config REBOOT
     -d	Wait DELAY before proceeding (in seconds or m/h/d suffix: -d 1.5m = 90s)
     -f	Force reboot (don't signal init, reboot directly)
     -n	Don't sync filesystems before reboot
+
+config HALT
+  bool
+  default y
+  depends on REBOOT
+
+config POWEROFF
+  bool
+  default y
+  depends on REBOOT
+
 */
 
 #define FOR_reboot
diff --git a/toys/posix/ulimit.c b/toys/posix/ulimit.c
index ffb1eb38..2ce7f936 100644
--- a/toys/posix/ulimit.c
+++ b/toys/posix/ulimit.c
@@ -17,7 +17,7 @@
  * runtime). We support -P to affect processes other than us.
 
 USE_ULIMIT(NEWTOY(ulimit, ">1P#<1SHavutsrRqpnmlifedc[-SH][!apvutsrRqnmlifedc]", TOYFLAG_USR|TOYFLAG_BIN))
-USE_ULIMIT(OLDTOY(prlimit, ulimit, TOYFLAG_USR|TOYFLAG_BIN))
+USE_PRLIMIT(OLDTOY(prlimit, ulimit, TOYFLAG_USR|TOYFLAG_BIN))
 
 config ULIMIT
   bool "ulimit"
@@ -40,6 +40,12 @@ config ULIMIT
     -r  Max realtime priority          -R  Realtime latency (us)
     -s  Stack size (KiB)               -t  Total CPU time (s)
     -u  Maximum processes (this UID)   -v  Virtual memory size (KiB)
+
+config PRLIMIT
+  bool
+  default y
+  depends on ULIMIT
+
 */
 
 #define FOR_ulimit
-- 
2.44.0

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to