Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
########################################################################
261 dpurdie 2
# Copyright ( C ) 2008 ERG Limited, All rights reserved
227 dpurdie 3
#
309 dpurdie 4
# Module name   : jats_svnasave_build.pl
5
# Module type   : JATS Utility
6
# Compiler(s)   : Perl
227 dpurdie 7
# Environment(s): jats
8
#
261 dpurdie 9
# Description   : Build Daemon Support Utility
10
#                 This utility will:
11
#                   +   Assume the CWD is the root-dir of a package
12
#                       within a versioned control view
13
#                   +   Determine a suitable label for the package
14
#                   +   Save the build file in the view
15
#                   +   Label the resultant view
227 dpurdie 16
#
261 dpurdie 17
# Usage:        : See POD at end of this file
227 dpurdie 18
#
267 dpurdie 19
#               jats etool  jats_save_build
20
#                   -infile     auto.xml/auto.pl
21
#                   -outfile    xxxdepends.xml/build.pl
22
#                   -pname      package_name
23
#                   -pversion   package_version
24
#                   -infofile   path_to_info_file
25
#                   -wiplabel   Existing WIP label (optional)
26
#
227 dpurdie 27
#......................................................................#
28
 
29
use strict;
30
use warnings;
31
use JatsError;
261 dpurdie 32
use JatsBuildFiles;
33
use JatsSystem;
34
use JatsProperties;
227 dpurdie 35
use Getopt::Long;
36
use Pod::Usage;                             # required for help support
261 dpurdie 37
use Cwd;
227 dpurdie 38
 
39
################################################################################
40
#   Option variables
41
#
42
 
261 dpurdie 43
my $VERSION = "2.0.0";                      # Update this
263 dpurdie 44
my $opt_debug   = $ENV{'GBE_DEBUG'};        # Allow global debug
45
my $opt_verbose = $ENV{'GBE_VERBOSE'};      # Allow global verbose
227 dpurdie 46
my $opt_infile  = "auto.pl";
47
my $opt_ofile = "build.pl";
48
my $opt_help = 0;
49
my $opt_branch_default = "AutoBuilder";
50
my $opt_branch;
51
my $opt_newbranch;
261 dpurdie 52
my $opt_infofile;
53
my $opt_pname;
54
my $opt_pversion;
55
my $opt_wiplabel;
56
my $opt_locate;
227 dpurdie 57
 
58
#
59
#   Globals
60
#
261 dpurdie 61
my $root_dir;
62
my $pkg_label;
63
my $tag_label;
227 dpurdie 64
my @error_list;
65
my $last_result;
241 dpurdie 66
my @last_results;
261 dpurdie 67
my $label_created;
227 dpurdie 68
 
261 dpurdie 69
#
70
#   Configuration options
71
#
227 dpurdie 72
my $result = GetOptions (
261 dpurdie 73
                "help:+"        => \$opt_help,              # flag, multiple use allowed
74
                "manual:3"      => \$opt_help,              # flag
75
                "verbose:+"     => \$opt_verbose,           # flag
76
 
77
                "outfile=s"     => \$opt_ofile,             # string
78
                "infile=s"      => \$opt_infile,            # string
79
                "branch=s"      => \$opt_branch,            # string
80
                "newbranch"     => \$opt_newbranch,         # string
81
 
82
                "infofile=s"    => \$opt_infofile,          # string
83
                "pname=s"       => \$opt_pname,             # string
84
                "pversion=s"    => \$opt_pversion,          # string
85
                "wiplabel=s"    => \$opt_wiplabel,          # string
86
                "locatepkg=s"   => \$opt_locate,            # string
87
 
88
                #
89
                #   Update documentation at the end of the file
90
                #
227 dpurdie 91
                );
92
 
93
#
94
#   Process help and manual options
95
#
96
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
261 dpurdie 97
pod2usage(-verbose => 1)  if ( $opt_help == 2 );
98
pod2usage(-verbose => 2)  if ( $opt_help > 2 );
227 dpurdie 99
 
