Fix bug 855067 - Localized Lightning builds using Thunderbird Infrastructure. r=Standard8,a=philipp
authorPhilipp Kewisch <mozilla@kewis.ch>
Mon, 17 Jun 2013 10:49:43 +0200
changeset 18490 1eda7c30ee58340e2271aff18ccea6a7273c4510
parent 18489 5a92a652a0f4a190ed3159ae2973759d26db74d9
child 18491 7be812eeae723c49dfb365198ff562a9139c7284
push id902
push userbugzilla@standard8.plus.com
push dateMon, 05 Aug 2013 09:09:02 +0000
treeherdertry-comm-central@36a590aa4907 [default view] [failures only]
reviewersStandard8, philipp
bugs855067
Fix bug 855067 - Localized Lightning builds using Thunderbird Infrastructure. r=Standard8,a=philipp
calendar/lightning/Makefile.in
calendar/lightning/lightning-packager.mk
calendar/lightning/lightning-symbols.mk
calendar/lightning/locales/moz.build
calendar/lightning/moz.build
calendar/locales/moz.build
calendar/locales/shipped-locales
calendar/providers/gdata/Makefile.in
mail/build.mk
mail/config/mozconfigs/linux32/l10n-mozconfig
mail/config/mozconfigs/linux64/l10n-mozconfig
mail/config/mozconfigs/macosx-universal/l10n-mozconfig
mail/config/mozconfigs/win32/l10n-mozconfig
mail/config/mozconfigs/win64/l10n-mozconfig
mail/locales/Makefile.in
--- a/calendar/lightning/Makefile.in
+++ b/calendar/lightning/Makefile.in
@@ -10,17 +10,17 @@ VPATH		= @srcdir@
 include $(DEPTH)/config/autoconf.mk
 
 # Calendar builders currently use STRIP_XPI to reduce the binary component in
 # Lightning.
 
 export XPI_NAME = lightning
 export USE_EXTENSION_MANIFEST = 1
 XPI_PKGNAME = lightning-$(LIGHTNING_VERSION).$(AB_CD).$(MOZ_PKG_PLATFORM)
-GDATA_XPI_PKGNAME = gdata-provider-$(GDATA_VERSION).$(AB_CD).$(MOZ_PKG_PLATFORM)
+XPI_VERSION = $(LIGHTNING_VERSION)
 
 XPI_EM_ID = {e2fda1a4-762b-4020-b5ad-a41df1933103}
 
 DIST_FILES = install.rdf application.ini
 PREF_JS_EXPORTS = $(srcdir)/content/lightning.js
 
 # Lighting version number
 LIGHTNING_VERSION := $(shell cat $(srcdir)/../sunbird/config/version.txt)
@@ -119,16 +119,21 @@ DEFINES += -DGRE_BUILDID=$(GRE_BUILDID)
 
 # xxx todo: unless our packaging story is revised (bug 406579) we package up timezones.sqlite
 libs::
 	$(NSINSTALL) -m 0644 $(srcdir)/../timezones/timezones.sqlite $(FINAL_TARGET)
 
 include $(topsrcdir)/config/rules.mk
 include $(srcdir)/lightning-packager.mk
 
+# For Lightning, we also need to preprocess the l10n prefs
+repack-process-extrafiles: lightning-extrafiles
+lightning-extrafiles:
+	$(PYTHON) $(MOZILLA_SRCDIR)/config/Preprocessor.py $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $(LOCALE_BASEDIR)/lightning-l10n.js  > $(DIST)/$(UNIVERSAL_PATH)xpi-stage/$(L10N_XPI_NAME)/$(PREF_DIR)/lightning-l10n.js
+
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 # If the macbundle dist dir was already created, sync lightning here to avoid
 # the need to make -C objdir/mail/app each time
 libs::
 	[ -d $(DIST)/$(MOZ_MACBUNDLE_NAME) ] && rsync -aL $(FINAL_TARGET)/ $(DIST)/$(MOZ_MACBUNDLE_NAME)/Contents/MacOS/extensions/$(XPI_EM_ID) || true
 endif
 
 ident:
--- a/calendar/lightning/lightning-packager.mk
+++ b/calendar/lightning/lightning-packager.mk
@@ -1,142 +1,181 @@
 # 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/.
 
