bug 1416891 - use LOCALIZED_GENERATED_FILES for updater.ini. r=nalexander draft
authorTed Mielczarek <ted@mielczarek.org>
Thu, 16 Nov 2017 17:28:30 -0500
changeset 705776 86b7f45f92e2ca615eb5fba2ad9985e6d3ce429b
parent 705775 3febcff2afe9821bcdbc4becc47ae22b7940b44e
child 705777 4de0da803df5d2dc92c04217b245a1327a922dbe
push id91576
push userbmo:ted@mielczarek.org
push dateThu, 30 Nov 2017 16:56:58 +0000
reviewersnalexander
bugs1416891
milestone59.0a1
bug 1416891 - use LOCALIZED_GENERATED_FILES for updater.ini. r=nalexander MozReview-Commit-ID: HQNYBkMwz4G
browser/locales/Makefile.in
browser/locales/generate_updater_ini.py
browser/locales/moz.build
--- a/browser/locales/Makefile.in
+++ b/browser/locales/Makefile.in
@@ -146,33 +146,16 @@ installers-%:
 	@$(MAKE) libs-$*
 	@$(MAKE) package-langpack-$*
 	@$(MAKE) repackage-zip-$*
 ifeq (WINNT,$(OS_ARCH))
 	@$(MAKE) package-win32-installer AB_CD=$* MOZ_PKG_FORMAT=SFX7Z
 endif
 	@echo 'repackaging done'
 
-ifdef MOZ_UPDATER
-# Note that we want updater.ini to be in the top directory, not the browser/
-# subdirectory, because that's where the updater is installed and runs.
-libs:: $(call MERGE_FILE,updater/updater.ini) $(call mkdir_deps,$(DIST)/bin)
-ifeq ($(OS_ARCH),WINNT)
-	cat $< $(srcdir)/../installer/windows/nsis/updater_append.ini | \
-	  sed -e 's/^InfoText=/Info=/' -e 's/^TitleText=/Title=/' | \
-	  sed -e 's/%MOZ_APP_DISPLAYNAME%/$(MOZ_APP_DISPLAYNAME)/' > \
-	  $(FINAL_TARGET)/../updater.ini
-else
-	cat $< | \
-	  sed -e 's/^InfoText=/Info=/' -e 's/^TitleText=/Title=/' | \
-	  sed -e 's/%MOZ_APP_DISPLAYNAME%/$(MOZ_APP_DISPLAYNAME)/' > \
-	  $(FINAL_TARGET)/../updater.ini
-endif
-endif
-
 ident:
 	@printf 'fx_revision '
 	@$(PYTHON) $(topsrcdir)/config/printconfigsetting.py \
 	    $(STAGEDIST)/application.ini App SourceStamp
 	@printf 'buildid '
 	@$(PYTHON) $(topsrcdir)/config/printconfigsetting.py \
 	    $(STAGEDIST)/application.ini App BuildID
 
new file mode 100644
--- /dev/null
+++ b/browser/locales/generate_updater_ini.py
@@ -0,0 +1,27 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# Generate updater.ini by doing some light substitution on the localized updater.ini input,
+# and appending the contents of updater_ini_append on Windows.
+
+from __future__ import absolute_import, unicode_literals, print_function
+
+import buildconfig
+import codecs
+import re
+import shutil
+
+def main(output, updater_ini, updater_ini_append, locale=None):
+    assert(locale is not None)
+    fixup_re = re.compile('^(Info|Title)Text=')
+    # updater.ini is always utf-8.
+    with codecs.open(updater_ini, 'rb', 'utf_8') as f:
+        for line in f:
+            line = fixup_re.sub(r'\1=', line)
+            line = line.replace('%MOZ_APP_DISPLAYNAME%', buildconfig.substs['MOZ_APP_DISPLAYNAME'])
+            output.write(line)
+    if buildconfig.substs['OS_TARGET'] == 'WINNT':
+        # Also append the contents of `updater_ini_append`.
+        with codecs.open(updater_ini_append, 'rb', 'utf_8') as f:
+            shutil.copyfileobj(f, output)
--- a/browser/locales/moz.build
+++ b/browser/locales/moz.build
@@ -7,16 +7,29 @@
 JAR_MANIFESTS += ['jar.mn']
 
 # If DIST_SUBDIR ever gets unset in browser this path might be wrong due to PREF_DIR changing.
 LOCALIZED_PP_FILES.defaults.preferences += ['en-US/firefox-l10n.js']
 
 if CONFIG['MOZ_CRASHREPORTER']:
     LOCALIZED_FILES += ['en-US/crashreporter/crashreporter-override.ini']
 
+if CONFIG['MOZ_UPDATER']:
+    LOCALIZED_GENERATED_FILES += ['updater.ini']
+    updater = LOCALIZED_GENERATED_FILES['updater.ini']
+    updater.script = 'generate_updater_ini.py'
+    updater.inputs = [
+        'en-US/updater/updater.ini',
+        '../installer/windows/nsis/updater_append.ini',
+    ]
+    # Yes, this is weird, but what can you do? This file doesn't want to be in the DIST_SUBDIR,
+    # but we can't really move it to a different directory until we change how locale repacks
+    # work.
+    LOCALIZED_FILES['..'] += ['!updater.ini']
+
 with Files("**"):
     BUG_COMPONENT = ("Toolkit", "Build Config")
 
 with Files("all-locales"):
     BUG_COMPONENT = ("Core", "Localization")
 
 with Files("en-US/**"):
     BUG_COMPONENT = ("Core", "Localization")