100
#
101
#   Configure the error reporting process now that we have the user options
102
#
261 dpurdie 103
ErrorConfig( 'name'    =>'ABTSAVE',
227 dpurdie 104
             'verbose' => $opt_verbose,
105
             'on_exit' => \&display_error_list
106
           );
107
Error ("Input and output file are the same: $opt_infile" )
108
    if ( $opt_infile eq $opt_ofile );
109
 
110
Error ("Must provide a branch when usng newbranch option")
111
    if ( $opt_newbranch && ! $opt_branch );
112
 
113
$opt_branch = $opt_branch_default
114
    unless ( $opt_branch );
115
 
309 dpurdie 116
Error ("Package Name not provided")
117
    unless ( $opt_pname );
261 dpurdie 118
 
309 dpurdie 119
Error ("Package Version not provided")
120
    unless ( $opt_pversion );
261 dpurdie 121
 
309 dpurdie 122
Warning("Path to info file not provided")
123
    unless ( $opt_infofile );
261 dpurdie 124
 
309 dpurdie 125
unlink ($opt_infofile) if $opt_infofile;
261 dpurdie 126
 
127
#
128
#   Locate the build directory and chdir to that directory
129
#
130
locate_build_directory();
131
 
132
#
133
#   Have changed to the directory with build files
134
#   Continue with user argument sanity check
135
#
136
Error ("Input file not found: $opt_infile" )
137
    unless ( -f $opt_infile );
138
 
139
Error ("Output file not found: $opt_ofile" )
140
    unless ( -f $opt_ofile );
141
 
142
#
227 dpurdie 143
#   Determine the name of the Branch to be used
144
#   This is based on the branch that the file is already on as ClearCase does
145
#   not allow multiple instances of a branch on different sub-branches
146
#
261 dpurdie 147
ClearCmd ('describe',  '-fmt', '%n', $opt_ofile);
227 dpurdie 148
Error ("Program Terminated") if ( @error_list );
149
Error ("File may not be a VOB object: $opt_ofile" ) unless ( $last_result );
150
my $full_name = $last_result;
151
 
152
$last_result =~ m~(.*)/([^/]+)$~;
153
my $full_path = $1;
154
 
155
$last_result =~ m~(.*)/([^/]+)/([^/]+)~;
156
my $current_branch = $2;
157
 
158
$last_result =~ m~@@(.*)/([^/]+)~;
159
my $full_branch = $1;
160
my $target_branch = $full_branch;
161
my $branch_point = "";
162
 
163
Error ("Cannot determine full pathname of the file: $full_name") unless ( $full_path );
164
 
165
Verbose2 ("FullName     : $full_name" );
166
Verbose2 ("FullPath     : $full_path" );
167
Verbose2 ("Branch       : $current_branch" );
168
Verbose2 ("Userb        : $opt_branch" );
169
Verbose2 ("FullBranch   : $full_branch" );
170
#
171
#
172
#   Determine the branch that the file is on
173
#   If it is not on the desired branch then we will need to create the branch
174
#
175
#   Ensure that the required branch exists in the current VOB
176
#   Need to handle some legacy branches that were created with the name AutoBuilder
177
#   by not creating AutoBuild/AutoBuilder.AutoBuilder branches but retaining the
178
#   existing AutoBuilder branch.
179
#
180
if ( $opt_newbranch )
181
{
182
    #
183
    #   User has asked for a new branch
184
    #   Place the file on /main/xxxxx
185
    #
186
    $branch_point = "-version /main/0";
187
    $target_branch = "/main/$opt_branch";
188
 
189
}
190
elsif ( $current_branch =~ m/^$opt_branch/ )
191
{
192
    #
193
    #   Current branch has the same name ( prefix) as the desired branch
194
    #   Use it
195
    #
196
    $opt_branch  = $current_branch;
197
}
198
else
199
{
200
    #
201
    #   Current branch has a different name
202
    #   Construct new branch name
203
    #
204
    $opt_branch = "$opt_branch.$current_branch";
205
    $target_branch .= "/$opt_branch";
206
}
207
 
