From 715d764a4a9b8ac2f1dd8d626d100bb21cbdb9f6 Mon Sep 17 00:00:00 2001 From: Benjamin Drung Date: Sat, 16 Jul 2011 18:52:18 +0200 Subject: Add a DH_XUL_EXT_VENDOR environment variable to dh_xul-ext. --- debian/changelog | 5 +-- man/dh_xul-ext.1 | 10 ++++++ src/dh_xul-ext | 28 +++++++++++---- tests/dh_xul-ext/all_environment/debian/changelog | 5 +++ tests/dh_xul-ext/all_environment/debian/compat | 1 + tests/dh_xul-ext/all_environment/debian/control | 17 +++++++++ tests/dh_xul-ext/all_environment/debian/rules | 8 +++++ tests/dh_xul-ext/all_environment/install.rdf | 40 ++++++++++++++++++++++ .../expected_result/all_environment.substvars | 4 +++ tests/dh_xul-ext/test | 2 +- tests/dh_xul-ext/ubuntu/debian/rules | 2 +- 11 files changed, 112 insertions(+), 10 deletions(-) create mode 100644 tests/dh_xul-ext/all_environment/debian/changelog create mode 100644 tests/dh_xul-ext/all_environment/debian/compat create mode 100644 tests/dh_xul-ext/all_environment/debian/control create mode 100755 tests/dh_xul-ext/all_environment/debian/rules create mode 100644 tests/dh_xul-ext/all_environment/install.rdf create mode 100644 tests/dh_xul-ext/expected_result/all_environment.substvars diff --git a/debian/changelog b/debian/changelog index f442ee6..02f3166 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,8 +3,9 @@ mozilla-devscripts (0.27) UNRELEASED; urgency=low * Update package lists for Debian unstable and Ubuntu oneiric. * Add a MOZ_XPI_CLEAN_COMMAND to xpi.mk; thanks to Ximin Luo for the patch (Closes: #632895). - * Add an --all parameter to dh_xul-ext to make packages that work with every - browser they can actually work with (Closes: #610499). + * Add an --all parameter and a DH_XUL_EXT_VENDOR environment variable to + dh_xul-ext to make packages that work with every browser they can actually + work with (Closes: #610499). * Update and fix my email addresses. -- Benjamin Drung Sat, 09 Jul 2011 11:07:58 +0200 diff --git a/man/dh_xul-ext.1 b/man/dh_xul-ext.1 index c90ea6f..bf90200 100644 --- a/man/dh_xul-ext.1 +++ b/man/dh_xul-ext.1 @@ -46,5 +46,15 @@ provided, all package listed in the control file will be processed. .TP \fB\-v\fR, \fB\-\-verbose\fR Print more information. +.SH ENVIRONMENT +.TP +.BR DH_XUL_EXT_VENDOR +The vendor (for example, \fBDebian\fR or \fBUbuntu\fR) that should be used for +calculating the dependencies. +.BR dpkg\-vendor (1) +will be used for determining the vendor if this environment variable is not set. +Setting the variable to \fBall\fR will have the same effect than calling +.BR dh_xul\-ext +with \fB\-\-all\fR. .SH AUTHOR Benjamin Drung diff --git a/src/dh_xul-ext b/src/dh_xul-ext index 26bc0d5..3abaa8c 100755 --- a/src/dh_xul-ext +++ b/src/dh_xul-ext @@ -25,6 +25,7 @@ from moz_version import compare_versions, convert_moz_to_debian_version import RDF +_VENDOR_ENV = "DH_XUL_EXT_VENDOR" # error codes COMMAND_LINE_SYNTAX_ERROR = 1 MULTIPLE_INSTALL_RDFS = 2 @@ -87,15 +88,30 @@ def _get_data_dir(): data_dir = os.path.dirname(__file__) return data_dir -def get_xul_apps(all_distros): - data_dir = _get_data_dir() - if all_distros: - csv_filenames = glob.glob(os.path.join(data_dir, "xul-app-data.csv.*")) +def get_vendor(): + """This function returns the vendor (e.g. Debian, Ubuntu) that should be + used for calculating the dependencies. DH_XUL_EXT_VENDOR will be used + if set. Otherwise dpkg-vendor will be used for determining the vendor.""" + if _VENDOR_ENV in os.environ: + vendor = os.environ[_VENDOR_ENV] else: cmd = ["dpkg-vendor", "--query", "Vendor"] process = subprocess.Popen(cmd, stdout=subprocess.PIPE) vendor = process.communicate()[0].strip() - csv_filenames = [os.path.join(data_dir, "xul-app-data.csv." + vendor)] + return vendor + +def get_xul_apps(script_name, all_distros): + vendor = get_vendor() + data_dir = _get_data_dir() + if all_distros or vendor == "all": + csv_filenames = glob.glob(os.path.join(data_dir, "xul-app-data.csv.*")) + else: + csv_filename = os.path.join(data_dir, "xul-app-data.csv." + vendor) + if not os.path.isfile(csv_filename): + print >> sys.stderr, ('%s: Unknown vendor "%s" specified.' % + (script_name, vendor)) + sys.exit(1) + csv_filenames = [csv_filename] xul_apps = [] for csv_filename in csv_filenames: @@ -337,7 +353,7 @@ def main(): (script_name, unknown_option)) print script_name + ": packages:", ", ".join(options.packages) - xul_apps = get_xul_apps(options.all) + xul_apps = get_xul_apps(script_name, options.all) if options.verbose and len(xul_apps) > 0: print script_name + ": found %i Xul applications:" % (len(xul_apps)) for xul_app in xul_apps: diff --git a/tests/dh_xul-ext/all_environment/debian/changelog b/tests/dh_xul-ext/all_environment/debian/changelog new file mode 100644 index 0000000..1b45ee9 --- /dev/null +++ b/tests/dh_xul-ext/all_environment/debian/changelog @@ -0,0 +1,5 @@ +test-package (1.0-1) UNRELEASED; urgency=low + + * Initial release. + + -- Benjamin Drung Sat, 09 Jul 2011 12:55:23 +0200 diff --git a/tests/dh_xul-ext/all_environment/debian/compat b/tests/dh_xul-ext/all_environment/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/tests/dh_xul-ext/all_environment/debian/compat @@ -0,0 +1 @@ +7 diff --git a/tests/dh_xul-ext/all_environment/debian/control b/tests/dh_xul-ext/all_environment/debian/control new file mode 100644 index 0000000..346ceba --- /dev/null +++ b/tests/dh_xul-ext/all_environment/debian/control @@ -0,0 +1,17 @@ +Source: test-package +Section: web +Priority: extra +Maintainer: Ubuntu Mozilla Team +Build-Depends: debhelper (>= 7.0.50~), mozilla-devscripts (>= 0.22~) +Standards-Version: 3.9.2 + +Package: xul-ext-test-package +Architecture: all +Depends: ${misc:Depends}, ${xpi:Depends} +Recommends: ${xpi:Recommends} +Provides: ${xpi:Provides} +Enhances: ${xpi:Enhances} +Description: mozilla-devscripts test package + This is a test package designed to test some scripts in mozilla-devscripts. + It is part of the mozilla-devscripts test suite and may do very odd things. It + should not be installed like a regular package. It may be an empty package. diff --git a/tests/dh_xul-ext/all_environment/debian/rules b/tests/dh_xul-ext/all_environment/debian/rules new file mode 100755 index 0000000..e1630ab --- /dev/null +++ b/tests/dh_xul-ext/all_environment/debian/rules @@ -0,0 +1,8 @@ +#!/usr/bin/make -f + +%: + dh $@ + +override_dh_install: + dh_install install.rdf /usr/share/xul-ext/test-package/ + DH_XUL_EXT_VENDOR=all ../../../src/dh_xul-ext diff --git a/tests/dh_xul-ext/all_environment/install.rdf b/tests/dh_xul-ext/all_environment/install.rdf new file mode 100644 index 0000000..773eaa0 --- /dev/null +++ b/tests/dh_xul-ext/all_environment/install.rdf @@ -0,0 +1,40 @@ + + + + {deadda7a-fee1-dead-coo1-d00ddeadc0de} + 1.0 + mozilla-devscripts test package + + + + {ec8030f7-c20a-464f-9b0e-13a3a9e97384} + 3.5 + 7.0a1 + + + + + + {3550f703-e582-4d05-9a08-453d09bdfdc6} + 3.0 + 7.0a1 + + + + + + {92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a} + 2.0 + 2.4a1 + + + + + + {a79fe89b-6662-4ff4-8e88-09950ad4dfde} + 0.1 + 100.0 + + + + diff --git a/tests/dh_xul-ext/expected_result/all_environment.substvars b/tests/dh_xul-ext/expected_result/all_environment.substvars new file mode 100644 index 0000000..0b86163 --- /dev/null +++ b/tests/dh_xul-ext/expected_result/all_environment.substvars @@ -0,0 +1,4 @@ +xpi:Depends=iceweasel (>= 3.5) | icedove (>= 3.0) | iceape (>= 2.0) | conkeror | firefox | thunderbird (>= 3.0) | seamonkey (>= 2.0) +xpi:Recommends= +xpi:Enhances=conkeror, firefox, iceape, icedove, iceweasel, seamonkey, thunderbird +xpi:Provides=conkeror-test-package, firefox-test-package, iceape-test-package, icedove-test-package, iceweasel-test-package, seamonkey-test-package, test-package, thunderbird-test-package diff --git a/tests/dh_xul-ext/test b/tests/dh_xul-ext/test index 9936ca6..7da0433 100755 --- a/tests/dh_xul-ext/test +++ b/tests/dh_xul-ext/test @@ -18,7 +18,7 @@ import os import sys import subprocess -TESTS = ("all", "debian", "ubuntu") +TESTS = ("all", "all_environment", "debian", "ubuntu") class TestError(Exception): pass diff --git a/tests/dh_xul-ext/ubuntu/debian/rules b/tests/dh_xul-ext/ubuntu/debian/rules index 0d70add..8893f54 100755 --- a/tests/dh_xul-ext/ubuntu/debian/rules +++ b/tests/dh_xul-ext/ubuntu/debian/rules @@ -5,4 +5,4 @@ override_dh_install: dh_install install.rdf /usr/share/xul-ext/test-package/ - DEB_VENDOR=Ubuntu ../../../src/dh_xul-ext + DH_XUL_EXT_VENDOR=Ubuntu ../../../src/dh_xul-ext -- cgit v1.2.3