summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Sack <asac@jwsdot.com>2008-02-29 01:20:59 +0100
committerAlexander Sack <asac@jwsdot.com>2008-02-29 01:20:59 +0100
commitbdb90b1ade0f22a009ac50a45eaa5bdbc117df9f (patch)
tree90a460673f0f3f04322c2f70fa24db8620e4b845 /src
parent4f78149299a1ef432b58f0d6f3231a21353fff68 (diff)
* introduce support to extract xpi translations from any build tree that
ships chrome.manifest indexed xul/xpi translations. This feature is ment to be hooked into install phase of then package build. - add src/lp-locale-export.mk * document in changelog - update debian/changelog
Diffstat (limited to 'src')
-rw-r--r--src/lp-locale-export.mk105
1 files changed, 105 insertions, 0 deletions
diff --git a/src/lp-locale-export.mk b/src/lp-locale-export.mk
new file mode 100644
index 0000000..f09aaf9
--- /dev/null
+++ b/src/lp-locale-export.mk
@@ -0,0 +1,105 @@
+#!/usr/bin/make -f
+# -*- mode: makefile; coding: utf-8 -*-
+
+# Copyright (c) 2008 Canonical Ltd.
+# Author(s): Alexander Sack <asac@ubuntu.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2, or (at
+# your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+# arguments: MOZ_TRANSLATION_TARGET_DIRS - application names that this xpi is suitable for
+# MOZ_TRANSLATION_TARGET_IDS - application IDS that this xpi can be hosted on
+# MOZ_TRANSLATION_TARGET_MAX_VERSION_$(ID) - max version for the target application with ID
+# MOZ_TRANSLATION_TARGET_MIN_VERSION_($ID) - min version for the target application with ID
+#
+# MOZ_TRANSLATION_AUTO_XPI_LOCALE - locales you want to generate xpis automatically for
+# MOZ_TRANSLATION_AUTO_XPI_SEARCHDIRS - directories you want to inspect for install manifests
+# and extract locale content from
+# MOZ_TRANSLATION_AUTO_XPI_OUTDIR
+#
+
+
+MOZ_TRANSLATION_AUTO_XPI_LOCALE ?= en-US
+MOZ_TRANSLATION_TARGET_IDS ?= {firefox-id}
+MOZ_TRANSLATION_TARGET_DIRS ?= firefox-addons
+#MOZ_TRANSLATION_TARGET_MAX_VERSION_{firefox-id} = 3.0.*
+#MOZ_TRANSLATION_TARGET_MIN_VERSION_{firefox-id} = 3.0b3
+
+# ---- define $(call ...) functions
+
+MOZCALL_all_manifests = \
+ $(shell \
+ find $(MOZ_TRANSLATION_AUTO_XPI_SEARCHDIRS) -name \*.manifest \
+ )
+
+MOZCALL_filter_manifest_locales_by_lang_to_norm = \
+ $(shell \
+ cat $(1) | grep "^locale " | grep " $(2) " >> $(3) \
+ )
+
+MOZCALL_manifest_locale_files_to_outdir = \
+ $(shell \
+ if test `grep -c ^locale $(1)` -gt 0; then \
+ tar -c -C `dirname $(1)`/ -f - \
+ `cat $(1) | \
+ grep "^locale " | \
+ grep " $(2) " | \
+ sed -e 's/^.* $(2) jar:\(.*\)!.*$$/\1/' \
+ ` | \
+ tar -C $(3) -x -f -; \
+ fi \
+ )
+
+
+# ---- define generic targets
+
+%.mkdir:
+ mkdir -p $*
+
+
+# create xpi in 3 steps:
+# 1. mkdir flat directory
+# 2. fill directory with locale files
+# 3. generate manifest
+
+$(MOZ_TRANSLATION_AUTO_XPI_OUTDIR)%.xpi: \
+ $(MOZ_TRANSLATION_AUTO_XPI_OUTDIR)%.xpi-flat.mkdir
+
+ # extract locale filenames from $$(MOZCALL_all_manifests) and
+ # move the files to $$(MOZCALL_manifest_locale_files_to_outdir)
+ $(foreach manifest,$(MOZCALL_all_manifests), \
+ $(call MOZCALL_manifest_locale_files_to_outdir, \
+ $(manifest),$*,$@-flat/))
+
+ # produce chrome.manifest for all locale entries
+ $(foreach manifest,$(MOZCALL_all_manifests), \
+ $(call MOZCALL_filter_manifest_locales_by_lang_to_norm, \
+ $(manifest),$*,$@-flat/chrome.manifest))
+
+ @sh -c "cd $@-flat/; zip -r ../$*.xpi ."
+
+
+# translate
+auto-locale-xpi.mk/translate : \
+ $(foreach l,$(MOZ_TRANSLATION_AUTO_XPI_LOCALE),$(MOZ_TRANSLATION_AUTO_XPI_OUTDIR)$(l).xpi)
+
+
+auto-locale-xpi.mk/clean:
+ rm -rf $(MOZ_TRANSLATION_AUTO_XPI_OUTDIR)*.xpi $(MOZ_TRANSLATION_AUTO_XPI_OUTDIR)*.xpi-flat
+
+
+# ---- hook in cdbs
+
+