208
Verbose2 ("TargetBranch : $target_branch" );
209
Verbose2 ("BranchPoint  : $branch_point" );
210
 
211
#
261 dpurdie 212
#   Determine the desired label for the package
213
#   May need to pick an unassigned label
214
#
215
determine_package_label();
216
 
217
#
218
#   Ensure that the specified package label exists
227 dpurdie 219
#   Determine if it is locked too
261 dpurdie 220
#   
221
Verbose ("Checking package label: $pkg_label");
222
ClearCmd ('describe', '-fmt', '%[locked]p', "lbtype:$pkg_label" );
227 dpurdie 223
Error ("Program Terminated") if ( @error_list );
224
my $was_locked = 1 unless ( $last_result =~ m~unlocked~ );
225
 
226
#
227
#   Create the desired branch if it does not already exist
261 dpurdie 228
#   Detected locked element and unlock it
227 dpurdie 229
#
261 dpurdie 230
Verbose ("Checking branch existence: $opt_branch");
231
ClearCmd ('lstype', '-short', "brtype:$opt_branch" );
227 dpurdie 232
if ( $last_result =~ m~\(locked\)~ )
233
{
261 dpurdie 234
    Verbose ("Unlocking branch: $opt_branch");
235
    ClearCmd( 'unlock', '-c', 'Unlocked by JATS ABTSAVE', "brtype:$opt_branch" );
227 dpurdie 236
}
237
elsif ( $last_result ne $opt_branch )
238
{
261 dpurdie 239
    Verbose ("Create new branch: $opt_branch");
240
    ClearCmd ('mkbrtype', '-c', "Contains saved versions of $opt_ofile files created by the AutoBuild system", $opt_branch );
227 dpurdie 241
    Error ("Program Terminated") if ( @error_list );
242
}
243
 
244
#
245
#   Ensure that the file is not locked
246
#   Unlock the file - can't do anything to a 'locked' file
247
#
261 dpurdie 248
Verbose ("Checking for locked file: $opt_ofile");
249
ClearCmd ('lslock', '-short', $opt_ofile );
227 dpurdie 250
if ( $last_result )
251
{
261 dpurdie 252
    Verbose ("Unlocking file: $opt_ofile");
253
    ClearCmd( 'unlock', '-c', 'Unlocked by JATS ABTSAVE', $opt_ofile );
227 dpurdie 254
}
255
 
256
if ( $current_branch ne $opt_branch )
257
{
258
    #
259
    #   Need to create the initial branch point, but only if one does not already
260
    #   exists
261
    #
261 dpurdie 262
    Verbose ("Check for existing branch: $opt_branch" );
331 dpurdie 263
    if ( ClearCmd( 'find', $opt_ofile, '-branch', "brtype($opt_branch)", '-print' ) )
227 dpurdie 264
    {
265
        Error ("Internal error. Cleartool find should not fail");
266
    }
267
    if ( $last_result )
268
    {
269
        #
270
        #   A branch already exists - and there can only be one
271
        #
331 dpurdie 272
        $last_result =~ m~@@(.*)~;
227 dpurdie 273
        $target_branch = $1;
274
        Error ("Cannot determine full branch path: $last_result") unless ( $target_branch );
275
        Verbose2 ("Target Branch: $target_branch" );
276
    }
277
    else
278
    {
279
        Verbose ("Create the initial branch point" );
261 dpurdie 280
        ClearCmd( 'mkbranch', '-nco', '-nc', '-nwarn', $branch_point, $opt_branch, $opt_ofile );
227 dpurdie 281
    }
282
}
283
 
284
#
285
#   Ensure that the branch with the target auto builder file on is not locked
286
#
261 dpurdie 287
ClearCmd ( 'lslock', '-short', "$opt_ofile\@\@$target_branch" );
227 dpurdie 288
if ( $last_result )
289
{
261 dpurdie 290
    Verbose ("Unlocking branch: $target_branch");
291
    ClearCmd( 'unlock', '-c', 'Unlocked by JATS ABTSAVE', "$opt_ofile\@\@$target_branch" );
227 dpurdie 292
}
293
 
294
 
