Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
#! perl
2
########################################################################
3
# Copyright ( C ) 2004 ERG Limited, All rights reserved
4
#
5
# Module name   : jats.sh
6
# Module type   : Makefile system
7
# Compiler(s)   : n/a
8
# Environment(s): jats
9
#
10
# Description   : Rewrite a build.pl file
11
#                 Use an external configuration file to provide a common
12
#                 source of configuration information
13
#
14
# Usage:
15
#
16
#......................................................................#
17
 
255 dpurdie 18
require 5.006_001;
227 dpurdie 19
use strict;
20
use warnings;
21
 
22
use JatsError;
23
use BuildName;
24
use Getopt::Long;
25
use Pod::Usage;                             # required for help support
26
 
27
 
28
################################################################################
29
#   Option variables
30
#
31
 
32
my $VERSION = "1.2.4";                      # Update this
33
my $opt_verbose = 0;
34
my $opt_datafile = "";
35
my $opt_ofile  = "auto.pl";
36
my $opt_infile = "build.pl";
37
my $opt_help = 0;
38
my $opt_manual;
39
my $opt_errors = 0;
40
my $opt_xml;
41
my $opt_oldproject;
42
my $opt_newproject;
43
 
44
#
45
#   Globals
46
#
47
my %component =  ();
48
my %component_use =  ();
49
my $not_use_count = 0;
50
my $suffix_count = 0;
51
 
247 dpurdie 52
#
53
#   Known extended fields
54
#   Only these values may be configured with the value=tag syntax
55
#   These may not be used as package names
56
#
57
my %fields = (
58
    'releasemanager.releasename' => undef,
59
    'releasemanager.projectname' => undef,
60
);
227 dpurdie 61
 
62
my $result = GetOptions (
63
                "help+"     => \$opt_help,          # flag, multiple use allowed
64
                "manual"    => \$opt_manual,        # flag
65
                "verbose+"  => \$opt_verbose,       # flag
66
                "config=s"  => \$opt_datafile,      # string
67
                "outfile=s" => \$opt_ofile,         # string
68
                "infile=s"  => \$opt_infile,        # string
69
                "errors"    => \$opt_errors,        # flag
70
                "xml!"       => \$opt_xml,          # flag
71
                "oldproject=s"  => \$opt_oldproject,
72
                "newproject=s"  => \$opt_newproject,
73
                );
74
 
75
#
76
#   Process help and manual options
77
#
78
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
79
pod2usage(-verbose => 1)  if ($opt_help == 2 );
80
pod2usage(-verbose => 2)  if ($opt_manual || ($opt_help > 2));
81
 
82
#
83
#   Configure the error reporting process now that we have the user options
84
#
85
ErrorConfig( 'name'    =>'REWRITE',
86
             'verbose' => $opt_verbose );
87
 
88
Error ("Must specify both Old and New project tags")
89
    if ( $opt_newproject xor $opt_oldproject );
90
 
91
Error ("No configuration file specified")
92
    unless ( $opt_datafile || $opt_newproject  );
93
 
94
Error ("Input and output file are the same" )
95
    if ( $opt_infile eq $opt_ofile );
96
 
97
#
98
#   Auto detect XML files
99
#
100
$opt_xml = 1
101
    if ( $opt_infile =~ m~\.xml$~i );
102
 
103
#
104
#   Process config and input files
105
#
106
read_config_file()          if $opt_datafile;
107
process_build_file()        unless( $opt_xml);
108
process_xml_build_file()    if ( $opt_xml);
109
 
110
Verbose ("Number of project extensions changed: $suffix_count")
111
    if ( $ opt_newproject );
112
 
113
Warning("No project extensions changed")
114
    if ( !$suffix_count && $opt_newproject);
115
 
116
Error("Unused packages found: $not_use_count")
117
    if ( $opt_errors && $not_use_count && $opt_datafile);
118
 
119
 
120
exit 0;
121
 
122
#-------------------------------------------------------------------------------
123
# Function        : read_config_file
124
#
125
# Description     : Read and store config file information
126
#
127
# Inputs          :
128
#
129
# Returns         :
130
#
131
 
