[tbb-commits] [tor-browser-build/master] Bug 26843: add projects/firefox-locale-bundle

gk at torproject.org gk at torproject.org
Thu Nov 22 08:39:40 UTC 2018


commit 43c9452946313a5ab3dd064501daa05096db86eb
Author: Nicolas Vigier <boklm at torproject.org>
Date:   Mon Nov 19 13:04:54 2018 +0100

    Bug 26843: add projects/firefox-locale-bundle
    
    projects/firefox-locale-bundle will clone or pull the mercurial
    repositories for each locale into the hg_clones/firefox-locale-bundle
    directory, and generate tarballs using the changesets listed in the
    firefox json file. The script get_hg_hash is used to parse
    this json file and output the hg changeset for the selected locale.
    
    Patch based on work started by GeKo.
---
 README                                     |  9 ++++++---
 projects/firefox-locale-bundle/build       | 29 +++++++++++++++++++++++++++++
 projects/firefox-locale-bundle/config      | 12 ++++++++++++
 projects/firefox-locale-bundle/get_hg_hash | 21 +++++++++++++++++++++
 4 files changed, 68 insertions(+), 3 deletions(-)

diff --git a/README b/README
index a20b659..8ebef9b 100644
--- a/README
+++ b/README
@@ -14,8 +14,10 @@ to extract container file systems, start containers and copy files to and
 from containers.
 
 The sources of most components are downloaded using git, which needs to
-be installed. The sources of webrtc are downloaded using gclient, which
-requires GTK+ 2.0 development files and curl to be installed.
+be installed. Some components are downloaded using mercurial which also
+needs to be installed. The sources of webrtc are downloaded using
+gclient, which requires GTK+ 2.0 development files and curl to be
+installed.
 
 You also need a few perl modules installed:
 - YAML::XS
@@ -41,7 +43,8 @@ If you are running Debian or Ubuntu, you can install them with:
                   libio-captureoutput-perl libpath-tiny-perl \
                   libstring-shellquote-perl libsort-versions-perl \
                   libdigest-sha-perl libdata-uuid-perl libdata-dump-perl \
-                  libfile-copy-recursive-perl git libgtk2.0-dev curl runc
+                  libfile-copy-recursive-perl git libgtk2.0-dev curl runc \
+                  mercurial
 
 The build system is based on rbm, which is included as a git submodule
 in the rbm/ directory. You can fetch the rbm git submodule by running
diff --git a/projects/firefox-locale-bundle/build b/projects/firefox-locale-bundle/build
new file mode 100644
index 0000000..3fec48e
--- /dev/null
+++ b/projects/firefox-locale-bundle/build
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+[% c("var/set_default_env") -%]
+
+clone_dir='[% c("basedir") %]/hg_clones/[% project %]'
+mkdir -p "$clone_dir"
+cd "$clone_dir"
+tmpdir=$(mktemp -d)
+
+[% FOREACH lang = c('var/locales') %]
+  [% SET lang = tmpl(lang);
+     SET hgurl = "https://hg.mozilla.org/l10n-central/" _ lang %]
+  if test -d [% lang %]
+  then
+      cd [% lang %]
+      [% c("hg") %] pull [% hgurl %]
+  else
+      [% c("hg") %] clone [% hgurl %] [% lang %]
+      cd [% lang %]
+  fi
+  hg_hash=$([% c("basedir") %]/projects/firefox-locale-bundle/get_hg_hash \
+                $rootdir/[% c('input_files_by_name/firefox_json') %] \
+                [% lang %])
+  [% c("hg") %] archive -r "$hg_hash" -t files "$tmpdir"/[% lang %]
+  cd ..
+[% END %]
+
+tar -C "$tmpdir" -czf [% dest_dir %]/[% c("filename") %] .
+rm -Rf "$tmpdir"
diff --git a/projects/firefox-locale-bundle/config b/projects/firefox-locale-bundle/config
new file mode 100644
index 0000000..13c5fb8
--- /dev/null
+++ b/projects/firefox-locale-bundle/config
@@ -0,0 +1,12 @@
+# vim: filetype=yaml sw=2
+version: '[% c("var/ff_version") %]-[% c("var/ff_build") %]'
+filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
+
+var:
+  use_container: 0
+  ff_version: '[% pc("firefox", "var/firefox_version") %]'
+  ff_build: build1
+
+input_files:
+  - name: firefox_json
+    URL: 'https://product-details.mozilla.org/1.0/l10n/Firefox-[% c("var/ff_version") %]-[% c("var/ff_build") %].json'
diff --git a/projects/firefox-locale-bundle/get_hg_hash b/projects/firefox-locale-bundle/get_hg_hash
new file mode 100755
index 0000000..0531113
--- /dev/null
+++ b/projects/firefox-locale-bundle/get_hg_hash
@@ -0,0 +1,21 @@
+#!/usr/bin/perl -w
+use strict;
+use File::Slurp;
+use JSON;
+
+sub exit_error {
+    print STDERR "Error: ", $_[0], "\n";
+    exit (exists $_[1] ? $_[1] : 1);
+}
+
+exit_error("Wrong number of arguments", 1) unless @ARGV == 2;
+
+my ($file, $locale) = @ARGV;
+my $json_text = read_file($file);
+exit_error("Error reading $file", 2) unless defined $json_text;
+
+my $data = decode_json($json_text);
+
+my $changeset = $data->{locales}{$locale}{changeset};
+exit_error("Can't find locale $locale in $file", 3) unless $changeset;
+print "$changeset\n";



More information about the tbb-commits mailing list