#/bin/sh

rm -rf slackel
rm -rf temp
mkdir -p slackel/{kernels,core,basic,full,settings}
mkdir -p temp

find /var/slapt-get -name *.t[gx]z -exec cp {} temp/ \;

for i in `cat lists/KERNEL`; do
	find temp/ | grep /$i- | sed "/$i-.*-.*-.*-.*/d" >> temp/KERNELLIST
done

for i in `cat lists/CORE`; do
	find temp/ | grep /$i- | sed "/$i-.*-.*-.*-.*/d" >> temp/CORELIST
done

for i in `cat lists/BASIC`; do
	find temp/ | grep /$i- | sed "/$i-.*-.*-.*-.*/d" >> temp/BASICLIST
done

for i in `cat lists/FULL`; do
	find temp/ | grep /$i- | sed "/$i-.*-.*-.*-.*/d" >> temp/FULLLIST
done

for i in `cat lists/SETTINGS`; do
	find temp/ | grep /$i- | sed "/$i-.*-.*-.*-.*/d" >> temp/SETTINGSLIST
done

for i in `cat temp/KERNELLIST`; do
	mv $i slackel/kernels/
done

for i in `cat temp/CORELIST`; do
	mv $i slackel/core/
done

for i in `cat temp/BASICLIST`; do
	mv $i slackel/basic/
done

for i in `cat temp/FULLLIST`; do
	mv $i slackel/full/
done

for i in `cat temp/SETTINGSLIST`; do
	mv $i slackel/settings/
done

