Subversion Repositories DevTools

Rev

Rev 5709 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
341 dpurdie 1
########################################################################
6177 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
341 dpurdie 3
#
4
# Module name   : jats_ccmerge_build
5
# Module type   : JATS Utility
6
# Environment(s): JATS
7
#
8
# Description   : A script to merge a build.pl from an autobuilder branch back
9
#                 to the main line.
10
#                 a build.
11
#
12
#......................................................................#
13
 
14
require 5.006_001;
15
use strict;
16
use warnings;
17
use JatsError;
18
use JatsSystem;
19
use FileUtils;
20
 
21
use Pod::Usage;                             # required for help support
22
use Getopt::Long;
23
use File::Copy;
24
use Cwd;
25
 
26
my $VERSION = "1.5.5";                      # Update this
27
 
28
#
29
#   Options
30
#
31
my $opt_debug   = $ENV{'GBE_DEBUG'};        # Allow global debug
32
my $opt_verbose = $ENV{'GBE_VERBOSE'};      # Allow global verbose
33
my $opt_help = 0;
34
 
35
#
36
#   Global Data
37
#
38
my $UNIX = $ENV{'GBE_UNIX'};
39
my @error_list;
40
my $last_result;
41
my @last_results;
42
 
43
#-------------------------------------------------------------------------------
44
# Function        : Mainline Entry Point
45
#
46
# Description     :
47
#
48
# Inputs          :
49
#
50
 
51
#
52
#   Parse the user options
53
#
54
my $result = GetOptions (
55
                "help|h:+"          => \$opt_help,
56
                "manual:3"          => \$opt_help,
57
                "verbose|v:+"       => \$opt_verbose,           # flag, multiple use allowed
58
                );
59
 
60
                #
61
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
62
                #
63
 
