1 | #!/bin/sh |
---|
2 | |
---|
3 | # Copyright 2008, 2009, 2010, 2011, 2012 Patrick J. Volkerding, Sebeka, MN, USA |
---|
4 | # All rights reserved. |
---|
5 | # |
---|
6 | # Redistribution and use of this script, with or without modification, is |
---|
7 | # permitted provided that the following conditions are met: |
---|
8 | # |
---|
9 | # 1. Redistributions of this script must retain the above copyright |
---|
10 | # notice, this list of conditions and the following disclaimer. |
---|
11 | # |
---|
12 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
---|
13 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
---|
14 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
---|
15 | # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
16 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
17 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
---|
18 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
---|
19 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
---|
20 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
---|
21 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
22 | |
---|
23 | |
---|
24 | PKGNAM=dhcp |
---|
25 | # Leave this one .gz as other compressors do not help much and we can keep |
---|
26 | # the original upstream .asc |
---|
27 | VERSION=${VERSION:-$(basename $(echo $PKGNAM-*.tar.gz | cut -f 2- -d -) .tar.gz)} |
---|
28 | BUILD=${BUILD:-1} |
---|
29 | |
---|
30 | PKG_VERSION=$(echo $VERSION | tr - _) |
---|
31 | |
---|
32 | NUMJOBS=${NUMJOBS:-" -j7 "} |
---|
33 | |
---|
34 | # Automatically determine the architecture we're building on: |
---|
35 | if [ -z "$ARCH" ]; then |
---|
36 | case "$( uname -m )" in |
---|
37 | i?86) export ARCH=i586 ;; |
---|
38 | arm*) export ARCH=arm ;; |
---|
39 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
40 | *) export ARCH=$( uname -m ) ;; |
---|
41 | esac |
---|
42 | fi |
---|
43 | |
---|
44 | CWD=$(pwd) |
---|
45 | TMP=${TMP:-/tmp} |
---|
46 | PKG=$TMP/package-dhcp |
---|
47 | |
---|
48 | if [ "$ARCH" = "i586" ]; then |
---|
49 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
50 | LIBDIRSUFFIX="" |
---|
51 | elif [ "$ARCH" = "s390" ]; then |
---|
52 | SLKCFLAGS="-O2" |
---|
53 | LIBDIRSUFFIX="" |
---|
54 | elif [ "$ARCH" = "x86_64" ]; then |
---|
55 | SLKCFLAGS="-O2 -fPIC" |
---|
56 | LIBDIRSUFFIX="64" |
---|
57 | else |
---|
58 | SLKCFLAGS="-O2" |
---|
59 | LIBDIRSUFFIX="" |
---|
60 | fi |
---|
61 | |
---|
62 | rm -rf $PKG |
---|
63 | mkdir -p $TMP $PKG |
---|
64 | |
---|
65 | cd $TMP |
---|
66 | rm -rf dhcp-$VERSION |
---|
67 | tar xvf $CWD/dhcp-$VERSION.tar.gz || exit 1 |
---|
68 | cd dhcp-$VERSION || exit 1 |
---|
69 | |
---|
70 | chown -R root:root . |
---|
71 | find . \ |
---|
72 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
73 | -exec chmod 755 {} \; -o \ |
---|
74 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
75 | -exec chmod 644 {} \; |
---|
76 | |
---|
77 | cat $CWD/dhcommon-getifaddrs.patch | patch -p1 || exit 1 |
---|
78 | |
---|
79 | # Add PATH setting to /sbin/dhclient-script |
---|
80 | zcat $CWD/dhclient-script.PATH.diff.gz | patch -p1 || exit 1 |
---|
81 | |
---|
82 | |
---|
83 | # Fix paths in manual pages |
---|
84 | sed -i \ |
---|
85 | -e "s,ETCDIR,/etc,g" \ |
---|
86 | -e "s,DBDIR,/var/state/dhcp,g" \ |
---|
87 | -e "s,RUNDIR,/var/run,g" \ |
---|
88 | client/*.{5,8} \ |
---|
89 | server/*.{5,8} \ |
---|
90 | doc/*/*.{5,8} |
---|
91 | |
---|
92 | CFLAGS="$SLKCFLAGS" \ |
---|
93 | ./configure \ |
---|
94 | --prefix=/usr \ |
---|
95 | --sysconfdir=/etc \ |
---|
96 | --localstatedir=/var \ |
---|
97 | --infodir=/usr/info \ |
---|
98 | --mandir=/usr/man \ |
---|
99 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
100 | --docdir=/usr/doc/dhcp-$VERSION \ |
---|
101 | --build=$ARCH-slackware-linux \ |
---|
102 | --with-srv-lease-file=/var/state/dhcp/dhcpd.leases \ |
---|
103 | --with-srv6-lease-file=/var/state/dhcp/dhcpd6.leases \ |
---|
104 | --with-cli-lease-file=/var/state/dhcp/dhclient.leases \ |
---|
105 | --with-cli6-lease-file=/var/state/dhcp/dhclient6.leases |
---|
106 | # Default pid dir is still /var/run, so no need to declare it |
---|
107 | |
---|
108 | make $NUMJOBS || make || exit 1 |
---|
109 | make install DESTDIR=$PKG || exit 1 |
---|
110 | |
---|
111 | # DHCP libraries need not be included, yet. |
---|
112 | rm -rf $PKG/usr/{include,lib${LIBDIRSUFFIX}} |
---|
113 | |
---|
114 | # We need this in /sbin |
---|
115 | mkdir -p $PKG/sbin |
---|
116 | mv $PKG/usr/sbin/dhclient $PKG/sbin |
---|
117 | |
---|
118 | # Install the dhclient-script for linux |
---|
119 | cat client/scripts/linux > $PKG/sbin/dhclient-script |
---|
120 | chmod 700 $PKG/sbin/dhclient-script |
---|
121 | |
---|
122 | # Create the initial *.leases files: |
---|
123 | mkdir -p $PKG/var/state/dhcp |
---|
124 | touch $PKG/var/state/dhcp/dhcpd.leases.new |
---|
125 | touch $PKG/var/state/dhcp/dhcpd6.leases.new |
---|
126 | touch $PKG/var/state/dhcp/dhclient.leases.new |
---|
127 | touch $PKG/var/state/dhcp/dhclient6.leases.new |
---|
128 | |
---|
129 | cat << EOF > $PKG/etc/dhcpd.conf.new |
---|
130 | # dhcpd.conf |
---|
131 | # |
---|
132 | # Configuration file for ISC dhcpd (see 'man dhcpd.conf') |
---|
133 | # |
---|
134 | EOF |
---|
135 | |
---|
136 | cat << EOF > $PKG/etc/dhclient.conf.new |
---|
137 | # dhclient.conf |
---|
138 | # |
---|
139 | # Configuration file for ISC dhclient (see 'man dhclient.conf') |
---|
140 | # |
---|
141 | EOF |
---|
142 | |
---|
143 | # Compress and if needed symlink the man pages: |
---|
144 | if [ -d $PKG/usr/man ]; then |
---|
145 | ( cd $PKG/usr/man |
---|
146 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
147 | ( cd $manpagedir |
---|
148 | for eachpage in $( find . -type l -maxdepth 1) ; do |
---|
149 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
150 | rm $eachpage |
---|
151 | done |
---|
152 | gzip -9 *.? |
---|
153 | ) |
---|
154 | done |
---|
155 | ) |
---|
156 | fi |
---|
157 | |
---|
158 | find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ |
---|
159 | | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
160 | |
---|
161 | mkdir -p $PKG/usr/doc/dhcp-$VERSION/examples |
---|
162 | cp -a \ |
---|
163 | LICENSE README RELNOTES \ |
---|
164 | $PKG/usr/doc/dhcp-$VERSION |
---|
165 | #mv $PKG/etc/dhcpd.conf $PKG/etc/dhclient.conf \ |
---|
166 | # $PKG/usr/doc/dhcp-$VERSION/examples |
---|
167 | |
---|
168 | # If there's a ChangeLog, installing at least part of the recent history |
---|
169 | # is useful, but don't let it get totally out of control: |
---|
170 | if [ -r ChangeLog ]; then |
---|
171 | DOCSDIR=$(echo $PKG/usr/doc/*-$VERSION) |
---|
172 | cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog |
---|
173 | touch -r ChangeLog $DOCSDIR/ChangeLog |
---|
174 | fi |
---|
175 | |
---|
176 | mkdir -p $PKG/install |
---|
177 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
178 | zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh |
---|
179 | |
---|
180 | cd $PKG |
---|
181 | /sbin/makepkg -l y -c n $TMP/dhcp-$PKG_VERSION-$ARCH-$BUILD.txz |
---|
182 | |
---|