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