tools/packages_in_rom.pl
author William Roberts <williamr@symbian.org>
Sat, 09 Oct 2010 15:54:10 +0100
changeset 7 58366ddcbc93
parent 6 d48e90a0206b
child 11 9fac6902f40b
permissions -rw-r--r--
Further tweaks to buildrom.pm, and updated originals after re-running imaker
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;
6
d48e90a0206b Update packages_in_rom.pl to clean up the data and generate the rom_content.csv file, adding a "package" column
William Roberts <williamr@symbian.org>
parents: 5
diff changeset
    20
my %ibyfiles;
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
    21
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
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
    23
	{
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
	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
    25
	
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
  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
    27
  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
    28
  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
    29
  	{
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
  	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
    31
  	
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
  	chomp $line;
6
d48e90a0206b Update packages_in_rom.pl to clean up the data and generate the rom_content.csv file, adding a "package" column
William Roberts <williamr@symbian.org>
parents: 5
diff changeset
    33
  	my ($romdest,$srcfile,$ibyfile) = split /\t/,$line;
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
    34
  	$romdest =~ s/\s*$//;		# strip off trailing spaces
6
d48e90a0206b Update packages_in_rom.pl to clean up the data and generate the rom_content.csv file, adding a "package" column
William Roberts <williamr@symbian.org>
parents: 5
diff changeset
    35
  	$romdest =~ s/\//\\/g; 	# convert to EPOC directory separators
d48e90a0206b Update packages_in_rom.pl to clean up the data and generate the rom_content.csv file, adding a "package" column
William Roberts <williamr@symbian.org>
parents: 5
diff changeset
    36
  	
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
    37
    $srcfile =~ s/\\/\//g;	# Unix directory separators please
6
d48e90a0206b Update packages_in_rom.pl to clean up the data and generate the rom_content.csv file, adding a "package" column
William Roberts <williamr@symbian.org>
parents: 5
diff changeset
    38
    $srcfile =~ s/^"(.*)"$/$1/; 	# Remove quotes
d48e90a0206b Update packages_in_rom.pl to clean up the data and generate the rom_content.csv file, adding a "package" column
William Roberts <williamr@symbian.org>
parents: 5
diff changeset
    39
    $srcfile =~ s/\/\//\//g; 	# Convert // to /
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
    40
    $srcfile =~ s/^\[0x[0-9a-fA-F]+\]//;	# remove HVID, if present
6
d48e90a0206b Update packages_in_rom.pl to clean up the data and generate the rom_content.csv file, adding a "package" column
William Roberts <williamr@symbian.org>
parents: 5
diff changeset
    41
    $srcfile =~ s/mbm_rom$/mbm/i; 	# use original name of derived file
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
    42
    $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
    43
    
6
d48e90a0206b Update packages_in_rom.pl to clean up the data and generate the rom_content.csv file, adding a "package" column
William Roberts <williamr@symbian.org>
parents: 5
diff changeset
    44
    $ibyfile =~ s/\\/\//g;	# Unix directory separators please
d48e90a0206b Update packages_in_rom.pl to clean up the data and generate the rom_content.csv file, adding a "package" column
William Roberts <williamr@symbian.org>
parents: 5
diff changeset
    45
    $ibyfile =~ s/^.*\/rom\/include\///; 	# normalise path to rom\include
d48e90a0206b Update packages_in_rom.pl to clean up the data and generate the rom_content.csv file, adding a "package" column
William Roberts <williamr@symbian.org>
parents: 5
diff changeset
    46
    
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
    47
  	$romfiles{$srcfile} = $romdest;
6
d48e90a0206b Update packages_in_rom.pl to clean up the data and generate the rom_content.csv file, adding a "package" column
William Roberts <williamr@symbian.org>
parents: 5
diff changeset
    48
  	$ibyfiles{$romdest} = $ibyfile;
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
    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
	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
    51
	}
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
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
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
    54
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
    55
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
    56
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
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
    58
  {
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
  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
    60
  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
    61
  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
    62
  $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
    63
  $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
    64
  
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
  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
    66
  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
    67
  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
    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
    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
    70
    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
    71
    
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
    $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
    73
    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
    74
    	{
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
    	$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
    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
    }
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
  }
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
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
    81
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
    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
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
    84
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
    85
  {
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
  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
    87
  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
    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
    $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
    90
    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
    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
  }
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
6
d48e90a0206b Update packages_in_rom.pl to clean up the data and generate the rom_content.csv file, adding a "package" column
William Roberts <williamr@symbian.org>
parents: 5
diff changeset
    94
print "ROM file,Host file,Iby file,Package,In/Out,Who,Why\n";
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
    95
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
    96
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
    97
	{
6
d48e90a0206b Update packages_in_rom.pl to clean up the data and generate the rom_content.csv file, adding a "package" column
William Roberts <williamr@symbian.org>
parents: 5
diff changeset
    98
	my $romfile = $romfiles{$file};
d48e90a0206b Update packages_in_rom.pl to clean up the data and generate the rom_content.csv file, adding a "package" column
William Roberts <williamr@symbian.org>
parents: 5
diff changeset
    99
	my $ibyfile = $ibyfiles{$romfile};
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
   100
	my $package = $package_by_romfile{$file};
6
d48e90a0206b Update packages_in_rom.pl to clean up the data and generate the rom_content.csv file, adding a "package" column
William Roberts <williamr@symbian.org>
parents: 5
diff changeset
   101
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
   102
	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
   103
		{
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
   104
		$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
   105
		$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
   106
		$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
   107
		}
6
d48e90a0206b Update packages_in_rom.pl to clean up the data and generate the rom_content.csv file, adding a "package" column
William Roberts <williamr@symbian.org>
parents: 5
diff changeset
   108
	print join(",", $romfile, $file, $ibyfile, $package, "","",""), "\n";
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
   109
	}
6
d48e90a0206b Update packages_in_rom.pl to clean up the data and generate the rom_content.csv file, adding a "package" column
William Roberts <williamr@symbian.org>
parents: 5
diff changeset
   110
printf STDERR "\n%d files in %s, %d unknowns\n", scalar keys %romfiles, $romlisting, $unknowns;