Version 2 of brew

Updated 2007-07-16 15:12:30 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

 # run 3 standard 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

 # 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

  line="#"
  while [ x"$line" != x"" ] ; do
      case "$line" in
        \#) ;;
        entity*) ;;
        ---*) ;;
        *entities\ found*) ;;
        *entity\ found*) ;;
        profile*) echo "not processed: $line" ;;
        package* | application* )
                echo "process $line" 
                cmd=$(echo "$line" | awk '{ printf "teacup install %s %s -is %s\n",$2,$3,$1}')
                echo $cmd
                $cmd
                ;;
        *)
                echo "unknown line: $line"
                ;;
      esac
      read line
  done < $1
  return 0
 }

 # Next, determine whether anything already 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

 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
        cat /tmp/teacup_notyet.txt
        steep /tmp/teacup_notyet.txt
 else
        echo "No new entities found" >&2
 fi

Category Application Category Repository Category System Administration