2 package GenerateManifest
;
10 use vars
qw(@ISA @EXPORT);
12 # Package that generates a jar manifest from an input file
19 my(%embed_files) = ();
22 sub GenerateManifest
($$$$$$$$) {
23 my($moz, $manifest, $chrome, $locale, $platform, $out_desc, $dir_sep, $verbose) = @_;
24 local(*OUTDESC
) = $out_desc;
26 parse_input_manifest
($moz, $manifest, $chrome, $locale, $verbose);
27 dump_output_manifest
($moz, $manifest, $chrome, $locale, $platform, *OUTDESC
, $dir_sep, $verbose);
31 sub parse_input_manifest
($$$$$) {
32 my($moz, $manifest, $chrome, $locale, $verbose) = @_;
34 print STDERR
"Parsing \"$manifest\"\n" unless !$verbose;
37 open(MANIFEST
, "<$manifest") or die ("Error: Cannot open manifest \"$manifest\".\n");
43 # Skip comments & blank lines
48 my($key, $value) = split(/,/, $_);
50 # Strip out any remaining whitespace from key & value
58 $embed_files{$key} = $value;
63 sub dump_output_manifest
($$$$$$$$) {
64 my($moz, $manifest, $chrome, $locale, $platform, $out_desc, $dir_sep, $verbose) = @_;
65 local(*OUTDESC
) = $out_desc;
67 print OUTDESC
"embed.jar:\n";
68 while (my($key, $value) = each %embed_files) {
70 $key =~ s/XXXX/$locale/g;
71 $value =~ s/XXXX/$locale/g;
72 $key =~ s/YYYY/$platform/g;
73 $value =~ s/YYYY/$platform/g;
74 if ( $dir_sep ne "/" ) { # swap / for $dir_sep
75 $value =~ s/\//$dir_sep/g
;
78 # Run ls on the dir/file to ensure it's there and to get a file list back
79 my($ls_path) = "$chrome$dir_sep$value";
80 my($is_dir) = (-d
$ls_path) ?
1 : 0;
81 my($is_file) = (-f
$ls_path) ?
1 : 0;
83 print STDERR
"Listing \"$ls_path\"\n" unless !$verbose;
85 if (!$is_dir && !$is_file) {
86 print STDERR
"Warning: File or directory \"$ls_path\" does not exist.\n";
90 # this code previously used |ls -1| to get a dir listing, but that
91 # doesn't work in MacPerl. Instead just use opendir() to get the
92 # file list (if it's a directory), or add the single file to our list
93 # if it's called out individually in the manifest.
96 @dirList = ($ls_path);
99 opendir(CHROMEDIR
, $ls_path);
100 @dirList = readdir(CHROMEDIR
);
104 my($chrome_file) = "";
108 $chrome_file = "$key$dir_sep$_";
109 $real_file = "$value$dir_sep$_";
115 # Ignore directories which are returned by ls
116 if (! -d
"$chrome$dir_sep$real_file") {
117 # before we put the file into the manifest, make sure it
118 # uses '/' as the separator. That's what manifest files expect.
119 $real_file =~ s/$dir_sep/\//g
;
120 $chrome_file =~ s/$dir_sep/\//g
;
121 print OUTDESC
" $chrome_file ($real_file)\n";