132
sub read_config_file
133
{
134
    open ( FILE, "<$opt_datafile" ) or Error ("Config file ($opt_datafile) not found" );
135
    while ( <FILE> )
136
    {
137
        #
138
        #   Clean up lines
139
        #   Skip comments and blank lines
140
        #   Remove leading and training white space
141
        #
142
        chomp;
143
        s~^\s*~~;
144
        s~#.*$~~;
145
        s~\s*$~~;
146
        next if ( length( $_) <= 0 );
147
 
148
#        Verbose ($_);
149
 
150
        #
247 dpurdie 151
        #   Extract special fields
152
        #   These are not dependent packages and are not mandatory
153
        #   These are of the form tag = name
154
        #
155
        if ( m{(\S+)\s*=\s*(.+)} )
156
        {
157
            Error ("Unsupported named field")  unless ( exists $fields{$1} );
158
            $fields{$1} = $2;
159
            Verbose ("Field: $1, \"$2\"");
160
            next;
161
        }
162
 
163
        #
227 dpurdie 164
        #   Process LinkPkgArchive and BuildPkgArchive statements
165
        #   These allow simple updating of the config file from Release manager
166
        #
167
        if ( m/LinkPkgArchive/ or m/BuildPkgArchive/ )
168
        {
169
            m/'(.*)'[^']*'(.*)'/;
170
 
171
            my $comp = $1;
172
            my $ver = $2;
173
 
174
#print "Got Archive stuff: $_ : $comp, $ver\n";
175
 
176
            Error "Version not specified for: $comp" unless ( $ver );
177
            Warning "Suspect version format for: $comp ($ver)" unless ( $ver =~ m~^\w+\.\w+\.\w+.\w+$~ || $ver =~ m~^\w+\.\w+\.\w+$~ );
178
 
179
            save_package( $comp, $ver );
180
            next;
181
        }
182
 
183
 
184
 
185
        #
186
        #   Process line as
187
        #       component version
188
        #
189
        my ( $comp, $ver, $opt ) = split( /[\s,]+/, $_, 3);
190
        Error "Version not specified for: $comp" unless ( $ver );
191
        Warning "Suspect version format for: $comp ($ver)" unless ( $ver =~ m~^\w+\.\w+\.\w+.\w+$~ || $ver =~ m~^\w+\.\w+\.\w+$~ );
192
        save_package( $comp, $ver );
193
    }
194
    close FILE;
195
 
196
#    DebugDumpData ("component", \%component );
197
}
198
 
199
#-------------------------------------------------------------------------------
200
# Function        : print_update
201
#
202
# Description     : Generate a display line tracking the changes made
203
#
204
# Inputs          :
205
#                   $title          - Update Type
206
#                   $name           - Package name
207
#                   $version        - Original version of package
208
#                   $new_version    - New version
209
#
210
# Returns         :
211
#
212
sub print_update
213
{
214
    my ($title, $name, $version, $new_version ) = @_;
215
    my $diff = ( $version ne $new_version ) ? '*' : '';
216
 
217
    #
218
    #   Always display diffs
219
    #   Display all if verbose
220
    #
221
    if ( $diff || $opt_verbose  )
222
    {
223
        $title = 'Package' unless ( $title );
224
        Message( sprintf("%-8s: %-35s, Version: %-15s %1.1s-> %-15s\n", $title, $name ,$version, $diff, $new_version));
225
    }
226
}
227
 
228
#-------------------------------------------------------------------------------
229
# Function        : process_build_file
230
#
231
# Description     : Rewrite one file
232
#                   build.pl -> build-new.pl
233
#
234
# Inputs          :
235
#
236
# Returns         :
237
#
238
sub process_build_file
239
{
240
    Verbose ("Processing build file: $opt_infile");
241
 
242
    #
243
    #   Unlink any OLD output file
244
    #
245
    unlink $opt_ofile;
246
 
247
    #
248
    #   Open the input and output files
249
    #
250
    open ( INFILE, "<$opt_infile" ) || Error( "Cannot open $opt_infile" );
251
    open ( OUTFILE, ">$opt_ofile" ) || Error( "Cannot create $opt_ofile" );
252
 
253
    my $build_info;
254
 
255
    my $release_name;
256
    my $release_version;
257
 
258
    while ( <INFILE> )
259
    {
260
        next if ( m~^\s*#~ );            # Skip comments
261
        #
262
        #   Process BuildName
263
        #
264
        if ( m~\s*BuildName[\s\(]~ )
265
        {
266
            #   Build names come in many flavours
267
            #   Must support a number of different formats
268
            #       "name nn.nn.nn prj"
269
            #       "name nn.nn.nn.prj"
270
            #
271
            #       "name nn.nn.nn prj", "nn.nn.nn"
272
            #       "name nn.nn.nn.prj", "nn.nn.nn"
273
            #
274
            #       "name", "nn.nn.nn.prj"
275
            #
276
            m~\(\s*(.*?)\s*\)~;
277
            my @args = split /\s*,\s*/, $1;
278
            $build_info = parseBuildName( @args );
279
 
280
            my $new_ver = get_package ( $build_info->{BUILDNAME_PACKAGE}, $build_info->{BUILDVERSION} );
281
            my $build_args = genBuildName( $build_info, $new_ver );
282
 
283
            #
284
            #   Rewrite the body of the directive
285
            #
286
            s~\(\s*(.*?)\s*\)~( $build_args )~;
287
            print_update( '', $build_info->{BUILDNAME_PACKAGE}, $build_info->{BUILDVERSION}, $new_ver );
288
 
289
        }
290
 
291
        #
292
        #   Process BuildPreviousVersion
293
        #   Save the current version information in this directive
294
        #
295
        if ( m/^\s*BuildPreviousVersion/ )
296
        {
297
            Error ("BuildPreviousVersion directive before BuildName") unless ( $build_info );
298
            m/['"](.*?)['"]/;
299
            my $prev = $1;
300
 
301
            s/['"](.*?)['"]/'$build_info->{BUILDVERSION}'/;
302
            print_update( 'PrevVer', '', $prev, $build_info->{BUILDVERSION} );
303
        }
304
 
305
        #
306
        #   Process BuildPkgArchive and LinkPkgArchive
307
        if ( m/^\s*LinkPkgArchive/ or m/^\s*BuildPkgArchive/ )
308
        {
309
            m/['"](.*?)['"][^'"]*['"](.*?)['"]/;
310
 
311
            my $comp = $1;
312
            my $ver = $2;
313
            my $new_ver = get_package ( $comp, $ver );
314
            s/['"](.*?)['"]([^'"]*)['"](.*?)['"]/'$comp'$2'$new_ver'/;
315
            print_update ('', $comp ,$ver, $new_ver );
316
        }
317
 
318
 
319
    } continue
320
    {
321
        #
322
        #   Always output the resultant line
323
        #
324
        print OUTFILE $_;
325
    }
326
 
327
    #
328
    #   Cleanup
329
    #
330
    close INFILE;
331
    close OUTFILE;
332
    display_unused();
333
}
334
 
335
#-------------------------------------------------------------------------------
336
# Function        : process_xml_build_file
337
#
338
# Description     : Rewrite one depends.xml file
339
#                   depends.xml -> auto.xml
340
#
341
#                   A very cheap and nasty XML (not)parser
342
#                   It assumes that entries are all on one line so that we can
343
#                   do trivial substitutions
344
#
345
#                   Processes
346
#                       <using ... >
247 dpurdie 347
#                       <property name="packagename" value="...">
348
#                       <property name="packageversion" value="...">
349
#                       <property name="releasemanager.releasename" value="...">
350
#                       <property name="releasemanager.projectname" value="...">
227 dpurdie 351
#                       <import file=...>
352
#
247 dpurdie 353
#                  Note: This function handles a wider scope of XML files
354
#                        than it really needs to. All thats needed is
249 dpurdie 355
#                        the <property name= value=> fields.
227 dpurdie 356
#
357
# Inputs          :
358
#
359
# Returns         :
360
#
361
sub process_xml_build_file
362
{
363
    Verbose ("$opt_infile");
364
 
365
    #
366
    #   Unlink any OLD output file
367
    #
368
    unlink $opt_ofile;
369
 
370
    #
371
    #   Open the input and output files
372
    #
373
    open ( INFILE, "<$opt_infile" ) || Error( "Cannot open $opt_infile" );
374
    open ( OUTFILE, ">$opt_ofile" ) || Error( "Cannot create $opt_ofile" );
375
 
376
    my $release_name;
377
    my $release_version;
378
 
379
    while ( <INFILE> )
380
    {
381
        #
382
        #   Process "project" statement
383
        #
384
        if ( m~<project~ )
385
        {
386
            #   Extract the package name
387
            #   this to determine the required version of the package
388
            #
249 dpurdie 389
            if ( m~name="([^"]*)"~ )
233 dpurdie 390
            {
391
                $release_name = $1;
392
                Error ("Empty 'name' attribute not found in 'project'") unless ( $release_name );
393
                Verbose2 ("Project: $release_name");
394
            }
227 dpurdie 395
        }
396
 
397
        #
398
        #   Process "property" statements
399
        #
400
        elsif ( m~<property~ )
401
        {
402
            #
247 dpurdie 403
            #   Extract name and value
404
            #   Both must exist
227 dpurdie 405
            #
247 dpurdie 406
            my $name;
407
            my $value;
227 dpurdie 408
 
249 dpurdie 409
            if ( m~name="([^"]*)"~  )
247 dpurdie 410
            {
411
                $name = $1;
412
            }
413
            else
414
            {
415
                Error ("Name attribute not found in 'property'");
416
            }
417
 
249 dpurdie 418
            if ( m~value="([^"]*)"~ )
247 dpurdie 419
            {
420
                $value = $1;
421
            }
422
            else
423
            {
424
                Error ("Value attribute not found in $name 'property'");
425
            }
426
            Verbose2 ("Property: $name, Value: $value");
427
 
227 dpurdie 428
            #
247 dpurdie 429
            #   Examine th property name
430
            #   Some of the them are special, others will be package names
227 dpurdie 431
            #
432
            if ( $name eq 'packagename' )
433
            {
247 dpurdie 434
                $release_name = $value;
227 dpurdie 435
                Error ("Value attribute not found in packagename 'property'") unless ( $release_name );
436
            }
437
            elsif ( $name eq 'packageversion' )
438
            {
247 dpurdie 439
                $release_version = $value;
227 dpurdie 440
 
441
                #
442
                #   Ensure that we already have the package name
443
                #
444
                Error ("packageversion before packagename") unless ( $release_name );
445
 
446
                my $new_ver = get_package ( $release_name, $release_version );
249 dpurdie 447
                s~(.*)value="([^"]*)"~$1value=\"$new_ver\"~;
227 dpurdie 448
                print_update( '', $release_name ,$release_version, $new_ver );
449
            }
247 dpurdie 450
            elsif ( defined $fields{$name} )
227 dpurdie 451
            {
452
                #
247 dpurdie 453
                #   Use tagged values in preference to packages
454
                #   There are very few tagged values.
227 dpurdie 455
                #
247 dpurdie 456
                my $new_value = $fields{$name};
457
                Error ("Release attribute not found: $name") unless ( $new_value );
458
 
249 dpurdie 459
                s~(.*)value="([^"]*)"~$1value=\"$new_value\"~;
247 dpurdie 460
                print_update( 'Release', $name ,$value, $new_value );
227 dpurdie 461
            }
462
            else
463
            {
247 dpurdie 464
                my $new_ver = get_package ( $name, $value );
249 dpurdie 465
                s~(.*)value="([^"]*)"~$1value=\"$new_ver\"~;
247 dpurdie 466
                print_update( '', $name ,$value, $new_ver );
227 dpurdie 467
            }
