1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-25 15:11:35 +00:00

busybox: Download and patch the dispatcher script from upstream

This commit is contained in:
Tethys Svensson 2020-07-29 00:24:19 +02:00
parent 179b74c216
commit dcc963bd2d
2 changed files with 15 additions and 70 deletions

View file

@ -31,6 +31,14 @@ let
CONFIG_FEATURE_UTMP n
CONFIG_FEATURE_WTMP n
'';
debianName = "busybox_1.30.1-5";
debianTarball = fetchTarball {
url = "http://deb.debian.org/debian/pool/main/b/busybox/${debianName}.debian.tar.xz";
sha256 = "03m4rvs2pd0hj0mdkdm3r4m1gh0bgwr0cvnqds297xnkfi5s01nx";
};
debianDispatcherScript = "${debianTarball}/tree/udhcpc/etc/udhcpc/default.script";
outDispatchPath = "$out/default.script";
in
stdenv.mkDerivation rec {
@ -81,7 +89,7 @@ stdenv.mkDerivation rec {
CONFIG_FEATURE_COPYBUF_KB 64
# Set the path for the udhcpc script
CONFIG_UDHCPC_DEFAULT_SCRIPT "$out/share/default.script"
CONFIG_UDHCPC_DEFAULT_SCRIPT "${outDispatchPath}"
${extraConfig}
CONFIG_CROSS_COMPILER_PREFIX "${stdenv.cc.targetPrefix}"
@ -98,9 +106,12 @@ stdenv.mkDerivation rec {
'';
postInstall = ''
mkdir $out/share
substituteAll ${./default.script} $out/share/default.script
chmod +x $out/share/default.script
sed -e '
1 a busybox() { '$out'/bin/busybox "$@"; }\
logger() { '$out'/bin/logger "$@"; }\
' ${debianDispatcherScript} > ${outDispatchPath}
chmod 555 ${outDispatchPath}
PATH=$out/bin patchShebangs ${outDispatchPath}
'';
depsBuildBuild = [ buildPackages.stdenv.cc ];

View file

@ -1,66 +0,0 @@
#!@bash@/bin/sh
# Busybox udhcpc dispatcher script.
# Copyright (C) 2009 by Axel Beckert.
# Copyright (C) 2014 by Michael Tokarev.
#
# Based on the busybox example scripts and the old udhcp source
# package default.* scripts.
RESOLV_CONF="/etc/resolv.conf"
log() {
@out@/bin/logger -t "udhcpc[$PPID]" -p daemon.$1 "$interface: $2"
}
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, ...
@out@/bin/ifconfig $interface ${mtu:+mtu $mtu} \
$ip netmask $subnet ${broadcast:+broadcast $broadcast}
# get current ("old") routes (after setting new IP)
crouter=$(@out@/bin/ip -4 route show dev $interface |
@out@/bin/awk '$1 == "default" { print $3; }')
router="${router%% *}" # linux kernel supports only one (default) route
if [ ".$router" != ".$crouter" ]; then
# reset just default routes
@out@/bin/ip -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=
@out@/bin/ip -4 route add default via $router dev $interface $onlink
fi
# Update resolver configuration file
[ -n "$domain" ] && R="domain $domain" || R=""
for i in $dns; do
R="$R
nameserver $i"
done
echo "$R" > "$RESOLV_CONF"
log info "$1: IP=$ip/$subnet router=$router domain=\"$domain\" dns=\"$dns\" lease=$lease"
;;
deconfig)
@out@/bin/ip link set $interface up
@out@/bin/ip -4 addr flush dev $interface
@out@/bin/ip -4 route flush dev $interface
log notice "deconfigured"
;;
leasefail | nak)
log err "configuration failed: $1: $message"
;;
*)
echo "$0: Unknown udhcpc command: $1" >&2
exit 1
;;
esac