-
Notifications
You must be signed in to change notification settings - Fork 109
/
make_babelzilla_build.pl
executable file
·70 lines (52 loc) · 1.69 KB
/
make_babelzilla_build.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/perl
#############################################################################
# This script will create a special development build meant only for upload #
# to Babelzilla. #
#############################################################################
use strict;
use warnings;
use lib qw(. ..);
use Packager;
sub Packager::fixLocales() {}
my $manifest = readFile("chrome.manifest");
unless ($manifest =~ /\bjar:chrome\/(\S+?)\.jar\b/)
{
die "Could not find JAR file name in chrome.manifest";
}
my $baseName = $1;
my %params = ();
$params{version} = shift @ARGV;
die "Please specify version number on command line" unless $params{version};
my $xpiFile = "$baseName-$params{version}.xpi";
my $pkg = Packager->new(\%params);
$pkg->readLocales('chrome/locale', 1);
chdir('chrome');
$pkg->makeJAR("$baseName.jar", 'content', 'skin', 'locale', '-/tests', '-/mochitest', '-/.incomplete');
chdir('..');
my @files = grep {-e $_} ('components', 'defaults', 'install.rdf', 'chrome.manifest', 'icon.png');
my $targetAppNum = 0;
$pkg->{postprocess_line} = \&postprocessInstallRDF;
$pkg->makeXPI($xpiFile, "chrome/$baseName.jar", @files);
unlink("chrome/$baseName.jar");
sub postprocessInstallRDF
{
my ($file, $line) = @_;
return $line unless $file eq "install.rdf";
if ($line =~ /\btargetApplication\b/)
{
$targetAppNum++;
return "" if $targetAppNum > 6;
}
return "" if $targetAppNum > 6 && $targetAppNum % 2 == 1;
return $line;
}
sub readFile
{
my $file = shift;
open(local *FILE, "<", $file) || die "Could not read file '$file'";
binmode(FILE);
local $/;
my $result = <FILE>;
close(FILE);
return $result;
}