468
        }
469
 
470
        #
471
        #   Process "using" statements
472
        #
473
        elsif ( m~<using~ )
474
        {
475
            #
476
            #   Extract the package name and version
477
            #   and use this to determine the required version of the package
478
            #
249 dpurdie 479
            m~name="([^"]*)"~;
227 dpurdie 480
            my $name = $1;
481
            Error ("Name attribute not found in 'using'") unless ( $name );
482
            Verbose2 ("Using: $name");
483
 
484
            #
485
            #   Extract the version
486
            #
249 dpurdie 487
            m~version="([^"]*)"~;
227 dpurdie 488
            $release_version = $1;
489
            Error ("Version attribute not found in package 'using' : $name") unless ( $release_version );
490
 
491
            my $new_ver = get_package ( $name, $release_version );
249 dpurdie 492
            s~(.*)version="([^"]*)"~$1version=\"$new_ver\"~;
227 dpurdie 493
            print_update( '', $name ,$release_version, $new_ver );
494
        }
495
 
496
        #
497
        #   Import File
247 dpurdie 498
        #   Only used to import ant-using
227 dpurdie 499
        #
500
        elsif ( m~<import~ )
501
        {
502
            #
503
            #   Extract the file
504
            #
249 dpurdie 505
            m~file="([^"]*)"~;