295
#
296
#   Look for a checked out file on the target branch
297
#   It may be reserved - this will kill the process, so unreserve it
298
#
261 dpurdie 299
if ( ClearCmd( 'lsco', '-long', '-brtype', $opt_branch, $opt_ofile ) )
227 dpurdie 300
{
301
    Error ("Internal error. Cleartool lsco should not fail");
302
}
303
 
241 dpurdie 304
#
305
#   Can only have one 'reserved' checkout on the branch, but it may not
306
#   be the first one listed.
307
#       Lines are in sets of 3
308
#           1) Not used
309
#           2) Has keyword reserved
310
#           3) Has full path to view server
311
#   Need veiew server path, iff its a reserved checkout
312
#
313
my $reserved = undef;
314
foreach ( @last_results )
227 dpurdie 315
{
316
    #
241 dpurdie 317
    #   Once reserved has been seen, the next line will contain the view path
321 dpurdie 318
    #   Note: ClearCmd has changed \ to /, so change them back
319
    #         May be problematical. It looks like this has been
320
    #         changed several times.
227 dpurdie 321
    #
241 dpurdie 322
    if ( $reserved )
323
    {
324
        m~\(\"(.+)\"\)~;
325
        my $view = $1;
321 dpurdie 326
        $view =~ s~/~\\~g unless ( $ENV{GBE_UNIX} );
327
        Verbose ("Reserved checkout: Target View: $view" );
261 dpurdie 328
        ClearCmd( 'unreserve', '-comment', 'Unreserved by JATS ABTSAVE', '-view', $view, $opt_ofile );
241 dpurdie 329
        #
330
        #   Only one reserved file can exist, so there is no more to do
331
        #
332
        last;
333
    }
334
 
335
    #
336
    #   Check to see if this line flags a reserved version
337
    #
338
    $reserved = m~\(reserved\)~;
227 dpurdie 339
}
340
 
341
#
342
#   Use clearcase to checkout the output file
343
#
261 dpurdie 344
Verbose ("Checkout file: $opt_ofile" );
345
ClearCmd ('co', '-nc', '-nq', '-ndata', '-nwarn', '-branch', $target_branch, $opt_ofile);
227 dpurdie 346
Error ("Program Terminated") if ( @error_list );
347
 
348
#
349
#   Place the label on this file
350
#       If the label is locked then unlock it first
351
#       This is OK, because we are the builder ( or have permission )
352
#
261 dpurdie 353
if ( $was_locked )
354
{
355
    Verbose ("Relocking label: $pkg_label");
356
    ClearCmd ('unlock', "lbtype:$pkg_label" );
357
}
227 dpurdie 358
 
261 dpurdie 359
ClearCmd ('mklabel', '-replace', $pkg_label, $opt_ofile );
227 dpurdie 360
my @delayed_error = @error_list;
361
 
261 dpurdie 362
ClearCmd ('lock', "lbtype:$pkg_label" ) if $was_locked;
227 dpurdie 363
 
364
#
365
#   Place a Hyperlink Merge arrow between the two files if it looks as though we
366
#   have stolen the file or its label. If the original build file is on a different branch
367
#   the we have stolen it.
368
#
261 dpurdie 369
Verbose ("Check need to create a Hyperlink" );
227 dpurdie 370
 
371
my $target_name = $opt_ofile;
372
Verbose2 ("FullName: $full_name :Branch: $full_branch" );
373
Verbose2 ("TargetName: $target_name :Branch: $target_branch" );
374
 
375
if ( ( $full_branch ne $target_branch ) && ( !$opt_newbranch ) )
376
{
261 dpurdie 377
    Verbose ("Creating Hyperlink" );
378
    ClearCmd ('mkhlink', 'Merge', $full_name, $target_name);
227 dpurdie 379
}
380
 
381
#
382
#   Check in the file auto.pl file as the new build.pl file
383
#   This may get ugly if the current config-spec does not have a rule to
384
#   select the "new" build.pl file. This is often the case
385
#
386
#   Examine the error output and discard these errors
387
#
261 dpurdie 388
Verbose ("Check in build file: $opt_ofile" );
389
ClearCmd ('ci', '-c', "AutoBuilder checkin: $pkg_label", '-identical', '-from', $opt_infile, $opt_ofile);
227 dpurdie 390
Error ("Program Terminated") unless ( $last_result =~ m/Checked in "$opt_ofile" version/ );
391
 
392
@error_list = @delayed_error;
393
Error ("Program Terminated") if ( @error_list );
394
 
261 dpurdie 395
#
396
#   Label the view
397
#
398
label_build_view();
399
 
227 dpurdie 400
exit 0;
401
 
402
#-------------------------------------------------------------------------------
261 dpurdie 403
# Function        : locate_build_directory
404
#
405
# Description     : Locate the build directory that contains the build files
406
#                   In an ANT build, this will e the root of the package
407
#                   Otherwise the build files may not be in the root directory
408
#
409
#
410
# Inputs          : Globals
411
#
412
# Returns         : Globals
413
#
414
sub locate_build_directory
415
{
416
    return unless ( $opt_locate );
417
 
418
    my $bscanner = BuildFileScanner ( '.', $opt_infile );
419
    my $count = $bscanner->locate();
420
 
421
    Error ("Autolocate. Build file not found: $opt_infile" )
422
        if ( $count <= 0 );
423
 
424
    #
425
    #   If multiple build files have been found
426
    #   Scan the buildfiles and determine the names of the packages that will
427
    #   be built. This can be used to generate nice error messages
428
    if ( $count > 1 )
429
    {
430
        $bscanner->scan();
431
        $count = $bscanner->match( $opt_locate );
432
 
433
        my $errmess;
434
        if ( $count <= 0 ) {
435
            $errmess = "None found that build package: $opt_locate";
436
 
437
        } elsif ( $count > 1 ) {
438
            $errmess = "Multiple build files build the required package: $opt_locate";
439
        }
440
 
441
        #
442
        #   Pretty error display
443
        #   Display build directory and the package name (mangled)
444
        #
445
        if ( $errmess )
446
        {
447
            Error ("Autolocate. Multiple build files found.",
448
                   $errmess,
449
                   "Build files found in:", $bscanner->formatData() );
450
        }
451
    }
452
 
453
    #
454
    #   Extract the required build file directory
455
    #
456
    my $dir = $bscanner->getMatchDir() || '';
457
    Verbose ("Autolocate. Found $count build files: $dir");
458
 
459
    #
460
    #   Select the one true build directory
461
    #
462
    if ( $dir ne '.' )
463
    {
464
        #
465
        #   Save the current directory for later
466
        #
467
        $root_dir = getcwd();
468
        chdir $dir || Error ("Cannot change directory: $dir");
469
    }
470
}
471
 
472
#-------------------------------------------------------------------------------
473
# Function        : determine_package_label
474
#
475
# Description     : Determine the label that is to be applied to the package
476
#                   There are several cases to consider
477
#                       1) Compatability mode: User provides label
309 dpurdie 478
#                       2) WIP Mode. Determine name of label to use in rename
261 dpurdie 479
#                       3) Create a new label
480
#
481
# Inputs          : Globals
482
#
483
# Returns         : Globals
484
#                       $pkg_label
485
#
486
sub determine_package_label
487
{
488
    #
489
    #   Determine the desired label for the package
490
    #   This is a function of the package name and the package version
491
    #   The two are joined with a '.'
492
    #
263 dpurdie 493
    $tag_label = $opt_pname . '_' . $opt_pversion;
261 dpurdie 494
 
495
    #
496
    #   Ensure that desired label is "free", if not then hunt for a new one
497
    #   Determine the name of a 'new' label
498
    #
499
    my $base_label = $tag_label;
500
    my $index = 0;
501
 
502
    while ( ++$index )
503
    {
504
        if ( $index > 20 )
505
        {
506
            Error ("Cannot determine new label. Retry limit exceeded");
507
        }
508
        Verbose2 ("Trying $tag_label");
509
 
510
        unless (ClearCmd ('describe', '-short', "lbtype:$tag_label" ) )
511
        {
512
            #
513
            #   Label found - so try another
514
            #
515
            Verbose2("Label found. Try another");
516
            $tag_label = $base_label . '.' . $index;
517
            next;
518
        }
519
 
520
        #
521
        #   Warn about non standard label
522
        #
523
        Verbose ("Package will be labeled: $tag_label");
524
        Warning ("Labeling with a non-standard label: $tag_label" )
525
            if ( $index > 1 );
526
        last;
527
    }
528
 
529
    #
530
    #   Free label has been found
531
    #   Create it now, unless we are processing a WIP
532
    #
533
    unless ( $opt_wiplabel )
534
    {
535
        Verbose ("Creating new label: $tag_label");
536
        ClearCmd ('mklbtype', '-c', 'Autobuild Created', $tag_label );
537
        Error ("Cannot create new label: $tag_label" ) if ( @error_list );
538
 
539
        #
540
        #   Mark as created by this utility
541
        #   Label should be deleted on error
542
        #
543
        $label_created = $tag_label;
544
        $pkg_label = $tag_label;
545
    }
546
    else
547
    {
548
        $pkg_label = $opt_wiplabel;
549
    }
550
}
551
 
552
#-------------------------------------------------------------------------------
553
# Function        : label_build_view
554
#
555
# Description     : Label the view
556
#
557
#                   Either:
558
#                       Rename the WIP label to required name
559
#                       Label all files in the view
331 dpurdie 560
#
561
#                   Always make the lable 'mine'
562
#                   This will prevent the old owner from unlocking the label.
563
#
261 dpurdie 564
#                   Use JATS to do the hard work
565
#
566
#
567
# Inputs          : Globals
568
#
569
# Returns         : 
570
#
571
sub label_build_view
572
{
573
    if ( $opt_wiplabel )
574
    {
575
        Verbose ("Rename label: From $opt_wiplabel to $tag_label");
309 dpurdie 576
        SystemConfig ( ExitOnError => 2);
331 dpurdie 577
        JatsCmd( 'label', '-unlock', $opt_wiplabel, '-rename', $tag_label, '-lock', '-mine' );
261 dpurdie 578
    }
579
    else
580
    {
581
        Verbose ("Apply new label to package: $tag_label");
265 dpurdie 582
 
261 dpurdie 583
        #
331 dpurdie 584
        #   Label the entire (static) view
585
        #   Use special form of the labeling process that is geared
586
        #   to label the entire view.
261 dpurdie 587
        #
321 dpurdie 588
        #       This will work because this should only be done within a
589
        #       static view based on a single label. Thus the view should
590
        #       contain ony the files that form the current package.
331 dpurdie 591
        #
309 dpurdie 592
        #   Handle errors as error exit will clean up
265 dpurdie 593
        #
331 dpurdie 594
        my $rv = JatsCmd( 'label', '-entireview', $tag_label, '-replace', '-lock', , '-mine' );
309 dpurdie 595
        Error ("Failed to label all files in view")
596
            if ( $rv );
261 dpurdie 597
    }
598
 
599
    #
600
    #   Write the label out to the specified file so that the user
601
    #   can do something with it
602
    #
603
    if ( $opt_infofile )
604
    {
605
 
606
        my $data = JatsProperties::New();
607
 
608
        $data->setProperty('Label', $tag_label);
609
        $data->setProperty('WipLabel', $opt_wiplabel ) if $opt_wiplabel;
610
        $data->setProperty('PackageName', $opt_pname);
611
        $data->setProperty('PackageVersion', $opt_pversion);
612
        $data->setProperty('clearcase.branch', $opt_branch);
613
 
614
        $data->Dump('InfoFile') if ($opt_verbose);
615
        $data->store( $opt_infofile );
616
    }
617
}
618
 
619
#-------------------------------------------------------------------------------
227 dpurdie 620
# Function        : ClearCmd
621
#
265 dpurdie 622
# Description     : Execute a ClearCase command and capture the results
241 dpurdie 623
#                   Errors are held in one array
624
#                   Result are held in another
227 dpurdie 625
#
626
# Inputs          :
627
#
628
# Returns         :
629
#
630
sub ClearCmd
631
{
261 dpurdie 632
    my $cmd = QuoteCommand (@_);
227 dpurdie 633
    Verbose2( "cleartool $cmd" );
634
 
635
        @error_list = ();
241 dpurdie 636
        @last_results = ();
227 dpurdie 637
        $last_result = undef;
638
 
639
        open(CMD, "cleartool $cmd  2>&1 |")    || Error( "can't run command: $!" );
640
        while (<CMD>)
641
        {
642
            chomp;
643
            $last_result = $_;
644
            $last_result =~ tr~\\/~/~s;
241 dpurdie 645
            push @last_results, $last_result;
227 dpurdie 646
 
261 dpurdie 647
            Verbose2 ( "cleartool resp:" . $_);
227 dpurdie 648
            push @error_list, $_ if ( m~Error:~ );
649
        }
650
        close(CMD);
651
 
652
    Verbose2( "Exit Status: $?" );
653
    return $? / 256;
654
}
655
 
656
#-------------------------------------------------------------------------------
657
# Function        : display_error_list
658
#
309 dpurdie 659
# Description     : Display the error list and clean up
227 dpurdie 660
#                   This function is registered as an Error callback function
661
#                   it will be called on error exit
662
#
663
# Inputs          :
664
#
665
# Returns         :
666
#
667
sub display_error_list
668
{
669
    foreach ( @error_list )
670
    {
671
        print "$_\n";
672
    }
309 dpurdie 673
 
674
    #
675
    #   Perform cleanup
676
    #       Delete the label if created it anyway (which we did)
677
    #       This leaves checked in build file on branch (live with it)
678
    #
679
    JatsCmd( 'label', '-delete', $tag_label )
680
        if ($label_created);
681
 
227 dpurdie 682
}
683
 
684
#-------------------------------------------------------------------------------
685
#   Documentation
686
#
687
 
688
=pod
689
 
690
=head1 NAME
691
 
261 dpurdie 692
jats_save_build - Save a build view to version control system
227 dpurdie 693
 
694
=head1 SYNOPSIS
695
 
696
  jats etool jats_save_build [options]
697
 
698
 Options:
261 dpurdie 699
    -help[=n]           - brief help message
227 dpurdie 700
    -help -help         - Detailed help message
261 dpurdie 701
    -man[=n]            - Full documentation
702
    -verbose[=n]        - Verbose operation
703
    -infile=xxx         - Input file (auto.pl)
704
    -outfile=xxx        - Output file (build.pl)
705
    -branch=xxx         - Branch to create (AutoBuilder)
227 dpurdie 706
    -newbranch          - Force file to be on a new (project) branch
261 dpurdie 707
    -infofile=path      - Save label information in 'path'
708
    -pname=name         - Name of the package
709
    -pversion=text      - Package version
710
    -locatepkg=text     - Package locator string
711
    -wiplabel=text      - Current package WIP label
227 dpurdie 712
 
713
=head1 OPTIONS
714
 
715
=over 8
716
 
261 dpurdie 717
=item B<-help[=n]>
227 dpurdie 718
 
719
Print a brief help message and exits.
720
 
261 dpurdie 721
The verbosity of the help text can be controlled by setting the help level to a
722
number in the range of 1 to 3, or by invoking the option multiple times.
227 dpurdie 723
 
261 dpurdie 724
=item B<-man[=n]>
227 dpurdie 725
 
261 dpurdie 726
Without a numeric argument this is the same as -help=3. Full help will be
727
displayed.
227 dpurdie 728
 
261 dpurdie 729
With a numeric argument, this option is the same as -help=n.
227 dpurdie 730
 
261 dpurdie 731
=item B<-verbose[=n]>
732
 
733
This option will increase the level of verbosity of the utility.
734
 
735
If an argument is provided, then it will be used to set the level, otherwise the
736
existing level will be incremented. This option may be specified multiple times.
737
 
738
=item B<-infile=xxxx>
739
 
740
This option specifies the name of the generated build configuration file that
741
will be used as a data-source for the check-in build file.
742
 
743
The default file name is 'auto.pl'.
744
 
745
=item B<-outfile=xxxx>
746
 
747
This option specifies the name of the target build configuration file that
748
will be checked in to version-control. Data from from file specifies with '-
749
infile' will be used to update the file.
750
 
751
The default file name is 'build.pl'.
752
 
753
=item B<-branch=xxxx>
754
 
755
This options specifies the root name of the target branch that will be sued to
756
contain the checked-in build file. If the branch does not exist it will be
757
created.
758
 
759
The default branch will be based on "AutoBuilder".
760
 
227 dpurdie 761
=item B<-newbranch>
762
 
763
This option will force the file to be checked into a new branch
764
The branch will be created on /main/0 unless it is already found elsewhere
765
 
766
This option allows a build.pl file to be placed on a new project branch.
767
 
261 dpurdie 768
=item B<-infofile=path>
769
 
770
This option specifies a file that this utility will use to communicate with a
771
user script. It will write the new label text into the file.
772
 
773
The file path is relative to the current working directory.
774
 
775
The file will be deleted, and only created if the utility is successful.
776
 
777
=item B<-pname=name>
778
 
779
This option specifies the package name. It will be used to construct a new
780
label for the package.
781
 
782
=item B<-pversion=xxx>
783
 
784
This option specifies the package version. It will be used to construct a new
785
label for the package.
786
 
787
=item B<-locatepkg=text>
788
 
789
This option specifies a name, by which the package's build files may be located.
790
This is only needed for JATS builds and will only be used to resolve the
791
location of build files when a package contains multiple build files.
792
 
793
=item B<-wiplabel=text>
794
 
795
This option controls the manner in which this utility will label the build view.
796
 
797
If present, the label specifies a 'Work In Progress' label. The label will be
798
renamed.
799
 
800
If not present, then the view will be labeled with a new label.
801
 
227 dpurdie 802
=back
803
 
804
=head1 DESCRIPTION
805
 
261 dpurdie 806
This utility is used by the automated build system to place build view under
807
version control. The utility will:
227 dpurdie 808
 
261 dpurdie 809
=over 8
227 dpurdie 810
 
261 dpurdie 811
=item * Determine a suitable label for the package
227 dpurdie 812
 
261 dpurdie 813
The label is constructed from the package name and the package version. The
814
utility will ensure that the label does not already exist. If it does it will
815
use an alternate form of the label.
816
 
817
=item * Determine a suitable branch name for the build files
818
 
819
The modified build file is placed on a file-branch.
820
 
821
=item * Locate the build files within the package
822
 
823
JATS build files do not need to be at the root of the package. The utility
824
will locate the JATS build files.
825
 
826
=item * Update the build files and save them into the version control system
827
 
828
The build file will be updated with new version information as provided by a
829
secondary configuration file.
830
 
831
The updated file will be checked into version control. It will be placed on a
832
branch so as not to affect dynamic views.
833
 
227 dpurdie 834
The operation will fail if that file is checked out "reserved". The program
835
can work around this - but its not done yet.
836
 
261 dpurdie 837
If the build file is sourced from a different branch then a Merge arrow
838
will be created to indicate where the file and its label was taken from.   
839
 
840
=item * Ensure that the package is labeled
841
 
842
The build view will be labeled.
843
 
844
If a WIP label is provided then the label will be applied to the modified
845
build file and then the label will be renamed.
846
 
847
If a WIP label is not provided, then the entire package will be labeled with a
848
suitable label.
849
 
850
=item * Return the label to the user
851
 
852
The label used to label the package will be returned to the user in an 'info'
853
file. This is a 'properties' file. The following properties are defined:
854
 
855
=over 8
856
 
857
=item   1) Label - The label used to tag the file
858
 
859
=item   3) WipLabel - The WIP label provided (optional)
860
 
861
=item   4) PackageName - The package name
862
 
863
=item   5) PackageVersion - The package version
864
 
865
=back
866
 
867
=back
868
 
227 dpurdie 869
=cut
870