Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
392 dpurdie 1
########################################################################
2
# Copyright (C) 1998-2012 Vix Technology, All rights reserved
3
#
4
# Module name   : cc2svn_cctest_paths.pl
5
# Module type   : Makefile system
6
# Compiler(s)   : Perl
7
# Environment(s): jats
8
#
9
# Description   : Test CC paths
10
#                 Process a cc2svn.raw.txt file and examine the CC
11
#                 tags for validity.
12
#
13
#                 Not fast as it creates a dynamic view for each one
14
#                 About one evry two seconds :(
15
#
16
#                 Creates a log file
17
#
1197 dpurdie 18
#                 Can be stopped by creating a stop file
392 dpurdie 19
#
20
#                 Can read in a log file and not retry known good labels
21
#
22
#......................................................................#
23
 
24
require 5.006_001;
25
use strict;
26
use warnings;
27
use JatsError;
28
use JatsSystem;
29
use Getopt::Long;
30
use Pod::Usage;                                 # required for help support
31
use JatsRmApi;
32
 
33
 
34
my $opt_verbose = 1;
35
my $opt_help = 0;
36
my $opt_manual;
37
 
38
#
39
#   Package information
40
#
41
our %ScmReleases;
42
our %ScmPackages;
43
our %ScmSuffixes;
44
 
45
my %Good;
46
my $goodFile = 'cc2svn_labeltest.txt';
47
my $badFile ='cc2svn_labeltest.bad.txt';
48
 
49
 
50
#-------------------------------------------------------------------------------
51
# Function        : Main Entry
52
#
53
# Description     :
54
#
55
# Inputs          :
56
#
57
# Returns         :
58
#
59
my $result = GetOptions (
60
                "help+"         => \$opt_help,          # flag, multiple use allowed
61
                "manual"        => \$opt_manual,        # flag
62
                "verbose+"      => \$opt_verbose,       # flag
63
                );
64
 
65
#
66
#   Process help and manual options
67
#
68
pod2usage(-verbose => 0)  if ($opt_help == 1  || ! $result);
69
pod2usage(-verbose => 1)  if ($opt_help == 2 );
70
pod2usage(-verbose => 2)  if ($opt_manual || ($opt_help > 2));
71
 
72
 
73
ErrorConfig( 'name'    =>'CCTEST_PATHS' );
74
unlink $badFile;
75
Message ("Reading input data");
76
inputData();
77
inputPastData();
78
 
79
    #
80
    #   Process the data and attempt to validate the label for each package
81
    #
82
    SystemConfig ('ExitOnError' => 0);
1197 dpurdie 83
    foreach ( sort {lc($ScmPackages{$a}{name}) cmp lc($ScmPackages{$b}{name}) } keys %ScmPackages )
392 dpurdie 84
    {
85
        next if ( exists $Good{$_} );
86
        if ( -f 'stop' )
87
        {
88
            unlink 'stop';
89
            Error ("Stop file encountered");
90
        }
91
        my $tag = $ScmPackages{$_}{vcstag};
92
        my $name = $ScmPackages{$_}{name};
93
        my $rv = 0;
94
        next if ( $tag =~ m~^SVN::~ );                     # Skip packages in Subversion
95
        next if ( $name eq 'AtmelHAL' );                   # Skip - vob not available
96
 
97
        $tag =~ tr~\\/~/~;
98
        if ( $tag !~ m~^CC::~ || examineVcsTag ($tag)){
99
            $rv = 55;
100
        }
101
 
102
        unless ( $rv )
103
        {
104
            $rv = JatsToolPrint ( 'cc2svn_cctest_path.pl', $tag );
105
        }
106
 
107
        doLog ($rv, "$_, $name: $tag, $rv");
108
    }
109
 
110
sub JatsToolPrint
111
{
112
#    Information ("Command: @_");
113
    JatsTool @_;
114
}
115
 
116
 
117
#-------------------------------------------------------------------------------
118
# Function        : inputData
119
#
120
# Description     : Write out data in a form to allow post processing
121
#
122
# Inputs          : 
123
#
124
# Returns         : 
125
#
126
sub inputData
127
{
128
 
129
    my $fname = 'cc2svn.raw.txt';
130
    Error "Cannot locate $fname" unless ( -f $fname );
131
    require $fname;
132
 
133
    Error "Data in $fname is not valid\n"
134
        unless ( keys(%ScmReleases) >= 0 );
135
 
136
#    DebugDumpData("ScmReleases", \%ScmReleases );
137
#    DebugDumpData("ScmPackages", \%ScmPackages );
138
#    DebugDumpData("ScmSuffixes", \%ScmSuffixes );
139
}
140
 
141
#-------------------------------------------------------------------------------
142
# Function        : examineVcsTag
143
#
144
# Description     : Examine a VCS Tag and determine if it looks like rubbish
145
#
146
# Inputs          : Tag to examine
147
#
148
# Returns         : Badness
149
#
150
sub examineVcsTag
151
{
152
    my ($vcstag) = @_;
153
    my $bad = 0;
154
    if ( $vcstag =~ m~^CC::(.*?)(::(.+))?$~ )
155
    {
156
        my $path = $1  || '';
157
        my $label = $2 || '';
158
#print "$vcstag, $bad, $path, $label\n";
159
        $bad = 1 unless ( $label );
160
        $bad = 1 if ( $label =~ m~^N/A$~i || $label  =~ m~^na$~i );
161
 
162
        $bad = 1 unless ( $path );
163
        $bad = 1 if ( $path =~ m~^N/A$~i || $path  =~ m~^na$~i );
164
        $bad = 1 if ( $path =~ m~^/dpkg_archive~ );
165
        $bad = 1 if ( $path =~ m~^dpkg_archive~ );
166
        $bad = 1 if ( $path =~ m~^http:~i );
167
        $bad = 1 if ( $path =~ m~^[A-Za-z]\:~ );
168
        $bad = 1 if ( $path =~ m~^//~ );
169
#        $bad = 1 unless ( $path =~ m~^/~ );
170
    }
171
    else
172
    {
173
        $bad = 1;
174
    }
175
    return $bad;
176
}
177
 
178
#-------------------------------------------------------------------------------
179
# Function        : doLog
180
#
181
# Description     : Log data to output file
182
#
183
# Inputs          : $rv                 - Result code
184
#                                         Determine log file
185
#                   Data to log
186
#
187
# Returns         : 
188
#
189
sub doLog
190
{
191
    my $rv = shift;
192
    my $file = $rv ? $badFile : $goodFile;
193
    open (my $fh, '>>', $file);
194
    print $fh @_, "\n";
195
    close $fh;
196
}
197
 
198
#-------------------------------------------------------------------------------
199
# Function        : inputPastData
200
#
201
# Description     : Read in a previous log file and determine versions that
202
#                   have already been examined
203
#
204
# Inputs          : 
205
#
206
# Returns         : 
207
#
208
sub inputPastData
209
{
210
    Message ("Reading historical data");
211
    open (my $fh, '<', $goodFile );
212
    while ( <$fh> )
213
    {
214
        #
215
        #   Format of data is:
216
        #       pvid, $name:, $tag, $rv
217
        #
218
        chomp;
219
        next if ( m~^#~ );
220
        my @data = split (/\s*,\s*/, $_);
221
        next if ( $data[2] );
222
        next unless ( $data[0] );
223
 
224
        $Good{$data[0]} = 1;
225
    }
226
    close $fh;
227
}
228