1 | #!/bin/bash |
---|
2 | |
---|
3 | # Copyright 2008, 2009, 2010, 2012, 2013, 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=iptables |
---|
26 | VERSION=${VERSION:-$(echo iptables-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
---|
27 | BUILD=${BUILD:-1} |
---|
28 | |
---|
29 | NUMJOBS=${NUMJOBS:-" -j$(expr $(nproc) + 1) "} |
---|
30 | |
---|
31 | # Automatically determine the architecture we're building on: |
---|
32 | if [ -z "$ARCH" ]; then |
---|
33 | case "$( uname -m )" in |
---|
34 | i?86) export ARCH=i586 ;; |
---|
35 | arm*) export ARCH=arm ;; |
---|
36 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
37 | *) export ARCH=$( uname -m ) ;; |
---|
38 | esac |
---|
39 | fi |
---|
40 | |
---|
41 | # If the variable PRINT_PACKAGE_NAME is set, then this script will report what |
---|
42 | # the name of the created package would be, and then exit. This information |
---|
43 | # could be useful to other scripts. |
---|
44 | if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then |
---|
45 | echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" |
---|
46 | exit 0 |
---|
47 | fi |
---|
48 | |
---|
49 | TMP=${TMP:-/tmp} |
---|
50 | PKG=$TMP/package-iptables |
---|
51 | |
---|
52 | if [ "$ARCH" = "i586" ]; then |
---|
53 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
54 | LIBDIRSUFFIX="" |
---|
55 | elif [ "$ARCH" = "s390" ]; then |
---|
56 | SLKCFLAGS="-O2" |
---|
57 | LIBDIRSUFFIX="" |
---|
58 | elif [ "$ARCH" = "x86_64" ]; then |
---|
59 | SLKCFLAGS="-O2 -fPIC" |
---|
60 | LIBDIRSUFFIX="64" |
---|
61 | else |
---|
62 | SLKCFLAGS="-O2" |
---|
63 | LIBDIRSUFFIX="" |
---|
64 | fi |
---|
65 | |
---|
66 | rm -rf $PKG |
---|
67 | mkdir -p $TMP $PKG |
---|
68 | cd $TMP |
---|
69 | rm -rf iptables-$VERSION |
---|
70 | tar xvf $CWD/iptables-$VERSION.tar.?z || exit 1 |
---|
71 | cd iptables-$VERSION || exit 1 |
---|
72 | |
---|
73 | chown -R root:root . |
---|
74 | find . \ |
---|
75 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
76 | -exec chmod 755 {} \; -o \ |
---|
77 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
78 | -exec chmod 644 {} \; |
---|
79 | |
---|
80 | CFLAGS="$SLKCFLAGS" \ |
---|
81 | ./configure \ |
---|
82 | --prefix=/usr \ |
---|
83 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
84 | --sysconfdir=/etc \ |
---|
85 | --mandir=/usr/man \ |
---|
86 | --docdir=/usr/doc/iptables-$VERSION \ |
---|
87 | --enable-devel \ |
---|
88 | --enable-libipq \ |
---|
89 | --enable-bpf-compiler \ |
---|
90 | --enable-nfsynproxy \ |
---|
91 | --disable-static \ |
---|
92 | --build=$ARCH-slackware-linux || exit 1 |
---|
93 | |
---|
94 | make $NUMJOBS || make || exit 1 |
---|
95 | make install DESTDIR=$PKG || exit 1 |
---|
96 | |
---|
97 | # Don't ship .la files: |
---|
98 | rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la |
---|
99 | |
---|
100 | find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ |
---|
101 | | cut -f 1 -d : | xargs strip --strip-debug 2> /dev/null |
---|
102 | |
---|
103 | # Compress and link manpages, if any: |
---|
104 | if [ -d $PKG/usr/man ]; then |
---|
105 | ( cd $PKG/usr/man |
---|
106 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
107 | ( cd $manpagedir |
---|
108 | for eachpage in $( find . -type l -maxdepth 1) ; do |
---|
109 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
110 | rm $eachpage |
---|
111 | done |
---|
112 | gzip -9 *.? |
---|
113 | ) |
---|
114 | done |
---|
115 | ) |
---|
116 | fi |
---|
117 | |
---|
118 | mkdir -p $PKG/usr/doc/iptables-$VERSION |
---|
119 | cp -a \ |
---|
120 | COPYING* INCOMPATIBILITIES INSTALL \ |
---|
121 | $PKG/usr/doc/iptables-$VERSION |
---|
122 | |
---|
123 | # If there's a ChangeLog, installing at least part of the recent history |
---|
124 | # is useful, but don't let it get totally out of control: |
---|
125 | if [ -r ChangeLog ]; then |
---|
126 | DOCSDIR=$(echo $PKG/usr/doc/*-$VERSION) |
---|
127 | cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog |
---|
128 | touch -r ChangeLog $DOCSDIR/ChangeLog |
---|
129 | fi |
---|
130 | |
---|
131 | mkdir -p $PKG/install |
---|
132 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
133 | |
---|
134 | cd $PKG |
---|
135 | /sbin/makepkg -l y -c n $TMP/iptables-$VERSION-$ARCH-$BUILD.txz |
---|
136 | |
---|