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