227 dpurdie 506
            my $file = $1;
507
            Error ("File attribute not found in 'import'") unless ( $file );
508
 
509
            #
510
            #   Extract the package name and version from the file
511
            #   Will be of the form /package/version/filename
512
            #
513
            $file =~ m~(.*?)/([^/]+)/([^/]+)/([^/]+)$~;
514
            my $prefix = $1;
515
            my $pname = $2;
516
            my $pver = $3;
517
            my $fname = $4;
518
            Error ("Package details not found in import file") unless ( $fname );
519
 
520
            my $new_ver = get_package ( $pname, $pver );
521
 
522
            #
523
            #   Rewrite the body of the directive
524
            #
249 dpurdie 525
            s~(.*)file="([^"]*)"~$1file=\"$prefix/$pname/$new_ver/$fname\"~;
227 dpurdie 526
            print_update( '', $pname ,$pver, $new_ver );
527
        }
528
 
529
    } continue
530
    {
531
        #
532
        #   Always output the resultant line
533
        #
534
        print OUTFILE $_;
535
    }
536
 
537
    #
538
    #   Cleanup
539
    #
540
    close INFILE;
541
    close OUTFILE;
542
    display_unused();
543
}
544
 
545
#-------------------------------------------------------------------------------
546
# Function        : display_unused
547
#
548
# Description     : Generate warnings about config items that were not used
549
#
550
# Inputs          :
551
#
552
# Returns         :
553
#
554
sub display_unused
555
{
556
    foreach my $comp ( sort keys %component_use )
557
    {
558
        foreach my $suf ( keys %{$component_use{$comp}} )
559
        {
560
            my $ver = get_version( $comp, $suf );
561
            Warning("Unused package: ${comp}_${ver}");
562
            $not_use_count++;
563
        }
564
    }
565
}
566
 
