|
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 Getopt::Long; |
|
22 use IniData; |
|
23 use EnvDb; |
|
24 use CommandController; |
|
25 |
|
26 |
|
27 # |
|
28 # Globals. |
|
29 # |
|
30 |
|
31 my $iniData = IniData->New(); |
|
32 my $commandController = CommandController->New($iniData, 'ValidateRel'); |
|
33 my $verbose = 0; |
|
34 my $validatesource = 0; |
|
35 my $fullbincheck = 0; |
|
36 my $keeptemp; |
|
37 my @comps; |
|
38 |
|
39 |
|
40 # |
|
41 # Main. |
|
42 # |
|
43 |
|
44 ProcessCommandLine(); |
|
45 ValidateRel(); |
|
46 |
|
47 |
|
48 # |
|
49 # Subs. |
|
50 # |
|
51 |
|
52 sub ProcessCommandLine { |
|
53 Getopt::Long::Configure ("bundling"); |
|
54 my $help; |
|
55 GetOptions("h" => \$help, "v+" => \$verbose, "s" => \$validatesource, "t" => \$keeptemp, "f" => \$fullbincheck); |
|
56 |
|
57 if ($help) { |
|
58 Usage(0); |
|
59 } |
|
60 |
|
61 if ($#ARGV == 0) { |
|
62 if (-f $ARGV[0]) { |
|
63 open IN, $ARGV[0] or die "Error: Couldn't open $ARGV[0] for reading: $!\n"; |
|
64 while (my $line = <IN>) { |
|
65 chomp $line; |
|
66 $line =~ s/^\s*$//; #remove lines entirely filled with white space |
|
67 $line =~ s/#.*//; #remove comments from lines |
|
68 $line =~ s/^\s*//; #remove whitespace from the start of lines |
|
69 if ($line eq '') { |
|
70 next; #Nothing left |
|
71 } |
|
72 my @cmdLine = split(/\s+/,$line); |
|
73 my $cmdLineCount = @cmdLine; |
|
74 my %relStruct; |
|
75 if($cmdLineCount > 0) { |
|
76 $relStruct{name} = $cmdLine[0]; |
|
77 if($cmdLineCount > 1) { |
|
78 $relStruct{ver} = $cmdLine[1]; |
|
79 } |
|
80 push @comps, \%relStruct; |
|
81 } |
|
82 } |
|
83 close IN; |
|
84 } |
|
85 else { |
|
86 push @comps, {name => $ARGV[0]}; |
|
87 } |
|
88 } |
|
89 elsif ($#ARGV == 1) { |
|
90 # Both component and version are specified |
|
91 push @comps, {name => $ARGV[0], |
|
92 ver => $ARGV[1]}; |
|
93 } |
|
94 else { |
|
95 print "Error: Invalid number of arguments\n"; |
|
96 Usage(1); |
|
97 } |
|
98 } |
|
99 |
|
100 sub Usage { |
|
101 my $exitCode = shift; |
|
102 |
|
103 Utils::PrintDeathMessage($exitCode, "\nUsage: validaterel [options] (<component> [<version>]) | <component_list_file> |
|
104 |
|
105 options: |
|
106 |
|
107 -h help |
|
108 -v verbose output (-vv very verbose) |
|
109 -s validate source code too |
|
110 -f fully check for added binaries (can be very slow) |
|
111 -t don't delete the temporary directory |
|
112 "); |
|
113 } |
|
114 |
|
115 sub ValidateRel { |
|
116 my $iniData = IniData->New(); |
|
117 my $envDb = EnvDb->Open($iniData, $verbose); |
|
118 |
|
119 foreach my $comp (@comps) { |
|
120 my $version; |
|
121 if(exists($comp->{ver})) { |
|
122 $version = $comp->{ver}; |
|
123 } |
|
124 else { |
|
125 $version = $envDb->Version($comp->{name}); |
|
126 } |
|
127 |
|
128 if(defined $version) { |
|
129 $envDb->ValidateComp($comp->{name}, $version, undef, $validatesource, $keeptemp, $fullbincheck); |
|
130 } |
|
131 else { |
|
132 print $comp->{name}." not installed\n"; |
|
133 } |
|
134 } |
|
135 } |
|
136 |
|
137 __END__ |
|
138 |
|
139 =head1 NAME |
|
140 |
|
141 ValidateRel - Validates the integrity of the installed binaries of a given component. |
|
142 |
|
143 =head1 SYNOPSIS |
|
144 |
|
145 validaterel [options] (<component> [<version>]) | <component_list_file> |
|
146 |
|
147 options: |
|
148 |
|
149 -h help |
|
150 -v verbose output (-vv very verbose) |
|
151 -s validate source code too |
|
152 -f fully check for added binaries |
|
153 -t keep temporary directory |
|
154 |
|
155 =head1 DESCRIPTION |
|
156 |
|
157 Unpacks the binaries of the specified version of the component to a temporary directory (if a version is not specified, the version of the component that was originally installed in the environment is retrieved from the environment database). It then compares them with the binaries in the current drive's F<\epoc32> tree using the standard EPOC tool C<EValid>. Reports the status of the component as a result of the validation. This will be I<clean> if the validation passed, I<dirty> if the validation failed, or I<pending release> if the component was already pending release. If the component passes its validation and the version is the same as the one present in the environment database, its signature file in F<\epoc32\relinfo> will be updated. |
|
158 |
|
159 You may also give a -s flag to indicate that you want to validate the source code. This is useful because in some cases the source code may change, without the binary files changing. (For example, a change of distrubution.policy). If this validation fails, but the binary validation succeeds, the status will be set to I<binaries clean, source dirty>. Only source code in the release packet will be validated - source files missing from the release packets will not be detected. |
|
160 |
|
161 A list of component names stored in a text file may be passed to validaterel to validate multiple components. |
|
162 |
|
163 With the -t flag, you will be told where the temporary directory was. You |
|
164 can then use that to investigate validation failures with evalid. |
|
165 |
|
166 =head1 KNOWN BUGS |
|
167 |
|
168 None. |
|
169 |
|
170 =head1 COPYRIGHT |
|
171 |
|
172 Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
173 All rights reserved. |
|
174 This component and the accompanying materials are made available |
|
175 under the terms of the License "Eclipse Public License v1.0" |
|
176 which accompanies this distribution, and is available |
|
177 at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
178 |
|
179 Initial Contributors: |
|
180 Nokia Corporation - initial contribution. |
|
181 |
|
182 Contributors: |
|
183 |
|
184 Description: |
|
185 |
|
186 |
|
187 =cut |