[2154c77] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | # Copyright 2006, 2007, 2008, 2009, 2010, 2012, 2017, 2018 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 | cd $(dirname $0) ; CWD=$(pwd) |
---|
| 24 | |
---|
| 25 | PKGNAM=net-tools |
---|
| 26 | VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
---|
| 27 | BUILD=${BUILD:-3} |
---|
| 28 | |
---|
| 29 | # Automatically determine the architecture we're building on: |
---|
| 30 | if [ -z "$ARCH" ]; then |
---|
| 31 | case "$( uname -m )" in |
---|
| 32 | i?86) export ARCH=i586 ;; |
---|
| 33 | arm*) export ARCH=arm ;; |
---|
| 34 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
| 35 | *) export ARCH=$( uname -m ) ;; |
---|
| 36 | esac |
---|
| 37 | fi |
---|
| 38 | |
---|
| 39 | # If the variable PRINT_PACKAGE_NAME is set, then this script will report what |
---|
| 40 | # the name of the created package would be, and then exit. This information |
---|
| 41 | # could be useful to other scripts. |
---|
| 42 | if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then |
---|
| 43 | echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" |
---|
| 44 | exit 0 |
---|
| 45 | fi |
---|
| 46 | |
---|
| 47 | TMP=${TMP:-/tmp} |
---|
| 48 | PKG=$TMP/package-${PKGNAM} |
---|
| 49 | rm -rf $PKG |
---|
| 50 | mkdir -p $TMP $PKG |
---|
| 51 | |
---|
| 52 | if [ "$ARCH" = "i386" ]; then |
---|
| 53 | SLKCFLAGS="-O2 -march=i386 -mcpu=i686" |
---|
| 54 | elif [ "$ARCH" = "i586" ]; then |
---|
| 55 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
| 56 | elif [ "$ARCH" = "s390" ]; then |
---|
| 57 | SLKCFLAGS="-O2" |
---|
| 58 | elif [ "$ARCH" = "x86_64" ]; then |
---|
| 59 | SLKCFLAGS="-O2 -fPIC" |
---|
| 60 | else |
---|
| 61 | SLKCFLAGS="-O2" |
---|
| 62 | fi |
---|
| 63 | |
---|
| 64 | cd $TMP |
---|
| 65 | rm -rf net-tools-$VERSION |
---|
| 66 | tar xvf $CWD/net-tools-$VERSION.tar.xz || exit 1 |
---|
| 67 | cd net-tools-$VERSION || exit 1 |
---|
| 68 | |
---|
| 69 | zcat $CWD/net-tools.config.h.gz > config.h |
---|
| 70 | |
---|
| 71 | chown -R root:root . |
---|
| 72 | find . \ |
---|
| 73 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
| 74 | -exec chmod 755 {} \+ -o \ |
---|
| 75 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
| 76 | -exec chmod 644 {} \+ |
---|
| 77 | |
---|
| 78 | mkdir -p $PKG/usr/doc/net-tools-$VERSION |
---|
| 79 | cp -a \ |
---|
| 80 | COPYING* INSTALLING README* THANKS TODO \ |
---|
| 81 | $PKG/usr/doc/net-tools-$VERSION |
---|
| 82 | chmod 644 $PKG/usr/doc/net-tools-$VERSION/* |
---|
| 83 | chown root:root $PKG/usr/doc/net-tools-$VERSION/* |
---|
| 84 | HAVE_FW_MASQUERADE=1 HAVE_ARP_TOOLS=1 HAVE_HOSTNAME_TOOLS=1 \ |
---|
| 85 | HAVE_HOSTNAME_SYMLINKS=1 HAVE_IP_TOOLS=1 HAVE_MII=1 \ |
---|
| 86 | HAVE_PLIP_TOOLS=1 HAVE_SERIAL_TOOLS=1 make || exit 1 |
---|
| 87 | strip --strip-unneeded ipmaddr iptunnel hostname arp ifconfig nameif rarp route netstat plipconfig slattach mii-tool |
---|
| 88 | mkdir -p $PKG/sbin $PKG/bin $PKG/usr/sbin |
---|
| 89 | cat arp > $PKG/sbin/arp |
---|
| 90 | cat ifconfig > $PKG/sbin/ifconfig |
---|
| 91 | cat rarp > $PKG/sbin/rarp |
---|
| 92 | cat route > $PKG/sbin/route |
---|
| 93 | cat mii-tool > $PKG/sbin/mii-tool |
---|
| 94 | cat nameif > $PKG/sbin/nameif |
---|
| 95 | cat netstat > $PKG/bin/netstat |
---|
| 96 | cat plipconfig > $PKG/sbin/plipconfig |
---|
| 97 | cat slattach > $PKG/usr/sbin/slattach |
---|
| 98 | cat ipmaddr > $PKG/sbin/ipmaddr |
---|
| 99 | cat iptunnel > $PKG/sbin/iptunnel |
---|
| 100 | chmod 755 $PKG/sbin/* $PKG/bin/* $PKG/usr/sbin/* |
---|
| 101 | cd man/en_US |
---|
| 102 | mkdir -p $PKG/usr/man/man{1,5,8} |
---|
| 103 | cat ethers.5 | gzip -9c > $PKG/usr/man/man5/ethers.5.gz |
---|
| 104 | for page in arp.8 ifconfig.8 mii-tool.8 nameif.8 netstat.8 rarp.8 route.8 \ |
---|
| 105 | slattach.8 plipconfig.8 ; do |
---|
| 106 | cat $page | gzip -9c > $PKG/usr/man/man8/$page.gz |
---|
| 107 | done |
---|
| 108 | |
---|
| 109 | # This is a little Slackware-specific tool used in some of the network |
---|
| 110 | # related scripts to calculate network and broadcast addresses: |
---|
| 111 | ( cd $PKG/bin |
---|
| 112 | cc -O2 -o ipmask $CWD/ipmask.c |
---|
| 113 | strip --strip-unneeded ipmask |
---|
| 114 | chmod 755 ipmask |
---|
| 115 | ) |
---|
| 116 | cat $CWD/ipmask.8 | gzip -9c > $PKG/usr/man/man8/ipmask.8.gz |
---|
| 117 | |
---|
| 118 | mkdir -p $PKG/install |
---|
| 119 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
| 120 | |
---|
| 121 | cd $PKG |
---|
| 122 | makepkg -l y -c n $TMP/${PKGNAM}-$VERSION-$ARCH-$BUILD.txz |
---|
| 123 | |
---|