Subversion Repositories DevTools

Rev

Rev 267 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 267 Rev 309
Line 1... Line 1...
1
########################################################################
1
########################################################################
2
# Copyright ( C ) 2008 ERG Limited, All rights reserved
2
# Copyright ( C ) 2008 ERG Limited, All rights reserved
3
#
3
#
4
# Module name   : jats_save_build.pl
4
# Module name   : jats_svnasave_build.pl
5
# Module type   : Makefile system
5
# Module type   : JATS Utility
6
# Compiler(s)   : n/a
6
# Compiler(s)   : Perl
7
# Environment(s): jats
7
# Environment(s): jats
8
#
8
#
9
# Description   : Build Daemon Support Utility
9
# Description   : Build Daemon Support Utility
10
#                 This utility will:
10
#                 This utility will:
11
#                   +   Assume the CWD is the root-dir of a package
11
#                   +   Assume the CWD is the root-dir of a package
12
#                       within a versioned control view
12
#                       within a versioned control view
13
#                   +   Determine a suitable label for the package
13
#                   +   Determine a suitable label for the package
14
#                   +   Save the build file in the view
14
#                   +   Save the build file in the view
15
#                   +   Label the resultant view
15
#                   +   Label the resultant view
16
#
16
#
17
# Note          : Intended to be backward compatible wth old (simple)
-
 
18
#                 functionality.
-
 
19
#
-
 
20
# Usage:        : See POD at end of this file
17
# Usage:        : See POD at end of this file
21
#
18
#
22
#                 Preferred (new) usage:
-
 
23
#
-
 
24
#               jats etool  jats_save_build
19
#               jats etool  jats_save_build
25
#                   -infile     auto.xml/auto.pl
20
#                   -infile     auto.xml/auto.pl
26
#                   -outfile    xxxdepends.xml/build.pl
21
#                   -outfile    xxxdepends.xml/build.pl
27
#                   -pname      package_name
22
#                   -pname      package_name
28
#                   -pversion   package_version
23
#                   -pversion   package_version
Line 49... Line 44...
49
my $opt_debug   = $ENV{'GBE_DEBUG'};        # Allow global debug
44
my $opt_debug   = $ENV{'GBE_DEBUG'};        # Allow global debug
50
my $opt_verbose = $ENV{'GBE_VERBOSE'};      # Allow global verbose
45
my $opt_verbose = $ENV{'GBE_VERBOSE'};      # Allow global verbose
51
my $opt_infile  = "auto.pl";
46
my $opt_infile  = "auto.pl";
52
my $opt_ofile = "build.pl";
47
my $opt_ofile = "build.pl";
53
my $opt_help = 0;
48
my $opt_help = 0;
54
my $opt_label;
-
 
55
my $opt_branch_default = "AutoBuilder";
49
my $opt_branch_default = "AutoBuilder";
56
my $opt_branch;
50
my $opt_branch;
57
my $opt_newbranch;
51
my $opt_newbranch;
58
my $opt_infofile;
52
my $opt_infofile;
59
my $opt_pname;
53
my $opt_pname;
Line 80... Line 74...
80
                "manual:3"      => \$opt_help,              # flag
74
                "manual:3"      => \$opt_help,              # flag
81
                "verbose:+"     => \$opt_verbose,           # flag
75
                "verbose:+"     => \$opt_verbose,           # flag
82
 
76
 
83
                "outfile=s"     => \$opt_ofile,             # string
77
                "outfile=s"     => \$opt_ofile,             # string
84
                "infile=s"      => \$opt_infile,            # string
78
                "infile=s"      => \$opt_infile,            # string
85
                "label=s"       => \$opt_label,             # string
-
 
86
                "branch=s"      => \$opt_branch,            # string
79
                "branch=s"      => \$opt_branch,            # string
87
                "newbranch"     => \$opt_newbranch,         # string
80
                "newbranch"     => \$opt_newbranch,         # string
88
 
81
 
89
                "infofile=s"    => \$opt_infofile,          # string
82
                "infofile=s"    => \$opt_infofile,          # string
90
                "pname=s"       => \$opt_pname,             # string
83
                "pname=s"       => \$opt_pname,             # string
Line 109... Line 102...
109
#
102
#
110
ErrorConfig( 'name'    =>'ABTSAVE',
103
ErrorConfig( 'name'    =>'ABTSAVE',
111
             'verbose' => $opt_verbose,
104
             'verbose' => $opt_verbose,
112
             'on_exit' => \&display_error_list
105
             'on_exit' => \&display_error_list
113
           );
106
           );
114
 
-
 
115
Error ("Input and output file are the same: $opt_infile" )
107
Error ("Input and output file are the same: $opt_infile" )
116
    if ( $opt_infile eq $opt_ofile );
108
    if ( $opt_infile eq $opt_ofile );
117
 
109
 