567
 
568
#-------------------------------------------------------------------------------
569
# Function        : save_package
570
#
571
# Description     : Save the package name and version
572
#
573
# Inputs          : $package
574
#                   $version
575
#
576
# Returns         : Nothing
577
#
578
sub save_package
579
{
580
    my ($package, $version) = @_;
581
 
582
    #
583
    #   Split the suffix off the version
584
    #
585
    my ($rel, $suf ) = extract_version( $package, $version);
586
 
587
    Error ("Multiple definitions for $package $version" )
588
        if ( $component{$package}{$suf} );
589
 
247 dpurdie 590
    Error ("Package Name is a reserved key field: $package" )
591
        if ( exists $fields{$package} );
592
 
227 dpurdie 593
    $component{$package}{$suf} = $rel;
594
    $component_use{$package}{$suf} = $rel;
595
 
596
    Verbose2 ("Package: $package, $version, $rel, $suf");
597
 
598
}
599
 
600
#-------------------------------------------------------------------------------
601
# Function        : get_package
602
#
603
# Description     : get the package version
604
#
605
# Inputs          : $package
606
#                   $version ( suffix is used only )
607
#
608
# Returns         : Replacement version
609
#
610
 
611
sub get_package
612
{
613
    my ($package, $version) = @_;
614
 
615
    #
616
    #   Split the suffix off the version
617
    #       Suffixes are not numeric
618
    #   Must allow for
619
    #       9.9.9
620
    #       9.9.cots
621
    #       9.9.9.cots
622
    #
623
    my ($rel, $suf ) = extract_version( $package, $version);
624
 
625
    Verbose2 ("Get Package: $package, $version, $rel, $suf");
626
 
627
    #
628
    #   If the CFG file has 'new' project extensions then we
629
    #   must transform them before attempting to look up the versions
630
    #
631
    if ( $opt_oldproject && $suf eq $opt_oldproject )
632
    {
633
        $suf = $opt_newproject;
634
        $suffix_count++;
635
    }
636
 
637
    #
638
    #   If a datafile was provided, then the packages MUST be present
639
    #
640
    if ( $opt_datafile )
641
    {
642
        Error ("No definitions for the package '$package'" )
643
            unless ( exists $component{$package} );
644
 
645
    #    print Data::Dumper->Dump ( [\%component], ["Component" ]);
646
 
647
        Error ("No definitions for '$package' '$version' '$suf'" )
648
            unless ( exists $component{$package}{$suf} );
649
    }
650
 
651
    #
652
    #   remove used packages from the "use" hash
653
    #
654
    delete $component_use{$package}{$suf};
655
    delete $component_use{$package} unless ( keys %{$component_use{$package}} );
656
 
657
    #
658
    #   Was the suffix real
659
    #
660
    return get_version( $package, $suf, $rel );
661
}
662
 
