#!/bin/sh # Heavily based on the Slackware 12.2 SlackBuild # Author: Gufo gufopeopleit - http://gufo.dontexist.org # License Gplv2 # Some suggestion taken from http://slackbuilds.org/ # Patch for kernel 2.6.23 added by Zapotech - No more needed for kernel 2.6.27.7-Slackware 12.2 APP=moblock VERSION=0.8 BUILD=${BUILD:-5gufo} ARCH=${ARCH:-i486} CWD=$(pwd) if [ "${TMP}" = "" ]; then TMP=/tmp fi if [ "$ARCH" = "i386" ]; then SLKCFLAGS="-O2 -march=i386 -mtune=i686" elif [ "$ARCH" = "i486" ]; then SLKCFLAGS="-O2 -march=i486 -mtune=i686" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC" fi PKG=${TMP}/${APP}-${VERSION}-build # Delete the leftover directories if they exist (due to a previous build) # and (re)create the packaging directory rm -rf ${PKG} ${TMP}/MoBlock-${VERSION} mkdir -p ${TMP} ${PKG} || exit 1 cd ${TMP} || exit 1 tar jxvf "$CWD"/MoBlock-${VERSION}-i586.tar.bz2 || exit 1 cd MoBlock-${VERSION} || exit 1 # Change ownership and permissions if necessary # This may not be needed in some source tarballs, but it never hurts chown -R root.root . chmod -R u+w,go+r-w,a-s . # This patch is needed for MoBlock to be used on kernel 2.6.23, in order to avoid MoBlock breaks down... # ...after the error message "NFNETLINK answers: Invalid argument". # This patch has no influence in moblock running on kernel versions < 2.6.23. Source: http://pastebin.archlinux.org/16670 # echo -e "\n Apply the patch-2.6.23..." # patch -p0 < $CWD/patch-2.6.23 CFLAGS="$SLKCFLAGS" make || exit 1 mkdir -p ${PKG}/usr/bin || exit 1 make install DESTDIR=${PKG} || exit 1 mkdir -p ${PKG}/install || exit 1 cp "$CWD"/slack-desc ${PKG}/install # Documentation mkdir -p ${PKG}/usr/doc/${APP}-${VERSION} || exit 1 cat $CWD/${APP}.SlackBuild > ${PKG}/usr/doc/${APP}-${VERSION}/${APP}.SlackBuild # Copy documentation to the docs directory and fix permissions cp -a *.sh README Changelog COPYING ${PKG}/usr/doc/${APP}-${VERSION} find ${PKG}/usr/doc/${APP}-${VERSION} -type f -exec chmod 644 {} \; #mkdir -p $PKG/usr/bin #cp -a MoBlock-ipq.sh MoBlock-nfq.sh $PKG/usr/bin/ mkdir -p $PKG/etc/moblock if [ -e $CWD/guarding.p2p.gz ]; then zcat $CWD/guarding.p2p.gz > ${PKG}/etc/moblock/guarding.p2p.new fi # Add doinst.sh to package (if it exists) if [ -e $CWD/doinst.sh.gz ]; then zcat $CWD/doinst.sh.gz > ${PKG}/install/doinst.sh fi if [ -e $CWD/rc.${APP}.gz ]; then mkdir ${PKG}/etc/rc.d/ zcat $CWD/rc.${APP}.gz > ${PKG}/etc/rc.d/rc.${APP}.new fi if [ -e $CWD/logrotate.gz ]; then mkdir ${PKG}/etc/logrotate.d/ zcat $CWD/logrotate.gz > ${PKG}/etc/logrotate.d/${APP}.new fi if [ -e $CWD/cron.daily.gz ]; then mkdir ${PKG}/etc/cron.daily zcat $CWD/cron.daily.gz > ${PKG}/etc/cron.daily/${APP}.new fi # Strip some libraries and binaries ( cd ${PKG} find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null ) # Compress man pages if they exist if [ -d ${PKG}/usr/man ]; then ( cd ${PKG}/usr/man find . -type f -exec gzip -9 {} \; for i in `find . -type l` ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done ) fi # Compress info pages if they exist (and remove the dir file) if [ -d ${PKG}/usr/info ]; then gzip -9 ${PKG}/usr/info/*.info rm -f ${PKG}/usr/info/dir fi cd ${PKG} requiredbuilder -v -y -s $CWD ${PKG} /sbin/makepkg -l y -c n ${TMP}/${APP}-${VERSION}-$ARCH-$BUILD.tgz cp ${TMP}/${APP}-${VERSION}-$ARCH-$BUILD.tgz "$CWD" rm -r ${PKG} ${TMP}/MoBlock-${VERSION}