Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
392 dpurdie 1
########################################################################
5710 dpurdie 2
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
392 dpurdie 3
#
4
# Module name   : jats_rm_play09a
5
# Module type   : Makefile system
6
# Compiler(s)   : n/a
7
# Environment(s): jats
8
#
9
# Description   : Get package information
10
#                 for a package name and version as specified on the
11
#                 command line.
12
#
13
# Usage:
14
#
15
# Version   Who      Date        Description
16
#
17
#......................................................................#
18
 
19
require 5.006_001;
20
use strict;
21
use warnings;
22
use JatsError;
23
use JatsRmApi;
24
 
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, pbi.BSA_ID, pv.PKG_LABEL" .
113
                   " FROM RELEASE_MANAGER.PACKAGES pkg, RELEASE_MANAGER.PACKAGE_VERSIONS pv, RELEASE_MANAGER.PACKAGE_BUILD_INFO pbi" .
114
                   " WHERE pkg.PKG_NAME = \'$pkg_name\' AND pkg.PKG_ID = pv.PKG_ID AND pv.PKG_VERSION = \'$pkg_ver\' AND pv.PV_ID = pbi.PV_ID";
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
                    my $be = $row[5] || 'Unknown';
128
                    my $label = $row[6] ||'NoLabel';
129
                    print "$pkg_name, $pkg_ver $label,, $path, $be\n";
130
                    last;
131
                }
132
            }
133
            $sth->finish();
134
        }
135
    }
136
    else
137
    {
138
        Error("GetData:Prepare failure" );
139
    }
140
}