| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | # Set initial variables: |
|---|
| 4 | CWD=`pwd` |
|---|
| 5 | if [ "$TMP" = "" ]; then |
|---|
| 6 | TMP=$CWD |
|---|
| 7 | fi |
|---|
| 8 | PKG=$TMP/package-dhcp |
|---|
| 9 | |
|---|
| 10 | VERSION=4.2.5 |
|---|
| 11 | ARCH=i386 |
|---|
| 12 | BUILD=1 |
|---|
| 13 | |
|---|
| 14 | if [ ! -d $TMP ]; then |
|---|
| 15 | mkdir -p $TMP # location to build the source |
|---|
| 16 | fi |
|---|
| 17 | if [ ! -d $PKG ]; then |
|---|
| 18 | mkdir -p $PKG # place for the package to be built |
|---|
| 19 | fi |
|---|
| 20 | |
|---|
| 21 | # Explode the package framework: |
|---|
| 22 | cd $PKG |
|---|
| 23 | explodepkg $CWD/_dhcp.tar.gz |
|---|
| 24 | |
|---|
| 25 | echo "+=============+" |
|---|
| 26 | echo "| dhcp-$VERSION |" |
|---|
| 27 | echo "+=============+" |
|---|
| 28 | cd $TMP |
|---|
| 29 | tar xzvf $CWD/dhcp-$VERSION.tar.gz |
|---|
| 30 | cd dhcp-$VERSION |
|---|
| 31 | |
|---|
| 32 | # Borrowed from https://github.com/ipfire/ipfire-3.x/tree/master/dhcp/patches |
|---|
| 33 | # Apply patches in a special order. |
|---|
| 34 | PATCHES="dhcp-4.2.5-remove-bind.patch \ |
|---|
| 35 | dhcp-4.2.4-P1-remove-dst.patch \ |
|---|
| 36 | dhcp-4.2.0-errwarn-message.patch \ |
|---|
| 37 | dhcp-4.2.0-release-by-ifup.patch \ |
|---|
| 38 | dhcp-4.2.4-unicast-bootp.patch \ |
|---|
| 39 | dhcp-4.2.0-default-requested-options.patch \ |
|---|
| 40 | dhcp-4.2.2-xen-checksum.patch \ |
|---|
| 41 | dhcp-4.2.5-manpages.patch \ |
|---|
| 42 | dhcp-4.2.0-garbage-chars.patch \ |
|---|
| 43 | dhcp-4.2.0-add_timeout_when_NULL.patch \ |
|---|
| 44 | dhcp-4.2.4-64_bit_lease_parse.patch \ |
|---|
| 45 | dhcp-4.2.0-logpid.patch \ |
|---|
| 46 | dhcp-4.2.4-UseMulticast.patch \ |
|---|
| 47 | dhcp-4.2.4-improved-xid.patch \ |
|---|
| 48 | dhcp-4.2.5-systemtap.patch \ |
|---|
| 49 | dhcp-4.2.3-P2-log_perror.patch \ |
|---|
| 50 | dhcp-4.2.4-getifaddrs.patch \ |
|---|
| 51 | dhcp-4.2.4-send_release.patch \ |
|---|
| 52 | dhcp-4.2.5-rfc5970-dhcpv6-options-for-network-boot.patch \ |
|---|
| 53 | dhcp-4.2.4-failOverPeer.patch \ |
|---|
| 54 | dhcp-4.2.5b1-atf-pkgconfig.patch \ |
|---|
| 55 | dhcp-4.2.4-P1-interval.patch \ |
|---|
| 56 | dhcp-4.2.4-P2-conflex-do-forward-updates.patch \ |
|---|
| 57 | dhcp-4.2.4-P2-dupl-key.patch \ |
|---|
| 58 | dhcp-4.2.5-next-server.patch" |
|---|
| 59 | |
|---|
| 60 | for P in $PATCHES ; do |
|---|
| 61 | echo "Applying patch $P" |
|---|
| 62 | patch -p1 < $CWD/ipfire-3.x/dhcp/patches/$P || exit |
|---|
| 63 | done |
|---|
| 64 | |
|---|
| 65 | #patch -p1 < $CWD/dhcp-4.2.5-remove-bind.patch || exit 1 |
|---|
| 66 | #patch -p1 < $CWD/dhcp-4.2.4-getifaddrs.patch || exit 1 |
|---|
| 67 | |
|---|
| 68 | export MAKEFLAGS="-j10" |
|---|
| 69 | ./configure --enable-ipv4-pktinfo \ |
|---|
| 70 | --disable-static \ |
|---|
| 71 | --with-srv-lease-file=/var/state/dhcp/dhcpd.leases \ |
|---|
| 72 | --with-srv6-lease-file=/var/state/dhcp/dhcpd6.leases \ |
|---|
| 73 | --with-cli-lease-file=/var/state/dhcp/dhclient.leases \ |
|---|
| 74 | --with-cli6-lease-file=/var/state/dhcp/dhclient6.leases || exit 1 |
|---|
| 75 | |
|---|
| 76 | make DEBUG="-O2 -march=i386 -mcpu=i686" || exit 1 |
|---|
| 77 | mkdir -p $PKG/usr/doc/dhcp-$VERSION |
|---|
| 78 | cp -a ANONCVS CHANGES COPYRIGHT README RELNOTES $PKG/usr/doc/dhcp-$VERSION |
|---|
| 79 | mkdir -p $PKG/usr/doc/dhcp-$VERSION/examples |
|---|
| 80 | cp -a client/dhclient.conf server/dhcpd.conf \ |
|---|
| 81 | $PKG/usr/doc/dhcp-$VERSION/examples |
|---|
| 82 | chown -R root.root $PKG/usr/doc/dhcp-$VERSION |
|---|
| 83 | cat << EOF > $PKG/etc/dhcpd.conf.new |
|---|
| 84 | # dhcpd.conf |
|---|
| 85 | # |
|---|
| 86 | # Configuration file for ISC dhcpd (see 'man dhcpd.conf') |
|---|
| 87 | # |
|---|
| 88 | allow unknown-clients; |
|---|
| 89 | ddns-updates off; |
|---|
| 90 | |
|---|
| 91 | subnet 192.168.0.0 netmask 255.255.255.0 { |
|---|
| 92 | range 192.168.0.100 192.168.0.254; |
|---|
| 93 | option domain-name-servers 192.168.0.1,192.168.0.1; |
|---|
| 94 | option routers 192.168.0.1; |
|---|
| 95 | option domain-name ""; |
|---|
| 96 | } |
|---|
| 97 | EOF |
|---|
| 98 | |
|---|
| 99 | cat << EOF > $PKG/etc/dhclient.conf.new |
|---|
| 100 | # dhclient.conf |
|---|
| 101 | # |
|---|
| 102 | # Configuration file for ISC dhclient (see 'man dhclient.conf') |
|---|
| 103 | # |
|---|
| 104 | EOF |
|---|
| 105 | |
|---|
| 106 | mkdir -p $PKG/service/dhcpd |
|---|
| 107 | cat << EOF > $PKG/service/dhcpd/run |
|---|
| 108 | #!/bin/bash |
|---|
| 109 | exec /usr/sbin/dhcpd -f |
|---|
| 110 | EOF |
|---|
| 111 | |
|---|
| 112 | mkdir -p $PKG/etc/postinst.d |
|---|
| 113 | cp $CWD/post.dhcp $PKG/etc/postinst.d || exit 1 |
|---|
| 114 | chmod +x $PKG/etc/postinst.d/post.dhcp || exit 1 |
|---|
| 115 | |
|---|
| 116 | chmod +x $PKG/service/dhcpd/run |
|---|
| 117 | cat client/scripts/linux > $PKG/sbin/dhclient-script |
|---|
| 118 | chmod 700 $PKG/sbin/dhclient-script |
|---|
| 119 | ( cd work.linux-2.2 |
|---|
| 120 | strip server/dhcpd client/dhclient relay/dhcrelay |
|---|
| 121 | cat server/dhcpd > $PKG/usr/sbin/dhcpd |
|---|
| 122 | cat relay/dhcrelay > $PKG/usr/sbin/dhcrelay |
|---|
| 123 | cat client/dhclient > $PKG/sbin/dhclient ) |
|---|
| 124 | mkdir -p $PKG/usr/man/man5 |
|---|
| 125 | mkdir -p $PKG/usr/man/man8 |
|---|
| 126 | for dir in client server ; do |
|---|
| 127 | cd $dir |
|---|
| 128 | for file in *.5 ; do |
|---|
| 129 | cat $file | sed -e "s#ETCDIR#/etc#g" -e "s#DBDIR#/var/db#g" \ |
|---|
| 130 | -e "s#RUNDIR#/var/run#g" | gzip -9c > $PKG/usr/man/man5/$file.gz |
|---|
| 131 | done |
|---|
| 132 | for file in *.8 ; do |
|---|
| 133 | cat $file | sed -e "s#ETCDIR#/etc#g" -e "s#DBDIR#/var/db#g" \ |
|---|
| 134 | -e "s#RUNDIR#/var/run#g" | gzip -9c > $PKG/usr/man/man8/$file.gz |
|---|
| 135 | done |
|---|
| 136 | cd .. |
|---|
| 137 | done |
|---|
| 138 | cat relay/dhcrelay.8 | sed -e "s#ETCDIR#/etc#g" -e "s#DBDIR#/var/db#g" \ |
|---|
| 139 | -e "s#RUNDIR#/var/run#g" | gzip -9c > $PKG/usr/man/man8/dhcrelay.8.gz |
|---|
| 140 | mkdir -p $PKG/install |
|---|
| 141 | cat $CWD/slack-desc > $PKG/install/slack-desc |
|---|
| 142 | |
|---|
| 143 | # Build the package: |
|---|
| 144 | cd $PKG |
|---|
| 145 | NAME=`echo $0|cut -f2 -d'.'` |
|---|
| 146 | makepkg -l y -c n $CWD/$NAME.pkg > /dev/null && |
|---|
| 147 | echo $VERSION > $CWD/$NAME.version && |
|---|
| 148 | arch > $CWD/$NAME.arch && |
|---|
| 149 | |
|---|
| 150 | # Clean up the extra stuff: |
|---|
| 151 | if [ ! "$1" = "--nocleanup" ]; then |
|---|
| 152 | rm -rf $TMP/dhcp-$VERSION |
|---|
| 153 | rm -rf $PKG |
|---|
| 154 | fi |
|---|