663
#-------------------------------------------------------------------------------
664
# Function        : extract_version
665
#
666
# Description     : Extracts a version and project suffix from a string
667
#
668
# Inputs          : $1  - Package name
669
#                   $2  - Package Version Input string
670
#
671
# Returns         : $1  - Vesrion part
672
#                   $2  - Suffix (project) part
673
#
674
sub extract_version
675
{
676
    my ($package, $version) = @_;
677
 
678
    my $rel;
679
    my $suf;
680
 
681
    if ( $version =~ m~^(.*?)([\.\s]([^0-9]+))$~ )
682
    {
683
        $rel = $1;
684
        $suf = $3;
685
        $suf = '' unless ( $suf );
686
    }
687
    else
688
    {
689
        $rel = $version;
690
        $suf = '';
691
    }
692
 
693
    return ( $rel, $suf );
694
}
695
 
696
#-------------------------------------------------------------------------------
697
# Function        : get_version
698
#
699
# Description     : Create a nice package version
700
#
701
# Inputs          : $package
702
#                   $suf
703
#
704
# Returns         :
705
#
706
sub get_version
707
{
708
    my ($package,$suf, $version) = @_;
709
 
710
    if ( exists( $component{$package}{$suf} ) )
711
    {
712
        $version = $component{$package}{$suf};
713
    }
714
 
715
    if ( $opt_oldproject && $suf eq $opt_oldproject )
716
    {
717
        $suf = $opt_newproject;
718
        $suffix_count++;
719
    }
720
 
721
    $version .= '.' . $suf if ( length( $suf) );
722
    return  $version;
723
 
724
}
725
 
726
#-------------------------------------------------------------------------------
727
# Function        : genBuildName
728
#
729
# Description     : Generate a BuildName argument string
730
#
731
# Inputs          : build_info      - Hash of buildname arguments
732
#                   new_ver         - New version
733
#
734
# Returns         : A string of quoted BuildName arguemnts
735
#
736
sub genBuildName
737
{
738
    my ( $build_info, $new_ver ) = @_;
739
    my @args;
740
 
741
    #
742
    #   Remove the project part from the new version name
743
    #
744
    my $prj = $build_info->{BUILDNAME_PROJECT};
745
 
746
    $prj = $opt_newproject
747
        if ( $opt_oldproject && $prj eq $opt_oldproject );
748
 
749
    $new_ver =~ s~\.$prj$~~ if ( $prj );
750
 
751
    #
752
    #   Determine the format of the BuildName
753
    #
754
    if ( $build_info->{RELAXED_VERSION} )
755
    {
756
        #
757
        #   Relaxed format
758
        #
759
        push @args, $build_info->{BUILDNAME_PACKAGE};
760
        push @args, $new_ver;
761
        push @args, $prj if ( $prj );
762
        push @args, '--RelaxedVersion';
763
    }
764
    else
765
    {
766
        #
767
        #   Generate two field version as some of the deployment scripts
768
        #   need this format.
769
        #
770
        push @args, "$build_info->{BUILDNAME_PACKAGE} $new_ver $prj";
771
        push @args, "$new_ver";
772
    }
773
 
774
    #
775
    #   Common arguments
776
    #
777
    push @args, "--PatchNum=$build_info->{DEPLOY_PATCH}"
778
        if ( $build_info->{DEPLOY_PATCH} );
779
 
780
    push @args, @{$build_info->{EXTRA_ARGS}} if exists ($build_info->{EXTRA_ARGS});
781
 
782
 
783
    #
784
    #   Format the arguments
785
    #
786
    return join ", ", map { "'$_'" } @args;
787
}
788
 
