#!/bin/sh ## SlackBuild: kismet ## Creator: D4rksh3ll < d4rksh3ll@gmail.com > ## Heavily based on the Slackware 12.0 SlackBuild ## #---------------- General Config EXT="d4rksh3ll" ARCH="i486" WGET="/usr/bin/wget -c" CWD=`pwd` #---------------- Package Config NAME="kismet" VERSION="2007-10-R1" BUILD="1$EXT" SOURCE="http://www.kismetwireless.net/code/$NAME-$VERSION.tar.gz" #---------------- Defining DOCS DOCFILES="ABOUT ABOUT-NLS ANNOUNCE AUTHORS CONFIGURATION CHANGES COPYING COPYRIGHT CREDITS \ ChangeLog CHANGELOG CONTRIBUTORS *FAQ* FEATURES FILES HACKING History HISTORY \ INSTALL* LICENSE LSM MANIFEST NEWS *README* *Readme* SITES *RELEASE* RELNOTES \ THANKS TIPS TODO VERSION CONFIGURATION* GPL License Doc doc Docs* docs* Roadmap \ ROADMAP *BUGS* index.ht* *INDEX*" #---------------- Checking that user is root if [ "$UID" -ne 0 ] ; then echo "You must be root to run this script." exit 1 fi #---------------- Setting up arch, and umask ## Determin the CFLAGS based on the arch from above if [ "$ARCH" = "i386" ]; then CFLAGS="-O2 -march=i386 -mcpu=i686" elif [ "$ARCH" = "i486" ]; then CFLAGS="-O2 -march=i486 -mtune=i686" elif [ "$ARCH" = "i686" ]; then CFLAGS="-O2 -march=i686 -mcpu=i686" elif [ "$ARCH" = "x86_64" ]; then CFLAGS="-O2 -march=x86_64" fi ## Default root umask, 0077, will bild broken packages umask 0022 #---------------- Getting Source ## Download the source if it is not present if [ -a $CWD/$NAME-$VERSION.tar.gz ]; then echo "Source for $NAME - $VERSION present not downloading" else $WGET $SOURCE || true fi ## Preparing build directory PKG="/tmp/package-$NAME" rm -rf $PKG mkdir -p $PKG ## Unpacking source code tar xvzf $CWD/$NAME-$VERSION.tar.gz cd $NAME-$VERSION ## Fixing source code permissions chown -R root:root . find . -perm 664 -exec chmod 644 {} \; find . -perm 600 -exec chmod 644 {} \; find . -perm 444 -exec chmod 644 {} \; find . -perm 400 -exec chmod 644 {} \; find . -perm 440 -exec chmod 644 {} \; find . -perm 777 -exec chmod 755 {} \; find . -perm 775 -exec chmod 755 {} \; find . -perm 511 -exec chmod 755 {} \; find . -perm 711 -exec chmod 755 {} \; find . -perm 555 -exec chmod 755 {} \; find . -perm 666 -exec chmod 644 {} \; ## Building Package if [ ! -r configure ]; then sh autogen.sh fi ./configure \ --prefix=/usr \ --sysconfdir=/etc \ --localstatedir=/var \ --mandir=/usr/man \ --program-prefix= \ --program-suffix= \ --build=$ARCH-slackware-linux make -j4 || return 1 make install DESTDIR=$PKG ## Moving DOCS to correct place DOCS="$PKG/usr/doc/$NAME-$VERSION" mkdir -p ${DOCS} for i in ${DOCFILES}; do if [ -e ${i} ]; then if ! [ -L ${i} ]; then cp -a ${i} ${DOCS} else cp -LRp ${i} ${DOCS} fi fi; done chmod 644 $PKG/usr/doc/$NAME-$VERSION/* chown -R root:root $PKG/usr/doc/$NAME-$VERSION/* ## Moving to package directory cd $PKG ## Strip binaries find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null ## Strip libreries find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null ## Gzipping man pages and infopages (rm /usr/info/dir) gzip -9q $PKG/usr/man/*/* ## Preparing /install directory mkdir -p $PKG/install # |-----handy-ruler------------------------------------------------------| cat > $PKG/install/slack-desc << END # HOW TO EDIT THIS FILE: # The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' on # the right side marks the last column you can put a character in. You must make # exactly 11 lines for the formatting to be correct. It's also customary to # leave one space after the ':'. |-----------------handy-ruler-------------------------------------------| $NAME: $NAME $VERSION $NAME: $NAME: Kismet is an 802.11 layer2 wireless network detector, sniffer, and $NAME: intrusion detection system. Kismet will work with any wireless card $NAME: which supports raw monitoring (rfmon) mode, and can sniff 802.11b, $NAME: 802.11a, and 802.11g traffic. $NAME: $NAME: $NAME: $NAME: Package by D4rksh3ll $NAME: END cat > $PKG/install/doinst.sh << __END__ #!/bin/sh config() { NEW="\$1" OLD="\`dirname \$NEW\`/\`basename \$NEW .new\`" # If there's no config file by that name, mv it over: if [ ! -r \$OLD ]; then mv \$NEW \$OLD elif [ "\`cat \$OLD | md5sum\`" = "\`cat \$NEW | md5sum\`" ]; then # toss the redundant copy rm \$NEW fi # Otherwise, we leave the .new copy for the admin to consider... } config etc/kismet.conf.new config etc/kismet_ui.conf.new config etc/kismet_drone.conf.new config etc/client_manuf.new config etc/ap_manuf.new __END__ mv $PKG/etc/kismet.conf $PKG/etc/kismet.conf.new mv $PKG/etc/kismet_ui.conf $PKG/etc/kismet_ui.conf.new mv $PKG/etc/kismet_drone.conf $PKG/etc/kismet_drone.conf.new mv $PKG/etc/ap_manuf $PKG/etc/ap_manuf.new mv $PKG/etc/client_manuf $PKG/etc/client_manuf.new ## Building package cd $PKG requiredbuilder -v -y -s $CWD $PKG makepkg -l y -c n $CWD/$NAME-${VERSION//-/.}-$ARCH-$BUILD.tgz cp $PKG/install/slack-desc $CWD/$NAME-${VERSION//-/.}-$ARCH-$BUILD.txt ## Done