602
|
1 |
# Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
# All rights reserved.
|
|
3 |
# This component and the accompanying materials are made available
|
|
4 |
# under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
# which accompanies this distribution, and is available
|
|
6 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
#
|
|
8 |
# Initial Contributors:
|
|
9 |
# Nokia Corporation - initial contribution.
|
|
10 |
#
|
|
11 |
# Contributors:
|
|
12 |
#
|
|
13 |
# Description:
|
|
14 |
#
|
|
15 |
#
|
|
16 |
# Description:
|
|
17 |
# Symbian::CBR::Delta::Manifest.pm
|
|
18 |
#
|
|
19 |
|
|
20 |
package Symbian::CBR::DeltaRelease::Manifest;
|
|
21 |
|
|
22 |
use strict;
|
|
23 |
use XML::Simple;
|
|
24 |
use Carp;
|
|
25 |
use POSIX qw(strftime);
|
|
26 |
use base qw (Exporter);
|
|
27 |
|
|
28 |
#
|
|
29 |
#Constants
|
|
30 |
#
|
|
31 |
|
|
32 |
use constant DELTA_MANIFEST_FILE => 'delta_manifest_baseline.xml';
|
|
33 |
use constant META_FILES => 'metafiles';
|
|
34 |
use constant ADDED_ZIPS => 'addedZips';
|
|
35 |
|
|
36 |
our @EXPORT_OK = qw(DELTA_MANIFEST_FILE META_FILES ADDED_ZIPS);
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
#
|
|
41 |
#Public.
|
|
42 |
#
|
|
43 |
|
|
44 |
sub new {
|
|
45 |
my $pkg = shift;
|
|
46 |
my $self = {};
|
|
47 |
bless $self, $pkg;
|
|
48 |
return $self;
|
|
49 |
}
|
|
50 |
|
|
51 |
sub Save {
|
|
52 |
my $self = shift;
|
|
53 |
my $destination = shift;
|
|
54 |
mkpath ($destination) unless (-e $destination);
|
|
55 |
my $manifestFile = File::Spec->catfile($destination,DELTA_MANIFEST_FILE);
|
|
56 |
print "Writing Delta manifest file.\n " ;
|
|
57 |
#Hash structure to be provided as input for XML::Simple->XMLout()
|
|
58 |
my $manifestHash = {
|
|
59 |
version => "1.0.0",
|
|
60 |
meta => { 'reference-baseline' => { 'value' => $self->{referenceBaseline} },
|
|
61 |
'reference-version' => { 'value' => $self->{referenceVersion} },
|
|
62 |
'nominated-baseline' => { 'value' => $self->{nominatedBaseline} },
|
|
63 |
'nominated-version' => { 'value' => $self->{nominatedVersion} },
|
|
64 |
'created-time' => { 'value' => strftime( '%Y-%m-%dT%H:%M:%S', localtime() ) } }
|
|
65 |
};
|
|
66 |
my $cgroups = {};
|
|
67 |
foreach my $thisComp (sort keys %{$self->{components}}) {
|
|
68 |
my $compStatus = $self->{components}{$thisComp}{'status'};
|
|
69 |
my $nomVer = $self->{components}{$thisComp}{'nominatedVersion'} if (defined $self->{components}{$thisComp}{'nominatedVersion'});
|
|
70 |
my $refVer = $self->{components}{$thisComp}{'referenceVersion'} if (defined $self->{components}{$thisComp}{'referenceVersion'});
|
|
71 |
my $zgroups = {};
|
|
72 |
my @zGroupArray = ();
|
|
73 |
foreach my $thisZip (sort keys %{$self->{components}{$thisComp}{'zipFiles'}}) {
|
|
74 |
my $thisZipFileStatus = $self->{components}{$thisComp}{'zipFiles'}{$thisZip}{'status'};
|
|
75 |
if ( !defined $zgroups->{$thisZip} ) {
|
|
76 |
$zgroups->{$thisZip} = {file => []};
|
|
77 |
if ($thisZip =~ /^exports([A-Z])\.zip$/i) {
|
|
78 |
$zgroups->{$thisZip}{'ipr-category'} = $1;
|
|
79 |
$zgroups->{$thisZip}{'content-type'} = "exports";
|
|
80 |
}
|
|
81 |
elsif ($thisZip =~ /^source([A-Z])\.zip$/i) {
|
|
82 |
$zgroups->{$thisZip}{'ipr-category'} = $1;
|
|
83 |
$zgroups->{$thisZip}{'content-type'} = "source";
|
|
84 |
}
|
|
85 |
elsif ($thisZip =~ /^binaries\.zip$/i) {
|
|
86 |
$zgroups->{$thisZip}{'content-type'} = "binary";
|
|
87 |
}
|
|
88 |
elsif ($thisZip =~ /^binaries\_([_a-zA-Z0-9]+)\.zip$/i) {
|
|
89 |
$zgroups->{$thisZip}{'content-type'} = "binary";
|
|
90 |
$zgroups->{$thisZip}{'platform'} = $1;
|
|
91 |
}
|
|
92 |
$zgroups->{$thisZip}{status} = $thisZipFileStatus;
|
|
93 |
push @zGroupArray, $zgroups->{$thisZip};
|
|
94 |
}
|
|
95 |
foreach my $thisFile (keys %{$self->{components}{$thisComp}{'zipFiles'}{$thisZip}{files}}) {
|
|
96 |
my $file = { path => $thisFile };
|
|
97 |
$file->{status} = $self->{components}{$thisComp}{'zipFiles'}{$thisZip}{files}{$thisFile}{status};
|
|
98 |
$file->{type} = $self->{components}{$thisComp}{'zipFiles'}{$thisZip}{files}{$thisFile}{type};
|
|
99 |
push @{$zgroups->{$thisZip}{file}}, $file;
|
|
100 |
}
|
|
101 |
}
|
|
102 |
if ( !defined $cgroups->{$thisComp} ) {
|
|
103 |
$cgroups->{$thisComp} = { files => [] };
|
|
104 |
$cgroups->{$thisComp}{name} = $thisComp;
|
|
105 |
$cgroups->{$thisComp}{status} = $compStatus;
|
|
106 |
$cgroups->{$thisComp}{referenceVersion} = $refVer if(defined $refVer);
|
|
107 |
$cgroups->{$thisComp}{nominatedVersion} = $nomVer if(defined $nomVer);
|
|
108 |
push @{$manifestHash->{component}}, $cgroups->{$thisComp};
|
|
109 |
}
|
|
110 |
foreach my $zgroup (@zGroupArray) {
|
|
111 |
push @{$cgroups->{$thisComp}{files}}, $zgroup;
|
|
112 |
}
|
|
113 |
foreach my $thisFile (sort keys %{$self->{components}{$thisComp}{metafiles}}) {
|
|
114 |
my $file = { path => $thisFile };
|
|
115 |
push @{$cgroups->{$thisComp}{metafiles}{file}}, $file;
|
|
116 |
}
|
|
117 |
}
|
|
118 |
#Use the hash structure for calling the XMLout() to write the manifest file
|
|
119 |
eval {XMLout(
|
|
120 |
$manifestHash,
|
|
121 |
xmldecl => '<?xml version="1.0" ?>',
|
|
122 |
rootname => 'manifest',
|
|
123 |
outputfile => $manifestFile )};
|
|
124 |
croak "Error: Can't write manifest file: $@\n" if $@;
|
|
125 |
}
|
|
126 |
|
|
127 |
sub LoadManifest {
|
|
128 |
my $self = shift;
|
|
129 |
my $manifestFile = shift;
|
|
130 |
print "Reading $manifestFile file.\n";
|
|
131 |
|
|
132 |
my $manifest = eval{XMLin(
|
|
133 |
$manifestFile,
|
|
134 |
forcearray => [ qw(component files file metafiles) ], keyattr => [])
|
|
135 |
};
|
|
136 |
|
|
137 |
croak "Error: Can't read manifest file '$manifestFile': $@\n" if $@;
|
|
138 |
|
|
139 |
# Mapping from xml keyword to our internal data structure keyword
|
|
140 |
my %metaFieldMap = ('nominated-baseline' => 'nominatedBaseline',
|
|
141 |
'nominated-version' => 'nominatedVersion',
|
|
142 |
'reference-baseline' => 'referenceBaseline',
|
|
143 |
'reference-version' => 'referenceVersion',
|
|
144 |
'created-time' => 'createdTime');
|
|
145 |
|
|
146 |
foreach my $metaInformation (@{$manifest->{meta}}) {
|
|
147 |
$self->{$metaFieldMap{$metaInformation->{name}}} = $metaInformation->{value};
|
|
148 |
}
|
|
149 |
|
|
150 |
foreach my $component ( @{$manifest->{component} } ) {
|
|
151 |
$self->{components}->{$component->{name}} = {
|
|
152 |
referenceVersion => $component->{referenceVersion},
|
|
153 |
nominatedVersion => $component->{nominatedVersion},
|
|
154 |
status => $component->{status}};
|
|
155 |
|
|
156 |
foreach my $zipfile ( @{ $component->{files} } ) {
|
|
157 |
my $content = $zipfile->{'content-type'};
|
|
158 |
my $category;
|
|
159 |
my $platform;
|
|
160 |
my $zipFileName ;
|
|
161 |
if ($content eq "source" or $content eq "exports") {
|
|
162 |
$category = $zipfile->{'ipr-category'};
|
|
163 |
$zipFileName = $content.$category.".zip";
|
|
164 |
}
|
|
165 |
else {
|
|
166 |
$platform = $zipfile->{platform};
|
|
167 |
if (defined $platform) {
|
|
168 |
$zipFileName = "binaries_".$platform.".zip";
|
|
169 |
}
|
|
170 |
else {
|
|
171 |
$zipFileName = "binaries.zip";
|
|
172 |
}
|
|
173 |
}
|
|
174 |
|
|
175 |
$self->{components}->{$component->{name}}->{zipFiles}->{$zipFileName}->{status} = $zipfile->{status};
|
|
176 |
|
|
177 |
foreach my $file (@{$zipfile->{file}}) {
|
|
178 |
$self->{components}->{$component->{name}}->{zipFiles}->{$zipFileName}->{files}->{$file->{path}} = {
|
|
179 |
status => $file->{status},
|
|
180 |
type => $file->{type}};
|
|
181 |
}
|
|
182 |
}
|
|
183 |
foreach my $metafiles ( @{ $component->{metafiles} } ) {
|
|
184 |
foreach my $file (@{$metafiles->{file}}) {
|
|
185 |
my $name = $file->{path};
|
|
186 |
$self->{components}->{$component->{name}}->{metafiles}->{$name} = 1;
|
|
187 |
}
|
|
188 |
}
|
|
189 |
}
|
|
190 |
}
|
|
191 |
|
|
192 |
sub SetReferenceBaselineComp {
|
|
193 |
my $self = shift;
|
|
194 |
my $comp = shift;
|
|
195 |
$self->{referenceBaseline} = $comp;
|
|
196 |
}
|
|
197 |
|
|
198 |
sub SetReferenceBaselineVer {
|
|
199 |
my $self = shift;
|
|
200 |
my $version = shift;
|
|
201 |
$self->{referenceVersion} = $version;
|
|
202 |
}
|
|
203 |
|
|
204 |
sub SetNominatedBaselineComp {
|
|
205 |
my $self = shift;
|
|
206 |
my $comp = shift;
|
|
207 |
$self->{nominatedBaseline} = $comp;
|
|
208 |
}
|
|
209 |
|
|
210 |
sub SetNominatedBaselineVer {
|
|
211 |
my $self = shift;
|
|
212 |
my $version = shift;
|
|
213 |
$self->{nominatedVersion} = $version;
|
|
214 |
}
|
|
215 |
|
|
216 |
sub SetComponentDetails {
|
|
217 |
my $self = shift;
|
|
218 |
my $comp = shift;
|
|
219 |
my $status = shift;
|
|
220 |
my $refVersion = shift;
|
|
221 |
my $nomVersion = shift;
|
|
222 |
$self->{components}{$comp}{'status'} = $status;
|
|
223 |
$self->{components}{$comp}{'referenceVersion'} = $refVersion if(defined $refVersion);
|
|
224 |
$self->{components}{$comp}{'nominatedVersion'} = $nomVersion if(defined $nomVersion);
|
|
225 |
}
|
|
226 |
|
|
227 |
sub SetZipfileDetails {
|
|
228 |
my $self = shift;
|
|
229 |
my $comp = shift;
|
|
230 |
my $zipFile = shift;
|
|
231 |
my $status = shift;
|
|
232 |
$self->{components}{$comp}{zipFiles}{$zipFile}{'status'} = $status;
|
|
233 |
}
|
|
234 |
|
|
235 |
sub SetFileDetails {
|
|
236 |
my $self = shift;
|
|
237 |
my $comp = shift;
|
|
238 |
my $zipFile = shift;
|
|
239 |
my $file = shift;
|
|
240 |
my $status = shift;
|
|
241 |
my $type = shift;
|
|
242 |
$self->{components}{$comp}{zipFiles}{$zipFile}{files}{$file}{status} = $status;
|
|
243 |
$self->{components}{$comp}{zipFiles}{$zipFile}{files}{$file}{type} = $type;
|
|
244 |
}
|
|
245 |
|
|
246 |
sub RecordMetaFile {
|
|
247 |
my $self = shift;
|
|
248 |
my $comp = shift;
|
|
249 |
my $file = shift;
|
|
250 |
$self->{components}{$comp}{metafiles}{$file} = 1;
|
|
251 |
}
|
|
252 |
|
|
253 |
sub GetReferenceBaselineComp {
|
|
254 |
my $self = shift;
|
|
255 |
return $self->{referenceBaseline} ;
|
|
256 |
}
|
|
257 |
|
|
258 |
sub GetReferenceBaselineVer {
|
|
259 |
my $self = shift;
|
|
260 |
return $self->{referenceVersion};
|
|
261 |
}
|
|
262 |
|
|
263 |
sub GetNominatedBaselineComp {
|
|
264 |
my $self = shift;
|
|
265 |
return $self->{nominatedBaseline};
|
|
266 |
}
|
|
267 |
|
|
268 |
sub GetNominatedBaselineVer {
|
|
269 |
my $self = shift;
|
|
270 |
return $self->{nominatedVersion};
|
|
271 |
}
|
|
272 |
|
|
273 |
sub ListAllComponents {
|
|
274 |
my $self = shift;
|
|
275 |
return $self->{components};
|
|
276 |
}
|
|
277 |
|
|
278 |
sub GetCompStatus {
|
|
279 |
my $self = shift;
|
|
280 |
my $comp = shift;
|
|
281 |
return $self->{components}{$comp}{'status'};
|
|
282 |
}
|
|
283 |
|
|
284 |
sub GetCompReferenceVer {
|
|
285 |
my $self = shift;
|
|
286 |
my $comp = shift;
|
|
287 |
return $self->{components}{$comp}{'referenceVersion'};
|
|
288 |
}
|
|
289 |
|
|
290 |
sub GetCompNominatedVer {
|
|
291 |
my $self = shift;
|
|
292 |
my $comp = shift;
|
|
293 |
return $self->{components}{$comp}{'nominatedVersion'};
|
|
294 |
}
|
|
295 |
|
|
296 |
|
|
297 |
sub GetZipFilesForComp {
|
|
298 |
my $self = shift;
|
|
299 |
my $comp = shift;
|
|
300 |
return ($self->{components}{$comp}{zipFiles} || {});
|
|
301 |
}
|
|
302 |
|
|
303 |
sub GetZipStatus {
|
|
304 |
my $self = shift;
|
|
305 |
my $comp = shift;
|
|
306 |
my $zipFile = shift;
|
|
307 |
return $self->{components}{$comp}{zipFiles}{$zipFile}{'status'};
|
|
308 |
}
|
|
309 |
|
|
310 |
sub GetFilesForZip {
|
|
311 |
my $self = shift;
|
|
312 |
my $comp = shift;
|
|
313 |
my $zipFile = shift;
|
|
314 |
return ($self->{components}{$comp}{zipFiles}{$zipFile}{files} || {});
|
|
315 |
}
|
|
316 |
|
|
317 |
sub GetFileStatus {
|
|
318 |
my $self = shift;
|
|
319 |
my $comp = shift;
|
|
320 |
my $zipFile = shift;
|
|
321 |
my $file = shift;
|
|
322 |
$self->{components}{$comp}{zipFiles}{$zipFile}{files}{$file}{status};
|
|
323 |
}
|
|
324 |
|
|
325 |
sub GetFileType {
|
|
326 |
my $self = shift;
|
|
327 |
my $comp = shift;
|
|
328 |
my $zipFile = shift;
|
|
329 |
my $file = shift;
|
|
330 |
return $self->{components}{$comp}{zipFiles}{$zipFile}{files}{$file}{type};
|
|
331 |
}
|
|
332 |
|
|
333 |
sub GetMetaFiles {
|
|
334 |
my $self = shift;
|
|
335 |
my $comp = shift;
|
|
336 |
return ($self->{components}{$comp}{metafiles} || {});
|
|
337 |
}
|
|
338 |
|
|
339 |
1;
|
|
340 |
|
|
341 |
__END__
|
|
342 |
|
|
343 |
=head1 NAME
|
|
344 |
|
|
345 |
Symbian::CBR::DeltaRelease::Manifest.pm - Provides an interface to data associated with a deltas created from reference version to the nominated version.
|
|
346 |
|
|
347 |
=head2 new
|
|
348 |
|
|
349 |
Creates a new Symbian::CBR::Delta::Manifest object.
|
|
350 |
|
|
351 |
=head2 Save
|
|
352 |
|
|
353 |
Expects to be passed a destination path. Creates destination path if destination path is not existing, and save the hash structure to xml file.
|
|
354 |
|
|
355 |
=head2 LoadManifest
|
|
356 |
|
|
357 |
Expects to be passed a manifest file name. Reads delta manifest file and converts into a hash structure.
|
|
358 |
|
|
359 |
=head1 KNOWN BUGS
|
|
360 |
|
|
361 |
None.
|
|
362 |
|
|
363 |
=head1 COPYRIGHT
|
|
364 |
|
|
365 |
Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
366 |
All rights reserved.
|
|
367 |
This component and the accompanying materials are made available
|
|
368 |
under the terms of the License "Eclipse Public License v1.0"
|
|
369 |
which accompanies this distribution, and is available
|
|
370 |
at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
371 |
|
|
372 |
Initial Contributors:
|
|
373 |
Nokia Corporation - initial contribution.
|
|
374 |
|
|
375 |
Contributors:
|
|
376 |
|
|
377 |
Description:
|
|
378 |
|
|
379 |
|
|
380 |
=cut
|