|
1 #!perl |
|
2 # Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 # All rights reserved. |
|
4 # This component and the accompanying materials are made available |
|
5 # under the terms of the License "Eclipse Public License v1.0" |
|
6 # which accompanies this distribution, and is available |
|
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 # |
|
9 # Initial Contributors: |
|
10 # Nokia Corporation - initial contribution. |
|
11 # |
|
12 # Contributors: |
|
13 # |
|
14 # Description: |
|
15 # |
|
16 # |
|
17 |
|
18 use strict; |
|
19 use FindBin; |
|
20 use lib "$FindBin::Bin"; |
|
21 use Tk; |
|
22 use Tk::Table; |
|
23 use Getopt::Long; |
|
24 use IniData; |
|
25 use EnvDb; |
|
26 |
|
27 |
|
28 # |
|
29 # Constants. |
|
30 # |
|
31 |
|
32 my $margin = 2; |
|
33 |
|
34 |
|
35 # |
|
36 # Globals. |
|
37 # |
|
38 |
|
39 my $verbose = 0; |
|
40 my $full = 0; |
|
41 my $component; |
|
42 my $iniData = IniData->New(); |
|
43 my $envDb; |
|
44 my $overallStatus; |
|
45 my $displayClean = 0; |
|
46 my $displayDirty = 0; |
|
47 my $displayPendingRelease = 0; |
|
48 my $noScan = 0; |
|
49 |
|
50 |
|
51 # |
|
52 # Main. |
|
53 # |
|
54 |
|
55 ProcessCommandLine(); |
|
56 CheckEnv(); |
|
57 DisplayInfo(); |
|
58 |
|
59 |
|
60 # |
|
61 # Subs. |
|
62 # |
|
63 |
|
64 sub ProcessCommandLine { |
|
65 Getopt::Long::Configure ("bundling"); |
|
66 my $help; |
|
67 GetOptions("h" => \$help, "f" => \$full, "c" => \$displayClean, "d" => \$displayDirty, "p" => \$displayPendingRelease, "n" => \$noScan, "v+" => \$verbose); |
|
68 if ($help) { |
|
69 Usage(0); |
|
70 } |
|
71 |
|
72 if (not $full and ($displayClean or $displayDirty or $displayPendingRelease)) { |
|
73 print "Warning: Inappropriate option(s)\n"; |
|
74 } |
|
75 |
|
76 if (not $displayClean and not $displayDirty and not $displayPendingRelease) { |
|
77 $displayClean = 1; |
|
78 $displayDirty = 1; |
|
79 $displayPendingRelease = 1; |
|
80 } |
|
81 |
|
82 $component = $ARGV[0]; |
|
83 $envDb = EnvDb->Open($iniData, $verbose); |
|
84 } |
|
85 |
|
86 sub Usage { |
|
87 my $exitCode = shift; |
|
88 |
|
89 Utils::PrintDeathMessage($exitCode, "\nUsage: envinfo [options] [<component>] |
|
90 |
|
91 options: |
|
92 |
|
93 -h help |
|
94 -v verbose output (-vv very verbose) |
|
95 -f display full information (the remaining switches only apply when this is used) |
|
96 -c display the components with status \"clean\" |
|
97 -d display the components with status \"dirty\" |
|
98 -p display the components with status \"pending release\" |
|
99 -n no scan"); |
|
100 } |
|
101 |
|
102 sub CheckEnv { |
|
103 unless ($noScan or not $full) { |
|
104 if (defined $component) { |
|
105 $envDb->CheckComp($component); |
|
106 } |
|
107 else { |
|
108 ($overallStatus) = $envDb->CheckEnv(); |
|
109 } |
|
110 } |
|
111 } |
|
112 |
|
113 sub DisplayInfo { |
|
114 # Create a list of the components to be displayed. |
|
115 my @comps; |
|
116 if (defined $component) { |
|
117 my $ver = $envDb->Version($component); |
|
118 unless (defined $ver) { |
|
119 die "Error: $component not found\n"; |
|
120 } |
|
121 push @comps, $component; |
|
122 } |
|
123 else { |
|
124 my $versionInfo = $envDb->VersionInfo(); |
|
125 foreach my $comp (sort keys %{$versionInfo}) { |
|
126 push @comps, $comp; |
|
127 } |
|
128 } |
|
129 |
|
130 my $tableData; |
|
131 if ($full) { |
|
132 $tableData = GenFullInfoTable(\@comps); |
|
133 } |
|
134 else { |
|
135 $tableData = GenMinimalInfoTable(\@comps); |
|
136 } |
|
137 |
|
138 # Only print the table if there's something in it. |
|
139 if (scalar(@$tableData) > 1) { |
|
140 print "\n"; |
|
141 DisplayTable($tableData, 1); |
|
142 } |
|
143 |
|
144 # Only display the overall status if a full check was done. |
|
145 if (defined $overallStatus) { |
|
146 print "\nOverall status: ", EnvDb::StatusString($overallStatus), "\n"; |
|
147 } |
|
148 } |
|
149 |
|
150 sub GenMinimalInfoTable { |
|
151 my $comps = shift; |
|
152 |
|
153 # Create a two dimentional array of the data to be printed. |
|
154 my $tableData = [["Component", "Version"]]; |
|
155 my $row = 1; |
|
156 foreach my $comp (@$comps) { |
|
157 my $ver = $envDb->Version($comp); |
|
158 $tableData->[$row++] = [$comp, $ver]; |
|
159 } |
|
160 return $tableData; |
|
161 } |
|
162 |
|
163 sub GenFullInfoTable { |
|
164 my $comps = shift; |
|
165 |
|
166 # Create a two dimentional array of the data to be printed. |
|
167 my $tableData = [["Component", "Version", "Internal version", "Status", "Mrp"]]; |
|
168 my $row = 1; |
|
169 foreach my $comp (@$comps) { |
|
170 my $ver = $envDb->Version($comp); |
|
171 my $status = $envDb->Status($comp); |
|
172 if (not $displayClean and $status == EnvDb::STATUS_CLEAN) { |
|
173 next; |
|
174 } |
|
175 elsif (not $displayDirty and ($status == EnvDb::STATUS_DIRTY or $status == EnvDb::STATUS_DIRTY_SOURCE)) { |
|
176 next; |
|
177 } |
|
178 elsif (not $displayPendingRelease and $status == EnvDb::STATUS_PENDING_RELEASE) { |
|
179 next; |
|
180 } |
|
181 |
|
182 my $mrpName = $envDb->MrpName($comp); |
|
183 unless (defined $mrpName) { |
|
184 $mrpName = "-"; |
|
185 } |
|
186 my $intVer = $envDb->InternalVersion($comp); |
|
187 unless (defined $intVer) { |
|
188 $intVer = "-"; |
|
189 } |
|
190 $tableData->[$row++] = [$comp, $ver, $intVer, EnvDb::StatusString($status), $mrpName]; |
|
191 } |
|
192 return $tableData; |
|
193 } |
|
194 |
|
195 sub DisplayTable { |
|
196 my $tableData = shift; |
|
197 my $numRows = scalar(@{$tableData}); |
|
198 die unless $numRows and defined $tableData->[0]; # There must be at least one column and row. |
|
199 my $numCols = scalar(@{$tableData->[0]}); |
|
200 |
|
201 my $mw = MainWindow->new(); |
|
202 CreateGrid($mw, $tableData); |
|
203 MainLoop(); |
|
204 } |
|
205 |
|
206 sub CreateGrid() { |
|
207 my $mw = shift; |
|
208 my $data = shift; |
|
209 my $numRows = scalar(@{$data}); |
|
210 die unless $numRows and defined $data->[0]; # There must be at least one column and row. |
|
211 my $numCols = scalar(@{$data->[0]}); |
|
212 |
|
213 foreach my $row (0 ... $numRows - 1) { |
|
214 my @row; |
|
215 foreach my $col (1 ... $numCols - 1) { |
|
216 $row[$col - 1] = $mw->Label(-text => $data->[$row][$col], |
|
217 -justify => 'left', |
|
218 -background => 'blue'); |
|
219 } |
|
220 $mw->Label(-text => $data->[$row][0], |
|
221 -justify => 'left')->grid(@row, |
|
222 -sticky => 'nsew'); |
|
223 } |
|
224 } |
|
225 |
|
226 =head1 NAME |
|
227 |
|
228 EnvInfoTk - Displays information about the installed components in the current environment. |
|
229 |
|
230 =head1 SYNOPSIS |
|
231 |
|
232 envinfo [options] [<component>] |
|
233 |
|
234 options: |
|
235 |
|
236 -h help |
|
237 -v verbose output (-vv very verbose) |
|
238 -f display full information (the remaining switches only apply when this is used) |
|
239 -c display the components with status "clean" |
|
240 -d display the components with status "dirty" |
|
241 -p display the components with status "pending release" |
|
242 -n no scan |
|
243 |
|
244 =head1 DESCRIPTION |
|
245 |
|
246 By default displays a brief summary table of the information contained in the current drive's environment database. For example: |
|
247 |
|
248 Component Version |
|
249 |
|
250 mycomp1 026 |
|
251 mycomp2 057 |
|
252 |
|
253 If envoked with the C<-f> switch a full table is displayed: |
|
254 |
|
255 Component Version Internal version Status Mrp |
|
256 |
|
257 mycomp1 026 //myproject/latest/mycomp1/...@10106 clean \mycomp1\mycomp1.mrp |
|
258 mycomp2 057 //myproject/latest/mycomp1/...@10157 clean \mycomp2\mycomp2.mrp |
|
259 |
|
260 Overall status: clean |
|
261 |
|
262 The C<Component> and C<Version> fields are self explanatory. The C<Internal version> field is a label used by the site that owns the component, to store an internal reference (normally generated by their source control system). This is likely to be of use only to the owning site. The C<Status> field may have the following values: |
|
263 |
|
264 =over 4 |
|
265 |
|
266 =item * |
|
267 |
|
268 B<clean> - The component's binaries all match the time stamp information that was stored when they were installed. |
|
269 |
|
270 =item * |
|
271 |
|
272 B<dirty> - One or more of the component's binaries doesn't match the time stamp information that was stored when they were installed. This may be because the source has been re-built but not changed (see the commands C<ValidateRel> and C<ValidateEnv> for details of how to check if a re-built set of binaries are identical to an already released set), or because changes have been made. |
|
273 |
|
274 =item * |
|
275 |
|
276 B<pending release> - The component is waiting to be released (see the commands C<PrepEnv> and C<MakeEnv> for details of how to make releases). |
|
277 |
|
278 =back |
|
279 |
|
280 The C<Mrp> field contains the name of the F<mrp> file that was used when the release was made. The overall status of the environment is displayed last. This may have the following values: |
|
281 |
|
282 =over 4 |
|
283 |
|
284 =item * |
|
285 |
|
286 B<clean> - All the installed components have a status of C<clean> and there are no files in the F<\epoc32> tree that have unkown origins (i.e. they are all known to belong to a component). |
|
287 |
|
288 =item * |
|
289 |
|
290 B<dirty> - One or more of the installed components has a status of C<dirty>, or there is one or more files in the F<\epoc32> tree that has unknown origins. |
|
291 |
|
292 =item * |
|
293 |
|
294 B<pending release> - All components have a status of either C<clean> or C<pending release> and there are no files in the F<\epoc32> with unknown origins. |
|
295 |
|
296 =back |
|
297 |
|
298 |
|
299 By default C<EnvInfoTk> will perform a scan of the F<\epoc32> tree checking all the time stamps. To avoid this processing, use the C<-n> switch. This will cause the status of each component when the last scan was performed to be displayed (which may now be out of date). The output of C<EnvInfoTk> can be filtered according to status using the switches C<-c>, C<-d> and C<-p>. For example, if you wanted to view all the components that are either C<dirty> or C<pending release>, type: |
|
300 |
|
301 envinfo -dp |
|
302 |
|
303 If envoked with a C<component> argument, then only the details of the specified component will be displayed and a scan of the F<\epoc32> tree will not be performed. |
|
304 |
|
305 =head1 KNOWN BUGS |
|
306 |
|
307 None. |
|
308 |
|
309 =head1 COPYRIGHT |
|
310 |
|
311 Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
312 All rights reserved. |
|
313 This component and the accompanying materials are made available |
|
314 under the terms of the License "Eclipse Public License v1.0" |
|
315 which accompanies this distribution, and is available |
|
316 at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
317 |
|
318 Initial Contributors: |
|
319 Nokia Corporation - initial contribution. |
|
320 |
|
321 Contributors: |
|
322 |
|
323 Description: |
|
324 |
|
325 |
|
326 =cut |