Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
392 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   : Get package information
11
#                 for a package name and version as specified on the
12
#                 command line.
13
#
14
# Usage:
15
#
16
# Version   Who      Date        Description
17
#
18
#......................................................................#
19
 
20
require 5.006_001;
21
use strict;
22
use warnings;
23
use JatsError;
24
use JatsRmApi;
25
 
26
#use Data::Dumper;
27
use Cwd;
28
use DBI;
29
use Getopt::Long;
30
use Pod::Usage;                             # required for help support
31
 
32
my $GBE_PERL     = $ENV{'GBE_PERL'};        # Essential ENV variables
33
my $GBE_CORE     = $ENV{'GBE_CORE'};
34
my $RM_DB;
35
 
36
################################################################################
37
#   Global data
38
#
39
my $VERSION = "1.0.0";
40
my %ReleasePackages;            # Packages in the release
41
my %BuildPackages;              # Packages for this build
42
my $base_name;
43
my $base_version;
44
 
45
 
46
#
47
#   Options
48
#
49
my $opt_help = 0;
50
my $opt_manual = 0;
51
my $opt_verbose = 0;
52
 
53
my $result = GetOptions (
54
                "help+"     => \$opt_help,          # flag, multiple use allowed
55
                "manual"    => \$opt_manual,        # flag
56
                "verbose+"  => \$opt_verbose,       # flag
57
                );
58
 
59
#
60
#   Process help and manual options
61
#
62
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
63
pod2usage(-verbose => 1)  if ($opt_help == 2 );
64
pod2usage(-verbose => 2)  if ($opt_manual || ($opt_help > 2));
65
 
66
#
67
#   Configure the error reporting process now that we have the user options
68
#
69
ErrorConfig( 'name'    =>'PLAY9',
70
             'verbose' => $opt_verbose );
71
 
72
unless ( $ARGV[0] && $ARGV[1] )
73
{
74
    Error( "Specify a package as 'name' 'version'" );
75
}
76
$base_name = $ARGV[0];
77
$base_version = $ARGV[1];
78
Verbose( "Base Package: $base_name, $base_version");
79
 
80
#
81
#   Body of the process
82
#
83
GetData ( $base_name, $base_version );
84
 
85
exit 0;
86
 
87
 
88
#-------------------------------------------------------------------------------
89
# Function        : GetData
90
#
91
# Description     :
92
#
93
# Inputs          : pkg_name
94
#                   pkg_ver
95
#
96
# Returns         :
97
#
98
sub GetData
99
{
100
    my ( $pkg_name, $pkg_ver ) = @_;
101
    my (@row);
102
    my $pv_id;
103
 
104
    #
105
    #   Establish a connection to Release Manager
106
    #
107
    connectRM(\$RM_DB) unless ( $RM_DB );
108
 
109
    #
110
    #   Extract data from Release Manager
111
    #
112
    my $m_sqlstr = "SELECT pkg.PKG_NAME, pkg.PKG_ID, pv.PKG_VERSION, pv.PV_ID, pv.SRC_PATH" .
113
                   " FROM PACKAGES pkg, PACKAGE_VERSIONS pv" .
114
                   " WHERE pkg.PKG_NAME = \'$pkg_name\' AND pkg.PKG_ID = pv.PKG_ID AND pv.PKG_VERSION = \'$pkg_ver\'";
115
 
116
    my $sth = $RM_DB->prepare($m_sqlstr);
117
    if ( defined($sth) )
118
    {
119
        if ( $sth->execute( ) )
120
        {
121
            if ( $sth->rows )
122
            {
123
                while ( @row = $sth->fetchrow_array )
124
                {
125
                    Verbose( "DATA: " . join(',', @row) );
126
                    my $path = $row[4] || 'None Specified';
127
                    print "$pkg_name, $pkg_ver, $path\n";
128
                    last;
129
                }
130
            }
131
            $sth->finish();
132
        }
133
    }
134
    else
135
    {
136
        Error("GetData:Prepare failure" );
137
    }
138
}
139
 
140