#!/bin/sh # Heavily based on the Slackware 12.0 SlackBuild # Set initial variables: NAME=firehol VERSION=${VERSION:-1.256} ARCH=${ARCH:-noarch} BUILD=${BUILD:-1kc} SOURCE=$NAME-$VERSION.tar.bz2 DOCS="COPYING ChangeLog README TODO WhatIsNew adblock.sh get-iana.sh doc/*" CWD=$(pwd) TMP=${TMP:-/tmp} OUT=${OUT:-/tmp} PKG=$TMP/package-$NAME SRC=$TMP/source-$NAME rm -rf $PKG $SRC || exit 1 # always erase old package and source tree mkdir -p $PKG $SRC $OUT [ "$(file $SOURCE | grep "bzip2 compressed data")" ] && tar -C $SRC -f $SOURCE -jvx [ "$(file $SOURCE | grep "gzip compressed data")" ] && tar -C $SRC -f $SOURCE -vxz ################################################## cd $SRC/* || exit 1 # SOURCE TREE ################################################## # Reset perm/user/group: find . -perm +111 -exec chmod 755 {} \; find . ! -perm +111 -exec chmod 644 {} \; chown -R root:root . # +++ add examples and script +++ mkdir -p $PKG/etc/firehol/services cp -a examples $PKG/etc/firehol mkdir -p $PKG/sbin cp -a firehol.sh $PKG/sbin/firehol chmod 750 $PKG/sbin/firehol # +++ add man pages +++ mkdir -p $PKG/usr/man/man1 $PKG/usr/man/man5 cp -a man/firehol.1 $PKG/usr/man/man1 cp -a man/firehol.conf.5 $PKG/usr/man/man5 # Add documentation: mkdir -p $PKG/usr/doc/$NAME-$VERSION cp -a $DOCS $PKG/usr/doc/$NAME-$VERSION ################################################## cd $PKG || exit 1 # PACKAGE TREE ################################################## # Compress info and man pages: rm -f usr/info/dir find usr/info usr/man -exec gzip -9 {} \; 2>/dev/null for link in $(find usr/info usr/man -type l ! -name \*.gz 2>/dev/null); do # fix symlinks ln -s $(readlink $link).gz $link.gz && rm $link done # Add install files: mkdir install cat $CWD/slack-desc > install/slack-desc [ -r "$CWD/slack-required" ] && cat $CWD/slack-required > install/slack-required [ -r "$CWD/doinst.sh" ] && cat $CWD/doinst.sh > install/doinst.sh # List files with unusual perm/user/group: find . -type d ! -perm 755 -exec ls -ld {} \; find . ! -type d ! -type l -perm +7022 -exec ls -ld {} \; find . ! -user root -exec ls -ld {} \; find . ! -group root ! -group bin -exec ls -ld {} \; # Build the package: requiredbuilder -v -y -s $CWD $PKG makepkg -l y -c n $OUT/$NAME-$VERSION-$ARCH-$BUILD.tgz # Clean up the extra stuff: [ "$1" = "--cleanup" ] && rm -rf $SRC $PKG