789
#-------------------------------------------------------------------------------
790
#   Documentation
791
#
792
 
793
=pod
794
 
795
=head1 NAME
796
 
797
jats_rewrite - Rewrite a build.pl file
798
 
799
=head1 SYNOPSIS
800
 
801
  jats etool jats_rewrite [options]
802
 
803
 Options:
804
    -help               - brief help message
805
    -help -help         - Detailed help message
806
    -man                - Full documentation
807
    -verbose            - Verbose operation
808
    -config xxx         - Configuration file. Full file name
809
    -oldproject         - Old project extension (optional)
810
    -newproject         - New project extension (optional)
811
    -infile xxx         - Input file (build.pl)
812
    -outfile xxx        - Output file (auto.pl)
813
    -errors             - Generate errors for unused config items
814
    -xml                - Process a build.xml file
815
 
816
=head1 OPTIONS
817
 
818
=over 8
819
 
820
=item B<-help>
821
 
822
Print a brief help message and exits.
823
 
824
=item B<-help -help>
825
 
826
Print a detailed help message with an explanation for each option.
827
 
828
=item B<-man>
829
 
830
Prints the manual page and exits.
831
 
832
=item B<-verbose>
833
 
247 dpurdie 834
Increases program output. This option may be specified multiple times
227 dpurdie 835
 
836
=item B<-config=xxx>
837
 
838
This option specifies the name of a configuration file that will provide the
839
transformation between of version numbers. The format of the config file is
840
described later.
841
 
842
The option is not required if -newproject and -oldproject are specified
843
 
844
=item B<-oldproject=xxx>
845
 
846
This option, in conjunction with B<-oldproject=xxx> allows the project
247 dpurdie 847
extensions to be modified. ie: .syd projects can be converted into .bej
227 dpurdie 848
projects.
849
 
247 dpurdie 850
If this option is present then the config data file is not required, although
227 dpurdie 851
it will be sued if it is present.
852
 
853
=item B<-newproject=xxx>
854
 
855
See B<-oldproject=xxx>
856
 
857
 
858
=item B<-infile=xxx>
859
 
860
The name of the input file. The default file is build.pl
861
 
862
=item B<-outfile=xxx>
863
 
864
The name of the output file. The default is auto.pl, even if an XML file is
865
being processed.
866
 
867
=item B<-errors>
868
 
869
This option will force the program to generate an error message if there are
870
packages in the config file that were not used by the re-write process.
871
 
872
=item B<-xml>
873
 
874
Process a build.xml file instead of a build.pl file.
247 dpurdie 875
This option will be set internally if the infile extension is '.xml'
227 dpurdie 876
 
877
=back
878
 
879
=head1 DESCRIPTION
880
 
247 dpurdie 881
This utility is used within the automated build system to rewrite build files
882
so that they contain suitable version numbers.
227 dpurdie 883
 
247 dpurdie 884
The program takes a configuration file, described below, that contains package
885
and version information for the build.
886
 
887
The program takes a JATS build.pl file, or an ANT style dependency file, and
888
will create a file that is similar, but contains modified package-version
889
information.
890
 
891
The build tools are designed to use this I<auto> file, in preference to the
892
original build file.
893
 
894
=head2 Format of the Configuration File
895
 
