Bug 923950 - Fix Android single locale repacks. r=glandium, a=bajaj
authorNick Alexander <nalexander@mozilla.com>
Sat, 14 Dec 2013 15:36:17 -0800
changeset 175745 ea80006dd4f924607ad2e38e06febeb5917961b0
parent 175744 ef058ebed6fbb248df3a9cf4272d34a5e0c2e977
child 175746 fdddb77835762992a8f60d35454b17a51092bca3
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium, bajaj
bugs923950
milestone28.0a2
Bug 923950 - Fix Android single locale repacks. r=glandium, a=bajaj There are two parts to this. The first is to add AndroidManifest.xml as a dependency to the "no dependencies" ap_ built during packaging. The aapt call requires it. So "no dependencies" is more accurately "no *resource* dependencies". The second is to avoid including the Android res/ directory in the language repack step. What happens is that the l10n.py script sees the Android res/ files left in the dist/ directory after unpacking and expects to find them in the objdir. They're not there, so the script fails. To avoid this, we delete them after unpacking. See the comments in packager.mk describing this process.
mobile/android/base/Makefile.in
mobile/android/base/crashreporter/res/drawable-mdpi/crash_reporter.png
mobile/android/base/crashreporter/res/layout/crash_reporter.xml
mobile/android/branding/aurora/res/drawable-hdpi/icon.png
mobile/android/branding/aurora/res/drawable-mdpi/icon.png
mobile/android/branding/aurora/res/drawable-xhdpi/icon.png
mobile/android/branding/aurora/res/drawable-xxhdpi/icon.png
mobile/android/branding/beta/res/drawable-hdpi/icon.png
mobile/android/branding/beta/res/drawable-mdpi/icon.png
mobile/android/branding/beta/res/drawable-xhdpi/icon.png
mobile/android/branding/beta/res/drawable-xxhdpi/icon.png
mobile/android/branding/nightly/res/drawable-hdpi/icon.png
mobile/android/branding/nightly/res/drawable-mdpi/icon.png
mobile/android/branding/nightly/res/drawable-xhdpi/icon.png
mobile/android/branding/nightly/res/drawable-xxhdpi/icon.png
mobile/android/branding/official/res/drawable-hdpi/icon.png
mobile/android/branding/official/res/drawable-mdpi/icon.png
mobile/android/branding/official/res/drawable-xhdpi/icon.png
mobile/android/branding/official/res/drawable-xxhdpi/icon.png
mobile/android/branding/unofficial/res/drawable-hdpi/icon.png
mobile/android/branding/unofficial/res/drawable-mdpi/icon.png
mobile/android/branding/unofficial/res/drawable-xhdpi/icon.png
mobile/android/branding/unofficial/res/drawable-xxhdpi/icon.png
python/mozbuild/mozbuild/jar.py
toolkit/mozapps/installer/packager.mk
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -171,17 +171,17 @@ android_res_files := $(wildcard $(addsuf
 # language repack.  So rather than adding rules into the main
 # makefile, and trying to work around the lack of information, we
 # force a rebuild of gecko.ap_ during packaging.  See below.
 
 res/values/strings.xml: FORCE
 	$(MAKE) -C locales
 
 all_resources = \
-  AndroidManifest.xml \
+  $(CURDIR)/AndroidManifest.xml \
   $(android_res_files) \
   $(ANDROID_GENERATED_RESFILES) \
   $(NULL)
 
 # All of generated/org/mozilla/gecko/R.java, gecko.ap_, and R.txt are
 # produced by aapt; this saves aapt invocations.
 
 $(gecko_package_dir)/R.java: .aapt.deps
@@ -219,18 +219,18 @@ endef
 # packaging.  It doesn't write the normal ap_, or R.java, since we
 # don't want the packaging step to write anything that would make a
 # further no-op build do work.  See also
 # toolkit/mozapps/installer/packager.mk.
 
 # .aapt.deps: $(all_resources)
 $(eval $(call aapt_command,.aapt.deps,$(all_resources),gecko.ap_,$(gecko_package_dir)/,./))
 
-# .aapt.nodeps: FORCE
-$(eval $(call aapt_command,.aapt.nodeps,FORCE,gecko-nodeps.ap_,gecko-nodeps/,gecko-nodeps/))
+# .aapt.nodeps: $(CURDIR)/AndroidManifest.xml FORCE
+$(eval $(call aapt_command,.aapt.nodeps,$(CURDIR)/AndroidManifest.xml FORCE,gecko-nodeps.ap_,gecko-nodeps/,gecko-nodeps/))
 
 fennec_ids.txt: $(gecko_package_dir)/R.java fennec-ids-generator.py
 	$(PYTHON) $(topsrcdir)/mobile/android/base/fennec-ids-generator.py -i $< -o $@
 
 # Override the Java settings with some specific android settings
 include $(topsrcdir)/config/android-common.mk
 
 libs:: classes.dex jni-stubs.inc GeneratedJNIWrappers.cpp fennec_ids.txt
--- a/python/mozbuild/mozbuild/jar.py
+++ b/python/mozbuild/mozbuild/jar.py
@@ -508,18 +508,18 @@ def main(args=None):
         if not options.relativesrcdir:
             p.error('relativesrcdir required when using l10n-base')
         if options.l10n_src:
             p.error('both l10n-src and l10n-base are not supported')
         jm.l10nbase = options.l10n_base
         jm.relativesrcdir = options.relativesrcdir
         jm.l10nmerge = options.locale_mergedir
         if jm.l10nmerge and not os.path.isdir(jm.l10nmerge):
-            logging.warning("WARNING: --locale-mergedir passed, but '%s' does not exist. Ignore this message if the locale is complete."
-                            )
+            logging.warning("WARNING: --locale-mergedir passed, but '%s' does not exist. "
+                "Ignore this message if the locale is complete." % jm.l10nmerge)
     elif options.locale_mergedir:
         p.error('l10n-base required when using locale-mergedir')
     jm.localedirs = options.l10n_src
     if options.root_manifest_entry_appid:
         jm.rootManifestAppId = options.root_manifest_entry_appid
     noise = logging.INFO
     if options.verbose is not None:
         noise = options.verbose and logging.DEBUG or logging.WARN
--- a/toolkit/mozapps/installer/packager.mk
+++ b/toolkit/mozapps/installer/packager.mk
@@ -440,24 +440,38 @@ OMNIJAR_NAME := $(notdir $(OMNIJAR_NAME)
 
 # We force build an ap_ that does not check dependencies below.
 # Language repacks take advantage of this unchecked dependency ap_ to
 # insert additional resources (translated strings) into the ap_
 # without the build system's participation.  This can do the wrong
 # thing if there are resource changes in between build time and
 # package time.  We try to prevent mismatched resources by erroring
 # out if the compiled resource IDs are not the same as the resource
-# IDs being packaged.
+# IDs being packaged.  If we're doing a single locale repack, however,
+# we don't have a complete object directory, so we can't compare
+# resource IDs.
+
+# A note on the res/ directory.  We unzip the ap_ during packaging,
+# which produces the res/ directory.  This directory is then included
+# in the final package.  When we unpack (during locale repacks), we
+# need to remove the res/ directory because these resources confuse
+# the l10n packaging script that updates omni.ja: the script tries to
+# localize the contents of the res/ directory, which fails.  Instead,
+# after the l10n packaging script completes, we build the ap_
+# described above (which includes freshly localized Android resources)
+# and the res/ directory is taken from the ap_ as part of the regular
+# packaging.
 
 PKG_SUFFIX      = .apk
 INNER_MAKE_PACKAGE	= \
   $(if $(ALREADY_SZIPPED),,$(foreach lib,$(SZIP_LIBRARIES),host/bin/szip $(MOZ_SZIP_FLAGS) $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(lib) && )) \
   make -C $(GECKO_APP_AP_PATH) gecko-nodeps.ap_ && \
   cp $(GECKO_APP_AP_PATH)/gecko-nodeps.ap_ $(_ABS_DIST)/gecko.ap_ && \
-  ( diff $(GECKO_APP_AP_PATH)/R.txt $(GECKO_APP_AP_PATH)/gecko-nodeps/R.txt >/dev/null || \
+  ( (test ! -f $(GECKO_APP_AP_PATH)/R.txt && echo "*** Warning: The R.txt that is being packaged might not agree with the R.txt that was built. This is normal during l10n repacks.") || \
+    diff $(GECKO_APP_AP_PATH)/R.txt $(GECKO_APP_AP_PATH)/gecko-nodeps/R.txt >/dev/null || \
     (echo "*** Error: The R.txt that was built and the R.txt that is being packaged are not the same. Rebuild mobile/android/base and re-package." && exit 1)) && \
   ( cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && \
     mkdir -p lib/$(ABI_DIR) && \
     mv libmozglue.so $(MOZ_CHILD_PROCESS_NAME) lib/$(ABI_DIR) && \
     unzip -o $(_ABS_DIST)/gecko.ap_ && \
     rm $(_ABS_DIST)/gecko.ap_ && \
     $(ZIP) $(if $(MOZ_ENABLE_SZIP),-0 )$(_ABS_DIST)/gecko.ap_ $(ASSET_SO_LIBRARIES) && \
     $(ZIP) -r9D $(_ABS_DIST)/gecko.ap_ $(DIST_FILES) -x $(NON_DIST_FILES) $(SZIP_LIBRARIES) && \
@@ -482,16 +496,17 @@ INNER_MAKE_PACKAGE	= \
 
 INNER_UNMAKE_PACKAGE	= \
   mkdir $(MOZ_PKG_DIR) && \
   ( cd $(MOZ_PKG_DIR) && \
     $(UNZIP) $(UNPACKAGE) && \
     mv lib/$(ABI_DIR)/libmozglue.so . && \
     mv lib/$(ABI_DIR)/*plugin-container* $(MOZ_CHILD_PROCESS_NAME) && \
     rm -rf lib/$(ABI_DIR) \
+    rm -rf res \
     $(if $(filter-out ./,$(OMNIJAR_DIR)), \
       && mv $(OMNIJAR_DIR)$(OMNIJAR_NAME) $(OMNIJAR_NAME)) )
 endif
 
 ifeq ($(MOZ_PKG_FORMAT),DMG)
 PKG_SUFFIX	= .dmg
 PKG_DMG_FLAGS	=
 ifneq (,$(MOZ_PKG_MAC_DSSTORE))