author | Shabe Razvi <shaber@symbian.org> |
Mon, 18 May 2009 11:39:37 +0100 | |
changeset 98 | aa585d28e584 |
parent 94 | 5e9bdb9269c7 |
child 102 | c2478fad90aa |
permissions | -rw-r--r-- |
73
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
1 |
use strict; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
2 |
use warnings; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
3 |
|
89
a8aa5d600806
Copy Text::CSV module into source and change to use it, as we can't rely on it appearing in the Perl library when Perl 5.6.1 is installed.
Simon Howkins <simonh@symbian.org>
parents:
88
diff
changeset
|
4 |
use FindBin; |
a8aa5d600806
Copy Text::CSV module into source and change to use it, as we can't rely on it appearing in the Perl library when Perl 5.6.1 is installed.
Simon Howkins <simonh@symbian.org>
parents:
88
diff
changeset
|
5 |
use lib "$FindBin::Bin/lib"; |
73
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
6 |
use Text::CSV; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
7 |
require XML::Simple; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
8 |
|
84
fcf94a72b33e
Improved zip template generation script, to take a third argument for the required location of the output file.
Simon Howkins <simonh@symbian.org>
parents:
76
diff
changeset
|
9 |
# Raw inputs come in as parameters to the script |
fcf94a72b33e
Improved zip template generation script, to take a third argument for the required location of the output file.
Simon Howkins <simonh@symbian.org>
parents:
76
diff
changeset
|
10 |
# TODO: Use a proper option parsing module |
73
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
11 |
my $sourcesCSV = shift or die "First arg must be source csv file"; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
12 |
my $template = shift or die "Second arg must be template file"; |
84
fcf94a72b33e
Improved zip template generation script, to take a third argument for the required location of the output file.
Simon Howkins <simonh@symbian.org>
parents:
76
diff
changeset
|
13 |
my $ftl = shift or die "Third arg must be output file"; |
fcf94a72b33e
Improved zip template generation script, to take a third argument for the required location of the output file.
Simon Howkins <simonh@symbian.org>
parents:
76
diff
changeset
|
14 |
shift and die "No more than three arguments please"; |
73
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
15 |
|
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
16 |
# Load CSV |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
17 |
open my $csvText, "<", $sourcesCSV or die; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
18 |
my $csv = Text::CSV->new(); |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
19 |
my @keys; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
20 |
my @packages; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
21 |
while (my $line = <$csvText>) |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
22 |
{ |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
23 |
chomp $line; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
24 |
next unless $line; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
25 |
unless ($csv->parse($line)) |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
26 |
{ |
89
a8aa5d600806
Copy Text::CSV module into source and change to use it, as we can't rely on it appearing in the Perl library when Perl 5.6.1 is installed.
Simon Howkins <simonh@symbian.org>
parents:
88
diff
changeset
|
27 |
my $err = $csv->error_input(); |
73
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
28 |
die "Failed to parse line '$line': $err"; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
29 |
} |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
30 |
|
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
31 |
if (! @keys) |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
32 |
{ |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
33 |
# First line - note the column names |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
34 |
@keys = $csv->fields(); |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
35 |
} |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
36 |
else |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
37 |
{ |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
38 |
# Already got the keys, so get the data |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
39 |
my %package; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
40 |
# Read into a hash slice |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
41 |
@package{@keys} = $csv->fields(); |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
42 |
push @packages, \%package; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
43 |
} |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
44 |
} |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
45 |
close $csvText; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
46 |
|
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
47 |
# This controls how the XML parsing decides what should be tags and what should be attributes |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
48 |
# It's been worked out mostly by trial and error :-( |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
49 |
my $keyAttr = { config => "name", name => "set"}; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
50 |
# Load template |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
51 |
my $xml = XML::Simple->new(); |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
52 |
my $zipConfig = $xml->XMLin($template, KeyAttr => $keyAttr); |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
53 |
my @allRndFiles; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
54 |
|
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
55 |
# For each package in CSV... |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
56 |
foreach my $package (@packages) |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
57 |
{ |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
58 |
warn "Warning: Package $package->{dst} does not appear on the local system\n" unless -d $package->{dst}; |
76
a115d49b621f
Include epl/sfl category in zipfile name
Shabe Razvi <shaber@symbian.org>
parents:
73
diff
changeset
|
59 |
$package->{dst} =~ s{^/}{}g; |
94
5e9bdb9269c7
Modified populateziptemplate.pl to use "oss" instead of "epl" keyword.
ThomasE@UK-ThomasE.symbian.int
parents:
90
diff
changeset
|
60 |
if ($package->{source} =~ m{/(sfl|oss)/sf/([^/]+)/([^/]+)}) |
76
a115d49b621f
Include epl/sfl category in zipfile name
Shabe Razvi <shaber@symbian.org>
parents:
73
diff
changeset
|
61 |
{ |
73
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
62 |
push @{$zipConfig->{config}->{config}->{src}->{config}->{$1}->{config}}, |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
63 |
{ |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
64 |
set => |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
65 |
[ |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
66 |
{ |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
67 |
name => "name", |
76
a115d49b621f
Include epl/sfl category in zipfile name
Shabe Razvi <shaber@symbian.org>
parents:
73
diff
changeset
|
68 |
value=> "src_$1_$2_$3", |
73
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
69 |
}, |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
70 |
{ |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
71 |
name => "include", |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
72 |
value => "$package->{dst}/**", |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
73 |
}, |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
74 |
] |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
75 |
}; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
76 |
} |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
77 |
elsif ($package->{source} =~ m{/rnd/([^/]+)/([^/]+)}) |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
78 |
{ |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
79 |
# RnD repository |
76
a115d49b621f
Include epl/sfl category in zipfile name
Shabe Razvi <shaber@symbian.org>
parents:
73
diff
changeset
|
80 |
my $name = "bin_rnd_$1_$2"; |
73
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
81 |
# Create a zip object |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
82 |
push @{$zipConfig->{config}->{config}->{src}->{config}->{rnd}->{config}}, |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
83 |
{ |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
84 |
set => |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
85 |
[ |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
86 |
{ |
88
28463bb10fde
Package RnD binaries from rnd root location to reduce size of include list
Shabe Razvi <shaber@symbian.org>
parents:
84
diff
changeset
|
87 |
name => "root.dir", |
28463bb10fde
Package RnD binaries from rnd root location to reduce size of include list
Shabe Razvi <shaber@symbian.org>
parents:
84
diff
changeset
|
88 |
value=> "\${build.drive}/$package->{dst}", |
28463bb10fde
Package RnD binaries from rnd root location to reduce size of include list
Shabe Razvi <shaber@symbian.org>
parents:
84
diff
changeset
|
89 |
}, |
28463bb10fde
Package RnD binaries from rnd root location to reduce size of include list
Shabe Razvi <shaber@symbian.org>
parents:
84
diff
changeset
|
90 |
{ |
73
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
91 |
name => "name", |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
92 |
value=> "$name", |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
93 |
}, |
88
28463bb10fde
Package RnD binaries from rnd root location to reduce size of include list
Shabe Razvi <shaber@symbian.org>
parents:
84
diff
changeset
|
94 |
{ |
28463bb10fde
Package RnD binaries from rnd root location to reduce size of include list
Shabe Razvi <shaber@symbian.org>
parents:
84
diff
changeset
|
95 |
name => "include", |
28463bb10fde
Package RnD binaries from rnd root location to reduce size of include list
Shabe Razvi <shaber@symbian.org>
parents:
84
diff
changeset
|
96 |
value=> "/**", |
28463bb10fde
Package RnD binaries from rnd root location to reduce size of include list
Shabe Razvi <shaber@symbian.org>
parents:
84
diff
changeset
|
97 |
}, |
73
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
98 |
] |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
99 |
}; |
90
5b27412eeaf0
Removed obsolete variable (@includes).
Simon Howkins <simonh@symbian.org>
parents:
89
diff
changeset
|
100 |
# Enumerate all the files on the local disk that are in this repository |
5b27412eeaf0
Removed obsolete variable (@includes).
Simon Howkins <simonh@symbian.org>
parents:
89
diff
changeset
|
101 |
(my $dosCompatibleDst = $package->{dst}) =~ s{/}{\\}g; |
5b27412eeaf0
Removed obsolete variable (@includes).
Simon Howkins <simonh@symbian.org>
parents:
89
diff
changeset
|
102 |
my @files = `dir /b/s/a-d $dosCompatibleDst 2> nul:`; |
5b27412eeaf0
Removed obsolete variable (@includes).
Simon Howkins <simonh@symbian.org>
parents:
89
diff
changeset
|
103 |
#print "@files\n"; |
5b27412eeaf0
Removed obsolete variable (@includes).
Simon Howkins <simonh@symbian.org>
parents:
89
diff
changeset
|
104 |
next unless @files; |
5b27412eeaf0
Removed obsolete variable (@includes).
Simon Howkins <simonh@symbian.org>
parents:
89
diff
changeset
|
105 |
# Add the files to this zip object |
5b27412eeaf0
Removed obsolete variable (@includes).
Simon Howkins <simonh@symbian.org>
parents:
89
diff
changeset
|
106 |
@files = grep { |
5b27412eeaf0
Removed obsolete variable (@includes).
Simon Howkins <simonh@symbian.org>
parents:
89
diff
changeset
|
107 |
chomp; |
5b27412eeaf0
Removed obsolete variable (@includes).
Simon Howkins <simonh@symbian.org>
parents:
89
diff
changeset
|
108 |
s{\\}{/}g; |
5b27412eeaf0
Removed obsolete variable (@includes).
Simon Howkins <simonh@symbian.org>
parents:
89
diff
changeset
|
109 |
s!^[A-Z]:/$package->{dst}/!!i; |
5b27412eeaf0
Removed obsolete variable (@includes).
Simon Howkins <simonh@symbian.org>
parents:
89
diff
changeset
|
110 |
m{^epoc32/}i; |
5b27412eeaf0
Removed obsolete variable (@includes).
Simon Howkins <simonh@symbian.org>
parents:
89
diff
changeset
|
111 |
} @files; |
5b27412eeaf0
Removed obsolete variable (@includes).
Simon Howkins <simonh@symbian.org>
parents:
89
diff
changeset
|
112 |
push @allRndFiles, @files; |
73
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
113 |
} |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
114 |
else |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
115 |
{ |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
116 |
die "Cannot determine license for '$package->{source}'"; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
117 |
} |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
118 |
} |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
119 |
|
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
120 |
# Turn the RnD source inclusion lists into a binary exclusion list |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
121 |
my @excludes = map { {name => "exclude", value => "$_"} } @allRndFiles; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
122 |
push @{$zipConfig->{config}->{config}->{bin}->{config}->{set}}, @excludes; |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
123 |
|
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
124 |
$xml->XMLout($zipConfig, OutputFile => $ftl, XMLDecl => 1, RootName => 'build', KeyAttr => $keyAttr); |
b8d6af733d6d
Add first cut of packaging solution
Shabe Razvi <shaber@symbian.org>
parents:
diff
changeset
|
125 |