227 dpurdie 896
The format of the configuration file is defined below.
897
 
247 dpurdie 898
The file is a line oriented text file.
227 dpurdie 899
 
247 dpurdie 900
Comments begin with a # and go the end of the line.
227 dpurdie 901
 
247 dpurdie 902
There are three types of configuration line:
227 dpurdie 903
 
247 dpurdie 904
=over 8
905
 
906
=item Assigned Items
907
 
908
These are of the form: B<tag = value> and are used to specify the value of
909
the following B<special> properties:
910
 
911
=over 8
912
 
913
=item releasemanager.projectname
914
 
915
The name of the Release Manager project used for the build.
916
 
917
=item releasemanager.releasename
918
 
919
The name of the Release Manager release, within the project, used for the build.
920
 
921
=back
922
 
923
These may be used to brand installer programs with Release Information.
924
Currently the use of these tags is only supported by the XML build files.
925
 
926
=item Package Version
927
 
928
Specifies the version of a package to use as two, space separated words of the
929
form C<package_name package_version> where package version is of the form:
930
 
931
=over 8
932
 
933
=item   * nn.nn.nnnn.aaa
934
 
935
=item   * nn.nn.nnnn
936
 
937
=item   * Other
938
 
939
=back
940
 
941
=item LinkPkgArchive or BuildPkgArchive
942
 
943
These are standard JATS LinkPkgArchive or BuildPkgArchive statements.
944
 
945
=back
946
 
947
=head2 XML File Rewrite
948
 
949
This program will process an ERG style ANT build dependency definition file
950
and replace the values of the properties seen within the file.
951
 
952
The following properties are special within the rewrite process:
953
 
954
=over 8
955
 
956
=item	packagename
957
 
958
This is the name of the package. It is not modified, but it
959
is used in conjunction with the C<packageversion> to identify the package, such
960
that the packageversion can be updated. This property is mandatory and must
961
appear before the C<packageversion>.
962
 
963
=item	packageversion
964
 
965
This is the version of the package. It can be rewritten by this program. This
966
property is mandatory.
967
 
968
=item	releasemanager.projectname
969
 
970
If this property is found the value will be replaced with an B<Assigned Item> of the
971
same name.
972
 
973
=item	releasemanager.releasename
974
 
975
If this property is found the value will be replaced with an B<Assigned Item> of the
976
same name.
977
 
978
=back
979
 
980
Properties that are not B<special> will be treated as the name of a package and
981
the value will be updated to reflect the required version of the package.
982
 
983
The XML rewrite process does not, and cannot handle, instances of packages
984
that have the same name, but different project suffixes. This is a limitation of
985
the ERG ANT build system and not a limitation of this utility.
986
 
987
=head2 JATS Build File Rewrite
988
 
989
This program will process a JATS style build.pl file and modify some
990
directives to update the file.
991
 
992
The following directives will be processed:
993
 
994
=over 8
995
 
996
=item BuildName
997
 
998
The existing version in the BuildName directive will be retained and may be used
999
in any BuildPreviousVersion directive that is seen.
1000
 
1001
=item BuildPreviousVersion
1002
 
1003
This will be updated to contain the version from the BuildName. This is
1004
intended to be used by deployment scripts.
1005
 
1006
=item LinkPkgArchive
1007
 
1008
The version will be updated to reflect the configured package versions. The
1009
project suffix, if present, will be used to identify the correct package.
1010
 
1011
=item BuildPkgArchive
1012
 
1013
The version will be updated to reflect the configured package versions. The
1014
project suffix, if present, will be used to identify the correct package.
1015
 
1016
=back
1017
 
1018
The JATS build file rewrite process, unlike the ANT process, does handle, instances of packages
1019
that have the same name, but different project suffixes. This allows the use
1020
of packages such as C<sysbasetypes.cr> and C<sysbasetypes.prj> within the one
1021
package.
1022
 
1023
Currently the JATS build file rewrite process does pass the
1024
releasemanager.projectname and the releasemanager.releasename items through to
1025
the underlying system. If present in the config file they will be unused. This
1026
is not an error.
1027
 
227 dpurdie 1028
=cut
1029