#!/bin/tcsh
# Copyright (c) 2005 Photon Research Associates. All rights reserved.
# Author: David Lee Faison
#
###############################################################################
#
# Redistribution and use in source form, with or without modification, are
# permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notices,
# this list of conditions and the following disclaimer.
#
# 2. The name of Photon Research Associates and/or the author may not be used
# to endorse or promote products derived from this software without specific
# prior written permission.
#
# This software is provided 'AS-IS' and any warranties, express or
# implied, including, but not limited to, the implied warranties of
# merchantability and fitness for a particular purpose are
# DISCLAIMED. In no event shall Photon Research Associates or the author,
# separately or in combination with one another, be liable for any
# direct, indirect, incidental, special, exemplary, or consequential
# damages (including, but not limited to, procurement of substitute goods or
# services; loss of use, data, or profits; or business interruption) however
# caused and on any theory of liability, whether in contract, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.
#
#####################################################################################
#
# PURPOSE: this script is designed to be invoked by a Perforce trigger. Examine the
# series of 'setenv' statements to determine the expected parameters and their order.
#
# Scripts that are invoked by this script must behave as follows:
#
# - if an error condition and message are to be passed back to Perforce, the text of
# the error message must be written to the file named by the $ERR_MSG_FILE environment
# variable.
#
# - the existence of the file named by the $ERR_MSG_FILE variable is sufficient to
# cause an error condition to be passed back to Perforce (e.g. causing a submit
# trigger to fail).
#
# - utilize the environment variable names that appear below to access the corresponding
# information.
#
#####################################################################################
setenv LOGFILENAME logs/trig.log.`date '+%y-%m-%d.%H.%M.%S'`
echo -------------------------------------------------------------------------------- >> $LOGFILENAME
echo `date` >> $LOGFILENAME
echo $* >> $LOGFILENAME
p4 sync //... >> $LOGFILENAME
setenv TRIG_CMD $1
setenv USER $2
setenv CHANGELIST $3
setenv CLIENT $4
setenv CLIENTHOST $5
setenv CLIENTIP $6
setenv SERVERHOST $7
setenv SERVERIP $8
setenv SERVERPORT $9
setenv SERVERROOT $10
setenv FORMFILE $11
setenv FORMNAME $12
setenv FORMTYPE $13
setenv ERR_MSG_FILE "~/.$$.msg"
$TRIG_CMD >>& $LOGFILENAME
if (-f $ERR_MSG_FILE) then
cat $ERR_MSG_FILE
rm $ERR_MSG_FILE
exit 1
endif