-ifdef UNIVERSAL_BINARY
+# NOTE: The packager is not only used in calendar/lightning but should be
+# general enough to be able to repackage other sub-extensions like
+# calendar/providers/gdata. This means no lightning-specific files, no version
+# numbers directly from lightning and be careful with relative paths.
+
+# This packager can be used to repackage extensions. To use it, set the
+# following variables in your Makefile, then include this file.
+#   XPI_NAME = lightning # The extension path name
+#   XPI_PKGNAME = lightning-2.2.en-US.mac # The extension package name
+#   XPI_VERSION = 2.2 # The extension version
+#
+# The following variables are optional:
+#   XPI_NO_UNIVERSAL = 1  # If set, no universal path is used on mac
+
+include $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/package-name.mk
+
+# Set the univeral path only if we are building a univeral binary and it was
+# not restricted by the calling makefile
+ifeq ($(UNIVERSAL_BINARY)|$(XPI_NO_UNIVERSAL),1|)
 UNIVERSAL_PATH=universal/
 else
 UNIVERSAL_PATH=
 endif
 
 _ABS_DIST := $(call core_abspath,$(DIST))
-ZIP_IN ?= $(_ABS_DIST)/$(UNIVERSAL_PATH)xpi-stage/$(XPI_NAME).xpi
 
 # This variable is to allow the wget-en-US target to know which ftp server to download from
 ifndef EN_US_BINARY_URL
 EN_US_BINARY_URL = $(error You must set EN_US_BINARY_URL)
 endif
 
-# Target Directory used for the l10n files
-L10N_TARGET = $(DIST)/$(UNIVERSAL_PATH)xpi-stage/$(XPI_NAME)-$(AB_CD)
-
-$(DIST)/$(UNIVERSAL_PATH)xpi-stage:
+XPI_STAGE_PATH = $(DIST)/$(UNIVERSAL_PATH)xpi-stage
+_ABS_XPI_STAGE_PATH = $(ABS_DIST)/$(UNIVERSAL_PATH)xpi-stage
+$(XPI_STAGE_PATH):
 	mkdir -p $@
 
-wget-en-US: $(DIST)/$(UNIVERSAL_PATH)xpi-stage
-ifndef WGET
-	$(error wget not installed)
-endif
-	(cd $(DIST)/xpi-stage && $(WGET) -nv -N $(EN_US_BINARY_URL)/$(XPI_NAME).xpi)
-	@echo "Downloaded $(EN_US_BINARY_URL)/$(PACKAGE) to	$(ZIP_IN)"
-
-unpack: $(ZIP_IN)
-# We're unpacking directly into FINAL_TARGET, this keeps code to do manual
-# repacks cleaner.
-	if test -d $(DIST)/$(UNIVERSAL_PATH)xpi-stage/$(XPI_NAME); then \
-	  $(RM) -r -v $(DIST)/$(UNIVERSAL_PATH)xpi-stage/$(XPI_NAME); \
-	fi
-	$(NSINSTALL) -D $(DIST)/$(UNIVERSAL_PATH)xpi-stage/$(XPI_NAME)
-	cd $(DIST)/$(UNIVERSAL_PATH)/xpi-stage/$(XPI_NAME) && $(UNZIP) $(ZIP_IN)
-	@echo done unpacking
-
-# Call this target to upload the localized lightning package.
-l10n-upload-%: AB_CD=$*
-l10n-upload-%:
-	$(PYTHON) $(MOZILLA_SRCDIR)/build/upload.py --base-path $(DIST)/$(UNIVERSAL_PATH)xpi-stage/  "$(L10N_TARGET).xpi"
+# Target Directory used for the l10n files
+L10N_TARGET = $(XPI_STAGE_PATH)/$(XPI_NAME)-$(AB_CD)
 
-# Call this target to trigger repackaging lightning for a specific language
-# Usage: make AB_CD=<language> repack-l10n
-repack-l10n: L10N_XPI_NAME=$(subst -en-US,,$(XPI_NAME)-$(AB_CD))
-repack-l10n: recreate-platformini repack-clobber libs-$(AB_CD) repack-process-extrafiles
-	@echo "Finished repackaging $(XPI_NAME) locale for Language $(AB_CD)"
-
-# This target should not be called directly
-repack-clobber-all:
-	@echo "Repackaging $(XPI_NAME) locale for Language $(AB_CD)"
-	$(RM) -rf $(L10N_TARGET)
-	cp -R $(DIST)/$(UNIVERSAL_PATH)xpi-stage/$(XPI_NAME) $(L10N_TARGET)
-
-# This target should not be called directly
-repack-clobber: repack-clobber-all
-	grep -v 'locale \w\+ en-US' $(L10N_TARGET)/chrome.manifest > $(L10N_TARGET)/chrome.manifest~ && \
-	  mv $(L10N_TARGET)/chrome.manifest~ $(L10N_TARGET)/chrome.manifest
-ifeq ($(MOZ_CHROME_FILE_FORMAT),flat)
-	$(RM) -rf $(L10N_TARGET)/chrome/lightning-en-US/
-	$(RM) -rf $(L10N_TARGET)/chrome/calendar-en-US/
-else ifeq ($(MOZ_CHROME_FILE_FORMAT),jar)
-	$(RM) -rf $(L10N_TARGET)/chrome/lightning-en-US.jar
-	$(RM) -rf $(L10N_TARGET)/chrome/calendar-en-US.jar
-else
-	@echo "ERROR: Unhandled chrome file format: $(MOZ_CHROME_FILE_FORMAT)"
-	@exit 1
-endif
-
+# Short name of the OS used in shipped-locales file. For now osx is the only
+# special case, so assume linux for everything else.
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 SHORTOS = osx
 else
