Subversion Repositories DevTools

Rev

Rev 5710 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
392 dpurdie 1
#! perl
2
########################################################################
5710 dpurdie 3
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
392 dpurdie 4
#
5
# Module name   : jats.sh
6
# Module type   : Makefile system
7
# Compiler(s)   : n/a
8
# Environment(s): jats
9
#
10
# Description   : Locate ALL build.pl files in a given release
11
#                 Convert the build.pl files to a new project
12
#                 Create a new branch for the build file
13
#                 Check the new file in
14
#
15
# Usage:          Convert 'sydney' build files to 'beijing' build files
16
#
17
# Version   Who      Date        Description
18
#
19
#......................................................................#
20
 
21
require 5.006_001;
22
use strict;
23
use warnings;
24
use JatsError;
25
use Pod::Usage;                             # required for help support
26
use Getopt::Long;
27
 
28
#use Data::Dumper;
29
use DBI;
30
use Cwd;
31
use JatsRmApi;
32
 
33
my $GBE_PERL     = $ENV{'GBE_PERL'};        # Essential ENV variables
34
my $GBE_CORE     = $ENV{'GBE_CORE'};
35
my $VERSION = '1.0.0';
36
my $opt_help = 0;
37
my $opt_manual = 0;
38
my $opt_verbose = 1;
39
my $opt_rtagid;
40
my $opt_branch;
41
my $opt_old_project;
42
my $opt_newproject;
43
my $RM_DB;
44
 
45
 
46
my @GDATA;
47
sub getPkgDetailsByRTAG_ID
48
{
49
    my ($RTAG_ID) = @_;
50
    my $foundDetails = 0;
51
    my (@row);
52
 
53
    # if we are not or cannot connect then return 0 as we have not found anything
54
    connectRM(\$RM_DB) unless ( $RM_DB );
55
 
56
    # First get details from pv_id
57
 
58
    my $m_sqlstr = "SELECT pv.PV_ID, pkg.PKG_NAME, pv.PKG_VERSION, pv.PKG_LABEL, pv.SRC_PATH, pv.BUILD_TYPE" .
59
                    " FROM RELEASE_CONTENT rc, PACKAGE_VERSIONS pv, PACKAGES pkg" .
60
                    " WHERE rc.RTAG_ID = $RTAG_ID AND rc.PV_ID = pv.PV_ID AND pv.PKG_ID = pkg.PKG_ID";
61
    my $sth = $RM_DB->prepare($m_sqlstr);
62
    if ( defined($sth) )
63
    {
64
        if ( $sth->execute( ) )
65
        {
66
            if ( $sth->rows )
67
            {
68
                while ( @row = $sth->fetchrow_array )
69
                {
70
                    my %DATA;
71
                    $DATA{pv_id}            = $row[0];
72
                    my $name = $DATA{name}             = $row[1];
73
                    my $ver = $DATA{version}          = $row[2];
74
                    my $label =                     $row[3] || '';
75
                    my $path = $row[4] || '';
76
 
77
#                    next if ( $ver =~ /syd$/i );
78
#                    next if ( $ver =~ /cr$/i );
79
#                    next if ( $ver =~ /mas$/i );
80
#                    next unless ( $ver =~ /cots$/i );
81
 
82
                    $path =~ tr~\\/~/~s;
83
#                    next if ( $path =~ m~^/~  );
84
print "$row[5] --";
85
printf ( "%40s %15s %50s %s\n",  $name, $ver, $label, $path);
86
#printf ( "copy e:\\%s\\%s .\n",  $name, $ver, $label, $path);
87
 
88
                    push @GDATA, (\%DATA);
89
                }
90
            }
91
            $sth->finish();
92
        }
93
    }
94
    else
95
    {
96
        Error("Prepare failure" );
97
    }
98
 
99
    $RM_DB->disconnect() || Error ("Disconnect failed");
100
 
101
 
102
}
103
 
