Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add ability to generate packages from prepared earlier xulapp file

  • Loading branch information...
commit c1d36434d2d198b8f4427f7794946038b1f238ae 1 parent 85c065f
@prefiks prefiks authored
View
86 build.pl
@@ -17,18 +17,10 @@
use OneTeam::Utils;
use OneTeam::Builder::Bundle;
-my @files;
my $topdir = getcwd;
my $dir = File::Spec->catdir($topdir, qw(chrome oneteam));
my %defs = @ARGV;
-for ($dir, map File::Spec->catdir($topdir, $_), "defaults", "components") {
- find(sub {
- push @files, $File::Find::name
- if -f and not ignored_file($File::Find::name);
- }, $_);
-}
-
$defs{VERSION} = sub { get_version($topdir) };
$defs{BRANCH} = sub { get_branch($topdir) };
$defs{PREFS} = sub { extract_prefs(sub { $_[0] =~ /^chat\./ and $_[0] !~ /^chat\.connection\.(base|host|port|ssl|overridehost|polling|user|pass)/ },
@@ -56,10 +48,10 @@ sub get_buildid {
my $saver =
exists $defs{DMG} ?
new OneTeam::Builder::Filter::Saver::Dmg($topdir, \&get_version_str, \&get_buildid,
- \%mar_options, $defs{XULRUNNER}) :
+ \%mar_options, $defs{XULRUNNER}, $defs{XULAPP_PATH}) :
exists $defs{TARBZ} ?
new OneTeam::Builder::Filter::Saver::TarBz($topdir, \&get_version_str, \&get_buildid,
- \%mar_options, $defs{XULRUNNER}) :
+ \%mar_options, $defs{XULRUNNER}, $defs{XULAPP_PATH}) :
exists $defs{XULAPP} ?
exists $defs{NOJAR} ?
new OneTeam::Builder::Filter::Saver::XulApp::Flat($topdir, \&get_version_str, \&get_buildid, \%mar_options) :
@@ -69,45 +61,59 @@ sub get_buildid {
$defs{XULAPP} = 1 if exists $defs{XPI} or exists $defs{DMG};
-my $locale_processor =
- new OneTeam::Builder::Filter::LocaleProcessor::XulApp($saver, split /,/, ($defs{LANGS}||""));
+if (not $defs{XULAPP_PATH}) {
+ my $locale_processor =
+ new OneTeam::Builder::Filter::LocaleProcessor::XulApp($saver, split /,/, ($defs{LANGS}||""));
-my @filters = (
- new OneTeam::Builder::Filter::Preprocessor(%defs),
- $locale_processor,
- new OneTeam::Builder::Filter::CommentsStripper(),
- $saver);
+ my @filters = (
+ new OneTeam::Builder::Filter::Preprocessor(%defs),
+ $locale_processor,
+ new OneTeam::Builder::Filter::CommentsStripper(),
+ $saver);
-my @locales = $locale_processor->locales;
+ my @files;
-for my $file (@files) {
- my $content = slurp($file);
+ for ($dir, map File::Spec->catdir($topdir, $_), "defaults", "components") {
+ find(sub {
+ push @files, $File::Find::name
+ if -f and not ignored_file($File::Find::name);
+ }, $_);
+ }
- my $rel_path = File::Spec->abs2rel($file, $dir);
- my $rel_path2 = File::Spec->abs2rel($file, $topdir);
- $rel_path = length($rel_path) > length($rel_path2) ? $rel_path2 :
- "chrome/$rel_path";
+ for my $file (@files) {
+ my $content = slurp($file);
- $content = $_->analyze($content, $rel_path)
- for @filters;
-}
+ my $rel_path = File::Spec->abs2rel($file, $dir);
+ my $rel_path2 = File::Spec->abs2rel($file, $topdir);
+ $rel_path = length($rel_path) > length($rel_path2) ? $rel_path2 :
+ "chrome/$rel_path";
+
+ $content = $_->analyze($content, $rel_path)
+ for @filters;
+ }
+
+ my @locales = $locale_processor->locales;
-for my $file (@files) {
- my %input;
+ for my $file (@files) {
+ my %input;
- @input{@locales} = (slurp($file)) x @locales;
+ @input{@locales} = (slurp($file)) x @locales;
- my $rel_path = File::Spec->abs2rel($file, $dir);
- my $rel_path2 = File::Spec->abs2rel($file, $topdir);
- $rel_path = length($rel_path) > length($rel_path2) ? $rel_path2 :
- "chrome/$rel_path";
+ my $rel_path = File::Spec->abs2rel($file, $dir);
+ my $rel_path2 = File::Spec->abs2rel($file, $topdir);
+ $rel_path = length($rel_path) > length($rel_path2) ? $rel_path2 :
+ "chrome/$rel_path";
- for my $filter (@filters) {
- for my $locale (@locales) {
- $input{$locale} = $filter->process($input{$locale},
- $rel_path, $locale);
+ for my $filter (@filters) {
+ for my $locale (@locales) {
+ $input{$locale} = $filter->process($input{$locale},
+ $rel_path, $locale);
+ }
}
}
-}
-$_->finalize() for @filters;
+ $_->finalize() for @filters;
+
+} else {
+ $saver->finalize();
+}
View
3  tools/perl5lib/OneTeam/Builder/Filter/Saver/Dmg.pm
@@ -11,7 +11,7 @@ use OneTeam::Utils;
use Cwd;
sub new {
- my ($class, $topdir, $version, $buildid, $mar_options, $xulrunner_path) = @_;
+ my ($class, $topdir, $version, $buildid, $mar_options, $xulrunner_path, $xulapp_path) = @_;
die "Please set XULRUNNER parameter" if not $xulrunner_path;
@@ -20,6 +20,7 @@ sub new {
outputdir => tempdir('otXXXXXX', TMPDIR => 1, CLEANUP => 1),
mar_options => $mar_options,
xulrunner_path => $xulrunner_path,
+ xulapp_path => $xulapp_path,
version => $version,
buildid => $buildid,
};
View
8 tools/perl5lib/OneTeam/Builder/Filter/Saver/TarBz.pm
@@ -11,7 +11,7 @@ use OneTeam::Utils;
use Cwd;
sub new {
- my ($class, $topdir, $version, $buildid, $mar_options, $xulrunner_path) = @_;
+ my ($class, $topdir, $version, $buildid, $mar_options, $xulrunner_path, $xulapp_path) = @_;
die "Please set XULRUNNER parameter" if not $xulrunner_path;
@@ -20,6 +20,7 @@ sub new {
outputdir => tempdir('otXXXXXX', TMPDIR => 1, CLEANUP => 1),
mar_options => $mar_options,
xulrunner_path => $xulrunner_path,
+ xulapp_path => $xulapp_path,
version => $version,
buildid => $buildid,
};
@@ -34,8 +35,8 @@ sub new {
sub _make_package {
my ($self, $tmpdir, $tmppfxdir) = @_;
- system("tar -C '$tmpdir' -cjf ".catfile($self->{topdir}, $self->_output_filename).
- " oneteam");
+ system("tar", "-C", $tmpdir, "-cjf",
+ catfile($self->{topdir}, $self->_output_filename), "oneteam");
}
sub _prepare_files {
@@ -65,6 +66,7 @@ sub _platform_files_to_skip {
return ('platform/WINNT_x86-msvc/components/oneteam.dll',
'platform/Darwin_x86-gcc3/components/liboneteam.dylib',
+ 'platform/Darwin_x86_64-gcc3/components/liboneteam.dylib',
grep({ index($_, $self->{abi}) < 0 }
('platform/Linux_x86-gcc3/components/liboneteam.so',
'platform/Linux_x86_64-gcc3/components/liboneteam.so')));
View
30 tools/perl5lib/OneTeam/Builder/Filter/Saver/XPI.pm
@@ -7,6 +7,7 @@ use File::Path;
use File::Find;
use File::Spec::Functions qw(splitpath catfile catpath splitdir catdir);
use File::Copy;
+use File::Basename;
use OneTeam::Utils;
use Cwd;
@@ -46,8 +47,7 @@ sub finalize {
my $tmppfxdir = $self->_prefix ? catdir($tmpdir, $self->_prefix) : $tmpdir;
my $chromedir = catdir($tmppfxdir, "chrome");
- mkpath([$chromedir], 0);
-
+ $self->_prepare_files_for_packing($tmpdir, $tmppfxdir, $chromedir);
$self->_prepare_files($tmpdir, $tmppfxdir, $chromedir);
$self->_generate_install_rdf($tmpdir, $tmppfxdir);
$self->_generate_update_rdf($tmpdir, $tmppfxdir);
@@ -63,9 +63,11 @@ sub _make_package {
system("cd '$tmppfxdir'; zip -q -9 -r '".catfile($self->{topdir}, $self->_output_filename)."' .")
}
-sub _prepare_files {
+sub _prepare_files_for_packing {
my ($self, $tmpdir, $tmppfxdir, $chromedir) = @_;
+ mkpath([$chromedir], 0);
+
my $d = catdir(qw(chrome icons default));
dircopy($d, catdir($self->{outputdir}, qw(skin default icons)),
$d, qw(default.ico default.xpm));
@@ -75,7 +77,21 @@ sub _prepare_files {
dircopy(catdir($self->{outputdir}, "defaults"), catdir($tmppfxdir, 'defaults'),
$self->{outputdir}, $self->_disabled_prefs);
dircopy(catdir($self->{outputdir}, "components"), catdir($tmppfxdir, 'components'));
- dircopy('platform', catdir($tmppfxdir, 'platform'), '', $self->_platform_files_to_skip);
+ dircopy('platform', catdir($tmppfxdir, 'platform'));
+}
+
+sub _prepare_files {
+ my ($self, $tmpdir, $tmppfxdir, $chromedir) = @_;
+
+ for ($self->_platform_files_to_skip) {
+ $_ = catfile($tmppfxdir, $_);
+
+ unlink($_);
+
+ do {
+ $_ = dirname($_);
+ } while (rmdir($_));
+ }
find({ wanted => sub {
my $path = $File::Find::name;
@@ -83,7 +99,7 @@ sub _prepare_files {
$self->{platform_components}->{$2} = $1
if $path =~ m!(?:^|/)(platform/([^/]+)/components/.*)!;
- }, no_chdir => 1}, 'platform');
+ }, no_chdir => 1}, catdir($tmppfxdir, 'platform'));
}
sub _generate_install_rdf {
@@ -178,12 +194,8 @@ sub _generate_components_manifest {
"{d2de57da-be3a-4ec2-86f7-c73049cc70ef}\n";
print $fh "interfaces components/oneteam.xpt\n\n";
- my %skip;
- @skip{$self->_platform_files_to_skip()} = ();
-
for (keys %{$self->{platform_components}}) {
my $path = $self->{platform_components}->{$_};
- next if exists $skip{$path};
print $fh "binary-component $path ABI=$_\n";
}
}
View
43 tools/perl5lib/OneTeam/Builder/Filter/Saver/XulApp.pm
@@ -11,11 +11,12 @@ use OneTeam::Utils;
use Cwd;
sub new {
- my ($class, $topdir, $version, $buildid, $mar_options) = @_;
+ my ($class, $topdir, $version, $buildid, $mar_options, $xulapp_path) = @_;
my $self = {
topdir => $topdir,
outputdir => tempdir('otXXXXXX', TMPDIR => 1, CLEANUP => 1),
mar_options => $mar_options,
+ xulapp_path => $xulapp_path,
version => $version,
buildid => $buildid,
};
@@ -62,17 +63,19 @@ sub _generate_update_rdf {
sub _generate_chrome_manifest {
my ($self, $tmpdir, $tmppfxdir) = @_;
- $self->SUPER::_generate_chrome_manifest($tmppfxdir, $tmppfxdir);
+ if (not $self->{xulapp_path}) {
+ $self->SUPER::_generate_chrome_manifest($tmppfxdir, $tmppfxdir);
- my $prefix = File::Spec->abs2rel("chrome", $self->_chrome_manifest_dir);
- $prefix = $prefix eq "." ? "" : "$prefix/";
+ my $prefix = File::Spec->abs2rel("chrome", $self->_chrome_manifest_dir);
+ $prefix = $prefix eq "." ? "" : "$prefix/";
- open($fh, ">>", catfile($tmppfxdir, $self->_chrome_manifest_dir, 'chrome.manifest')) or
- die "Unable to create file: $!";
+ open($fh, ">>", catfile($tmppfxdir, $self->_chrome_manifest_dir, 'chrome.manifest')) or
+ die "Unable to create file: $!";
- print $fh "locale branding en-US jar:oneteam.jar!/locale/branding/\n";
+ print $fh "locale branding en-US jar:oneteam.jar!/locale/branding/\n";
- close $fh;
+ close $fh;
+ }
open($fh, ">>", catfile($tmppfxdir, 'chrome.manifest')) or
die "Unable to create file: $!";
@@ -83,6 +86,30 @@ sub _generate_chrome_manifest {
close ($fh);
}
+sub _prepare_files_for_packing {
+ my ($self, $tmpdir, $tmppfxdir, $chromedir) = @_;
+
+ if ($self->{xulapp_path}) {
+ mkpath([$tmppfxdir], 0);
+ system("unzip", "-q", $self->{xulapp_path}, "-d", $tmppfxdir);
+
+ unlink(catfile($tmppfxdir, "chrome.manifest"));
+
+ my $appinfo = slurp(catfile($tmppfxdir, "application.ini"));
+
+ $appinfo =~ /Version\s*=\s*(\S+)/i;
+ my $version = $1;
+
+ $appinfo =~ /BuildID\s*=\s*(\S+)/i;
+ my $buildid = $1;
+
+ $self->{version} = sub { return $version };
+ $self->{buildid} = sub { return $buildid };
+ } else {
+ $self->SUPER::_prepare_files_for_packing($tmppfxdir, $tmppfxdir, $chromedir);
+ }
+}
+
sub _prepare_files {
my ($self, $tmpdir, $tmppfxdir, $chromedir) = @_;
Please sign in to comment.
Something went wrong with that request. Please try again.