#!/bin/bash
echo "copy packages?"
read copy
CWD=$(pwd)
for i in ../../newpkgs2/*.t?z;do 
	name=$(pkgname $i|cut -d"/" -f4)
	found=$(find . -name $name-[0-9]*t?z)
	dir=$(echo $found|cut -d"/" -f2)
	#echo $i
	#echo $name
	#echo $dir
	if [ $found ];then
		if [ "$copy" == "yes" ];then
			rm $(find . -name $name-[0-9]*)
			echo " copying $name $dir"
			cp $i $dir/
		else
			echo $Ji
		fi
	else
		echo "$i was not found"
		inlist=$(grep -R $name ../veclinux/)
		echo $inlist
		if [ ! "$inlist" ];then
			echo "$name is not in list"
			ls ../veclinux/*
			echo "which bulk?"
			read BULK
			echo $name >>../veclinux/$BULK
		fi
	fi
done
echo "check bulk lists?"
read ans
if [ "$ans" == "yes" ];then
for i in */*.t?z;do 
	#echo $i
	name=$(basename $(pkgname $i))
	found=$i
	dir=$(echo $found|cut -d"/" -f1)
	echo $name
	if [ $name == "vlconfig2" ];then
		echo "vlconfig2 should not bein lists"
	else
	  inlist=$(grep -R ^$name$ ../veclinux/|grep -v CD2)
	  echo $inlist
	  if [ "x$inlist" == "x" ];then
		echo "$name is not in list"
		ls ../veclinux/*
		echo "which bulk?"
		read BULK
		echo $name >>../veclinux/$BULK
	  fi
  	fi
done
fi

