#!/bin/bash
if [ $# -eq 0 ]
  then
    echo "&lt;script> name"
    exit
fi

if [ ! -f lftp.exe ];
then
 echo "lftp.exe doesn't exist run this file from where it exists"
 exit
fi
cwd=`pwd`
items=`ldd.exe lftp.exe | grep --invert-match Windows | cut -d " " -f3`
tmpdir=`mktemp.exe --directory`
echo "Creating temporary directory $tmpdir"
mkdir $tmpdir/bin
mkdir $tmpdir/etc
for item in $items
do
 echo "Copying LFTP dependency file: $item to $tmpdir/bin"
 cp $item $tmpdir/bin
done
items=`ldd.exe /bin/ssh.exe | grep --invert-match Windows | cut -d " " -f3`
for item in $items
do
 echo "Copying SSH dependency file: $item"
 cp $item $tmpdir/bin
done
items=`ldd.exe /bin/bash.exe | grep --invert-match Windows | cut -d " " -f3`
for item in $items
do
 echo "Copying BASH dependency file: $item"
 cp $item $tmpdir/bin
done
echo "Copying required files"
cp lftp.exe $tmpdir/bin
cp ../lftp.conf $tmpdir/etc
cp /bin/ssh.exe $tmpdir/bin
cp /bin/bash.exe $tmpdir/bin
cd $tmpdir
cp -r $tmpdir /cygdrive/c/lftpbuilding/compiled/$1
cd /cygdrive/c/lftpbuilding/compiled/ 
cp GPL.txt $1/
cp nwgat.ninja.url $1/
cp lftp.conf $1/etc/
cd $1/
zip -r ../$1.zip ./*
