--- /dev/null
+#!/bin/bash
+# Get a list of package files that can be moved out
+
+echo "Now in `pwd` going to $1"
+cd $1
+echo "Landed in `pwd` "
+echo "File count:"
+ls *.deb | wc -l
+# exit 9
+
+
+KEEPGEN=4 # how many generations to keep of each package
+
+KEEP="/tmp/packs.keep"
+MOVE="/tmp/packs.move"
+rm -f $KEEP
+rm -f $MOVE
+
+PRODS=`ls *.deb| cut -d'_' -f1 | sort -u`
+for P in $PRODS
+do
+ for V in `ls -rt ${P}_*.deb | tail -$KEEPGEN | cut -d'_' -f2 `
+ do
+ echo ${P}_${V} >> $KEEP
+ done
+done
+
+ls *.deb | cut -d'_' -f1-2 | grep -v -f $KEEP > $MOVE
+
+for M in `cat $MOVE`
+do
+ echo "Removing"
+ ls ${M}_*
+ rm ${M}_*
+ # FIXME - instead of ls, move the files away
+done
+
+# rm -f $KEEP
+#rm -f $MOVE