#!/bin/bash/
###SBuildCheck2.sh

CWD=$(pwd)
found="false"
rm /tmp/sources.txt
rm /tmp/directory.txt
echo "abs" >> /tmp/sources.txt
echo "alien" >> /tmp/sources.txt
echo "current" >> /tmp/sources.txt
echo "phantomX" >> /tmp/sources.txt
echo "testing" >> /tmp/sources.txt

echo "a" >> /tmp/directory.txt
echo "ap" >> /tmp/directory.txt
echo "d" >> /tmp/directory.txt
echo "emulators" >> /tmp/directory.txt
echo "games" >> /tmp/directory.txt
echo "kde" >> /tmp/directory.txt
echo "l" >> /tmp/directory.txt
echo "n" >> /tmp/directory.txt
echo "x" >> /tmp/directory.txt
echo "xap" >> /tmp/directory.txt
echo "xfce" >> /tmp/directory.txt

###Get the name of the application you are looking for and dump it into a variable.
echo "Please, enter name of package"
read PKGNAME

while read sources
do

while read directory
do
if [ "$found" = "false" ];
then
wget -r -L  http://vectorlinux.osuosl.org/veclinux-7.0/source/$sources/$directory/$PKGNAME/
fi
if [ $? -eq 0 ];
	then
	if [ "$found" = "false" ];
	then
	echo "Source found for package "$PKGNAME
	fi
	found="true"
fi

done < /tmp/directory.txt
done < /tmp/sources.txt
cd $CWD
find ./ -name "index.html*" -execdir rm {} \;
find ./ -name "header-inc" -execdir rm -r {} \;
find ./ -name "icons" -execdir rm -r {} \;
rm /tmp/sources.txt
rm /tmp/directory.txt
