2 ################################################################################
5 # Description: Builds in a view
6 # Author: Andrew@DeFaria.com
7 # Created: Wed Jun 11 13:22:11 PDT 2003
9 # Modifications:06/17/2003 AD: Changed 2310_onu -> onu2310 as the card directory
10 # has changed. Also added -to and -cc options.
12 # (c) Copyright 2003, Andrew@DeFaria.com, all rights reserved
14 ################################################################################
15 # Set me to command name
19 adm_base="$SITE_TOOLS_PATH/adm"
22 adm_fpath=${adm_fpath:-$adm_base/functions}
28 if [ ! -z "$1" ]; then
31 display "Usage: $me: [-to <email_address>] [-cc <email_address>]"
32 display "\t\t [-q|uiet ] [-v|erbose] [-d|ebug] [-usage]"
33 display "\t\t [-noupdate] <viewtag> [ <viewtag>... ]"
36 display "\t-to:\t\tEmail address where to mail the build log"
37 display "\t-cc:\t\tEmail address where to cc the build log"
38 display "\t-quiet:\t\tBe quiet"
39 display "\t-verbose:\tTurn on verbose mode"
40 display "\t-debug:\t\tTurn on debug mode"
41 display "\t-usage:\t\tDisplay usage"
42 display "\t-noupdate:\tSkip updating of snapshot views"
43 display "\t\t\t(default: Snapshot views are updated)"
44 display "\t<viewtag>\tView tag(s) to build"
51 # Get cards definition
52 . $SITE_TOOLS_PATH/adm/etc/cards
54 declare -i build_status=0
56 function send_message {
64 display "From: ccadmin\nTo: $to\nSubject: Build of $view_to_build $msg" > /tmp/msg.$$
66 display "From: ccadmin\nTo: $to\ncc: $cc\nSubject: Build of $view_to_build $msg" > /tmp/msg.$$
70 cat /tmp/msg.$$ $logfile.acct $logfile | $ssmtp -t
72 # Clean up accounting file
82 display "\n\tCard Summary" >> $logfile.acct
83 display "****************************" >> $logfile.acct
84 for card in $cards; do
85 if [ -f "$card.build.log" ]; then
86 warnings=$(grep -i warning $card.build.log | grep -vc "Warnings: 0")
87 errors=$(grep -i error $card.build.log | grep -v "Errors: 0" | grep -vc "cli_errors.c")
88 display "$card:\tWarnings: $warnings\tErrors: $errors" >> $logfile.acct
95 while [ $# -ge 1 ]; do
128 views_to_build="$views_to_build $1"
135 if [ -z "$to" ]; then
136 to="$SITE_ADMIN_EMAIL"
139 for view_to_build in $views_to_build; do
140 # First check to see if there is a snapshot view
141 if [ -d "$SITE_SNAPSHOT_VIEW_PATH/$view_to_build" ]; then
142 view_path="$SITE_SNAPSHOT_VIEW_PATH"
144 if [ $update_view = "yes" ]; then
145 verbose "Updating view $view_to_build..."
146 $SITE_TOOLS_PATH/bin/update_view -q $view_to_build
148 if [ $? -ne 0 ]; then
149 error "Failed to update view $view_to_build" 1
151 verbose "Updated view $view_to_build"
154 else # Now check ot see if it's a dynamic view
155 view_path="$SITE_DYNAMIC_VIEW_PATH"
156 if [ ! -d $view_path/$view_to_build ]; then
157 # View not started - start it
158 verbose "Starting view $view_to_build..."
159 cleartool startview $view_to_build > /dev/null 2>&1
161 if [ $? -ne 0 ]; then
162 error "Unable to start view $view_to_build" 2
167 if [ -d "$view_path/$view_to_build" ]; then
168 logfile=/tmp/$view_to_build.build.log
169 verbose "Start build of $view_to_build @ $(date)"
170 echo "Start build of $view_to_build @ $(date)" > $logfile
173 cd $view_path/$view_to_build/salira/neopon/build
174 $SITE_TOOLS_PATH/bin/build -nomonitor -sequential -clean -quiet -tee $logfile
178 if [ $build_status -eq 0 ]; then
184 display "\nEnd build of $view_to_build $msg @ $(date)" >> $logfile
185 display "Logfile: $(hostname):/tmp/$view_to_build.build.log" >> $logfile
189 # Check for errors and notify the right people
190 if [ "$quiet" = "yes" ]; then
191 # If quiet then do not notify
194 $SITE_TOOLS_PATH/bin/notify_err
197 warning "Cannot find view $view_path/$view_to_build"