104
#-------------------------------------------------------------------------------
105
# Function        : getRtagId
106
#
107
# Description     : Given a release name, determine the RTAG_ID
108
#
109
# Inputs          :
110
#
111
# Returns         :
112
#
113
sub getRtagId
114
{
115
    my ($RTAG_ID) = @_;
116
    my $foundDetails = 0;
117
    my (@row);
118
 
119
    # if we are not or cannot connect then return 0 as we have not found anything
120
    connectRM(\$RM_DB) unless ( $RM_DB );
121
 
122
    # First get details from pv_id
123
 
124
    my $m_sqlstr = "SELECT rt.RTAG_ID, rt.RTAG_NAME, rt.DESCRIPTION, pj.PROJ_ID, pj.PROJ_NAME, rt.OFFICIAL FROM RELEASE_TAGS rt, PROJECTS pj WHERE rt.PROJ_ID = pj.PROJ_ID ORDER BY pj.PROJ_NAME";
125
    my $sth = $RM_DB->prepare($m_sqlstr);
126
    if ( defined($sth) )
127
    {
128
        if ( $sth->execute( ) )
129
        {
130
            if ( $sth->rows )
131
            {
132
                while ( @row = $sth->fetchrow_array )
133
                {
134
                    printf "%20s, %8s(%s), %40s\n", $row[4], $row[0], $row[5], $row[1];
135
                }
136
            }
137
            $sth->finish();
138
        }
139
    }
140
    else
141
    {
142
        Error("Prepare failure" );
143
    }
144
 
145
    $RM_DB->disconnect() || Error ("Disconnect failed");
146
 
147
    exit;
148
}
149
 
150
#-------------------------------------------------------------------------------
151
# Function        : Main
152
#
153
# Description     :
154
#
155
# Inputs          :
156
#
157
# Returns         :
158
#
159
 
160
ErrorConfig( 'name'    =>'ConvertBuild' );
161
 
162
 
163
#
164
#   Extract options fromthe user command line
165
#
166
my $result = GetOptions (
167
                "help+"         => \$opt_help,              # flag, multiple use allowed
168
                "manual"        => \$opt_manual,            # flag, multiple use allowed
169
                "verbose+"      => \$opt_verbose,           # flag, multiple use allowed
170
                "rtagid=s"      => \$opt_rtagid,
171
                "branch=s"      => \$opt_branch,
172
                "oldproject=s"  => \$opt_old_project,
173
                "newproject=s"  => \$opt_newproject,
174
                );
175
 
176
                #
177
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
178
                #
179
 
180
#
181
#   Process help and manual options
182
#
183
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
184
pod2usage(-verbose => 1)  if ($opt_help == 2 );
185
pod2usage(-verbose => 2)  if ($opt_manual || ($opt_help > 2));
186
 
187
#
188
#   Validate the user options
189
#
190
Error ("RTAGID must be provided (ie 2362)" ) unless ( $opt_rtagid );
191
 
192
getPkgDetailsByRTAG_ID($opt_rtagid);           # 2362 : Syd Release 1
193
#DebugDumpData("GDATA", \@GDATA);
194
exit;
195
 
196
 
197
 
198
#-------------------------------------------------------------------------------
199
#   Documentation
200
#
201
 
202
=pod
203
 
204
=head1 NAME
205
 
206
jats_convert_build - Convert a Releases build.pl files
207
 
208
=head1 SYNOPSIS
209
 
210
  jats jats_convert_build [options]
211
 
212
 Options:
213
    -help              - brief help message
214
    -help -help        - Detailed help message
215
    -man               - Full documentation
216
    -rtagid=tag        - RTAG ID of the view defining packages to process
217
    -branch=xxx        - Branch for new build.pl files
218
    -oldproject=xx     - Project name of base projects (syd)
219
    -newproject=xx     - Project name of new base ( bej )
220
 
221
=head1 OPTIONS
222
 
223
=over 8
224
 
225
=item B<-help>
226
 
227
Print a brief help message and exits.
228
 
229
=item B<-help -help>
230
 
231
Print a detailed help message with an explanation for each option.
232
 
233
=item B<-man>
234
 
235
Prints the manual page and exits.
236
 
237
=back
238
 
239
=head1 DESCRIPTION
240
 
241
This program does stuff.
242
 
243
 
244
=cut
245