-# For now, osx is the only special case. Therefore, we can just fallback to
-# detecting linux which should be the second argument.
 SHORTOS = linux
 endif
 
-# Repack the existing lightning to contain all locales in lightning-all.xpi
-repack-l10n-all: AB_CD=all
-repack-l10n-all: L10N_XPI_NAME=lightning-all
-repack-l10n-all: repack-clobber-all $(addprefix libs-,$(shell awk '{ if ($$2 == "" || $$2 == "$(SHORTOS)") { print $$1 } }' $(topsrcdir)/calendar/locales/shipped-locales))
+# function oslocales(filename)
+oslocales = $(shell awk '{ if ($$2 == "" || $$2 == "$(SHORTOS)") { print $$1 } }' $1)
+
+# function apposlocales(app)
+apposlocales = $(call oslocales,$(topsrcdir)/$1/locales/$(if $(filter $(MOZ_UPDATE_CHANNEL),beta release),shipped-locales,all-locales))
+
+# function print_ltnconfig(section,configname)
+print_ltnconfig = $(shell $(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py $(XPI_STAGE_PATH)/$(XPI_NAME)/application.ini $1 $2)
+
+# Lightning uses Thunderbird's build machinery, so we need to hack the binary
+# url to use Lightning's directories.
+wget-en-US: FINAL_BINARY_URL = $(subst thunderbird,calendar/lightning,$(EN_US_BINARY_URL))
+wget-en-US: $(XPI_STAGE_PATH)
+wget-en-US: ZIP_IN ?= $(_ABS_XPI_STAGE_PATH)/$(XPI_PKGNAME).xpi
+wget-en-US:
+	(cd $(XPI_STAGE_PATH) && $(WGET) -nv -N $(FINAL_BINARY_URL)/$(XPI_PKGNAME).xpi)
+	@echo "Downloaded $(FINAL_BINARY_URL)/$(XPI_PKGNAME) to	$(ZIP_IN)"
+
+# If this file is missing, its probably the release run where we can't
+# influence the download location. Fake it from the env vars we have
+ensure-stage-dir: $(if $(wildcard $(XPI_STAGE_PATH)/$(XPI_NAME)/),,wget-from-env)
+wget-from-env: BUILD_NR=$(shell echo $(POST_UPLOAD_CMD) | sed -n -e 's/.*-n \([0-9]*\).*/\1/p')
+wget-from-env: CANDIDATE_NR=$(XPI_VERSION)
+wget-from-env: EN_US_BINARY_URL=http://$(UPLOAD_HOST)/pub/mozilla.org/calendar/lightning/nightly/$(CANDIDATE_NR)-candidates/build$(BUILD_NR)/$(MOZ_PKG_PLATFORM)
+wget-from-env: XPI_PKGNAME:=$(subst .$(AB_CD).,.en-US.,$(XPI_PKGNAME))
+wget-from-env: ZIP_IN=$(_ABS_XPI_STAGE_PATH)/$(XPI_PKGNAME).xpi
+wget-from-env: wget-en-US unpack
+
+# We're unpacking directly into FINAL_TARGET, this keeps code to do manual
+# repacks cleaner.
+unpack: ZIP_IN ?= $(_ABS_XPI_STAGE_PATH)/$(XPI_PKGNAME).xpi
+unpack: $(ZIP_IN)
+	if test -d $(XPI_STAGE_PATH)/$(XPI_NAME); then \
+	  $(RM) -r -v $(XPI_STAGE_PATH)/$(XPI_NAME); \
+	fi
+	$(NSINSTALL) -D $(XPI_STAGE_PATH)/$(XPI_NAME)
+	cd $(XPI_STAGE_PATH)/$(XPI_NAME) && $(UNZIP) $(ZIP_IN)
+	@echo done unpacking
+
+# Nothing to package for en-US, its just the usual english xpi
+langpack-en-US:
+	@echo "Skipping $@ as en-US is the default"
 
-.PHONY : repack-l10n-all
+# Skip those locales in Thunderbird but not in Lightning. Use either
+# all-locales or shipped-locales, depending on if we are doing a
+# regular repack or a release repack
+CAL_LOCALES = $(call apposlocales,calendar)
+TB_LOCALES = $(call apposlocales,mail)
+TB_SKIP_LOCALES = $(filter-out $(CAL_LOCALES) en-US,$(TB_LOCALES))
+$(addprefix langpack-,$(TB_SKIP_LOCALES)) $(addprefix upload-,$(TB_SKIP_LOCALES)):
+	@echo "Skipping $@ as it is not in Lightning's $(LOCALES_FILENAME)"
+
+# Calling these targets with prerequisites causes the libs and subsequent
+# targets to be switched in order due to some make voodoo. Therefore we call
+# the targets explicitly, which seems to work better.
+langpack-%: L10N_XPI_NAME=$(XPI_NAME)-$*
+langpack-%: L10N_XPI_PKGNAME=$(subst $(AB_CD),$*,$(XPI_PKGNAME))
+langpack-%: AB_CD=$*
+langpack-%: ensure-stage-dir
+	$(MAKE) L10N_XPI_NAME=$(L10N_XPI_NAME) L10N_XPI_PKGNAME=$(L10N_XPI_PKGNAME) AB_CD=$(AB_CD) \
+	  recreate-platformini repack-stage repack-process-extrafiles libs-$(AB_CD)
+	@echo "Done packaging $(L10N_XPI_PKGNAME).xpi"
 
-# Helper target to align names better to targets from other locale Makefiles
-repack-l10n-%:
-	$(MAKE) AB_CD=$* repack-l10n
+clobber-%: AB_CD=$*
+clobber-%:
+	$(RM) -r $(L10N_TARGET)
+
+repackage-zip-%:
+	@echo "Already repackaged zip for $* in langpack step"
+
+repack-stage: repack-stage-all
+	grep -v 'locale \w\+ en-US' $(L10N_TARGET)/chrome.manifest > $(L10N_TARGET)/chrome.manifest~ && \
+	  mv $(L10N_TARGET)/chrome.manifest~ $(L10N_TARGET)/chrome.manifest
+	find $(call core_abspath,$(L10N_TARGET)) -name '*en-US*' -print0 | xargs -0 rm -rf
+
+repack-stage-all: $(XPI_STAGE_PATH)/$(XPI_NAME)
+	@echo "Repackaging $(XPI_PKGNAME) locale for Language $(AB_CD)"
+	$(RM) -rf $(L10N_TARGET)
+	cp -R $(XPI_STAGE_PATH)/$(XPI_NAME) $(L10N_TARGET)
+
+# Repack the existing lightning to contain all locales in lightning-all.xpi
+langpack-all: AB_CD=all
+langpack-all: L10N_XPI_NAME=$(XPI_NAME)-all
+langpack-all: L10N_XPI_PKGNAME=$(subst .$(AB_CD),,$(XPI_PKGNAME))
+langpack-all: recreate-platformini repack-stage-all $(addprefix libs-,$(call apposlocales,calendar))
+	@echo "Done packaging"
 
 # Actual locale packaging targets. If L10N_XPI_NAME is set, then use it.
 # Otherwise keep the original XPI_NAME
 # Overriding the final target is a bit of a hack for universal builds
 # so that we can ensure we get the right xpi that gets repacked.
-# The ../ is added to dist because calendar/lightning/locales is at a different level
-# to this makefile.
 libs-%: FINAL_XPI_NAME=$(if $(L10N_XPI_NAME),$(L10N_XPI_NAME),$(XPI_NAME))
+libs-%: FINAL_XPI_PKGNAME=$(if $(L10N_XPI_PKGNAME),$(L10N_XPI_PKGNAME),$(XPI_PKGNAME))
 libs-%:
-	$(MAKE) -C locales libs AB_CD=$* FINAL_TARGET=$(_ABS_DIST)/$(UNIVERSAL_PATH)xpi-stage/$(FINAL_XPI_NAME) XPI_NAME=$(FINAL_XPI_NAME) XPI_PKGNAME=$(FINAL_XPI_NAME) USE_EXTENSION_MANIFEST=1
-	$(MAKE) -C ../locales libs AB_CD=$* FINAL_TARGET=$(_ABS_DIST)/$(UNIVERSAL_PATH)xpi-stage/$(FINAL_XPI_NAME) XPI_NAME=$(FINAL_XPI_NAME) XPI_PKGNAME=$(FINAL_XPI_NAME) USE_EXTENSION_MANIFEST=1
+	$(MAKE) -C locales libs AB_CD=$* FINAL_TARGET=$(_ABS_DIST)/$(UNIVERSAL_PATH)xpi-stage/$(FINAL_XPI_NAME) \
+	  XPI_NAME=$(FINAL_XPI_NAME) XPI_PKGNAME=$(FINAL_XPI_PKGNAME) USE_EXTENSION_MANIFEST=1
 
-# For localized xpis, the install.rdf and lightning-l10n.js need to be
-# reprocessed with some defines from the locale.
+# For localized xpis, the install.rdf need to be reprocessed with some defines
+# from the locale.
 repack-process-extrafiles: LOCALE_BASEDIR=$(call EXPAND_LOCALE_SRCDIR,calendar/locales)
 repack-process-extrafiles:
-	$(PYTHON) $(MOZILLA_SRCDIR)/config/Preprocessor.py $(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) -I $(LOCALE_BASEDIR)/defines.inc $(srcdir)/install.rdf > $(DIST)/$(UNIVERSAL_PATH)xpi-stage/$(L10N_XPI_NAME)/install.rdf
-	$(PYTHON) $(MOZILLA_SRCDIR)/config/Preprocessor.py $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $(LOCALE_BASEDIR)/lightning-l10n.js  > $(DIST)/$(UNIVERSAL_PATH)xpi-stage/$(L10N_XPI_NAME)/$(PREF_DIR)/lightning-l10n.js
+	$(PYTHON) $(MOZILLA_SRCDIR)/config/Preprocessor.py \
+	  $(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
+	  -I $(LOCALE_BASEDIR)/defines.inc \
+	  $(srcdir)/install.rdf > $(XPI_STAGE_PATH)/$(L10N_XPI_NAME)/install.rdf
 
-# When repackaging lightning from the builder, platform.ini is not yet created.i
+# When repackaging Lightning from the builder, platform.ini is not yet created.
 # Recreate it from the application.ini bundled with the downloaded xpi.
 $(LIBXUL_DIST)/bin/platform.ini:
 	 echo "[Build]" >> $(LIBXUL_DIST)/bin/platform.ini
-	 
-	 echo -n "Milestone=" >> $(LIBXUL_DIST)/bin/platform.ini
-	 $(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py $(DIST)/$(UNIVERSAL_PATH)xpi-stage/$(XPI_NAME)/application.ini Gecko MaxVersion >> $(LIBXUL_DIST)/bin/platform.ini
-	 
-	 echo -n "SourceStamp=" >> $(LIBXUL_DIST)/bin/platform.ini
-	 $(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py $(DIST)/$(UNIVERSAL_PATH)xpi-stage/$(XPI_NAME)/application.ini Build SourceStamp >> $(LIBXUL_DIST)/bin/platform.ini
-	 
-	 echo -n "SourceRepository=" >> $(LIBXUL_DIST)/bin/platform.ini
-	 $(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py $(DIST)/$(UNIVERSAL_PATH)xpi-stage/$(XPI_NAME)/application.ini Build SourceRepository >> $(LIBXUL_DIST)/bin/platform.ini
-	 
-	 echo -n "BuildID=" >> $(LIBXUL_DIST)/bin/platform.ini
-	 $(PYTHON) $(MOZILLA_SRCDIR)/config/printconfigsetting.py $(DIST)/$(UNIVERSAL_PATH)xpi-stage/$(XPI_NAME)/application.ini App BuildID >> $(LIBXUL_DIST)/bin/platform.ini
+	 echo "Milestone=$(call print_ltnconfig,Gecko,MaxVersion)" >> $(LIBXUL_DIST)/bin/platform.ini
+	 echo "SourceStamp=$(call print_ltnconfig,Build,SourceStamp)" >> $(LIBXUL_DIST)/bin/platform.ini
+	 echo "SourceRepository=$(call print_ltnconfig,Build,SourceRepository)" >> $(LIBXUL_DIST)/bin/platform.ini
+	 echo "BuildID=$(call print_ltnconfig,App,BuildID)" >> $(LIBXUL_DIST)/bin/platform.ini
 
 recreate-platformini: $(LIBXUL_DIST)/bin/platform.ini
 
-stage_upload:
-	$(NSINSTALL) -D $(DIST)/$(MOZ_PKG_PLATFORM)
-	$(INSTALL) $(IFLAGS1) $(DIST)/$(UNIVERSAL_PATH)/xpi-stage/$(XPI_PKGNAME).xpi $(DIST)/$(MOZ_PKG_PLATFORM)
-	$(INSTALL) $(IFLAGS1) $(DIST)/xpi-stage/$(GDATA_XPI_PKGNAME).xpi $(DIST)/$(MOZ_PKG_PLATFORM)
 
 # Lightning uses Thunderbird's build machinery, so we need to hack the post
-# upload command to use Lightning's directories.
-upload: POST_UPLOAD_CMD := $(subst thunderbird,calendar/lightning,$(POST_UPLOAD_CMD))
-upload: stage_upload
-	POST_UPLOAD_CMD="$(POST_UPLOAD_CMD)" \
+# upload command to use Lightning's directories and version.
+upload: upload-$(AB_CD)
+upload-%: LTN_UPLOAD_CMD := $(patsubst $(THUNDERBIRD_VERSION)%,$(XPI_VERSION),$(subst thunderbird,calendar/lightning,$(POST_UPLOAD_CMD)))
+upload-%: stage_upload
+	POST_UPLOAD_CMD="$(LTN_UPLOAD_CMD)" \
 	  $(PYTHON) $(MOZILLA_DIR)/build/upload.py --base-path $(DIST) \
-	  $(DIST)/$(MOZ_PKG_PLATFORM)/$(XPI_PKGNAME).xpi \
-	  $(DIST)/$(MOZ_PKG_PLATFORM)/$(GDATA_XPI_PKGNAME).xpi
+	  "$(DIST)/$(MOZ_PKG_PLATFORM)/$(XPI_PKGNAME).xpi"
+
+stage_upload:
+	$(NSINSTALL) -D $(DIST)/$(MOZ_PKG_PLATFORM)
+	$(call install_cmd,$(IFLAGS1) $(XPI_STAGE_PATH)/$(XPI_PKGNAME).xpi $(DIST)/$(MOZ_PKG_PLATFORM))
--- a/calendar/lightning/lightning-symbols.mk
+++ b/calendar/lightning/lightning-symbols.mk
@@ -5,18 +5,16 @@
 ###################################
 # Warning this code is copied
 # from mozilla-central/Makefile.in
 # and needs to be kept in sync.
 ###################################
 SYMBOL_INDEX_NAME = \
    $(MOZ_APP_NAME)-$(MOZ_APP_VERSION)-$(OS_TARGET)-$(BUILDID)$(EXTRA_BUILDID)-symbols.txt
 
-include $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/package-name.mk
-
 ifeq ($(OS_ARCH),WINNT)
 # we want to copy PDB files on Windows
 MAKE_SYM_STORE_ARGS := -c --vcs-info
 ifdef PDBSTR_PATH
 MAKE_SYM_STORE_ARGS += -i
 endif
 DUMP_SYMS_BIN ?= $(MOZILLA_SRCDIR)/toolkit/crashreporter/tools/win32/dump_syms_vc$(_MSC_VER).exe
 # PDB files don't get moved to dist, so we need to scan the whole objdir
--- a/calendar/lightning/locales/moz.build
+++ b/calendar/lightning/locales/moz.build
@@ -1,4 +1,6 @@
 # vim: set filetype=python:
 # 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/.
+
+DIRS += ['../../locales']
--- a/calendar/lightning/moz.build
+++ b/calendar/lightning/moz.build
@@ -1,16 +1,15 @@
 # vim: set filetype=python:
 # 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/.
 
 DIRS += [
     '../libical',
-    '../locales',
     '../base',
     '../providers',
     '../import-export',
     '../itip',
     'components',
     'locales',
 ]
 
--- a/calendar/locales/moz.build
+++ b/calendar/locales/moz.build
@@ -1,8 +1,4 @@
 # vim: set filetype=python:
 # 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/.
-
-if not CONFIG['AB_CD']:
-    DIRS += ['../timezones']
-
--- a/calendar/locales/shipped-locales
+++ b/calendar/locales/shipped-locales
@@ -1,13 +1,14 @@
 ca
 cs
 da
 de
 en-GB
+en-US
 es-AR
 es-ES
 et
 eu
 fi
 fr
 fy-NL
 ga-IE
--- a/calendar/providers/gdata/Makefile.in
+++ b/calendar/providers/gdata/Makefile.in
@@ -3,34 +3,33 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 DEPTH = @DEPTH@
 topsrcdir = @top_srcdir@
 srcdir = @srcdir@
 VPATH = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
-include $(MOZILLA_SRCDIR)/toolkit/mozapps/installer/package-name.mk
 
 export USE_EXTENSION_MANIFEST = 1
 export XPI_NAME = gdata-provider
 DIST_FILES = install.rdf
 XPI_PKGNAME = gdata-provider-$(GDATA_VERSION).$(AB_CD).$(MOZ_PKG_PLATFORM)
+XPI_VERSION = $(GDATA_VERSION)
+XPI_NO_UNIVERSAL = 1
 
 CALENDAR_VERSION := $(shell cat $(topsrcdir)/calendar/sunbird/config/version.txt)
 THUNDERBIRD_VERSION := $(shell cat $(topsrcdir)/mail/config/version.txt)
 SEAMONKEY_VERSION := $(shell cat $(topsrcdir)/suite/config/version.txt)
 GDATA_VERSION = $(shell $(PYTHON) $(srcdir)/makeversion.py $(CALENDAR_VERSION))
 
 DEFINES += -DAB_CD=$(AB_CD) \
            -DCALENDAR_VERSION=$(CALENDAR_VERSION) \
            -DSEAMONKEY_VERSION=$(SEAMONKEY_VERSION) \
            -DTHUNDERBIRD_VERSION=$(THUNDERBIRD_VERSION) \
            -DCOMM_BUILD=$(COMM_BUILD) \
            -DGDATA_VERSION=$(GDATA_VERSION) \
            $(NULL)
 
 PREF_JS_EXPORTS = $(srcdir)/defaults/preferences.js
 
-libs-%:
-	$(MAKE) -C locales libs AB_CD=$* XPI_NAME=$(XPI_NAME) USE_EXTENSION_MANIFEST=1
-
 include $(topsrcdir)/config/rules.mk
+include $(topsrcdir)/calendar/lightning/lightning-packager.mk
--- a/mail/build.mk
+++ b/mail/build.mk
@@ -25,16 +25,17 @@ install::
 
 source-package::
 	@$(MAKE) -C mail/installer source-package
 
 upload::
 	@$(MAKE) -C mail/installer upload
 ifdef MOZ_CALENDAR
 	@$(MAKE) -C calendar/lightning upload
+	@$(MAKE) -C calendar/providers/gdata upload
 endif
 
 source-upload::
 	@$(MAKE) -C mail/installer source-upload
 
 hg-bundle::
 	@$(MAKE) -C mail/installer hg-bundle
 
--- a/mail/config/mozconfigs/linux32/l10n-mozconfig
+++ b/mail/config/mozconfigs/linux32/l10n-mozconfig
@@ -1,14 +1,17 @@
 ac_add_options --enable-application=mail
 ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}
 ac_add_options --enable-update-packaging
 ac_add_options --enable-codesighs
 ac_add_options --with-l10n-base=../../l10n
 
+# Build lightning locales
+ac_add_options --enable-calendar
+
 # Temporary options until bug 794378 is fixed
 ac_add_options --enable-gnomevfs
 ac_add_options --disable-gio
 
 . $topsrcdir/build/unix/mozconfig.linux
 
 # Avoid dependency on libstdc++ 4.5
 ac_add_options --enable-stdcxx-compat
--- a/mail/config/mozconfigs/linux64/l10n-mozconfig
+++ b/mail/config/mozconfigs/linux64/l10n-mozconfig
@@ -1,14 +1,17 @@
 ac_add_options --enable-application=mail
 ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}
 ac_add_options --enable-update-packaging
 ac_add_options --enable-codesighs
 ac_add_options --with-l10n-base=../../l10n
 
+# Build lightning locales
+ac_add_options --enable-calendar
+
 # Temporary options until bug 794378 is fixed
 ac_add_options --enable-gnomevfs
 ac_add_options --disable-gio
 
 . $topsrcdir/build/unix/mozconfig.linux
 
 # Avoid dependency on libstdc++ 4.5
 ac_add_options --enable-stdcxx-compat
--- a/mail/config/mozconfigs/macosx-universal/l10n-mozconfig
+++ b/mail/config/mozconfigs/macosx-universal/l10n-mozconfig
@@ -12,18 +12,19 @@ fi
 # Universal builds override the default of mail (bug 575283 comment 29)
 ac_add_options --enable-application=mail
 ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}
 ac_add_options --enable-update-packaging
 ac_add_options --enable-codesighs
 ac_add_options --disable-install-strip
 ac_add_options --with-l10n-base=../../../l10n
 
-# Make sure Lightning is also unified
-#mk_add_options MOZ_POSTFLIGHT_ALL+=calendar/lightning/build/universal.mk
+# Build lightning locales
+ac_add_options --enable-calendar
+mk_add_options MOZ_POSTFLIGHT_ALL+=calendar/lightning/build/universal.mk
 
 # For NSS symbols
 export MOZ_DEBUG_SYMBOLS=1
 
 # Needed to enable breakpad in application.ini
 export MOZILLA_OFFICIAL=1
 
 # Enable parallel compiling
--- a/mail/config/mozconfigs/win32/l10n-mozconfig
+++ b/mail/config/mozconfigs/win32/l10n-mozconfig
@@ -1,16 +1,19 @@
 . "$topsrcdir/build/mozconfig.common"
 
 ac_add_options --enable-application=mail
 ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}
 ac_add_options --enable-update-packaging
 ac_add_options --enable-jemalloc
 ac_add_options --with-l10n-base=../../l10n
 
+# Build lightning locales
+ac_add_options --enable-calendar
+
 # For NSS symbols
 export MOZ_DEBUG_SYMBOLS=1
 
 # Needed to enable breakpad in application.ini
 export MOZILLA_OFFICIAL=1
 
 if test -n "${_PYMAKE}"; then
   mk_add_options MOZ_MAKE_FLAGS=-j4
--- a/mail/config/mozconfigs/win64/l10n-mozconfig
+++ b/mail/config/mozconfigs/win64/l10n-mozconfig
@@ -3,16 +3,19 @@
 ac_add_options --target=x86_64-pc-mingw32
 ac_add_options --host=x86_64-pc-mingw32
 
 ac_add_options --enable-application=mail
 ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}
 ac_add_options --enable-update-packaging
 ac_add_options --enable-jemalloc
 
