2 #################################################################################
3 # File: install_triggers
4 # Description: [Re]Creates Clearcase triggers
5 # Author: Andrew DeFaria <ADeFaria@Salira.com>
6 # Created: Tue Mar 12 13:56:31 2002
10 # (c) Copyright 2002, Salira Optical Network Systems, all rights reserved.
12 ################################################################################
13 # Set me to command name
16 # Source /etc/site_parms
17 if [ -f /etc/site_parms ]; then
20 echo "$me: WARNING: /etc/site_parms does not exist!"
24 adm_base="$SITE_TOOLS_PATH/adm"
27 adm_fpath=${adm_fpath:-$adm_base/functions}
32 # trigger_data contains the triggers. The fields are separated by a "%".
34 # Field 1: Name of trigger (must not contain spaces)
35 # Field 2: Comment for trigger
36 # Field 3: Options. Currently specify one of preop, postop or all. Leading "-" will be
38 # Field 4: All modifier. Enter "all" if this is an all element trigger, blank otherwise
39 # Field 5: Operation kind. Things like checkin, checkout (See help for mktrtype for more)
40 # Field 6: Site. This is one of US, CN or all. If this trigger is only supposed to be
41 # at one site then designate which site, otherwise all
42 # Field 7: What to execute. We assume and supply perl. We also prepend this with
43 # the path to the Triggers directory.
44 # Field 8: Additional parameters (e.g. NotifyTrigger.pl <path to msg file>). Not that this
45 # must be the full pathname (e.g. T:/Triggers/Messages/NotifySoftare.msg works fine)
47 check_in_pre%Check comments on check in%all%preop%checkin%all%CheckinPreop.pl%%\n\
48 check_in_post%Label check in with bug ID label%all%postop%checkin%all%CheckinPostop.pl%%\n\
49 notify_ci_software%Notify Software group of checkins%%postop%checkin%all%NotifyTrigger.pl%NotifySoftware.msg\n\
50 notify_ci_software_china%Notify China Software group of checkins%%postop%checkin%CN%NotifyTrigger.pl%NotifySoftware.msg\n\
51 notify_ci_rli%Notify Rick Li of checkins%all%postop%checkin%all%NotifyTrigger.pl%NotifyRickLi.msg\n\
52 remove_empty_branch%Remove empty branches after uncheckout, rmver, or rmbranch%all%postop%uncheckout,rmver,rmbranch%all%RemoveEmptyBranch.pl%
53 set_ownership%Set ownership to ccadmin%all%postop%mkelem%all%SetOwnershipTrigger.pl%%\
57 perl=$(cygpath -w //$SITE_BUILD_SERVER/Tools/Perl/bin/perl.exe)
59 # Where trigger stuff is
60 trigbase=$(cygpath -w //$SITE_VIEW_SERVER/$SITE_VIEW_SHARENAME/$SITE_OFFICIAL_VIEW/$SITE_TOOLS_VOB/bin/clearcase/triggers)
63 msgbase=$(cygpath -w $trigbase/messages)
65 function create_trigger {
76 execute="$perl $trigbase\\$6"
78 if [ ! -z "$7" ]; then
79 execute="$execute $msgbase\\$7"
82 # Check to see if the trigger already exists
83 cleartool lstype trtype:$name > /dev/null 2>&1
85 # If so set $replace with the -replace option
93 echo "cleartool mktrtype $replace -element $op1 $op2 $opkind -comment \"$comment\" -execwin \"$execute\" $name" > /tmp/$me
100 $name 1> /dev/null 2>> /tmp/$me
102 # Check status and inform the user
103 if [ $? -eq 0 ]; then
104 if [ -z "$replace" ]; then
105 verbose "Created $name trigger"
107 verbose "Replaced $name trigger"
110 if [ -z "$replace" ]; then
111 warning "Unable to create $name trigger"
113 warning "Unable to replace $name trigger"
123 while [ $# -ge 1 ]; do
141 # Need to cd to the vob so that Clearcase can determine which vob this trigger applies to.
142 # Note that we assume that the view official exists and we are applying triggers to the
144 cd $SITE_VIEW_STORAGE/$SITE_OFFICIAL_VIEW/salira
146 # Process triggers from $trigger_data
148 echo -e "$trigger_data" | while read name comment op1 op2 opkind site execstr parms; do
149 if [ "$parms" = "%" ]; then
152 if [ "$op1" = "%" ]; then
156 if [ "$site" = "all" -o "$site" = $SITE_NAME ]; then
157 create_trigger $name $comment "$op1" $op2 $opkind $execstr $parms
159 verbose "Skipping $name trigger - only appliable to the $site site"