* Latest dhcp.

* Dhcp client script: create resolv.conf even if the DHCP server
  doesn't provide a domain name, only a list of name servers.  (The
  QEMU DHCP server does this.)

svn path=/nixpkgs/trunk/; revision=7920
This commit is contained in:
Eelco Dolstra 2007-02-20 14:20:16 +00:00
parent b8057ff11a
commit 7f1a438ca8
5 changed files with 37 additions and 193 deletions

20
pkgs/tools/networking/dhcp/builder.sh Executable file → Normal file
View File

@ -2,23 +2,15 @@ source $stdenv/setup
export DESTDIR=$out
configurePhase=configurePhase
configurePhase() {
./configure
prefix=$out
}
preBuild() {
sed -e "s^@nettools\@^$nettools^g" \
-e "s^@coreutils\@^$coreutils^g" \
-e "s^@bash\@^$bash^g" \
-e "s^@iputils\@^$iputils^g" \
-e "s^@gnused\@^$gnused^g" \
< client/scripts/linux > client/scripts/linux.tmp
mv client/scripts/linux.tmp client/scripts/linux
./configure
prefix=$out
}
preBuild=preBuild
configurePhase=configurePhase
preBuild() {
substituteInPlace client/scripts/linux --replace /bin/bash $shell
}
genericBuild

View File

@ -1,13 +1,13 @@
{stdenv, fetchurl, groff, nettools, coreutils, iputils, gnused, bash}:
stdenv.mkDerivation {
name = "dhcp-3.0.4";
name = "dhcp-3.0.5";
builder=./builder.sh;
src = fetchurl {
url = http://nix.cs.uu.nl/dist/tarballs/dhcp-3.0.4.tar.gz;
md5 = "004ef935fd54b8046b16bdde31a9e151";
url = http://ftp.isc.org/isc/dhcp/dhcp-3.0.5.tar.gz;
sha256 = "1dpz6y08vrn3mw0lrlwq1sfiq6nsixpwwgb9hngddka1lfr5yi6x";
};
buildInputs = [groff];
inherit nettools coreutils iputils gnused bash;
patches = [./dhcp-3.0.3-path.patch ./dhcp-3.0.3-bash.patch];
patches = [./resolv-without-domain.patch];
}

View File

@ -1,9 +0,0 @@
diff -ruN dhcp-3.0.3/client/scripts/linux dhcp-3.0.3.new/client/scripts/linux
--- dhcp-3.0.3/client/scripts/linux 2002-11-15 02:09:09.000000000 +0100
+++ dhcp-3.0.3.new/client/scripts/linux 2005-10-16 22:42:09.000000000 +0200
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!@bash@/bin/bash
# dhclient-script for Linux. Dan Halbert, March, 1997.
# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
# No guarantees about this. I'm a novice at the details of Linux

View File