+# Build lightning locales
+ac_add_options --enable-calendar
+
 # Needed to enable breakpad in application.ini
 export MOZILLA_OFFICIAL=1
 
 if test -n "${_PYMAKE}"; then
   mk_add_options MOZ_MAKE_FLAGS=-j4
 else
   mk_add_options MOZ_MAKE_FLAGS=-j1
 fi
--- a/mail/locales/Makefile.in
+++ b/mail/locales/Makefile.in
@@ -123,23 +123,16 @@ clobber-zip:
 	$(RM) -rf $(STAGEDIST)/searchplugins \
 	  $(STAGEDIST)/dictionaries \
 	  $(STAGEDIST)/hyphenation/$(AB_CD) \
 	  $(STAGEDIST)/isp/$(AB_CD) \
 	  $(STAGEDIST)/chrome/$(AB_CD)
 
 langpack: langpack-$(AB_CD)
 
-# This is a generic target that will make a langpack, repack ZIP (+tarball)
-# builds, and repack and installer if applicable. It is called from the
-# tinderbox scripts. Alter it with caution.
-
-installers-%: clobber-% langpack-% repackage-win32-installer-% repackage-zip-%
-	@echo "repackaging done"
-
 ifdef MOZ_UPDATER
 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
@@ -196,8 +189,43 @@ endif
 	chmod -vR 775 $(UPLOAD_DIR)
 
 merge-%:
 ifdef LOCALE_MERGEDIR
 	$(RM) -rf $(LOCALE_MERGEDIR)
 	MACOSX_DEPLOYMENT_TARGET= compare-locales -m $(LOCALE_MERGEDIR) $(srcdir)/l10n.ini $(L10NBASEDIR) $*
 endif
 	@echo
