[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1009309: udhcpc: allow usage without busybox



Source: busybox
Version: 1:1.30.1-7
Severity: wishlist
Tags: patch

Hi Aurelien,

would it be possible to avoid the udhcpc -> busybox dependency? It may
seem strange to remove busybox in a quest to reduce file system usage at
first, but if you need iproute2 for other reasons, it should be fine at
providing what udhcpc needs. I'm attaching a patch so you can judge the
impact.

If that's not a reasonable move forward, how about demoting the
dependency to Recommends? Admittedly, the case of using udhcpc without
using its default script is rare, so I wasn't convinced about that
approach yet.

What do you think?

Helmut
diff --minimal -Nru busybox-1.30.1/debian/changelog busybox-1.30.1/debian/changelog
--- busybox-1.30.1/debian/changelog	2021-08-22 16:39:45.000000000 +0200
+++ busybox-1.30.1/debian/changelog	2022-04-11 13:59:07.000000000 +0200
@@ -1,3 +1,10 @@
+busybox (1:1.30.1-7.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Allow using udhcpc without busybox. (Closes: #-1)
+
+ -- Helmut Grohne <helmut.grohne@intenta.de>  Mon, 11 Apr 2022 13:59:07 +0200
+
 busybox (1:1.30.1-7) unstable; urgency=medium
 
   [ Debian Janitor ]
diff --minimal -Nru busybox-1.30.1/debian/control busybox-1.30.1/debian/control
--- busybox-1.30.1/debian/control	2021-08-22 11:37:14.000000000 +0200
+++ busybox-1.30.1/debian/control	2022-04-11 13:59:04.000000000 +0200
@@ -104,7 +104,7 @@
 Section: net
 Architecture: linux-any
 Depends:
- busybox (>> ${source:Upstream-Version}) | busybox-static (>> ${source:Upstream-Version}),
+ busybox (>> ${source:Upstream-Version}) | busybox-static (>> ${source:Upstream-Version}) | iproute2,
  ${misc:Depends},
 Description: Provides the busybox DHCP client implementation
  Busybox contains a very small yet fully functional RFC compliant DHCP
diff --minimal -Nru busybox-1.30.1/debian/tree/udhcpc/etc/udhcpc/default.script busybox-1.30.1/debian/tree/udhcpc/etc/udhcpc/default.script
--- busybox-1.30.1/debian/tree/udhcpc/etc/udhcpc/default.script	2019-08-07 23:12:03.000000000 +0200
+++ busybox-1.30.1/debian/tree/udhcpc/etc/udhcpc/default.script	2022-04-11 13:58:08.000000000 +0200
@@ -12,28 +12,33 @@
     logger -t "udhcpc[$PPID]" -p daemon.$1 "$interface: $2"
 }
 
+command -v ip >/dev/null && ip_exe=ip || ip_exe="busybox ip"
+command -v awk >/dev/null && awk_exe=awk || awk_exe="busybox awk"
+
 case $1 in
     bound|renew)
 
 	# Configure new IP address.
 	# Do it unconditionally even if the address hasn't changed,
 	# to also set subnet, broadcast, mtu, ...
-	busybox ifconfig $interface ${mtu:+mtu $mtu} \
-	    $ip netmask $subnet ${broadcast:+broadcast $broadcast}
+	[ -n "$mtu" ] && $ip_exe link set dev $interface mtu $mtu
+	$ip_exe -4 addr flush dev $interface
+	$ip_exe -4 addr add $ip/$subnet ${broadcast:+broadcast $broadcast} \
+	    dev $interface
 
 	# get current ("old") routes (after setting new IP)
-	crouter=$(busybox ip -4 route show dev $interface |
-	          busybox awk '$1 == "default" { print $3; }')
+	crouter=$($ip_exe -4 route show dev $interface |
+	          $awk_exe '$1 == "default" { print $3; }')
 	router="${router%% *}" # linux kernel supports only one (default) route
 	if [ ".$router" != ".$crouter" ]; then
 	    # reset just default routes
-	    busybox ip -4 route flush exact 0.0.0.0/0 dev $interface
+	    $ip_exe -4 route flush exact 0.0.0.0/0 dev $interface
 	fi
 	if [ -n "$router" ]; then
 	    # special case for /32 subnets: use onlink keyword
 	    [ ".$subnet" = .255.255.255.255 ] \
 		    && onlink=onlink || onlink=
-	    busybox ip -4 route add default via $router dev $interface $onlink
+	    $ip_exe -4 route add default via $router dev $interface $onlink
 	fi
 
 	# Update resolver configuration file
@@ -53,9 +58,9 @@
 	;;
 
     deconfig)
-	busybox ip link set $interface up
-	busybox ip -4 addr flush dev $interface
-	busybox ip -4 route flush dev $interface
+	$ip_exe link set $interface up
+	$ip_exe -4 addr flush dev $interface
+	$ip_exe -4 route flush dev $interface
 	[ -x /sbin/resolvconf ] &&
 	    resolvconf -d "$interface.udhcpc"
 	log notice "deconfigured"

Reply to: