Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
392 dpurdie 1
########################################################################
6177 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
392 dpurdie 3
#
4
# Module name   : jats.sh
5
# Module type   : Makefile system
6
# Compiler(s)   : n/a
7
# Environment(s): jats
8
#
9
# Description   : Display the currently released version of ALL packages
10
#                 that are a part of a given release
11
#
12
#                 Can saves results in a file.
13
#
14
# Usage:
15
#
16
#......................................................................#
17
 
18
require 5.006_001;
19
use strict;
20
use warnings;
21
use JatsError;
22
use Getopt::Long;
23
use Pod::Usage;                             # required for help support
24
use JatsRmApi;
25
use IO::Handle;
26
 
27
use DBI;
28
 
29
my $VERSION = "1.2.3";                      # Update this
30
my $opt_verbose = 1;
31
my $opt_help = 0;
32
my $opt_manual;
33
my $opt_rtag_id;
34
my $opt_ofile;
35
my $RM_DB;
36
 
37
#-------------------------------------------------------------------------------
38
# Function        : Main Entry
39
#
40
# Description     :
41
#
42
# Inputs          :
43
#
44
# Returns         :
45
#
46
my $result = GetOptions (
47
                "help+"     => \$opt_help,          # flag, multiple use allowed
48
                "manual"    => \$opt_manual,        # flag
49
                "verbose+"  => \$opt_verbose,       # flag
50
                "rtagid=s"  => \$opt_rtag_id,       # string
51
                "outfile=s" => \$opt_ofile,         # string
52
                );
53
 
54
#
55
#   Process help and manual options
56
#
57
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
58
pod2usage(-verbose => 1)  if ($opt_help == 2 );
59
pod2usage(-verbose => 2)  if ($opt_manual || ($opt_help > 2));
60
 
61
ErrorConfig( 'name'    =>'PLAY12' );
62
 
63
Error ("No RTAGID specified") unless ( $opt_rtag_id );
64
 
65
if ( $opt_ofile )
66
{
67
    open (OFILE, ">", $opt_ofile)  || Error("Cannot open output file: $opt_ofile");
68
    STDOUT->fdopen( \*OFILE, 'w' ) || Error("Cannot open output file: $!");
69
 
70
}
71
 
72
getPkgDetailsByRTAG_ID($opt_rtag_id);
73
exit;
74
 
75
 
76
sub getPkgDetailsByRTAG_ID
77
{
78
    my ($RTAG_ID) = @_;
79
    my (@row);
80
 
81
    # if we are not or cannot connect then return 0 as we have not found anything
82
    connectRM(\$RM_DB) unless ( $RM_DB );
83
 
84
    # First get details from pv_id
85
 
86
    my $m_sqlstr = "SELECT pv.PV_ID, pkg.PKG_NAME, pv.PKG_VERSION, pv.PKG_LABEL, pv.SRC_PATH, pv.BUILD_TYPE" .
87
                    " FROM RELEASE_MANAGER.RELEASE_CONTENT rc, RELEASE_MANAGER.PACKAGE_VERSIONS pv, RELEASE_MANAGER.PACKAGES pkg" .
88
                    " WHERE rc.RTAG_ID = $RTAG_ID AND rc.PV_ID = pv.PV_ID AND pv.PKG_ID = pkg.PKG_ID";
89
    my $sth = $RM_DB->prepare($m_sqlstr);
90
    if ( defined($sth) )
91
    {
92
        if ( $sth->execute( ) )
93
        {
94
            if ( $sth->rows )
95
            {
96
                while ( @row = $sth->fetchrow_array )
97
                {
98
                    my $pv_id   = $row[0];
99
                    my $name    = $row[1];
100
                    my $ver     = $row[2];
101
                    my $label   = $row[3] || '';
102
                    my $path    = $row[4] || '';
103
                    $path =~ tr~\\/~/~s;
104
 
105
                    print "$name $ver\n";
106
                }
107
            }
108
            $sth->finish();
109
        }
110
    }
111
    else
112
    {
113
        Error("Prepare failure" );
114
    }
115
}
116