3 =head1 NAME $RCSfile: TriggerUtils.pm,v $
13 Andrew DeFaria <Andrew@ClearSCM.com>
21 Fri Mar 11 15:37:34 PST 2011
25 $Date: 2011/03/26 06:24:30 $
31 Provides an some utilities for the CCDB Triggers.
43 use lib "$FindBin::Bin/../../lib";
49 our $VIEW_DRIVE = 'M';
50 our $VIEWTAG_PREFIX = ($^O =~ /mswin/i or $^O =~ /cygwin/)
64 my $logfileName = "$FindBin::Bin/trigger.log";
67 # Display a message to the user using clearprompt
70 my $cmd = "clearprompt proceed -newline -type error -prompt \"$msg\" ";
71 $cmd .= "-mask abort -default abort";
79 # Log a message to the log file
82 return unless $ENV{CCDB_TRIGGER_DEBUG};
85 open $logfile, '>>', $logfileName
86 or die "Unable to open logfile $logfile - $!\n";
88 $logfile->autoflush (1);
91 my $timestamp = timestamp;
93 print $logfile "$FindBin::Script: $timestamp: $msg\n";
101 # Log message to log file then display it to user
109 my ($msg, $err) = @_;
120 # CCDB stores pvob's in the database with the VOBTAG_PREFIX removed. This
121 # makes a vob name OS independent as on Windows it's \$pvob and Unix/Linux
122 # it's /vob/$pvob (or sometimes /vobs/$pvob! This is site specific). Now we
123 # have a handy method in Clearcase.pm for this but we want speed here. Doing a
124 # "use Clearcase;" will invoke a cleartool subproccess ($Clearcase::CC) and we
125 # don't want that overhead. So we are replicating that code here. We are
126 # hinging off of the first character of the vob name (either '\', or '/') to
127 # indicate if we are Windows or non-Windows. Additionally we are hardcoding
128 # '/vob/' as the vob tag prefix for the Unix/Linux case.
129 if (substr ($pvob, 0, 1) eq '\\') {
130 $pvob = substr $pvob, 1;
131 } elsif (substr ($pvob, 0, 1) eq '/') {
132 if ($pvob =~ /\/vob\/(.+)/) {
141 triglog 'Dumping CLEARCASE_* environment';
143 foreach (keys %ENV) {
144 next unless /CLEARCASE_/;
146 triglog "$_: $ENV{$_}";
156 =head1 CONFIGURATION AND ENVIRONMENT
158 DEBUG: If set then $debug is set to this level.
160 VERBOSE: If set then $verbose is set to this level.
162 TRACE: If set then $trace is set to this level.
172 =head2 ClearSCM Perl Modules
183 <a href="http://clearscm.com/php/scm_man.php?file=lib/DateUtils.pm">DateUtils</a><br>
188 =head1 BUGS AND LIMITATIONS
190 There are no known bugs in this module
192 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
194 =head1 LICENSE AND COPYRIGHT
196 Copyright (c) 2011, ClearSCM, Inc. All rights reserved.