@ -1,166 +0,0 @@
diff -ruN dhcp-3.0.3/client/scripts/linux dhcp-3.0.3.new/client/scripts/linux
--- dhcp-3.0.3/client/scripts/linux 2002-11-15 02:09:09.000000000 +0100
+++ dhcp-3.0.3.new/client/scripts/linux 2005-10-12 22:12:20.000000000 +0200
@@ -25,7 +25,7 @@
make_resolv_conf() {
if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
echo search $new_domain_name >/etc/resolv.conf
- chmod 644 /etc/resolv.conf
+ @coreutils@/bin/chmod 644 /etc/resolv.conf
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf
done
@@ -53,10 +53,10 @@
fi
fi
-release=`uname -r`
-release=`expr $release : '\(.*\)\..*'`
-relminor=`echo $release |sed -e 's/[0-9]*\.\([0-9][0-9]*\)\(\..*\)*$/\1/'`
-relmajor=`echo $release |sed -e 's/\([0-9][0-9]*\)\..*$/\1/'`
+release=`@coreutils@/bin/uname -r`
+release=`@coreutils@/bin/expr $release : '\(.*\)\..*'`
+relminor=`echo $release |@gnused@/bin/sed -e 's/[0-9]*\.\([0-9][0-9]*\)\(\..*\)*$/\1/'`
+relmajor=`echo $release |@gnused@/bin/sed -e 's/\([0-9][0-9]*\)\..*$/\1/'`
if [ x$new_broadcast_address != x ]; then
new_broadcast_arg="broadcast $new_broadcast_address"
@@ -82,20 +82,20 @@
if [ x$reason = xPREINIT ]; then
if [ x$alias_ip_address != x ]; then
# Bring down alias interface. Its routes will disappear too.
- ifconfig $interface:0- inet 0
+ @nettools@/sbin/ifconfig $interface:0- inet 0
fi
if [ $relmajor -lt 2 ] || ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] )
then
- ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
+ @nettools@/sbin/ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
broadcast 255.255.255.255 up
# Add route to make broadcast work. Do not omit netmask.
- route add default dev $interface netmask 0.0.0.0
+ @nettools@/sbin/route add default dev $interface netmask 0.0.0.0
else
- ifconfig $interface 0 up
+ @nettools@/sbin/ifconfig $interface 0 up
fi
# We need to give the kernel some time to get the interface up.
- sleep 1
+ @coreutils@/bin/sleep 1
exit_with_hooks 0
fi
@@ -106,45 +106,45 @@
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
[ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
- current_hostname=`hostname`
+ current_hostname=`@nettools@/bin/hostname`
if [ x$current_hostname = x ] || \
[ x$current_hostname = x$old_host_name ]; then
if [ x$current_hostname = x ] || \
[ x$new_host_name != x$old_host_name ]; then
- hostname $new_host_name
+ @nettools@/bin/hostname $new_host_name
fi
fi
if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
[ x$alias_ip_address != x$old_ip_address ]; then
# Possible new alias. Remove old alias.
- ifconfig $interface:0- inet 0
+ @nettools@/sbin/ifconfig $interface:0- inet 0
fi
if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
# IP address changed. Bringing down the interface will delete all routes,
# and clear the ARP cache.
- ifconfig $interface inet 0 down
+ @nettools@/sbin/ifconfig $interface inet 0 down
fi
if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
[ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
- ifconfig $interface inet $new_ip_address $new_subnet_arg \
+ @nettools@/sbin/ifconfig $interface inet $new_ip_address $new_subnet_arg \
$new_broadcast_arg
# Add a network route to the computed network address.
if [ $relmajor -lt 2 ] || \
( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then
- route add -net $new_network_number $new_subnet_arg dev $interface
+ @nettools@/sbin/route add -net $new_network_number $new_subnet_arg dev $interface
fi
for router in $new_routers; do
- route add default gw $router
+ @nettools@/sbin/route add default gw $router
done
fi
if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
then
- ifconfig $interface:0- inet 0
- ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
- route add -host $alias_ip_address $interface:0
+ @nettools@/sbin/ifconfig $interface:0- inet 0
+ @nettools@/sbin/ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
+ @nettools@/sbin/route add -host $alias_ip_address $interface:0
fi
make_resolv_conf
exit_with_hooks 0
@@ -154,44 +154,44 @@
|| [ x$reason = xSTOP ]; then
if [ x$alias_ip_address != x ]; then
# Turn off alias interface.
- ifconfig $interface:0- inet 0
+ @nettools@/sbin/ifconfig $interface:0- inet 0
fi
if [ x$old_ip_address != x ]; then
# Shut down interface, which will delete routes and clear arp cache.
- ifconfig $interface inet 0 down
+ @nettools@/sbin/ifconfig $interface inet 0 down
fi
if [ x$alias_ip_address != x ]; then
- ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
- route add -host $alias_ip_address $interface:0
+ @nettools@/sbin/ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
+ @nettools@/sbin/route add -host $alias_ip_address $interface:0
fi
exit_with_hooks 0
fi
if [ x$reason = xTIMEOUT ]; then
if [ x$alias_ip_address != x ]; then
- ifconfig $interface:0- inet 0
+ @nettools@/sbin/ifconfig $interface:0- inet 0
fi
- ifconfig $interface inet $new_ip_address $new_subnet_arg \
+ @nettools@/sbin/ifconfig $interface inet $new_ip_address $new_subnet_arg \
$new_broadcast_arg
set $new_routers
############## what is -w in ping?
- if ping -q -c 1 $1; then
+ if @iputils@/bin/ping -q -c 1 $1; then
if [ x$new_ip_address != x$alias_ip_address ] && \
[ x$alias_ip_address != x ]; then
- ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
- route add -host $alias_ip_address dev $interface:0
+ @nettools@/sbin/ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
+ @nettools@/sbin/route add -host $alias_ip_address dev $interface:0
fi
if [ $relmajor -lt 2 ] || \
( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then
- route add -net $new_network_number
+ @nettools@/sbin/route add -net $new_network_number
fi
for router in $new_routers; do
- route add default gw $router
+ @nettools@/sbin/route add default gw $router
done
make_resolv_conf
exit_with_hooks 0
fi
- ifconfig $interface inet 0 down
+ @nettools@/sbin/ifconfig $interface inet 0 down
exit_with_hooks 1
fi

View File

@ -0,0 +1,27 @@
diff -rc dhcp-3.0.5-orig/client/scripts/linux dhcp-3.0.5/client/scripts/linux
*** dhcp-3.0.5-orig/client/scripts/linux Fri Nov 15 02:09:09 2002
--- dhcp-3.0.5/client/scripts/linux Tue Feb 20 15:02:34 2007
***************
*** 23,31 ****
# of the $1 in its args.
make_resolv_conf() {
! if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
! echo search $new_domain_name >/etc/resolv.conf
chmod 644 /etc/resolv.conf
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf
done
--- 23,34 ----
# of the $1 in its args.
make_resolv_conf() {
! if [ x"$new_domain_name_servers" != x ]; then
! echo -n >/etc/resolv.conf
chmod 644 /etc/resolv.conf
+ if [ "x$new_domain_name" != x ]; then
+ echo search $new_domain_name >>/etc/resolv.conf
+ fi
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf
done