Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
6887 dpurdie 1
########################################################################
2
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
3
#
4
# Module name   : jats.sh
5
# Module type   : Makefile system
6
# Compiler(s)   : n/a
7
# Environment(s): jats
8
#
9
# Description   : Determine packages with mismatched dpkg_archive names
10
#                 ie: Case differences
11
#
12
#......................................................................#
13
 
14
require 5.006_001;
15
use strict;
16
use warnings;
17
use JatsError;
18
use JatsSystem;
19
use Getopt::Long;
20
use Pod::Usage;                             # required for help support
21
use JatsRmApi;
22
 
23
use DBI;
24
 
25
my $VERSION = "1.2.3";                      # Update this
26
my $opt_verbose = 1;
27
my $opt_help = 0;
28
my $opt_manual;
29
my $RM_DB;
30
 
31
#
32
#   Package information
33
#
34
my $total;
35
my %Names;
36
my %NamesLc;
37
my %PkgNames;
38
 
39
#-------------------------------------------------------------------------------
40
# Function        : Main Entry
41
#
42
# Description     :
43
#
44
# Inputs          :
45
#
46
# Returns         :
47
#
48
my $result = GetOptions (
49
                "help+"         => \$opt_help,          # flag, multiple use allowed
50
                "manual"        => \$opt_manual,        # flag
51
                "verbose+"      => \$opt_verbose,       # flag
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
 
62
ErrorConfig( 'name'    =>'PLAY23' );
63
 
64
getDpkgArchiveNames();
65
getPkgDetailsByRTAG_ID();
66
#DebugDumpData("Names", \%Names );
67
#DebugDumpData("Names", \%PkgNames );
68
 
69
foreach my $dir ( sort keys %PkgNames) 
70
{
71
    if ( exists $Names{$dir})
72
    {
73
        next;
74
    }
75
    if ( exists $NamesLc{lc $dir} )
76
    {
77
        Warning("$dir does not exist - but " . $NamesLc{lc $dir} . " does");
78
    }
79
}
80
 
81
 
82
 
83
print "Package Names: $total\n";
84
exit;
85
 
86
sub getDpkgArchiveNames
87
{
88
    my $dir = $ENV{GBE_DPKG};
89
    Error ("DPKG_ARCHIVE is not a dir") 
90
        unless(-d $dir);
91
 
92
    opendir (my $dh, $dir) or Error ("Coundn't read DPKG_ARHIVE");
93
    while (readdir $dh)
94
    {
95
        $PkgNames{$_} = 1;
96
    }
97
    close $dh;
98
}
99
 
100
 
101
sub getPkgDetailsByRTAG_ID
102
{
103
    my $foundDetails = 0;
104
    my (@row);
105
 
106
    # if we are not or cannot connect then return 0 as we have not found anything
107
    connectRM(\$RM_DB);
108
 
109
    # First get all packages that are referenced in a Release
110
 
111
    my $m_sqlstr = "SELECT DISTINCT pkg.PKG_NAME" .
112
                   " FROM RELEASE_MANAGER.RELEASE_CONTENT rc, RELEASE_MANAGER.PACKAGE_VERSIONS pv, RELEASE_MANAGER.PACKAGES pkg" .
113
                   " WHERE rc.PV_ID = pv.PV_ID AND pv.PKG_ID = pkg.PKG_ID" .
114
                   " order by pkg.PKG_NAME";
115
    my $sth = $RM_DB->prepare($m_sqlstr);
116
    if ( defined($sth) )
117
    {
118
        if ( $sth->execute( ) )
119
        {
120
            print "--- Execute\n";
121
            if ( $sth->rows )
122
            {
123
                print "--- Execute ROWS\n";
124
                while ( @row = $sth->fetchrow_array )
125
                {
126
                    print "Data: @row\n";
127
                    my %data;
128
                    my $name = $row[0];
129
                    $Names{$name} = 1;
130
                    $NamesLc{lc $name} = $name;
131
                    $total++;
132
                }
133
            }
134
            print "--- Finish\n";
135
            $sth->finish();
136
        }
137
        else
138
        {
139
            Error("Execute failure: $m_sqlstr" );
140
        }
141
    }
142
    else
143
    {
144
        Error("Prepare failure" );
145
    }
146
}
147