In playing with teacup
, there have been a few actions I've found myself performing that got me started thinking about automating. So I wrote brew
, which goes out and takes a crack at updating my local repository, based on the activestate activetcl repository.
The next thing I found myself doing was trying to deal with a local repository with multiple versions of an extension. After a year of using teacup, I had several versions of teacup itself, as well as of the base-tcl, etc.
Initially, I tried just deleting the extra files. That turned out to be a mistake - at some point, some teacup command I executed attempted to do some sort of integrity check and was unhappy about the state of the local repository.
Then I found that I needed to use teacup remove
to get rid of something that I'd installed.
So, I created clean_pot
- a ksh
script that generates a list of extension names which have more than one version in the local repository. I haven't automated the remove yet - that is going to take a bit of code to figure out which one is the newest
one, so I don't accidentally delete the wrong thing.
teacup list --as csv --at-default > $TEADIR/teacup_local.txt
cut -d, -f1,2 $TEADIR/teacup_local.txt | sort | uniq -c | \
sort -n > $TEADIR/teacup_dups.txt
cnt=$(grep -c -v '^ 1 ' $TEADIR/teacup_dups.txt)
if [[ $cnt -ne 0 ]] ; then
grep -v '^ 1 ' $TEADIR/teacup_dups.txt | sed 's/^ +[0-9]+ //' |\
sed 's/$/,/' > $TEADIR/cleanup.txt
echo "Run 'teacup remove' with all but the newest of these"
fgrep -f $TEADIR/cleanup.txt $TEADIR/teacup_local.txt | cut -d, -f2,3 |
echo "No duplicates found"
Note that I actually use a personal tool rather than sed to do the changes to the text. So the sed lines need some sort of tweaking. I don't use sed because it is so obtuse even to an old regular expression writer like me. Hopefully someone will come along and show us the sed magic to get those lines to work as expected.
Next on my list of things to do is a program that locates the applications in a repository and copies the appropriate ones into a common execution directory (like /usr/local/bin/ or whatever).