[tor-commits] [tor-launcher/master] Bug 28044: Integrate Tor Launcher into tor-browser

gk at torproject.org gk at torproject.org
Mon May 13 09:47:44 UTC 2019


commit b46c6039d1a5bf95aa9cbd777a51220d1df80aa0
Author: Kathy Brade <brade at pearlcrescent.com>
Date:   Tue Feb 12 12:02:27 2019 -0500

    Bug 28044: Integrate Tor Launcher into tor-browser
    
    Fix locale-related issues.
      Renamed en locale to en-US (previously done during packaging).
      Added moz.build for integration with the Firefox build process.
      Enhanced the import-translations.sh script to omit incomplete locales
        and to generate jar.mn and chrome.manifest.
      Removed checking for incomplete locales from the pkg-prepare make target.
      Improved the output generated by import-translations.sh and pkg-prepare.
---
 Makefile                                           | 32 ++++++------
 README                                             | 20 +++----
 chrome.manifest.in                                 |  4 +-
 jar.mn.in                                          | 27 ++++++++++
 localization/import-translations.sh                | 61 +++++++++++++++++++---
 moz.build                                          |  8 +++
 .../locale/{en => en-US}/network-settings.dtd      |  0
 .../locale/{en => en-US}/torlauncher.properties    |  0
 8 files changed, 114 insertions(+), 38 deletions(-)

diff --git a/Makefile b/Makefile
index f629d52..44f9a2d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,15 @@
-### Copyright (c) 2014, The Tor Project, Inc.
+### Copyright (c) 2019, The Tor Project, Inc.
 ### See src/LICENSE for licensing information.
 
+# Makefile for packaging Tor Launcher outside of the browser build. The only
+# target in this file that is used by the Tor Browser build process is
+# import-translations.
+
 EXT_NAME=tor-launcher
 VERSION:=`grep em:version src/install.rdf | sed -e 's/[<>]/	/g' | cut -f3`
 XPI_NAME:=$(shell echo "$(EXT_NAME)-$(VERSION).xpi")
 STANDALONE_NAME=$(EXT_NAME)-standalone
 STANDALONE_TARBALL=$(shell echo "$(STANDALONE_NAME)-$(VERSION).tar.gz")
-REQUIRED_TRANSLATION_FILES=$(shell ls -1 src/chrome/locale/en/)
 
 AVAIL_TARGETS=help package standalone import-translations clean
 
@@ -36,23 +39,18 @@ pkg-prepare:	clean
 		fi \
 	fi
 	@cp -a chrome.manifest.in "$(TMP)/$(EXT_NAME)"/chrome.manifest