118
Error ("Must provide a branch when usng newbranch option")
110
Error ("Must provide a branch when usng newbranch option")
119
    if ( $opt_newbranch && ! $opt_branch );
111
    if ( $opt_newbranch && ! $opt_branch );
120
 
112
 
121
$opt_branch = $opt_branch_default
113
$opt_branch = $opt_branch_default
122
    unless ( $opt_branch );
114
    unless ( $opt_branch );
123
 
115
 
124
#
-
 
125
#   If $opt_label has been provided, then operate in a backwardly
-
 
126
#   compatible manner. Only perform the build file save. Do not perform
-
 
127
#   any of the advanced label operations.
-
 
128
#
-
 
129
unless ( $opt_label )
-
 
130
{
-
 
131
    Error ("Package Name not provided")
116
Error ("Package Name not provided")
132
        unless ( $opt_pname );
117
    unless ( $opt_pname );
133
 
-
 
134
    Error ("Package Version not provided")
-
 
135
        unless ( $opt_pversion );
-
 
136
 
118
 
137
    Warning("Path to info file not provided")
119
Error ("Package Version not provided")
138
        unless ( $opt_infofile );
120
    unless ( $opt_pversion );
139
    unlink ($opt_infofile) if $opt_infofile;
-
 
140
}
-
 
141
else
-
 
142
{
-
 
143
    #
-
 
144
    #   Ensure none of the 'new' options are used
-
 
145
    #
-
 
146
    Error ("Option not compatible with -label: locatepkg")
-
 
147
        if ( $opt_locate );
-
 
148
 
121
 
149
    Error ("Option not compatible with -label: wiplabel")
122
Warning("Path to info file not provided")
150
        if ( $opt_wiplabel );
123
    unless ( $opt_infofile );
151
 
124
 
152
    Error ("Option not compatible with -label: infofile")
-
 
153
        if ( $opt_infofile );
125
unlink ($opt_infofile) if $opt_infofile;
154
}
-
 
155
 
126
 
