Moved debian-tools (from CVS) to here.
[git-tools-moved-to-github.git] / update-archive / symclean.sh
diff --git a/update-archive/symclean.sh b/update-archive/symclean.sh
new file mode 100755 (executable)
index 0000000..8e6e1ff
--- /dev/null
@@ -0,0 +1,39 @@
+#!/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