[ebc5ae5] | 1 | #!/bin/sh |
---|
| 2 | |
---|
| 3 | # Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 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=bind |
---|
| 25 | VERSION=${VERSION:-9.11.0-P2} |
---|
| 26 | BUILD=${BUILD:-1} |
---|
| 27 | |
---|
| 28 | # Automatically determine the architecture we're building on: |
---|
| 29 | if [ -z "$ARCH" ]; then |
---|
| 30 | case "$( uname -m )" in |
---|
| 31 | i?86) export ARCH=i586 ;; |
---|
| 32 | arm*) export ARCH=arm ;; |
---|
| 33 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
| 34 | *) export ARCH=$( uname -m ) ;; |
---|
| 35 | esac |
---|
| 36 | fi |
---|
| 37 | |
---|
| 38 | NUMJOBS=${NUMJOBS:-" -j7 "} |
---|
| 39 | |
---|
| 40 | CWD=$(pwd) |
---|
| 41 | TMP=/bind-$(mcookie) |
---|
| 42 | PKG=$TMP/package-${PKGNAM} |
---|
| 43 | rm -rf $PKG |
---|
| 44 | mkdir -p $TMP $PKG/etc/default |
---|
| 45 | |
---|
| 46 | if [ "$ARCH" = "i586" ]; then |
---|
| 47 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
| 48 | LIBDIRSUFFIX="" |
---|
| 49 | elif [ "$ARCH" = "s390" ]; then |
---|
| 50 | SLKCFLAGS="-O2" |
---|
| 51 | LIBDIRSUFFIX="" |
---|
| 52 | elif [ "$ARCH" = "x86_64" ]; then |
---|
| 53 | SLKCFLAGS="-O2 -fPIC" |
---|
| 54 | LIBDIRSUFFIX="64" |
---|
| 55 | fi |
---|
| 56 | |
---|
| 57 | cd $TMP |
---|
| 58 | rm -rf ${PKGNAM}-${VERSION} |
---|
| 59 | tar xvf $CWD/${PKGNAM}-$VERSION.tar.gz || exit 1 |
---|
| 60 | cd ${PKGNAM}-$VERSION || exit 1 |
---|
| 61 | |
---|
| 62 | # Remove use of SO_BSDCOMPAT which has been obsolete since the 2.2.x kernel |
---|
| 63 | # series, and generates warnings under 2.6.x kernels. This _might_ be fixed |
---|
| 64 | # upstream already, but an explicit #undef SO_BSDCOMPAT does not hurt: |
---|
| 65 | zcat $CWD/bind.so_bsdcompat.diff.gz | patch -p1 --verbose || exit |
---|
| 66 | |
---|
| 67 | # Make sure ownerships and permissions are sane: |
---|
| 68 | chown -R root:root . |
---|
| 69 | find . \ |
---|
| 70 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
| 71 | -exec chmod 755 {} \; -o \ |
---|
| 72 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
| 73 | -exec chmod 644 {} \; |
---|
| 74 | |
---|
| 75 | # Configure: |
---|
| 76 | CFLAGS="$SLKCFLAGS" \ |
---|
| 77 | ./configure \ |
---|
| 78 | --prefix=/usr \ |
---|
| 79 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
| 80 | --sysconfdir=/etc \ |
---|
| 81 | --localstatedir=/var \ |
---|
| 82 | --with-libtool \ |
---|
| 83 | --with-idn=/usr \ |
---|
| 84 | --mandir=/usr/man \ |
---|
| 85 | --enable-shared \ |
---|
| 86 | --disable-static \ |
---|
| 87 | --enable-threads \ |
---|
| 88 | --with-openssl=/usr \ |
---|
| 89 | --build=$ARCH-slackware-linux || exit 1 |
---|
| 90 | |
---|
| 91 | # Build and install: |
---|
| 92 | make $NUMJOBS || make || exit 1 |
---|
| 93 | make install DESTDIR=$PKG || exit 1 |
---|
| 94 | |
---|
| 95 | # We like symlinks. |
---|
| 96 | ( cd $PKG/usr/sbin |
---|
| 97 | ln -sf named lwresd |
---|
| 98 | ) |
---|
| 99 | |
---|
| 100 | # We like a lot of symlinks. |
---|
| 101 | ( cd $PKG/usr/man/man3 |
---|
| 102 | sh $CWD/3link.sh |
---|
| 103 | ) |
---|
| 104 | |
---|
| 105 | # Install init script: |
---|
| 106 | mkdir -p $PKG/etc/rc.d |
---|
| 107 | cp -a $CWD/rc.bind $PKG/etc/rc.d/rc.bind.new |
---|
| 108 | chmod 644 $PKG/etc/rc.d/rc.bind.new |
---|
| 109 | |
---|
| 110 | # Add /var/run/named directory: |
---|
| 111 | mkdir -p $PKG/var/run/named |
---|
| 112 | |
---|
| 113 | # Fix library perms: |
---|
| 114 | chmod 755 $PKG/usr/lib${LIBDIRSUFFIX}/* |
---|
| 115 | |
---|
| 116 | # Strip binaries: |
---|
| 117 | find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ |
---|
| 118 | | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
| 119 | |
---|
| 120 | # Symlink hardlinked man pages: |
---|
| 121 | ( cd $PKG/usr/man/man1 |
---|
| 122 | ln -sf isc-config.sh.1 bind9-config.1 |
---|
| 123 | ) |
---|
| 124 | |
---|
| 125 | # Compress manual pages: |
---|
| 126 | find $PKG/usr/man -type f -exec gzip -9 {} \; |
---|
| 127 | for i in $( find $PKG/usr/man -type l ) ; do |
---|
| 128 | ln -s $( readlink $i ).gz $i.gz |
---|
| 129 | rm $i |
---|
| 130 | done |
---|
| 131 | |
---|
| 132 | # Add a documentation directory: |
---|
| 133 | mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION |
---|
| 134 | cp -a \ |
---|
| 135 | CHANGES COPYRIGHT FAQ* README* \ |
---|
| 136 | doc/arm doc/misc \ |
---|
| 137 | $PKG/usr/doc/${PKGNAM}-$VERSION |
---|
| 138 | |
---|
| 139 | # This one should have the correct perms of the config file: |
---|
| 140 | #chmod 644 $PKG/usr/doc/${PKGNAM}-$VERSION/misc/rndc.conf-sample |
---|
| 141 | |
---|
| 142 | # One format of this is plenty. Especially get rid of the bloated PDF. |
---|
| 143 | ( cd $PKG/usr/doc/bind-$VERSION/arm |
---|
| 144 | rm -f Makefile* *.pdf *.xml README.SGML latex-fixup.pl |
---|
| 145 | ) |
---|
| 146 | |
---|
| 147 | # Add sample config files for a simple caching nameserver: |
---|
| 148 | mkdir -p $PKG/var/named/caching-example |
---|
| 149 | cat $CWD/caching-example/named.conf > $PKG/etc/named.conf.new |
---|
| 150 | cat $CWD/caching-example/localhost.zone > $PKG/var/named/caching-example/localhost.zone |
---|
| 151 | cat $CWD/caching-example/named.local > $PKG/var/named/caching-example/named.local |
---|
| 152 | cat $CWD/caching-example/named.root > $PKG/var/named/caching-example/named.root |
---|
| 153 | # This name is deprecated, but having it here doesn't hurt in case |
---|
| 154 | # an old configuration file wants it: |
---|
| 155 | cat $CWD/caching-example/named.root > $PKG/var/named/caching-example/named.ca |
---|
| 156 | |
---|
| 157 | mkdir -p $PKG/install |
---|
| 158 | zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh |
---|
| 159 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
| 160 | |
---|
| 161 | cd $PKG |
---|
| 162 | /sbin/makepkg -l y -c n $TMP/${PKGNAM}-$(echo $VERSION | tr - _)-$ARCH-$BUILD.txz |
---|
| 163 | |
---|