Version 9 of brew

Updated 2007-10-26 18:45:58 by LV

LV 2007 July 05

So, I've been playing with activetcl's teacup command for the past half year or so and found myself nearly every day performing at least three actions with it.

So, the following is a ksh script (probably will work with other unix shells as well, and also probably simple enough to convert to tcl) that automates the process.

It got its first big work out this morning - my test copy of activetcl is installed in /tmp - and they rebooted the machine (and deleted all contents of /tmp) while I was away on vacation... so brew got its chance to work through the process.


 #! /bin/ksh

 # Version 4: clean up of code
 # Version 3: attempt to add code so brew doesn't install all versions 
 # Version 2: crudely process output from list and run installs
 # Version 1: initial attempt at running just the commands.

 # used for temporary files - modify as needed
 tmp=/tmp
 if [ ! -d $tmp ] ; then
        echo "$0: Unable to brew teapot updates due to missing directory." >&2
        exit 1
 fi

 # run 3 basic teacup commands. Evolve this script, over time,
 # to query the user if there are potential things to install

 # First, update teacup itself, so we are using the latest code
 teacup update-self
 teacup update

 # Now, read the results of teacup and install items found

 debug="0"
 if [ "$#" -ne 0 ] ; then
        debug=1
        set -vx
 fi

 function steep {
 if [ "$#" -ne 1 ] ; then
        echo "USAGE: steep file" >&2
        return -1
 fi

 namelist=""
 line="#"
 while [ x"$line" != x"" ] ; do
     case "$line" in
        \#) ;;
        entity*) ;;
        ---*) ;;
        *entities\ found*) ;;
        *entity\ found*) ;;
        profile*) echo "not processed: $line" ;;
        package* | application* )
                thisname=$(echo "$line" | cut -c13-44 | sed 's/ //g')
                if [ x"$namelist" != x"" ] ; then
                    echo "Is $thisname in $namelist"
                    echo $thisname | egrep -s -e $namelist
                    rc=$?
                    if [[ $rc -eq 1 ]] ; then 
                        namelist="$thisname|$namelist"
                        cmd=$(echo "$line" | gawk '{ printf "teacup install --force --with-recommends %s %s -is %s\n",$2,$3,$1}')
                        echo $cmd
                        $cmd
                    else
                        echo "$thisname has previously been handled"
                    fi
                else
                        namelist="$thisname|"
                        cmd=$(echo "$line" | gawk '{ printf "teacup install --force --with-recommends %s %s -is %s\n",$2,$3,$1}')
                        echo $cmd
                        $cmd
                fi
                ;;
        *)
                echo "unknown line in $1: $line"
                ;;
     esac
     read line
 done < $1
 return 0
 }

 # install anything not yet installed first
 teacup list --only uninstalled > $tmp/teacup_notyet.txt 2>&1
 cmp -s $tmp/teacup_nohits.txt $tmp/teacup_notyet.txt
 if [ $? -ne 0 ] ; then
        # something was returned from teacup
        sort -u +1 -2 $tmp/teacup_notyet.txt | \
        gawk 'NF == 4 && $1 != "entity" && $1 !~ "----" { printf "teacup install --force --with-recommends %s -is %s\n",$2,$1}' > $tmp/teacup_install.ksh
        ksh $tmp/teacup_install.ksh
 else
        echo "No new entities found" >&2
 fi

 # Next, determine whether anything (including those just completed)
 #  installed has been updated
 teacup list --only newer  > $tmp/teacup_newer.txt 2>&1
 echo "0 entities found" > $tmp/teacup_nohits.txt
 cmp -s $tmp/teacup_nohits.txt $tmp/teacup_newer.txt
 if [ $? -ne 0 ] ; then
        # something was returned from teacup
        cat $tmp/teacup_newer.txt
        steep $tmp/teacup_newer.txt
 else
        echo "No updated entities found" >&2
 fi

LV 2007 Sep 10 Head's up! If you consider using this script, be aware of a consequence that version 2 has. I haven't figured out a way to do this so that only the newest version of a package is installed. So the code just keeps on forcing installs.

Ideally, there would be a way to get only the newest item installed. I just haven't figured out how to do that yet.

Note that I recommend that when initially starting to use the repository, you initially run the command

 teacup install Activestate::ActiveTcl

to fill the repository. That way, brew will tend to only get the new extensions anyways.

See also clean_pot.


LV 2007 Oct 26 Today, teacup update-self resulted in a teacup with an update option. This is documented as being similar to doing pretty much what the above does - a list --only newer, list --only unknown, and then an install --force. I've added a call to that just after the teacup update-self - shouldn't be cases of seeing anything installed from the rest of the code any longer!


Category Application - Category Repository - Category System Administration