[94a6f37] | 1 | #!/bin/bash |
---|
[6a55355] | 2 | |
---|
[94a6f37] | 3 | # Copyright 2014, 2018 Patrick J. Volkerding, Sebeka, Minnesota, USA |
---|
[6a55355] | 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 | |
---|
[94a6f37] | 23 | cd $(dirname $0) ; CWD=$(pwd) |
---|
| 24 | |
---|
[6a55355] | 25 | PKGNAM=libnftnl |
---|
[94a6f37] | 26 | VERSION=${VERSION:-$(echo $PKGNAM-*.tar.lz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
---|
[6a55355] | 27 | BUILD=${BUILD:-1} |
---|
| 28 | |
---|
[94a6f37] | 29 | NUMJOBS=${NUMJOBS:-" -j$(expr $(nproc) + 1) "} |
---|
[6a55355] | 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 | |
---|
[94a6f37] | 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 | |
---|
[6a55355] | 49 | if [ "$ARCH" = "i586" ]; then |
---|
| 50 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
| 51 | LIBDIRSUFFIX="" |
---|
| 52 | elif [ "$ARCH" = "s390" ]; then |
---|
| 53 | SLKCFLAGS="-O2" |
---|
| 54 | LIBDIRSUFFIX="" |
---|
| 55 | elif [ "$ARCH" = "x86_64" ]; then |
---|
| 56 | SLKCFLAGS="-O2 -fPIC" |
---|
| 57 | LIBDIRSUFFIX="64" |
---|
| 58 | else |
---|
| 59 | SLKCFLAGS="-O2" |
---|
| 60 | LIBDIRSUFFIX="" |
---|
| 61 | fi |
---|
| 62 | |
---|
| 63 | TMP=${TMP:-/tmp} |
---|
| 64 | PKG=$TMP/package-$PKGNAM |
---|
| 65 | |
---|
| 66 | rm -rf $PKG |
---|
| 67 | mkdir -p $TMP $PKG |
---|
| 68 | |
---|
| 69 | cd $TMP |
---|
| 70 | rm -rf $PKGNAM-$VERSION |
---|
[94a6f37] | 71 | tar xf $CWD/$PKGNAM-$VERSION.tar.lz || exit 1 |
---|
[6a55355] | 72 | cd $PKGNAM-$VERSION || exit 1 |
---|
| 73 | |
---|
| 74 | chown -R root:root . |
---|
| 75 | find . \ |
---|
| 76 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
| 77 | -exec chmod 755 {} \; -o \ |
---|
| 78 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
| 79 | -exec chmod 644 {} \; |
---|
| 80 | |
---|
| 81 | CFLAGS="$SLKCFLAGS" \ |
---|
| 82 | CXXFLAGS="$SLKCFLAGS" \ |
---|
| 83 | ./configure \ |
---|
| 84 | --prefix=/usr \ |
---|
| 85 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
| 86 | --sysconfdir=/etc \ |
---|
| 87 | --localstatedir=/var \ |
---|
| 88 | --mandir=/usr/man \ |
---|
| 89 | --docdir=/usr/doc/$PKGNAM-$VERSION \ |
---|
| 90 | --disable-static \ |
---|
| 91 | --build=$ARCH-slackware-linux || exit 1 |
---|
| 92 | |
---|
| 93 | make $NUMJOBS || make || exit 1 |
---|
| 94 | make install DESTDIR=$PKG || exit 1 |
---|
| 95 | |
---|
| 96 | rm -f $PKG/usr/lib${LIBDIRSUFFIX}/*.la |
---|
| 97 | |
---|
| 98 | find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | \ |
---|
| 99 | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true |
---|
| 100 | |
---|
| 101 | # Compress and if needed symlink the man pages: |
---|
| 102 | if [ -d $PKG/usr/man ]; then |
---|
| 103 | ( cd $PKG/usr/man |
---|
| 104 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
| 105 | ( cd $manpagedir |
---|
| 106 | for eachpage in $( find . -type l -maxdepth 1) ; do |
---|
| 107 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
| 108 | rm $eachpage |
---|
| 109 | done |
---|
| 110 | gzip -9 *.? |
---|
| 111 | ) |
---|
| 112 | done |
---|
| 113 | ) |
---|
| 114 | fi |
---|
| 115 | |
---|
| 116 | mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION |
---|
[94a6f37] | 117 | cp -a COPYING* $PKG/usr/doc/$PKGNAM-$VERSION |
---|
[6a55355] | 118 | |
---|
| 119 | mkdir -p $PKG/install |
---|
| 120 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
| 121 | |
---|
| 122 | cd $PKG |
---|
| 123 | /sbin/makepkg -l y -c n $TMP/$PKGNAM-$VERSION-$ARCH-$BUILD.txz |
---|