#!/bin/sh
#
######################################################
# nbtscan TCE package for TinyCore 2.x               #
#                                                    #
# NetBIOS Name Netwwork Scanner                      #
#                                                    #
# Packed by Bela Markus, bmarkus@hasix.org           #
#                                                    #
# Package home http://www.inetcat.net                #
#                                                    #
# September 15, 2009                                 #
######################################################
#
# Define package names and tmp directory
#
SRCNAM=nbtscan-1.5.1.tar.gz
WRKDIR=nbtscan-1.5.1a
EXTNAM=nbtscan
TMPDIR=/tmp/nbtscan
#
# Export variables needed for compilation
#
export CFLAGS="-march=i486 -mtune=i686 -Os -pipe"
export CXXFLAGS="-march=i486 -mtune=i686 -Os -pipe -fno-exceptions -fno-rtti"
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
#
# Remove dirs and files left from previous creation
#
rm -r -f $TMPDIR
rm -r -f $WRKDIR
#
# Crete temporary directory
#
mkdir -p $TMPDIR
#
# Unpack source in current directory
#
tar -xf $SRCNAM
#
# Configure it
#
cd $WRKDIR
#
./configure
#./configure --prefix=/usr/local
#
# Compile
#
make
#make install DESTDIR=$TMPDIR
#
#
# Create directory structure and move files as
# --prefix and DESTDIR options not honored
#
mkdir -p $TMPDIR/usr/local/sbin
cp nbtscan $TMPDIR/usr/local/sbin
#
# Adjust directory access rigths
#
find $TMPDIR/ -type d | xargs chmod -v 755;
#
# Strip executables
#
find $TMPDIR | xargs file | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded
#
# Delete compilation work directory
#
cd ..
rm -r -f $WRKDIR
#
# Create .tcz extension in temp dir
#
cd  $TMPDIR
cd ..
mksquashfs $TMPDIR $EXTNAM.tcz
cd  $TMPDIR
find usr -not -type d > $EXTNAM.list
mv ../$EXTNAM.tcz .
#
# Create md5 file
#
md5sum $EXTNAM.tcz > $EXTNAM.tcz.md5.txt
#
# Cleanup temp directory
#
rm -r -f usr  
