Subversion Repositories DevTools

Rev

Rev 233 | Rev 249 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 233 Rev 247
Line 11... Line 11...
11
#                 Use an external configuration file to provide a common
11
#                 Use an external configuration file to provide a common
12
#                 source of configuration information
12
#                 source of configuration information
13
#
13
#
14
# Usage:
14
# Usage:
15
#
15
#
16
# Version   Who      Date        Description
-
 
17
#
-
 
18
#......................................................................#
16
#......................................................................#
19
 
17
 
20
require 5.6.1;
18
require 5.6.1;
21
use strict;
19
use strict;
22
use warnings;
20
use warnings;
Line 49... Line 47...
49
my %component =  ();
47
my %component =  ();
50
my %component_use =  ();
48
my %component_use =  ();
51
my $not_use_count = 0;
49
my $not_use_count = 0;
52
my $suffix_count = 0;
50
my $suffix_count = 0;
53
 
51
 
-
 
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
);
54
 
61
 
55
my $result = GetOptions (
62
my $result = GetOptions (
56
                "help+"     => \$opt_help,          # flag, multiple use allowed
63
                "help+"     => \$opt_help,          # flag, multiple use allowed
57
                "manual"    => \$opt_manual,        # flag
64
                "manual"    => \$opt_manual,        # flag
58
                "verbose+"  => \$opt_verbose,       # flag
65
                "verbose+"  => \$opt_verbose,       # flag
Line 139... Line 146...
139
        next if ( length( $_) <= 0 );
146
        next if ( length( $_) <= 0 );
140
 
147
 
141
#        Verbose ($_);
148
#        Verbose ($_);
142
 
149
 
143
        #
150
        #
-
 
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
        #
144
        #   Process LinkPkgArchive and BuildPkgArchive statements
164
        #   Process LinkPkgArchive and BuildPkgArchive statements
145
        #   These allow simple updating of the config file from Release manager
165
        #   These allow simple updating of the config file from Release manager
146
        #
166
        #
147
        if ( m/LinkPkgArchive/ or m/BuildPkgArchive/ )
167
        if ( m/LinkPkgArchive/ or m/BuildPkgArchive/ )
148
        {
168
        {
Line 322... Line 342...
322
#                   It assumes that entries are all on one line so that we can
342
#                   It assumes that entries are all on one line so that we can
323
#                   do trivial substitutions
343
#                   do trivial substitutions
324
#
344
#
325
#                   Processes
345
#                   Processes
326
#                       <using ... >
346
#                       <using ... >
327
#                       <property name="packagename" ...>
347
#                       <property name="packagename" value="...">
-
 
348
#                       <property name="packageversion" value="...">
-
 
349
#                       <property name="releasemanager.releasename" value="...">
-
 
350
#                       <property name="releasemanager.projectname" value="...">
328
#                       <import file=...>
351
#                       <import file=...>
329
#
352
#
-
 
353
#                  Note: This function handles a wider scope of XML files
-
 
354
#                        than it really needs to. All thats needed is
-
 
355
#                        the <property name= vale=> fields.
330
#
356
#
331
# Inputs          :
357
# Inputs          :
332
#
358
#
333
# Returns         :
359
# Returns         :
334
#
360
#
Line 372... Line 398...
372
        #   Process "property" statements
398
        #   Process "property" statements
373
        #
399
        #
374
        elsif ( m~<property~ )
400
        elsif ( m~<property~ )
375
        {
401
        {
376
            #
402
            #
377
            #   Extract the package name and version
403
            #   Extract name and value
378
            #   and use this to determine the required version of the package
404
            #   Both must exist
379
            #
405
            #
380
            m~name=\"([^"]*)"~;
406
            my $name;
381
            my $name = $1;
407
            my $value;
382
            Error ("Name attribute not found in 'property'") unless ( $name );
-
 
383
            Verbose2 ("Property: $name");
-
 
384
 
408
 
-
 
409
            if ( m~name=\"([^"]*)"~  )
-
 
410
            {
-
 
411
                $name = $1;
-
 
412
            }
-
 
413
            else
-
 
414
            {
-
 
415
                Error ("Name attribute not found in 'property'");
-
 
416
            }
-
 
417
 
-
 
418
            if ( m~value=\"([^"]*)"~ )
-
 
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
            
385
            #
428
            #
386
            #   Update the package name
429
            #   Examine th property name
387
            #   The real package name is held in the value attribute
430
            #   Some of the them are special, others will be package names
388
            #
431
            #
389
            if ( $name eq 'packagename' )
432
            if ( $name eq 'packagename' )
390
            {
433
            {
391
                m~value=\"([^"]*)"~;
-
 
392
                $release_name = $1;
434
                $release_name = $value;
393
                Error ("Value attribute not found in packagename 'property'") unless ( $release_name );
435
                Error ("Value attribute not found in packagename 'property'") unless ( $release_name );
394
            }
436
            }
