diff options
-rwxr-xr-x | src/dh_xul-ext | 105 |
1 files changed, 72 insertions, 33 deletions
diff --git a/src/dh_xul-ext b/src/dh_xul-ext index 58aa8d5..505c500 100755 --- a/src/dh_xul-ext +++ b/src/dh_xul-ext @@ -1,24 +1,18 @@ #!/usr/bin/python -# Copyright (c) 2009 Benjamin Drung <bdrung@ubuntu.com> +# Copyright (c) 2009-2010, Benjamin Drung <bdrung@ubuntu.com> # -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. # -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. import csv import glob @@ -27,7 +21,7 @@ import os import subprocess import sys -from moz_version import compare_versions +from moz_version import compare_versions, convert_moz_to_debian_version import RDF @@ -35,13 +29,54 @@ import RDF COMMAND_LINE_SYNTAX_ERROR = 1 MULTIPLE_INSTALL_RDFs = 2 +class XulApp(object): + def __init__(self, xul_id, package, sol, eol): + self.xul_id = xul_id + self.package = package + self.sol = sol + self.eol = eol + self.min_version = None + self.max_version = None + + def __str__(self): + return self.xul_id + ": " + self.package + " (" + self.sol + " to " + \ + self.eol + ")" + + def get_eol(self): + return self.eol + + def get_id(self): + return self.xul_id + + def get_package(self): + return self.package + + def get_sol(self): + return self.sol + + def get_versioned_package(self): + versioned_package = self.package + if self.min_version: + versioned_package += " (>= " + convert_moz_to_debian_version(self.min_version) + ")" + return versioned_package + + def set_max_version(self, max_version): + if compare_versions(self.eol, max_version) > 0: + self.max_version = max_version + + def set_min_version(self, min_version): + if compare_versions(self.sol, min_version) < 0: + self.min_version = min_version + + def get_xul_apps(): csvfile = open("/usr/share/mozilla-devscripts/xul-app-data.csv") csv_reader = csv.DictReader(csvfile) - rows = [] + xul_apps = [] for row in csv_reader: - rows.append(row) - return rows + xul_app = XulApp(row["id"], row["package"], row["sol"], row["eol"]) + xul_apps.append(xul_app) + return xul_apps def get_supported_apps(script_name, xul_apps, install_rdf, package, verbose=False): # create array of id_max_min triples @@ -77,22 +112,24 @@ def get_supported_apps(script_name, xul_apps, install_rdf, package, verbose=Fals # find supported apps/packages supported_apps = list() for xul_app in xul_apps: - supported_app = filter(lambda x: x[0] == xul_app["id"], id_max_min) + supported_app = filter(lambda x: x[0] == xul_app.get_id(), id_max_min) if len(supported_app) == 1: # package is supported by extension (appid, max_version, min_version) = supported_app.pop() - if compare_versions(xul_app["sol"], max_version) <= 0: - if compare_versions(xul_app["eol"], min_version) >= 0: - supported_apps.append(xul_app["package"]) + if compare_versions(xul_app.get_sol(), max_version) <= 0: + if compare_versions(xul_app.get_eol(), min_version) >= 0: + xul_app.set_min_version(min_version) + xul_app.set_max_version(max_version) + supported_apps.append(xul_app) if verbose: - print "%s: %s supports %s." % (script_name, package, xul_app["package"]) + print "%s: %s supports %s." % (script_name, package, xul_app.get_package()) elif verbose: - print "%s: %s does not support %s (any more)." % (script_name, package, xul_app["package"]) + print "%s: %s does not support %s (any more)." % (script_name, package, xul_app.get_package()) elif verbose: - print "%s: %s does not support %s (yet)." % (script_name, package, xul_app["package"]) + print "%s: %s does not support %s (yet)." % (script_name, package, xul_app.get_package()) elif len(supported_app) > 1: print "%s: Found error in %s. There are multiple entries for application ID %s." % \ - (script_name, install_rdf, xul_app["id"]) + (script_name, install_rdf, xul_app.get_id()) return supported_apps @@ -129,7 +166,8 @@ def get_provided_package_names(package, supported_apps): if ext_name == get_source_package_name(): provides.add(ext_name) - for app in supported_apps: + for xul_app in supported_apps: + app = xul_app.get_package() for i in xrange(len(app) - 1, -1, -1): if app[i] == '-': app = app[:i] @@ -176,10 +214,11 @@ def generate_substvars(script_name, xul_apps, package, verbose=False): # remove existing varibles lines = filter(lambda s: not s.startswith("xpi:"), lines) - packages = get_supported_apps(script_name, xul_apps, install_rdf, package, verbose) + supported_apps = get_supported_apps(script_name, xul_apps, install_rdf, package, verbose) + packages = map(lambda a: a.get_package(), supported_apps) lines.append("xpi:Recommends=" + " | ".join(packages) + "\n") lines.append("xpi:Enhances=" + ", ".join(sorted(packages)) + "\n") - packages = get_provided_package_names(package, packages) + packages = get_provided_package_names(package, supported_apps) lines.append("xpi:Provides=" + ", ".join(sorted(packages)) + "\n") # write new variables @@ -235,7 +274,7 @@ if __name__ == "__main__": if options.verbose and len(xul_apps) > 0: print script_name + ": found %i Xul applications:" % (len(xul_apps)) for xul_app in xul_apps: - print xul_app["id"] + ": " + xul_app["package"] + " (" + xul_app["sol"] + " to " + xul_app["eol"] + ")" + print xul_app for package in options.packages: generate_substvars(script_name, xul_apps, package, options.verbose) |