1#!/bin/sh
2CWD=`pwd`
3PKG=/tmp/package-dnsmasq
4
5VERSION=2.24
6ARCH=${ARCH:-i486}
7BUILD=${BUILD:-1}
8
9if [ "$ARCH" = "i386" ]; then
10  SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
11elif [ "$ARCH" = "i486" ]; then
12  SLKCFLAGS="-O2 -march=i486 -mcpu=i686"
13elif [ "$ARCH" = "s390" ]; then
14  SLKCFLAGS="-O2"
15elif [ "$ARCH" = "x86_64" ]; then
16  SLKCFLAGS="-O2"
17fi
18
19rm -rf $PKG
20mkdir -p $PKG
21cd /tmp
22rm -rf dnsmasq-$VERSION
23tar xzvf $CWD/dnsmasq-$VERSION.tar.gz
24cd dnsmasq-$VERSION
25zcat $CWD/dnsmasq.leasedir.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit
26chown -R root.root .
27make install-i18n PREFIX=/usr DESTDIR=$PKG MANDIR=/usr/man
28chmod 755 $PKG/usr/sbin/dnsmasq
29chown -R root.bin $PKG/usr/sbin
30gzip -9 $PKG/usr/man/man8/dnsmasq.8
31for f in $PKG/usr/share/man/*; do
32   if [ -f $$f/man8/dnsmasq.8 ]; then
33        gzip -9 $$f/man8/dnsmasq.8 ;
34   fi
35done
36gzip -9 $PKG/usr/man/*/man8/dnsmasq.8
37mkdir -p $PKG/var/state/dnsmasq
38( cd $PKG
39  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
40  find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
41)
42mkdir $PKG/etc
43cat dnsmasq.conf.example > $PKG/etc/dnsmasq.conf.new
44mkdir $PKG/etc/rc.d
45zcat $CWD/rc.dnsmasq.gz > $PKG/etc/rc.d/rc.dnsmasq.new
46mkdir -p $PKG/usr/doc/dnsmasq-$VERSION
47cp -a \
48  CHANGELOG COPYING FAQ UPGRADING_to_2.0 doc.html setup.html \
49  $PKG/usr/doc/dnsmasq-$VERSION
50mkdir -p $PKG/install
51cat $CWD/slack-desc > $PKG/install/slack-desc
52zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
53
54cd $PKG
55makepkg -l y -c n ../dnsmasq-$VERSION-$ARCH-$BUILD.tgz
56
57