64
#
65
#   Process help and manual options
66
#
67
pod2usage(-verbose => 0, -message => "Version: $VERSION")
68
    if ($opt_help == 1 || ! $result || $#ARGV >= 0);
69
pod2usage(-verbose => 1)  if ($opt_help == 2 );
70
pod2usage(-verbose => 2)  if ($opt_help > 2);
71
 
72
#
73
#   Configure the error reporting process now that we have the user options
74
#
75
ErrorConfig( 'name'    => 'MERGBUILD',
76
             'verbose' => $opt_verbose );
77
 
78
#
79
#   Only for windows
80
#
81
Error ("This program only works under Windows")
82
    if ( $UNIX );
83
 
84
#
85
#   Determine the branch of the build.pl file
86
#
87
Error ("No build.pl file found" )
88
    unless ( -f 'build.pl' );
89
 
90
ClearCmd ('describe', '-fmt', '%Sn', 'build.pl' );
91
Error ('Can\'t describe build.pl', @error_list) if @error_list;
92
Error ('build.pl may be hijacked. It is not a Vob Object') unless ( $last_result );
93
my $branch = $last_result;
94
Verbose ("Branch: $branch");
95
 
96
#
97
#   Determine parent branch
98
#
99
my @parts = split( '/', $branch );
100
Error ("Build.pl is not on an AutoBuilder Branch." )
101
    unless ( $parts[-2] =~ m~^AutoBuilder\.~ );
102
my $parent = join ('/', @parts[0 .. $#parts - 2]);
103
Verbose "Parent Branch: $parent\n";
104
 
105
#
106
#   Checkout the build.pl file on the parent branch
107
#
108
File::Copy::copy( 'build.pl', 'build.pl.merge' );
109
ClearCmd ('co', '-unreserved', '-c', 'Merged back from AutoBuild', '-ndata', 'build.pl@@'.$parent.'/LATEST');
110
Error ('Can\'t checkout build.pl', @error_list) if @error_list;
111
 
112
#
113
#   Draw a merge link to show what has been done
114
#
115
Verbose ("Creating Hyperlink" );
116
my $source_name = 'build.pl@@'.$branch;
117
my $target_name = 'build.pl@@'.$parent.'/CHECKEDOUT';
118
ClearCmd ('mkhlink', 'Merge', $source_name, $target_name);
119
Warning ('Can\'t create merge arrows', @error_list) if @error_list;
120
 
121
#
122
#   Copy in the base build.pl file and make it writable
123
#
124
Verbose ('Copy original build.pl file');
125
File::Copy::move( 'build.pl.merge', 'build.pl' );
126
chmod( 0755, 'build.pl' );
127
 
128
exit 0;
129
 
130
#-------------------------------------------------------------------------------
131
# Function        : ClearCmd
132
#
133
# Description     : Execute a ClearCase command and capture the results
134
#                   Errors are held in one array
135
#                   Result are held in another
136
#
137
# Inputs          :
138
#
139
# Returns         :
140
#
141
sub ClearCmd
142
{
143
    my $cmd = QuoteCommand (@_);
144
    Verbose2( "cleartool $cmd" );
145
 
146
        @error_list = ();
147
        @last_results = ();
148
        $last_result = undef;
149
 
150
        open(CMD, "cleartool $cmd  2>&1 |")    || Error( "can't run command: $!" );
151
        while (<CMD>)
152
        {
153
            chomp;
154
            $last_result = $_;
155
            $last_result =~ tr~\\/~/~s;
156
            push @last_results, $last_result;
157
 
158
            Verbose2 ( "cleartool resp:" . $_);
159
            push @error_list, $_ if ( m~Error:~ );
160
        }
161
        close(CMD);
162
 
163
    Verbose2( "Exit Status: $?" );
164
    return $? / 256;
165
}
166
 
167
#-------------------------------------------------------------------------------
168
#   Documentation
169
#
170
 
171
=pod
172
 
361 dpurdie 173
=for htmltoc    GENERAL::ClearCase::
174
 
341 dpurdie 175
=head1 NAME
176
 
177
jats_ccmerge_build - Merge autobuilt build.pl file to parent branch
178
 
179
=head1 SYNOPSIS
180
 
181
  jats jats_ccmerge_build [options]
182
 
183
 Options:
184
    -help              - brief help message
185
    -help -help        - Detailed help message
186
    -man[=n]           - Full documentation
187
    -verbose[=n]       - Control program verbosity
188
 
189
=head1 OPTIONS
190
 
191
=over 8
192
 
193
=item B<-help>
194
 
195
Print a brief help message and exits.
196
 
197
=item B<-help -help>
198
 
199
Print a detailed help message with an explanation for each option.
200
 
201
=item B<-man[=n]>
202
 
203
Prints the manual page and exits.
204
 
205
If a numeric manual level is provide then it will be used to control the
206
verbosity of help provided. This should be in the range of 1 to 3.
207
 
208
=item B<--verbose[=n]>
209
 
210
This option will increase the level of verbosity of the JATS command and command
211
invoked by the JATS shell.
212
 
213
If an argument is provided, then it will be used to set the level, otherwise the
214
existing level will be incremented. This option may be specified multiple times.
215
 
216
=back
217
 
218
=head1 DESCRIPTION
219
 
220
This program assists in the maintainance of the the JATS build.pl file.
221
 
222
When a package is rippled by the build daemons the resultant build.pl file is
223
placed on a ClearCase branch dedicated to the AutoBuild process. When a developer
224
manually modifies the build file it 'should' be on the packages main branch and
225
not on the daemons AutoBuild branch.
226
 
227
This utility simplifies this process. The utility will:
228
 
229
=over 8
230
 
361 dpurdie 231
=item *
341 dpurdie 232
 
361 dpurdie 233
Ensure that the build.pl file exists
341 dpurdie 234
 
361 dpurdie 235
=item *
236
 
237
Determine the full ClearCase branch of the build.pl file
238
 
341 dpurdie 239
This command can only be executed within a ClearCase view. Moreover the user
240
must have located the build.pl file. If the build.pl file is not on an
241
AutoBuilder branch then the utility will terminate.
242
 
361 dpurdie 243
=item *
341 dpurdie 244
 
361 dpurdie 245
Determine the parent of the AutoBuiler branch
341 dpurdie 246
 
361 dpurdie 247
=item *
248
 
249
Checkout the build.pl on the tail of the parent branch
250
 
341 dpurdie 251
The original 'build.pl' is preserved. At the end of the checkout the version
252
that is checkout will have the content of the original build.pl
253
 
361 dpurdie 254
=item *
341 dpurdie 255
 
361 dpurdie 256
Draw a Merge Arraw from the build.pl to the checked out version.
341 dpurdie 257
 
361 dpurdie 258
=item *
259
 
260
Mark the resultant file writable.
261
 
341 dpurdie 262
=back
263
 
264
=cut
265