395
 
-
 
396
            elsif ( $name eq 'packageversion' )
437
            elsif ( $name eq 'packageversion' )
397
            {
438
            {
398
                m~value=\"([^"]*)"~;
-
 
399
                $release_version = $1;
439
                $release_version = $value;
400
                Error ("Value attribute not found in packageversion 'property'") unless ( $release_version );
-
 
401
 
440
 
402
                #
441
                #
403
                #   Ensure that we already have the package name
442
                #   Ensure that we already have the package name
404
                #
443
                #
405
                Error ("packageversion before packagename") unless ( $release_name );
444
                Error ("packageversion before packagename") unless ( $release_name );
406
 
445
 
407
                my $new_ver = get_package ( $release_name, $release_version );
446
                my $new_ver = get_package ( $release_name, $release_version );
408
                s~(.*)value=\"([^"]*)"~$1value=\"$new_ver\"~;
447
                s~(.*)value=\"([^"]*)"~$1value=\"$new_ver\"~;
409
                print_update( '', $release_name ,$release_version, $new_ver );
448
                print_update( '', $release_name ,$release_version, $new_ver );
410
            }
449
            }
411
 
-
 
412
            elsif ( $name eq 'env' )
450
            elsif ( defined $fields{$name} )
413
            {
451
            {
414
                #
452
                #
415
                #   'env' is special
453
                #   Use tagged values in preference to packages
416
                #   Its not a package. Skip it
454
                #   There are very few tagged values.
417
                #
455
                #
418
            }
456
                my $new_value = $fields{$name};
-
 
457
                Error ("Release attribute not found: $name") unless ( $new_value );
419
 
458
 
-
 
459
                s~(.*)value=\"([^"]*)"~$1value=\"$new_value\"~;
-
 
460
                print_update( 'Release', $name ,$value, $new_value );
-
 
461
            }
420
            else
462
            else
421
            {
463
            {
422
                m~value=\"([^"]*)"~;
-
 
423
                $release_version = $1;
-
 
424
                Error ("Value attribute not found in package 'property' : $name") unless ( $release_version );
-
 
425
 
-
 
426
                my $new_ver = get_package ( $name, $release_version );
464
                my $new_ver = get_package ( $name, $value );
427
                s~(.*)value=\"([^"]*)"~$1value=\"$new_ver\"~;
465
                s~(.*)value=\"([^"]*)"~$1value=\"$new_ver\"~;
428
                print_update( '', $name ,$release_version, $new_ver );
466
                print_update( '', $name ,$value, $new_ver );
429
            }
467
            }
430
        }
468
        }
431
 
469
 
432
        #
470
        #
433
        #   Process "using" statements
471
        #   Process "using" statements
Line 455... Line 493...
455
            print_update( '', $name ,$release_version, $new_ver );
493
            print_update( '', $name ,$release_version, $new_ver );
456
        }
494
        }
457
 
495
 
458
        #
496
        #
459
        #   Import File
497
        #   Import File
460
        #   Only used to imprt ant-using
498
        #   Only used to import ant-using
461
        #
499
        #
462
        elsif ( m~<import~ )
500
        elsif ( m~<import~ )
