diff options
author | Benjamin Drung <bdrung@ubuntu.com> | 2011-07-09 20:22:00 +0200 |
---|---|---|
committer | Benjamin Drung <bdrung@ubuntu.com> | 2011-07-09 20:22:00 +0200 |
commit | c5178d7b50957a9f54f9bed8a6d7ccf081798118 (patch) | |
tree | 5a69ef5711c18b80607bcec84bc52ead63934450 /src | |
parent | df58f3a3d891a494232d6e49a5a1862a557e8930 (diff) |
Add an --all parameter to dh_xul-ext to make packages that work with every
browser they can actually work with (Closes: #610499).
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 3 | ||||
-rwxr-xr-x | src/dh_xul-ext | 56 |
2 files changed, 50 insertions, 9 deletions
diff --git a/src/Makefile b/src/Makefile index 04a65ae..1c285d1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -79,7 +79,8 @@ install: $(subst_files) $(extra_files) $(foreach dir,$(extra_dirs),$(wildcard $( done find $(DESTDIR)$(DATADIR) -type f \( -name \*.pl -o -name \*.sh \) -exec chmod -v 755 {} \; chmod 755 $(DESTDIR)$(DATADIR)/minefield-packager.mk - install -m 644 xul-app-data.csv.$(VENDOR) $(DESTDIR)$(DATADIR)/xul-app-data.csv + install -m 644 xul-app-data.csv.Debian $(DESTDIR)$(DATADIR)/xul-app-data.csv.Debian + install -m 644 xul-app-data.csv.Ubuntu $(DESTDIR)$(DATADIR)/xul-app-data.csv.Ubuntu install -D -m 644 xul-ext.pm $(DESTDIR)$(PREFIX)/share/perl5/Debian/Debhelper/Sequence/xul_ext.pm install -D -m 644 xul-ext_build.pm $(DESTDIR)$(PREFIX)/share/perl5/Debian/Debhelper/Buildsystem/xul_ext.pm diff --git a/src/dh_xul-ext b/src/dh_xul-ext index 8413b3f..df9cb2b 100755 --- a/src/dh_xul-ext +++ b/src/dh_xul-ext @@ -15,8 +15,10 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. import csv +import glob import optparse import os +import subprocess import sys from moz_version import compare_versions, convert_moz_to_debian_version @@ -59,6 +61,9 @@ class XulApp(object): versioned_package += " (>= " + deb_min_version + ")" return versioned_package + def is_same_package(self, xul_app): + return self.xul_id == xul_app.xul_id and self.package == xul_app.package + def set_max_version(self, max_version): if compare_versions(self.eol, max_version) > 0: self.max_version = max_version @@ -67,14 +72,44 @@ class XulApp(object): if compare_versions(self.sol, min_version) < 0: self.min_version = min_version + def update_version(self, sol, eol): + if compare_versions(self.sol, sol) > 0: + self.sol = sol + if compare_versions(self.eol, eol) < 0: + self.eol = eol + + +def _get_data_dir(): + """Get the data directory based on the module location.""" + if __file__.startswith("/usr/bin"): + data_dir = "/usr/share/mozilla-devscripts" + else: + 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.*")) + 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)] -def get_xul_apps(): - csvfile = open("/usr/share/mozilla-devscripts/xul-app-data.csv") - csv_reader = csv.DictReader(csvfile) xul_apps = [] - for row in csv_reader: - xul_app = XulApp(row["id"], row["package"], row["sol"], row["eol"]) - xul_apps.append(xul_app) + for csv_filename in csv_filenames: + csvfile = open(csv_filename) + csv_reader = csv.DictReader(csvfile) + for row in csv_reader: + xul_app = XulApp(row["id"], row["package"], row["sol"], row["eol"]) + existing = [x for x in xul_apps if x.is_same_package(xul_app)] + if existing: + xul_app = existing[0] + xul_app.update_version(row["sol"], row["eol"]) + else: + xul_apps.append(xul_app) + return xul_apps def get_supported_apps(script_name, xul_apps, install_rdf, package, @@ -207,7 +242,9 @@ def find_install_rdfs(path): def generate_substvars(script_name, xul_apps, package, verbose=False): install_rdfs = find_install_rdfs("debian/" + package) if len(install_rdfs) == 0: - # this package does not contain a xul extension + if verbose: + print script_name + ": " + package + \ + " does not contain a XUL extension (no install.rdf found)." return elif len(install_rdfs) > 1: print >> sys.stderr, ("%s: %s contains multiple install.rdf files. " @@ -277,6 +314,9 @@ def main(): script_name = os.path.basename(sys.argv[0]) epilog = "See %s(1) for more info." % (script_name) parser = UnknownOptionIgnoringOptionParser(epilog=epilog) + parser.add_option("-a", "--all", action="store_true", dest="all", + help="expand substvars to all known XUL applications " + "(not only of your distribution)", default=False) parser.add_option("-p", "--package", dest="packages", metavar="PACKAGE", action="append", default=[], help="calculate substvars only for the specified PACKAGE") @@ -294,7 +334,7 @@ def main(): (script_name, unknown_option)) print script_name + ": packages:", ", ".join(options.packages) - xul_apps = get_xul_apps() + xul_apps = get_xul_apps(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: |