author | Dario Sestito <darios@symbian.org> |
Thu, 10 Jun 2010 11:06:18 +0100 | |
changeset 256 | 578dff671e26 |
parent 162 | 4a47f1403d9b |
permissions | -rw-r--r-- |
162
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
1 |
#!/usr/bin/perl |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
2 |
|
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
3 |
# Copyright (c) 2009 Symbian Foundation Ltd |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
4 |
# This component and the accompanying materials are made available |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
5 |
# under the terms of the License "Eclipse Public License v1.0" |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
6 |
# which accompanies this distribution, and is available |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
8 |
# |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
9 |
# Initial Contributors: |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
10 |
# Symbian Foundation Ltd - initial contribution. |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
11 |
# |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
12 |
# Contributors: |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
13 |
# |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
14 |
# Description: |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
15 |
# Update sources.csv files in a subtree of interim/fbf/projects/packages, |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
16 |
# based on a sources.csv file from the corresponding interim/fbf/projects/platforms |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
17 |
# definition. Will use "hg remove" to get rid of dirs for obsolete packages |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
18 |
# |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
19 |
# Stand in the root of the tree in packages, e.g. Symbian3, and run this script |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
20 |
# supplying the single model sources.csv file as input, e.g. |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
21 |
# platforms/Symbian3/single/sources_fcl.csv |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
22 |
|
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
23 |
use strict; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
24 |
|
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
25 |
my $headerline = <>; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
26 |
my $line; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
27 |
|
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
28 |
my %dirs; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
29 |
while ($line =<>) |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
30 |
{ |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
31 |
if ($line =~ /\/(oss|sfl)\/(MCL|FCL)\/sf\/([^,]+)\/,/) |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
32 |
{ |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
33 |
my $license = $1; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
34 |
my $codeline = $2; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
35 |
my $path = $3; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
36 |
|
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
37 |
$dirs{$path} = $line; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
38 |
next; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
39 |
} |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
40 |
} |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
41 |
|
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
42 |
sub update_csv_file($) |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
43 |
{ |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
44 |
my ($path) = @_; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
45 |
open FILE, "<$path/sources.csv"; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
46 |
my @lines = <FILE>; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
47 |
close FILE; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
48 |
|
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
49 |
# replace the existing lines with ones from the main sources.csv |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
50 |
my @newlines; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
51 |
foreach my $line (@lines) |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
52 |
{ |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
53 |
if ($line =~ /\/(oss|sfl)\/(MCL|FCL)\/sf\/([^,]+)\/,/) |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
54 |
{ |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
55 |
my $license = $1; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
56 |
my $codeline = $2; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
57 |
my $package = $3; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
58 |
|
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
59 |
push @newlines, $dirs{$package}; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
60 |
next; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
61 |
} |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
62 |
push @newlines, $line; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
63 |
} |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
64 |
|
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
65 |
open FILE, ">$path/sources.csv"; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
66 |
print FILE @newlines; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
67 |
close FILE; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
68 |
} |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
69 |
|
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
70 |
my %found_dirs; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
71 |
my @listing = `dir /s/b sources.csv`; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
72 |
foreach $line (@listing) |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
73 |
{ |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
74 |
# G:\system_model\packages\CompilerCompatibility\app\commonemail\sources.csv |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
75 |
if ($line =~ /\\([^\\]+)\\([^\\]+)\\sources.csv/) |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
76 |
{ |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
77 |
my $layer = $1; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
78 |
my $package = $2; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
79 |
my $path = "$layer/$package"; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
80 |
|
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
81 |
if (defined $dirs{$path}) |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
82 |
{ |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
83 |
if (!-e "$path/package_definition.xml") |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
84 |
{ |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
85 |
print "$path needs a package_definition.xml file\n"; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
86 |
} |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
87 |
update_csv_file($path); |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
88 |
$found_dirs{$path} = 1; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
89 |
next; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
90 |
} |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
91 |
else |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
92 |
{ |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
93 |
system("hg", "remove", "$layer//$package"); |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
94 |
} |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
95 |
} |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
96 |
} |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
97 |
|
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
98 |
foreach my $path (sort keys %dirs) |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
99 |
{ |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
100 |
next if $found_dirs{$path}; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
101 |
|
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
102 |
mkdir $path; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
103 |
open FILE, ">$path/sources.csv"; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
104 |
print FILE $headerline, $dirs{$path}; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
105 |
close FILE; |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
106 |
system("hg", "add", "$path/sources.csv"); |
4a47f1403d9b
check_sources_csv.pl - utility for updating the sources.csv files in fbf/projects/packages trees
William Roberts <williamr@symbian.org>
parents:
diff
changeset
|
107 |
} |