463
        {
501
        {
464
            #
502
            #
465
            #   Extract the file
503
            #   Extract the file
Line 547... Line 585...
547
    my ($rel, $suf ) = extract_version( $package, $version);
585
    my ($rel, $suf ) = extract_version( $package, $version);
548
 
586
 
549
    Error ("Multiple definitions for $package $version" )
587
    Error ("Multiple definitions for $package $version" )
550
        if ( $component{$package}{$suf} );
588
        if ( $component{$package}{$suf} );
551
 
589
 
-
 
590
    Error ("Package Name is a reserved key field: $package" )
-
 
591
        if ( exists $fields{$package} );
-
 
592
 
552
    $component{$package}{$suf} = $rel;
593
    $component{$package}{$suf} = $rel;
553
    $component_use{$package}{$suf} = $rel;
594
    $component_use{$package}{$suf} = $rel;
554
 
595
 
555
    Verbose2 ("Package: $package, $version, $rel, $suf");
596
    Verbose2 ("Package: $package, $version, $rel, $suf");
556
 
597
 
Line 788... Line 829...
788
 
829
 
789
Prints the manual page and exits.
830
Prints the manual page and exits.
790
 
831
 
791
=item B<-verbose>
832
=item B<-verbose>
792
 
833
 
793
Increases program output. This option may be specified mutiple times
834
Increases program output. This option may be specified multiple times
794
 
835
 
795
=item B<-config=xxx>
836
=item B<-config=xxx>
796
 
837
 
797
This option specifies the name of a configuration file that will provide the
838
This option specifies the name of a configuration file that will provide the
798
transformation between of version numbers. The format of the config file is
839
transformation between of version numbers. The format of the config file is
Line 801... Line 842...
801
The option is not required if -newproject and -oldproject are specified
842
The option is not required if -newproject and -oldproject are specified
802
 
843
 
803
=item B<-oldproject=xxx>
844
=item B<-oldproject=xxx>
804
 
845
 
805
This option, in conjunction with B<-oldproject=xxx> allows the project
846
This option, in conjunction with B<-oldproject=xxx> allows the project
806
extensions to be modified. ie: .syd projects can eb converted into .bej
847
extensions to be modified. ie: .syd projects can be converted into .bej
807
projects.
848
projects.
808
 
849
 
809
If this option is present thenthe config data file is not required, although
850
If this option is present then the config data file is not required, although
810
it will be sued if it is present.
851
it will be sued if it is present.
811
 
852
 
812
=item B<-newproject=xxx>
853
=item B<-newproject=xxx>
813
 
854
 
814
See B<-oldproject=xxx>
855
See B<-oldproject=xxx>
Line 829... Line 870...
829
packages in the config file that were not used by the re-write process.
870
packages in the config file that were not used by the re-write process.
830
 
871
 
831
=item B<-xml>
872
=item B<-xml>
832
 
873
 
833
Process a build.xml file instead of a build.pl file.
874
Process a build.xml file instead of a build.pl file.
834
This option will be set internally if the infile extesnion is '.xml'
875
This option will be set internally if the infile extension is '.xml'
835
 
876
 
836
=back
877
=back
837
 
878
 
838
=head1 DESCRIPTION
879
=head1 DESCRIPTION
839
 
880
 
-
 
881
This utility is used within the automated build system to rewrite build files
-
 
882
so that they contain suitable version numbers.
-
 
883
 
-
 
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
 
840
=head2 CONFIG FILE FORMAT
894
=head2 Format of the Configuration File
841
 
895
 
842
The format of the configuration file is defined below.
896
The format of the configuration file is defined below.
843
 
897
 
-
 
898
The file is a line oriented text file.
-
 
899
 
844
Comments begin with a # and go the end of the line
900
Comments begin with a # and go the end of the line.
-
 
901
 
-
 
902
There are three types of configuration line:
845
 
903
 
-
 
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
 
846
  There are two types of config line
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
 
847
      package version
926
=item Package Version
-
 
927
 
848
          Specifies the version of a package to use 
928
Specifies the version of a package to use as two, space separated words of the
849
          The version may be of the form:
929
form C<package_name package_version> where package version is of the form:
-
 
930
 
-
 
931
=over 8
-
 
932
 
850
              nn.nn.nn.aaa
933
=item   * nn.nn.nnnn.aaa
-
 
934
 
851
              nn.nn.nn
935
=item   * nn.nn.nnnn
-
 
936
 
852
              other
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
853
 
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
 
854
    Standard LinkPkgArchive or BuildPkgArchive statements
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.
855
 
1027
 
856
=cut
1028
=cut
857
 
1029