|
1 # Copyright (c) 2010 Symbian Foundation Ltd. |
|
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 # Symbian Foundation - initial contribution. |
|
10 # |
|
11 # Contributors: |
|
12 # |
|
13 # Description: |
|
14 # This package is to identify the packages which contributed to a ROM image |
|
15 # dir /s/b build_info\logs\releaseables\*.tsv | perl packages_in_rom.pl romfile.dir - |
|
16 |
|
17 use strict; |
|
18 |
|
19 my %romfiles; |
|
20 |
|
21 sub scan_rom_dir_file($) |
|
22 { |
|
23 my ($romdirfile) = @_; |
|
24 |
|
25 my $line; |
|
26 open FILE, "<$romdirfile" or print "Failed to read $romdirfile: $!\n" and return; |
|
27 while ($line = <FILE>) |
|
28 { |
|
29 next if ($line !~ /\t/); |
|
30 |
|
31 chomp $line; |
|
32 my ($romdest,$srcfile) = split /\t/,$line; |
|
33 $romdest =~ s/\s*$//; # strip off trailing spaces |
|
34 $srcfile =~ s/\\/\//g; # Unix directory separators please |
|
35 |
|
36 $srcfile =~ s/^\[0x[0-9a-fA-F]+\]//; # remove HVID, if present |
|
37 $srcfile = lc $srcfile; # sigh... |
|
38 |
|
39 $romfiles{$srcfile} = $romdest; |
|
40 } |
|
41 close FILE; |
|
42 } |
|
43 |
|
44 my %packages; |
|
45 my %packagenames; |
|
46 my %package_by_romfile; |
|
47 |
|
48 sub scan_tsv($) |
|
49 { |
|
50 my ($tsvfile) = @_; |
|
51 return if ($tsvfile !~ /\/(([^\/]+)\/([^\/]+))\/info.tsv$/i); |
|
52 my $packagename = $1; |
|
53 $packagename =~ s/\\/\//g; |
|
54 $packagenames{$packagename} = 1; |
|
55 |
|
56 my $line; |
|
57 open FILE, "<$tsvfile" or print "Failed to read $tsvfile: $!\n" and return; |
|
58 while ($line = <FILE>) |
|
59 { |
|
60 chomp $line; |
|
61 my ($filename,$type,$config) = split /\t/,$line; |
|
62 |
|
63 $filename = lc $filename; # sigh... |
|
64 if (defined $romfiles{$filename}) |
|
65 { |
|
66 $package_by_romfile{$filename} = $packagename; |
|
67 } |
|
68 } |
|
69 } |
|
70 |
|
71 my $romlisting = shift @ARGV; |
|
72 scan_rom_dir_file($romlisting); |
|
73 |
|
74 my $tsvfile; |
|
75 while ($tsvfile = <>) |
|
76 { |
|
77 chomp $tsvfile; |
|
78 if ($tsvfile =~ /info.tsv$/) |
|
79 { |
|
80 $tsvfile =~ s/\\/\//g; |
|
81 scan_tsv($tsvfile); |
|
82 } |
|
83 } |
|
84 |
|
85 print "File\tPackage\n"; |
|
86 my $unknowns = 0; |
|
87 foreach my $file (sort keys %romfiles) |
|
88 { |
|
89 my $package = $package_by_romfile{$file}; |
|
90 if (!defined $package) |
|
91 { |
|
92 $package = "(unknown)"; |
|
93 $package_by_romfile{$file} = $package; |
|
94 $unknowns += 1; |
|
95 } |
|
96 printf "%s\t%s\n", $file, $package; |
|
97 } |
|
98 printf "\n%d files in %s, %d unknowns\n", scalar keys %romfiles, $romlisting, $unknowns; |