tools/packages_in_rom.pl
author William Roberts <williamr@symbian.org>
Fri, 08 Oct 2010 18:10:20 +0100
changeset 5 c42508d52961
child 6 d48e90a0206b
permissions -rw-r--r--
Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
     1
# Copyright (c) 2010 Symbian Foundation Ltd.
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
     2
# All rights reserved.
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
     3
# This component and the accompanying materials are made available
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
     5
# which accompanies this distribution, and is available
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
     7
#
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
     8
# Initial Contributors:
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
     9
# Symbian Foundation - initial contribution.
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    10
#
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    11
# Contributors:
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    12
#
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    13
# Description: 
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    14
# This package is to identify the packages which contributed to a ROM image
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    15
# dir /s/b build_info\logs\releaseables\*.tsv | perl packages_in_rom.pl romfile.dir -
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    16
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    17
use strict;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    18
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    19
my %romfiles;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    20
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    21
sub scan_rom_dir_file($)
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    22
	{
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    23
	my ($romdirfile) = @_;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    24
	
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    25
  my $line;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    26
  open FILE, "<$romdirfile" or print "Failed to read $romdirfile: $!\n" and return;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    27
  while ($line = <FILE>)
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    28
  	{
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    29
  	next if ($line !~ /\t/);
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    30
  	
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    31
  	chomp $line;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    32
  	my ($romdest,$srcfile) = split /\t/,$line;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    33
  	$romdest =~ s/\s*$//;		# strip off trailing spaces
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    34
    $srcfile =~ s/\\/\//g;	# Unix directory separators please
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    35
    
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    36
    $srcfile =~ s/^\[0x[0-9a-fA-F]+\]//;	# remove HVID, if present
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    37
    $srcfile = lc $srcfile; 	# sigh...
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    38
    
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    39
  	$romfiles{$srcfile} = $romdest;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    40
		}
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    41
	close FILE;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    42
	}
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    43
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    44
my %packages;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    45
my %packagenames;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    46
my %package_by_romfile;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    47
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    48
sub scan_tsv($)
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    49
  {
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    50
  my ($tsvfile) = @_;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    51
  return if ($tsvfile !~ /\/(([^\/]+)\/([^\/]+))\/info.tsv$/i);
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    52
  my $packagename = $1;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    53
  $packagename =~ s/\\/\//g;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    54
  $packagenames{$packagename} = 1;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    55
  
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    56
  my $line;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    57
  open FILE, "<$tsvfile" or print "Failed to read $tsvfile: $!\n" and return;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    58
  while ($line = <FILE>)
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    59
    {
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    60
    chomp $line;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    61
    my ($filename,$type,$config) = split /\t/,$line;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    62
    
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    63
    $filename = lc $filename;		# sigh...
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    64
    if (defined $romfiles{$filename})
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    65
    	{
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    66
    	$package_by_romfile{$filename} = $packagename;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    67
    	}
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    68
    }
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    69
  }
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    70
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    71
my $romlisting = shift @ARGV;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    72
scan_rom_dir_file($romlisting);
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    73
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    74
my $tsvfile;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    75
while ($tsvfile = <>)
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    76
  {
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    77
  chomp $tsvfile;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    78
  if ($tsvfile =~ /info.tsv$/)
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    79
    {
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    80
    $tsvfile =~ s/\\/\//g;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    81
    scan_tsv($tsvfile);
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    82
    }
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    83
  }
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    84
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    85
print "File\tPackage\n";
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    86
my $unknowns = 0;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    87
foreach my $file (sort keys %romfiles)
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    88
	{
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    89
	my $package = $package_by_romfile{$file};
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    90
	if (!defined $package)
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    91
		{
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    92
		$package = "(unknown)";
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    93
		$package_by_romfile{$file} = $package;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    94
		$unknowns += 1;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    95
		}
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    96
	printf "%s\t%s\n", $file, $package;
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    97
	}
c42508d52961 Add perl script to identify the packages which provide files in a ROM, and generate original\syborg_content_by_package.txt
William Roberts <williamr@symbian.org>
parents:
diff changeset
    98
printf "\n%d files in %s, %d unknowns\n", scalar keys %romfiles, $romlisting, $unknowns;