#!/bin/sh # Set initial variables: CWD=`pwd` if [ "$TMP" = "" ]; then TMP=$CWD fi PKG=$TMP/package-dhcp VERSION=4.2.5 ARCH=i386 BUILD=1 if [ ! -d $TMP ]; then mkdir -p $TMP # location to build the source fi if [ ! -d $PKG ]; then mkdir -p $PKG # place for the package to be built fi # Explode the package framework: cd $PKG explodepkg $CWD/_dhcp.tar.gz echo "+=============+" echo "| dhcp-$VERSION |" echo "+=============+" cd $TMP tar xzvf $CWD/dhcp-$VERSION.tar.gz cd dhcp-$VERSION # Borrowed from https://github.com/ipfire/ipfire-3.x/tree/master/dhcp/patches # Apply patches in a special order. PATCHES="dhcp-4.2.5-remove-bind.patch \ dhcp-4.2.4-P1-remove-dst.patch \ dhcp-4.2.0-errwarn-message.patch \ dhcp-4.2.0-release-by-ifup.patch \ dhcp-4.2.4-unicast-bootp.patch \ dhcp-4.2.0-default-requested-options.patch \ dhcp-4.2.2-xen-checksum.patch \ dhcp-4.2.5-manpages.patch \ dhcp-4.2.0-garbage-chars.patch \ dhcp-4.2.0-add_timeout_when_NULL.patch \ dhcp-4.2.4-64_bit_lease_parse.patch \ dhcp-4.2.0-logpid.patch \ dhcp-4.2.4-UseMulticast.patch \ dhcp-4.2.4-improved-xid.patch \ dhcp-4.2.5-systemtap.patch \ dhcp-4.2.3-P2-log_perror.patch \ dhcp-4.2.4-getifaddrs.patch \ dhcp-4.2.4-send_release.patch \ dhcp-4.2.5-rfc5970-dhcpv6-options-for-network-boot.patch \ dhcp-4.2.4-failOverPeer.patch \ dhcp-4.2.5b1-atf-pkgconfig.patch \ dhcp-4.2.4-P1-interval.patch \ dhcp-4.2.4-P2-conflex-do-forward-updates.patch \ dhcp-4.2.4-P2-dupl-key.patch \ dhcp-4.2.5-next-server.patch" for P in $PATCHES ; do echo "Applying patch $P" patch -p1 < $CWD/ipfire-3.x/dhcp/patches/$P || exit done #patch -p1 < $CWD/dhcp-4.2.5-remove-bind.patch || exit 1 #patch -p1 < $CWD/dhcp-4.2.4-getifaddrs.patch || exit 1 export MAKEFLAGS="-j10" ./configure --enable-ipv4-pktinfo \ --disable-static \ --with-srv-lease-file=/var/state/dhcp/dhcpd.leases \ --with-srv6-lease-file=/var/state/dhcp/dhcpd6.leases \ --with-cli-lease-file=/var/state/dhcp/dhclient.leases \ --with-cli6-lease-file=/var/state/dhcp/dhclient6.leases || exit 1 make DEBUG="-O2 -march=i386 -mcpu=i686" || exit 1 mkdir -p $PKG/usr/doc/dhcp-$VERSION cp -a ANONCVS CHANGES COPYRIGHT README RELNOTES $PKG/usr/doc/dhcp-$VERSION mkdir -p $PKG/usr/doc/dhcp-$VERSION/examples cp -a client/dhclient.conf server/dhcpd.conf \ $PKG/usr/doc/dhcp-$VERSION/examples chown -R root.root $PKG/usr/doc/dhcp-$VERSION cat << EOF > $PKG/etc/dhcpd.conf.new # dhcpd.conf # # Configuration file for ISC dhcpd (see 'man dhcpd.conf') # allow unknown-clients; ddns-updates off; subnet 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.100 192.168.0.254; option domain-name-servers 192.168.0.1,192.168.0.1; option routers 192.168.0.1; option domain-name ""; } EOF cat << EOF > $PKG/etc/dhclient.conf.new # dhclient.conf # # Configuration file for ISC dhclient (see 'man dhclient.conf') # EOF mkdir -p $PKG/service/dhcpd cat << EOF > $PKG/service/dhcpd/run #!/bin/bash exec /usr/sbin/dhcpd -f EOF mkdir -p $PKG/etc/postinst.d cp $CWD/post.dhcp $PKG/etc/postinst.d || exit 1 chmod +x $PKG/etc/postinst.d/post.dhcp || exit 1 chmod +x $PKG/service/dhcpd/run cat client/scripts/linux > $PKG/sbin/dhclient-script chmod 700 $PKG/sbin/dhclient-script ( cd work.linux-2.2 strip server/dhcpd client/dhclient relay/dhcrelay cat server/dhcpd > $PKG/usr/sbin/dhcpd cat relay/dhcrelay > $PKG/usr/sbin/dhcrelay cat client/dhclient > $PKG/sbin/dhclient ) mkdir -p $PKG/usr/man/man5 mkdir -p $PKG/usr/man/man8 for dir in client server ; do cd $dir for file in *.5 ; do cat $file | sed -e "s#ETCDIR#/etc#g" -e "s#DBDIR#/var/db#g" \ -e "s#RUNDIR#/var/run#g" | gzip -9c > $PKG/usr/man/man5/$file.gz done for file in *.8 ; do cat $file | sed -e "s#ETCDIR#/etc#g" -e "s#DBDIR#/var/db#g" \ -e "s#RUNDIR#/var/run#g" | gzip -9c > $PKG/usr/man/man8/$file.gz done cd .. done cat relay/dhcrelay.8 | sed -e "s#ETCDIR#/etc#g" -e "s#DBDIR#/var/db#g" \ -e "s#RUNDIR#/var/run#g" | gzip -9c > $PKG/usr/man/man8/dhcrelay.8.gz mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc # Build the package: cd $PKG NAME=`echo $0|cut -f2 -d'.'` makepkg -l y -c n $CWD/$NAME.pkg > /dev/null && echo $VERSION > $CWD/$NAME.version && arch > $CWD/$NAME.arch && # Clean up the extra stuff: if [ ! "$1" = "--nocleanup" ]; then rm -rf $TMP/dhcp-$VERSION rm -rf $PKG fi