Subversion Repositories DevTools

Rev

Rev 351 | Rev 357 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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