[Pkg-mozext-commits] [adblock-plus] 58/464: Added support for localized data in install.rdf, info is taken from meta.properties in locale directory. Also added make_babelzilla_build.pl to buildtools repository.
David Prévot
taffit at moszumanska.debian.org
Tue Jul 22 20:44:02 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus.
commit d09c00e98f2b016dc3132086cd89f825324a3e2f
Author: Wladimir Palant <trev at adblockplus.org>
Date: Wed Jan 6 10:57:10 2010 +0100
Added support for localized data in install.rdf, info is taken from meta.properties in locale directory. Also added make_babelzilla_build.pl to buildtools repository.
---
Packager.pm | 58 +++++++++++++++++++++++++++++++
create_xpi.pl | 3 +-
create_xpi.pl => make_babelzilla_build.pl | 39 +++++++++++----------
setupTestEnvironment.pl | 20 ++++++-----
4 files changed, 92 insertions(+), 28 deletions(-)
diff --git a/Packager.pm b/Packager.pm
index 9be7c66..74702c1 100644
--- a/Packager.pm
+++ b/Packager.pm
@@ -46,6 +46,61 @@ sub readLocales
$self->{locales} = \@locales;
}
+sub readLocaleData
+{
+ my ($self, $localesDir) = @_;
+
+ $self->{localeData} = {};
+ $self->{name} = '';
+ $self->{description} = '';
+
+ foreach my $locale (@{$self->{locales}})
+ {
+ my $data = $self->readFile("$localesDir/$locale/meta.properties");
+ next unless defined $data;
+
+ $self->{localeData}{$locale} = {id => $locale};
+ while ($data =~ /^\s*(?![!#])(\S+)\s*=\s*(.+)$/mg)
+ {
+ if ($1 eq "name" || $1 eq "description" || $1 eq "translator")
+ {
+ $self->{localeData}{$locale}{$1} = $2;
+ }
+ }
+ }
+
+ if (exists($self->{localeData}{"en-US"}))
+ {
+ $self->{name} = $self->{localeData}{"en-US"}{name} if exists($self->{localeData}{"en-US"}{name});
+ $self->{description} = $self->{localeData}{"en-US"}{description} if exists($self->{localeData}{"en-US"}{description});
+ delete $self->{localeData}{"en-US"};
+ }
+
+ my $info = "";
+ foreach my $locale (values %{$self->{localeData}})
+ {
+ next unless (exists($locale->{translator}) && $locale->{translator}) ||
+ (exists($locale->{name}) && $locale->{name} && $locale->{name} ne $self->{name}) ||
+ (exists($locale->{description}) && $locale->{description} && $locale->{description} ne $self->{description});
+
+ my $translator = (exists($locale->{translator}) && $locale->{translator} ? "\t\t\t<em:translator>$locale->{translator}</em:translator>" : "");
+ $locale->{name} = $self->{name} unless exists($locale->{name}) && $locale->{name} && $locale->{name} ne $self->{name};
+ $locale->{description} = $self->{description} unless exists($locale->{description}) && $locale->{description} && $locale->{description} ne $self->{description};
+
+ $info .= <<EOT;
+\t<em:localized>
+\t\t<Description>
+\t\t\t<em:locale>$locale->{id}</em:locale>
+\t\t\t<em:name>$locale->{name}</em:name>
+\t\t\t<em:description>$locale->{description}</em:description>
+$translator
+\t\t</Description>
+\t</em:localized>
+EOT
+ }
+ $self->{localizedInfo} = $info;
+}
+
sub rm_rec
{
my ($self, $dir) = @_;
@@ -95,6 +150,9 @@ sub cp
s/^((?: )+)/"\t" x (length($1)\/2)/e;
s/\{\{VERSION\}\}/$self->{version}/g if $extendedTextMode;
s/\{\{BUILD\}\}/$self->{build}/g if $extendedTextMode;
+ s/\{\{NAME\}\}/$self->{name}/g if $extendedTextMode;
+ s/\{\{DESCRIPTION\}\}/$self->{description}/g if $extendedTextMode;
+ s/\{\{LOCALIZED\}\}/$self->{localizedInfo}/g if $extendedTextMode;
if ($extendedTextMode && /\{\{LOCALE\}\}/)
{
my $loc = "";
diff --git a/create_xpi.pl b/create_xpi.pl
index 3715b91..ae2a0bc 100644
--- a/create_xpi.pl
+++ b/create_xpi.pl
@@ -35,9 +35,10 @@ $params{locales} = \@ARGV if @ARGV;
my $pkg = Packager->new(\%params);
$pkg->readVersion('version');
$pkg->readLocales('chrome/locale') unless exists $params{locales};
+$pkg->readLocaleData('chrome/locale');
chdir('chrome');
-$pkg->makeJAR("$baseName.jar", 'content', 'skin', 'locale', '-/tests', '-/mochitest', '-/.incomplete');
+$pkg->makeJAR("$baseName.jar", 'content', 'skin', 'locale', '-/tests', '-/mochitest', '-/.incomplete', '-/meta.properties');
chdir('..');
my @files = grep {-e $_} ('components', 'defaults', 'install.rdf', 'chrome.manifest', 'icon.png');
diff --git a/create_xpi.pl b/make_babelzilla_build.pl
similarity index 59%
copy from create_xpi.pl
copy to make_babelzilla_build.pl
index 3715b91..9fb476a 100644
--- a/create_xpi.pl
+++ b/make_babelzilla_build.pl
@@ -1,8 +1,8 @@
#!/usr/bin/perl
#############################################################################
-# This script will create an extension build. Usually, this script #
-# shouldn't be run directly, use make_devbuild.pl instead. #
+# This script will create a special development build meant only for upload #
+# to Babelzilla. #
#############################################################################
use strict;
@@ -10,6 +10,8 @@ use warnings;
use lib qw(buildtools);
use Packager;
+sub Packager::fixLocales() {}
+
my $manifest = readFile("chrome.manifest");
unless ($manifest =~ /\bjar:chrome\/(\S+?)\.jar\b/)
{
@@ -18,23 +20,14 @@ unless ($manifest =~ /\bjar:chrome\/(\S+?)\.jar\b/)
my $baseName = $1;
my %params = ();
+$params{version} = shift @ARGV;
+die "Please specify version number on command line" unless $params{version};
-my $xpiFile = shift @ARGV || "$baseName.xpi";
-if (@ARGV && $ARGV[0] =~ /^\+/)
-{
- $params{devbuild} = $ARGV[0];
- shift @ARGV;
-}
-else
-{
- $params{postprocess_line} = \&removeTimeLine;
-}
-
-$params{locales} = \@ARGV if @ARGV;
+my $xpiFile = "$baseName-$params{version}.xpi";
my $pkg = Packager->new(\%params);
-$pkg->readVersion('version');
-$pkg->readLocales('chrome/locale') unless exists $params{locales};
+$pkg->readLocales('chrome/locale', 1);
+$pkg->readLocaleData('chrome/locale');
chdir('chrome');
$pkg->makeJAR("$baseName.jar", 'content', 'skin', 'locale', '-/tests', '-/mochitest', '-/.incomplete');
@@ -42,14 +35,24 @@ 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 removeTimeLine
+sub postprocessInstallRDF
{
my ($file, $line) = @_;
- return "\n" if $file =~ /\.js$/ && $line =~ /\btimeLine\.(\w+)\(/;
+ 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;
}
diff --git a/setupTestEnvironment.pl b/setupTestEnvironment.pl
index 551e3b3..26f6650 100644
--- a/setupTestEnvironment.pl
+++ b/setupTestEnvironment.pl
@@ -20,14 +20,13 @@
use strict;
use warnings;
use Cwd;
+use lib qw(buildtools);
+use Packager;
-my $version = readFile("version");
-$version =~ s/[^\w\.]//gs;
-
-opendir(local* LOCALES, "chrome/locale") || die "Could not read directory chrome/locales";
-my @locales = grep {!/[^\w\-]/} readdir(LOCALES);
- at locales = sort {$a eq "en-US" ? -1 : ($b eq "en-US" ? 1 : $a cmp $b)} @locales;
-closedir(LOCALES);
+my $pkg = Packager->new();
+$pkg->readVersion('version');
+$pkg->readLocales('chrome/locale');
+$pkg->readLocaleData('chrome/locale');
my @files = ();
my $installManifest = fixupFile(readFile("install.rdf"));
@@ -142,12 +141,15 @@ sub fixupFile
{
my $str = shift;
- $str =~ s/{{VERSION}}/$version/g;
+ $str =~ s/{{VERSION}}/$pkg->{version}/g;
$str =~ s/{{BUILD}}//g;
+ $str =~ s/{{NAME}}/$pkg->{name}/g;
+ $str =~ s/{{DESCRIPTION}}/$pkg->{description}/g;
+ $str =~ s/{{LOCALIZED}}/$pkg->{localizedInfo}/g;
$str =~ s/^.*{{LOCALE}}.*$/
my @result = ();
my $template = $&;
- foreach my $locale (@locales)
+ foreach my $locale (@{$pkg->{locales}})
{
push(@result, $template);
$result[-1] =~ s~{{LOCALE}}~$locale~g;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git
More information about the Pkg-mozext-commits
mailing list