-	@mv "$(TMP)/$(EXT_NAME)"/chrome/locale/en \
-	    "$(TMP)/$(EXT_NAME)"/chrome/locale/en-US
 	@for d in "$(TMP)/$(EXT_NAME)"/chrome/locale/*; do \
-	   if [ "`basename "$${d}"`" = "en-US" ]; then \
+	   locale="`basename $${d}`"; \
+	   if [ "$${locale}" = "en-US" ]; then \
 	     continue; \
 	   fi; \
-	   for f in $(REQUIRED_TRANSLATION_FILES); do \
-	     if [ ! -e "$${d}/$${f}" ] || \
-	        ( \
-	          [ -n "$(BUNDLE_LOCALES)" ] && \
-	          ! echo $(BUNDLE_LOCALES) | grep -qw `basename "$${d}"` \
-	        ); then \
-	       echo "Removing locale $${d} (missing resource $${f})"; \
+	   if [ -n "$(BUNDLE_LOCALES)" ]; then \
+	     if ! echo $(BUNDLE_LOCALES) | grep -qw "$${locale}"; then \
 	       rm -rf "$${d}"; \
-	       break; \
+	     else \
+	       echo "Including locale $${locale}"; \
 	     fi \
-	   done \
+	   fi \
 	 done
 	@for l in $(BUNDLE_LOCALES); do \
 	   if [ ! -d "$(TMP)/$(EXT_NAME)"/chrome/locale/"$${l}" ]; then \
@@ -62,8 +60,10 @@ pkg-prepare:	clean
 	 done
 	@for d in "$(TMP)/$(EXT_NAME)"/chrome/locale/*; do \
 	   locale="`basename $${d}`"; \
-	   echo "locale torlauncher $${locale} chrome/locale/$${locale}/" >> \
-	        "$(TMP)/$(EXT_NAME)"/chrome.manifest; \
+	   if [ "$${locale}" != "en-US" ]; then \
+	     echo "locale torlauncher $${locale} chrome/locale/$${locale}/" >> \
+	          "$(TMP)/$(EXT_NAME)"/chrome.manifest; \
+	   fi; \
 	 done
 
 package:	pkg-prepare
diff --git a/README b/README
index 568acc1..ac536a1 100644
--- a/README
+++ b/README
@@ -1,8 +1,7 @@
 PLEASE NOTE:
-  Tor Launcher is packaged with Tor Browser, Tor Messenger, and
-  other Tor-enabled applications and is designed for those
-  applications. You should not install and try to use it in
-  Mozilla Firefox or another Firefox-based browser.
+  Tor Launcher is built into Tor Browser, and it may be built as a
+  XUL/XPCOM extension for use with TorBirdy.  You should not install
+  and try to use it in Mozilla Firefox or another Firefox-based browser.
 
 OVERVIEW
 Tor Launcher is a browser extension that starts the tor process
@@ -32,18 +31,11 @@ for other product releases; e.g., maint-0.2.10 is a branch that is
 used for releases in the Tor Browser 6.5 series.
 
 BUILDING TOR LAUNCHER
-Official builds of Tor Launcher are done as part of a larger
-application build process. For example, look here for information
-about the Tor Browser build process:
+Official builds that use the Tor Launcher code are done as part of
+a larger application build process. For example, look here for
+information about the Tor Browser build process:
   https://trac.torproject.org/projects/tor/wiki/doc/TorBrowser/Hacking
 
-If you want to build your own standalone copy of Tor Launcher in
-order to test a translation or code change that you have made, run
-the following command:
-  make package
-
-The resulting xpi file is created in a subdirectory named pkg.
-
 CONTACTING THE DEVELOPERS
 To contact the Tor Launcher developers, use the #tor-dev channel
 on irc.oftc.net or post a message to the tbb-dev mailing list (see
diff --git a/chrome.manifest.in b/chrome.manifest.in
index a869569..1800533 100644
--- a/chrome.manifest.in
+++ b/chrome.manifest.in
@@ -1,4 +1,4 @@
-### Copyright (c) 2013, The Tor Project, Inc.
+### Copyright (c) 2019, The Tor Project, Inc.
 ### See LICENSE for licensing information.
 
 content torlauncher chrome/content/
@@ -14,3 +14,5 @@ contract @torproject.org/torlauncher-protocol-service;1 {4F476361-23FB-43EF-A427
 component {FE7B4CAF-BCF4-4848-8BFF-EFA66C9AFDA1} components/tl-process.js
 contract @torproject.org/torlauncher-process-service;1 {FE7B4CAF-BCF4-4848-8BFF-EFA66C9AFDA1}
 category profile-after-change TorProcessService @torproject.org/torlauncher-process-service;1
+
+locale torlauncher en-US chrome/locale/en-US/
diff --git a/jar.mn.in b/jar.mn.in
new file mode 100644
index 0000000..9d0d0ee
--- /dev/null
+++ b/jar.mn.in
@@ -0,0 +1,27 @@
+#filter substitution
+### Copyright (c) 2019, The Tor Project, Inc.
+### See LICENSE for licensing information.
+
+torlauncher.jar:
+  components/     (src/components/*)
+
+% content  torlauncher %content/
+  content/        (src/chrome/content/*)
+
+  modules/        (src/modules/*)
+
+% resource torlauncher  %
+
+% skin     torlauncher  default %skin/
+  skin/           (src/chrome/skin/*)
+
+% component {4F476361-23FB-43EF-A427-B36A14D3208E}         %components/tl-protocol.js
+% contract  @torproject.org/torlauncher-protocol-service;1 {4F476361-23FB-43EF-A427-B36A14D3208E}
+
+% component {FE7B4CAF-BCF4-4848-8BFF-EFA66C9AFDA1}         %components/tl-process.js
+% contract  @torproject.org/torlauncher-process-service;1  {FE7B4CAF-BCF4-4848-8BFF-EFA66C9AFDA1}
+
+% category  profile-after-change TorProcessService @torproject.org/torlauncher-process-service;1
+
+% locale torlauncher en-US %locale/en-US/
+  locale/en-US/ (src/chrome/locale/en-US/*)
diff --git a/localization/import-translations.sh b/localization/import-translations.sh
index f78df42..a1d9bd4 100755
--- a/localization/import-translations.sh
+++ b/localization/import-translations.sh
@@ -1,12 +1,16 @@
 #!/bin/sh
 
+### Copyright (c) 2019, The Tor Project, Inc.
+### See LICENSE for licensing information.
+
 TRANSLATION_BRANCHES="
 tor-launcher-network-settings
 tor-launcher-properties
 "
 
-if [ -d translation ];
-then
+# Import translated string files from the translation git repository.
+echo "Updating translated files"
+if [ -d translation ]; then
   cd translation
   git fetch origin
   cd ..
@@ -17,16 +21,59 @@ fi
 cd translation
 for branch in ${TRANSLATION_BRANCHES}
 do
-  git checkout ${branch}
-  git merge origin/${branch}
+  git checkout --quiet ${branch}
+  git merge --quiet origin/${branch}
   for locale in *
   do
-    if [ ! -d "${locale}" ]
-    then
+    target_locale=$(echo "${locale}" | tr _ -)
+    if [ "${target_locale}" = "en" -o "${target_locale}" = "en-US" \
+        -o ! -d "${locale}" ]; then
       continue
     fi
-    target="../../src/chrome/locale/$(echo "${locale}" | tr _ -)"
+    target="../../src/chrome/locale/${target_locale}"
     mkdir -p "${target}"
     cp -f "${locale}"/* "${target}"/
   done
 done
+cd ..
+
+# Remove all locales that are missing one or more string files.
+# Remove all locales for which no translation has been done.
+# Re-create the chrome.manifest and jar.mn files by appending to templates.
+echo "Removing incomplete locales; updating chrome.manifest and jar.mn"
+cd ../src/chrome/locale
+CHROME_MANIFEST=../../../chrome.manifest
+JAR_MN=../../../jar.mn
+cp ${CHROME_MANIFEST}.in ${CHROME_MANIFEST}
+cp ${JAR_MN}.in ${JAR_MN}
+REQUIRED_TRANSLATION_FILES=`ls -1 en-US/`
+for locale in *; do
+  if [ "${locale}" = "en-US" ]; then
+    continue
+  fi
+  omit_locale=0
+  for f in ${REQUIRED_TRANSLATION_FILES}; do
+    if [ ! -e "${locale}/${f}" ]; then
+      echo "Removing locale ${locale} due to missing resource ${f}"
+      omit_locale=1
+      break
+    fi
+  done
+  if [ ${omit_locale} -eq 0 ]; then
+    diff -r en-US "${locale}" > /dev/null
+    if [ $? -eq 0 ]; then
+      echo "Removing locale ${locale} because it has the same content as en-US"
+      omit_locale=1
+    fi
+  fi
+  if [ ${omit_locale} -ne 0 ]; then
+    rm -rf "${locale}"
+  else
+    echo "locale torlauncher ${locale} chrome/locale/${locale}/" >> \
+        ${CHROME_MANIFEST}
+    echo "% locale torlauncher ${locale} %locale/${locale}/" >> \
+        ${JAR_MN}
+    echo "  locale/${locale}/ (src/chrome/locale/${locale}/*)" >> \
+        ${JAR_MN}
+  fi
+done
diff --git a/moz.build b/moz.build
new file mode 100644
index 0000000..bf6d4a6
--- /dev/null
+++ b/moz.build
@@ -0,0 +1,8 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+### Copyright (c) 2019, The Tor Project, Inc.
+### See LICENSE for licensing information.
+
+JAR_MANIFESTS += ['jar.mn']
+
+JS_PREFERENCE_FILES += [ 'src/defaults/preferences/torlauncher-prefs.js' ]
diff --git a/src/chrome/locale/en/network-settings.dtd b/src/chrome/locale/en-US/network-settings.dtd
similarity index 100%
rename from src/chrome/locale/en/network-settings.dtd
rename to src/chrome/locale/en-US/network-settings.dtd
diff --git a/src/chrome/locale/en/torlauncher.properties b/src/chrome/locale/en-US/torlauncher.properties
similarity index 100%
rename from src/chrome/locale/en/torlauncher.properties
rename to src/chrome/locale/en-US/torlauncher.properties





More information about the tor-commits mailing list