+
+ifdef MOZ_CALENDAR
+LIGHTNING_PATH=$(DEPTH)/calendar/lightning
+GDATA_PATH=$(DEPTH)/calendar/providers/gdata
+
+# Define hooks for forwarding targets
+INSTALLERS_TARGETS += calendar-clobber-% calendar-langpack-% calendar-repackage-zip-%
+FORWARD_TARGETS=wget-en-US unpack
+FORWARD_PATTERN_TARGETS=clobber-% langpack-% repackage-zip-%
+
+# Add calendar targets to the non-pattern rules
+wget-en-US: calendar-wget-en-US
+unpack: calendar-unpack
+upload: calendar-upload
+
+# And finally, define the calendar targets
+$(addprefix calendar-,$(FORWARD_TARGETS)):
+	$(MAKE) -C $(LIGHTNING_PATH) $(subst calendar-,,$@)
+	# TODO temporarily disable gdata since it wasn't built $(MAKE) -C $(GDATA_PATH) $(subst calendar-,,$@)
+
+$(addprefix calendar-,$(FORWARD_PATTERN_TARGETS)):
+	$(MAKE) -C $(LIGHTNING_PATH) $(subst calendar-,,$@)
+	# TODO temporarily disable gdata since it wasn't built $(MAKE) -C $(GDATA_PATH) $(subst calendar-,,$@)
+
+calendar-upload:
+	$(MAKE) -C $(LIGHTNING_PATH) upload AB_CD=$(AB_CD)
+	# TODO temporarily disable gdata since it wasn't built $(MAKE) -C $(GDATA_PATH) upload AB_CD=$(AB_CD)
+endif
+
+# This is a generic target that will make a langpack, repack ZIP (+tarball)
+# builds, and repack and installer if applicable. It is called from the
+# tinderbox scripts. Alter it with caution.
+INSTALLERS_TARGETS += clobber-% langpack-% repackage-win32-installer-% repackage-zip-%
+installers-%: $(INSTALLERS_TARGETS)
+	@echo "repackaging done"