summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog6
-rw-r--r--src/Makefile1
-rw-r--r--src/xpi.mk92
3 files changed, 99 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index f39d624..14cc2ff 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,12 @@ mozilla-devscripts (0.05) UNRELEASED; urgency=low
mozilla/memory to build
- update src/patches/xulbrowser_target.patch
+ [ Alexander Sack ]
+ * add initial xpi makefile helper that tries to make extension package
+ maintenance as trivial as possible
+ - add src/xpi.mk
+ - update src/Makefile
+
-- Fabien Tassin <fta@sofaraway.org> Fri, 15 Feb 2008 22:02:42 +0100
mozilla-devscripts (0.04) hardy; urgency=low
diff --git a/src/Makefile b/src/Makefile
index d41331d..b1a8434 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -31,6 +31,7 @@ mk_files = \
xulrunner-1.9.mk \
mozclient.mk \
compare.mk \
+ xpi.mk \
$(NULL)
extra_mk_files = \
diff --git a/src/xpi.mk b/src/xpi.mk
new file mode 100644
index 0000000..227c8f5
--- /dev/null
+++ b/src/xpi.mk
@@ -0,0 +1,92 @@
+# -*- 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.
+
+
+#
+# Usage: include this file in your cdbs debian/rules file and define the
+# following variables:
+#
+# MOZ_EXTENSION_PKG (MANDATORY):
+# define the binary package name used to ship this xpi
+#
+# MOZ_XPI_FILE (OPTIONAL):
+# if defined the given .xpi file is used; otherwise we try to
+# guess one using wildcard (*.xpi)
+#
+# MOZ_XPI_EMID (OPTIONAL):
+# if defined the given id is used to determine the link name
+# in the firefox extensions directory. if not defined we try
+# our best to extract the em:id from the install.rdf file shipped
+# by any xpi
+#
+
+TEMPDIR := $(shell rm -rf temp-xpi-*; mktemp -d temp-xpi-XXXXXXXX)
+
+ifneq (,$(MOZ_XPI_FILE))
+XPI_FILE = $(MOZ_XPI_FILE)
+else
+XPI_FILE = $(wildcard *.xpi)
+endif
+
+ifneq (,$(MOZ_XPI_EMID))
+XPI_EMID = $(MOZ_XPI_EMID)
+else
+XPI_EMID = $(shell xpath -e '/node()/Description/em:id/text()' $(1)/install.rdf 2>/dev/null)
+endif
+
+# cdbs hooks (TODO implement these)
+
+# general helper targets
+unzip-%:
+ unzip -d $(TEMPDIR) $*
+ touch $@
+
+install-%:
+ dh_installdirs -p$(MOZ_EXTENSION_PKG) /usr/lib/firefox-addons/extensions
+ dh_install -p$(MOZ_EXTENSION_PKG) $(wildcard $(TEMPDIR)/*) /usr/share/$(MOZ_EXTENSION_PKG)
+ dh_link -p$(MOZ_EXTENSION_PKG) /usr/share/$(MOZ_EXTENSION_PKG) /usr/lib/firefox-addons/extensions/$(call XPI_EMID,$(TEMPDIR))
+ touch $@
+
+stamp-extension-install: $(XPI_FILE) unzip-$(XPI_FILE) install-$(XPI_FILE)
+ touch stamp-extension-install
+
+
+# only attempt to do things if a pkg was provided; otherwise error out
+ifneq (,$(MOZ_EXTENSION_PKG))
+xpi-install: stamp-extension-install
+
+xpi-clean:
+ dh_clean -p$(MOZ_EXTENSION_PKG)
+ -rm -f stamp-extension-install \
+ unzip-* \
+ install-* \
+ $(NULL)
+ -rm -rf $(TEMPDIR)
+
+
+else
+xpi-install:
+ echo "*** need to define MOZ_EXTENSION_PKG"
+ exit 2
+
+xpi-clean:
+ echo "*** need to define MOZ_EXTENSION_PKG"
+ exit 2
+endif
+