156
#
127
#
157
#   Locate the build directory and chdir to that directory
128
#   Locate the build directory and chdir to that directory
158
#
129
#
159
locate_build_directory();
130
locate_build_directory();
Line 500... Line 471...
500
# Function        : determine_package_label
471
# Function        : determine_package_label
501
#
472
#
502
# Description     : Determine the label that is to be applied to the package
473
# Description     : Determine the label that is to be applied to the package
503
#                   There are several cases to consider
474
#                   There are several cases to consider
504
#                       1) Compatability mode: User provides label
475
#                       1) Compatability mode: User provides label
505
#                       2) WIP Mode. Determine name of label to ise in rename
476
#                       2) WIP Mode. Determine name of label to use in rename
506
#                       3) Create a new label
477
#                       3) Create a new label
507
#
478
#
508
# Inputs          : Globals
479
# Inputs          : Globals
509
#
480
#
510
# Returns         : Globals
481
# Returns         : Globals
511
#                       $pkg_label
482
#                       $pkg_label
512
#
483
#
513
sub determine_package_label
484
sub determine_package_label
514
{
485
{
515
 
-
 
516
    #
-
 
517
    #   Compatability mode
-
 
518
    #
-
 
519
    if ( $opt_label )
-
 
520
    {
-
 
521
        $pkg_label = $opt_label;
-
 
522
        return;
-
 
523
    }
-
 
524
 
-
 
525
    #
486
    #
526
    #   Determine the desired label for the package
487
    #   Determine the desired label for the package
527
    #   This is a function of the package name and the package version
488
    #   This is a function of the package name and the package version
528
    #   The two are joined with a '.'
489
    #   The two are joined with a '.'
529
    #
490
    #
Line 602... Line 563...
602
#
563
#
603
# Returns         : 
564
# Returns         : 
604
#
565
#
605
sub label_build_view
566
sub label_build_view
606
{
567
{
607
    #
-
 
608
    #   In compatability mode - do nothing
-
 
609
    #
-
 
610
    return if ( $opt_label );
-
 
611
 
-
 
612
    if ( $opt_wiplabel )
568
    if ( $opt_wiplabel )
613
    {
569
    {
614
        Verbose ("Rename label: From $opt_wiplabel to $tag_label");
570
        Verbose ("Rename label: From $opt_wiplabel to $tag_label");
-
 
571
        SystemConfig ( ExitOnError => 2);
615
        JatsCmd( 'label', '-unlock', $opt_wiplabel, '-rename', $tag_label, '-lock' );
572
        JatsCmd( 'label', '-unlock', $opt_wiplabel, '-rename', $tag_label, '-lock' );
616
    }
573
    }
617
    else
574
    else
618
    {
575
    {
619
        Verbose ("Apply new label to package: $tag_label");
576
        Verbose ("Apply new label to package: $tag_label");
Line 639... Line 596...
639
 
596
 
640
        chdir ( $base_dir ) || Error ("Cannot chdir to vob base", $base_dir);
597
        chdir ( $base_dir ) || Error ("Cannot chdir to vob base", $base_dir);
641
 
598
 
642
        #
599
        #
643
        #   Label the entire (static) view
600
        #   Label the entire (static) view
-
 
601
        #   Handle errors as error exit will clean up
644
        #
602
        #
645
        JatsCmd( 'label', '-label', $tag_label, '-replace', '-lock' );
603
        my $rv =JatsCmd( 'label', '-label', $tag_label, '-replace', '-lock' );
-
 
604
        Error ("Failed to label all files in view")
-
 
605
            if ( $rv );
646
    }
606
    }
647
 
607
 
648
    #
608
    #
649
    #   Write the label out to the specified file so that the user
609
    #   Write the label out to the specified file so that the user
650
    #   can do something with it
610
    #   can do something with it
Line 703... Line 663...
703
}
663
}
704
 
664
 
705
#-------------------------------------------------------------------------------
665
#-------------------------------------------------------------------------------
706
# Function        : display_error_list
666
# Function        : display_error_list
707
#
667
#
708
# Description     : Display the error list
668
# Description     : Display the error list and clean up
709
#                   This function is registered as an Error callback function
669
#                   This function is registered as an Error callback function
710
#                   it will be called on error exit
670
#                   it will be called on error exit
711
#
671
#
712
# Inputs          :
672
# Inputs          :
713
#
673
#
Line 717... Line 677...
717
{
677
{
718
    foreach ( @error_list )
678
    foreach ( @error_list )
719
    {
679
    {
720
        print "$_\n";
680
        print "$_\n";
721
    }
681
    }
-
 
682
 
-
 
683
    #
-
 
684
    #   Perform cleanup
-
 
685
    #       Delete the label if created it anyway (which we did)
-
 
686
    #       This leaves checked in build file on branch (live with it)
-
 
687
    #
-
 
688
    JatsCmd( 'label', '-delete', $tag_label )
-
 
689
        if ($label_created);
-
 
690
    
722
}
691
}
723
 
692
 
724
#-------------------------------------------------------------------------------
693
#-------------------------------------------------------------------------------
725
#   Documentation
694
#   Documentation
726
#
695
#
Line 740... Line 709...
740
    -help -help         - Detailed help message
709
    -help -help         - Detailed help message
741
    -man[=n]            - Full documentation
710
    -man[=n]            - Full documentation
742
    -verbose[=n]        - Verbose operation
711
    -verbose[=n]        - Verbose operation
743
    -infile=xxx         - Input file (auto.pl)
712
    -infile=xxx         - Input file (auto.pl)
744
    -outfile=xxx        - Output file (build.pl)
713
    -outfile=xxx        - Output file (build.pl)
745
    -label xxx          - Label the new file (Compatability Mode)
-
 
746
    -branch=xxx         - Branch to create (AutoBuilder)
714
    -branch=xxx         - Branch to create (AutoBuilder)
747
    -newbranch          - Force file to be on a new (project) branch
715
    -newbranch          - Force file to be on a new (project) branch
748
    -infofile=path      - Save label information in 'path'
716
    -infofile=path      - Save label information in 'path'
749
    -pname=name         - Name of the package
717
    -pname=name         - Name of the package
750
    -pversion=text      - Package version
718
    -pversion=text      - Package version
Line 789... Line 757...
789
will be checked in to version-control. Data from from file specifies with '-
757
will be checked in to version-control. Data from from file specifies with '-
790
infile' will be used to update the file.
758
infile' will be used to update the file.
791
 
759
 
792
The default file name is 'build.pl'.
760
The default file name is 'build.pl'.
793
 
761
 
794
=item B<-label=xxxx>
-
 
795
 
-
 
796
This option is provided for backward compatability. If present then much of the
-
 
797
functionality of this utility will be supressed. The utility will only check-
-
 
798
in the modified build files. It will not:
-
 
799
 
-
 
800
=over 8
-
 
801
 
-
 
802
=item   Locate the build files
-
 
803
 
-
 
804
=item   Determine an available label
-
 
805
 
-
 
806
=item   Create the label
-
 
807
 
-
 
808
=item   Label the view
-
 
809
 
-
 
810
=item   Rename the WIP label
-
 
811
 
-
 
812
=item   Generate the information file
-
 
813
 
-
 
814
=back
-
 
815
 
-
 
816
=item B<-branch=xxxx>
762
=item B<-branch=xxxx>
817
 
763
 
818
This options specifies the root name of the target branch that will be sued to
764
This options specifies the root name of the target branch that will be sued to
819
contain the checked-in build file. If the branch does not exist it will be
765
contain the checked-in build file. If the branch does not exist it will be
820
created.
766
created.