Subversion Repositories DevTools

Rev

Rev 7299 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
392 dpurdie 1
#! perl
2
########################################################################
7300 dpurdie 3
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
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   : Get Build Information
11
#                 See how simple it might be to determine a packages build
12
#                 information
13
#
14
# Usage         : jats jats_get_build_info
15
#
16
# Version   Who      Date        Description
17
#
18
#......................................................................#
19
 
20
require 5.006_001;
21
use strict;
22
use warnings;
23
use JatsError;
24
 
25
#use Data::Dumper;
26
use Cwd;
27
use DBI;
28
use Getopt::Long;
29
use Pod::Usage;                             # required for help support
30
use JatsRmApi;
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 %TargetPackage;              # Package being processed
41
 
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'    =>'GetBuildInfo',
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
#   Extract information to create the view
82
#
83
GetPackageDetails( $base_name, $base_version );
84
 
85
exit 0;
86
 
87
#-------------------------------------------------------------------------------
88
# Function        : GetPackageDetails
89
#
90
# Description     : Determine the package details
91
#
92
#
93
# Inputs          : pkg_name
94
#                   pkg_ver
95
#
96
# Returns         :
97
#
98
sub GetPackageDetails
99
{
100
    my ( $pkg_name, $pkg_ver ) = @_;
101
 
102
    #
103
    #   Establish a connection to Release Manager
104
    #
105
    connectRM(\$RM_DB) unless ( $RM_DB );
106
 
107
    #
108
    #   Extract data from Release Manager
109
    #   Note: The required package may be in one of a number of tables
110
    #
111
    my $m_sqlstr = "SELECT pkg.PKG_NAME, pkg.PKG_ID, pv.PKG_VERSION, pv.PV_ID, pv.SRC_PATH, pv.PKG_LABEL" .
112
                   " FROM PACKAGES pkg, PACKAGE_VERSIONS pv" .
113
                   " WHERE pkg.PKG_NAME = \'$pkg_name\'" .
114
                   " AND pkg.PKG_ID = pv.PKG_ID" .
115
                   " AND pv.PKG_VERSION = \'$pkg_ver\'";
116
 
117
    my $sth = $RM_DB->prepare($m_sqlstr);
118
    if ( defined($sth) )
119
    {
120
        if ( $sth->execute( ) )
121
        {
122
            if ( $sth->rows )
123
            {
124
                while ( my @row = $sth->fetchrow_array )
125
                {
126
                    $TargetPackage{name} = $pkg_name;
127
                    $TargetPackage{version} = $pkg_ver;
128
                    $TargetPackage{path} = $row[4] || Error("Package path not in RM");
129
                    $TargetPackage{PKG_ID} = $row[1];
130
                    $TargetPackage{PV_ID} = $row[3];
131
                    $TargetPackage{label} = $row[5] || Error("Package Label not in RM");
132
 
133
                    $TargetPackage{path} =~ tr~\\/~/~s;
134
 
135
                    Verbose ("DATA: @row");
136
                    last;
137
                }
138
            }
139
            else
140
            {
141
                Error("Package $pkg_name, $pkg_ver not found in RM");
142
            }
143
            $sth->finish();
144
        }
145
    }
146
    else
147
    {
148
        Error("GetData:Prepare failure" );
149
    }
150
 
151
    DebugDumpData("PackageData", \%TargetPackage);
152
}
153
 
154