diff options
author | Benjamin Drung <bdrung@ubuntu.com> | 2009-12-30 00:58:00 +0100 |
---|---|---|
committer | Benjamin Drung <bdrung@ubuntu.com> | 2009-12-30 00:58:00 +0100 |
commit | ed6eede32a507daa779a1a0580681c3c7b333477 (patch) | |
tree | 050eae17a2ac6c903b0a87bc0406f2a624f90340 /src/dh_xul-ext | |
parent | 8bb55ed5ab94e24dcde7f6eb2b5d52234b23488b (diff) |
- Convert xpi-data-*.mk files into xul-app-data.csv* files for dh_xul-ext
- remove src/xpi-config.mk.in
- remove src/xpi-data-Debian.mk
- remove src/xpi-data-Ubuntu.mk
- remove src/xpi-data-all.mk
- remove src/xpi-data-common.mk
- add src/xul-app-data.csv.Debian
- add src/xul-app-data.csv.Ubuntu
- update src/Makefile
Diffstat (limited to 'src/dh_xul-ext')
-rwxr-xr-x | src/dh_xul-ext | 95 |
1 files changed, 29 insertions, 66 deletions
diff --git a/src/dh_xul-ext b/src/dh_xul-ext index c2a9980..39c10d8 100755 --- a/src/dh_xul-ext +++ b/src/dh_xul-ext @@ -20,13 +20,14 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. +import csv import getopt import glob import os import subprocess import sys -from moz_version import compare_versions, convert_debian_to_moz_version +from moz_version import compare_versions from rdflib import Namespace from rdflib.Graph import Graph @@ -36,53 +37,14 @@ COMMAND_LINE_SYNTAX_ERROR = 1 MULTIPLE_INSTALL_RDFs = 2 def get_xul_apps(): - # TODO: patch packages - return [("xulrunner-1.9", "", "toolkit@mozilla.org", "1.9.0.*"), - ("xulrunner-1.9.1", "1.9.1.5+nobinonly-0ubuntu0.9.10.1", "toolkit@mozilla.org", "1.9.1.*"), - ("firefox-3.6", "3.6~b1-0ubuntu1", "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}", "3.6.*"), - ("abrowser-3.6", "3.6~b1-0ubuntu1", "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}", "3.6.*"), - ("firefox-3.5", "3.5.3+build1+nobinonly-0ubuntu6", "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}", "3.5.*"), - ("abrowser-3.5", "3.5.3+build1+nobinonly-0ubuntu6", "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}", "3.5.*"), - ("firefox-3.0", "3.0.0.14", "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}", "3.0.*"), - ("thunderbird-3.0", "3.0-0ubuntu1", "{3550f703-e582-4d05-9a08-453d09bdfdc6}", "3.0.*"), - ("thunderbird", "2.0.0.14", "{3550f703-e582-4d05-9a08-453d09bdfdc6}", "2.*")] - packages = list() - for filename in glob.glob("/var/lib/apt/lists/*_Packages"): - with open(filename) as f: - package_name = None - version = None - xul_appid = None - xul_eol = "*" - for line in f: - if line == "\n": - if xul_appid is not None: - # find duplicates and keep older version - found_duplicate = False - for i in xrange(len(packages) - 1, -1, -1): - if packages[i][0] == package_name: - command = ['dpkg', '--compare-versions', version, 'lt', packages[i][1]] - if subprocess.call(command) == 0: - del packages[i] - else: - found_duplicate = True - break - if not found_duplicate: - packages.append([package_name, version, xul_appid, xul_eol]) - package_name = None - version = None - xul_appid = None - xul_eol = "*" - elif line.startswith("Package:"): - package_name = line[line.find(":")+1:].strip() - elif line.startswith("Version:"): - version = line[line.find(":")+1:].strip() - elif line.startswith("Xul-AppId"): - xul_appid = line[line.find(":")+1:].strip() - elif line.startswith("Xul-Eol"): - xul_eol = line[line.find(":")+1:].strip() - return sorted(packages) - -def get_supported_apps(xul_apps, install_rdf, package, verbose=False): + csvfile = open("/usr/share/mozilla-devscripts/xul-app-data.csv") + csv_reader = csv.DictReader(csvfile) + rows = [] + for row in csv_reader: + rows.append(row) + return rows + +def get_supported_apps(script_name, xul_apps, install_rdf, package, verbose=False): # create array of id_max_min triples id_max_min = [] rdf_graph = Graph() @@ -105,30 +67,29 @@ def get_supported_apps(xul_apps, install_rdf, package, verbose=False): id_max_min.append (( str(target[0]), str(target[1]), str (target[2]) )) if verbose: - print "%s: %i supported XUL applications:" % (sys.argv[0], len(id_max_min)) + print "%s: %s supports %i XUL application(s):" % (script_name, package, len(id_max_min)) for (appid, max_version, min_version) in id_max_min: print "%s %s to %s" % (appid, min_version, max_version) # find supported apps/packages supported_apps = list() - for (package_name, version, xul_appid, xul_eol) in xul_apps: - supported_app = filter(lambda x: x[0] == xul_appid, id_max_min) + for xul_app in xul_apps: + supported_app = filter(lambda x: x[0] == xul_app["id"], id_max_min) if len(supported_app) == 1: # package is supported by extension (appid, max_version, min_version) = supported_app.pop() - xul_sol = convert_debian_to_moz_version(version) - if compare_versions(xul_sol, max_version) <= 0: - if compare_versions(xul_eol, min_version) >= 0: - supported_apps.append(package_name) + 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 verbose: - print "%s: %s supports %s." % (sys.argv[0], package, package_name) + print "%s: %s supports %s." % (script_name, package, xul_app["package"]) elif verbose: - print "%s: %s does not support %s (any more)." % (sys.argv[0], package, package_name) + print "%s: %s does not support %s (any more)." % (script_name, package, xul_app["package"]) elif verbose: - print "%s: %s does not support %s (yet)." % (sys.argv[0], package, package_name) + print "%s: %s does not support %s (yet)." % (script_name, package, xul_app["package"]) elif len(supported_app) > 1: print "%s: Found error in %s. There are multiple entries for application ID %s." % \ - (sys.argv[0], install_rdf, xul_appid) + (script_name, install_rdf, xul_app["id"]) return supported_apps @@ -191,13 +152,13 @@ def find_install_rdfs(path): return install_rdfs -def generate_substvars(xul_apps, package, verbose=False): +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 return elif len(install_rdfs) > 1: - print >> sys.stderr, "%s: %s contains multiple install.rdf files. That's not supported." % (sys.argv[0], package) + print >> sys.stderr, "%s: %s contains multiple install.rdf files. That's not supported." % (script_name, package) sys.exit(MULTIPLE_INSTALL_RDFs) install_rdf = install_rdfs.pop() @@ -212,7 +173,7 @@ def generate_substvars(xul_apps, package, verbose=False): # remove existing varibles lines = filter(lambda s: not s.startswith("xpi:"), lines) - packages = get_supported_apps(xul_apps, install_rdf, package, verbose) + packages = get_supported_apps(script_name, xul_apps, install_rdf, package, verbose) lines.append("xpi:Recommends=" + " | ".join(packages) + "\n") lines.append("xpi:Enhances=" + ", ".join(sorted(packages)) + "\n") packages = get_provided_package_names(package, packages) @@ -250,14 +211,16 @@ if __name__ == "__main__": if len(packages) == 0: packages = get_all_packages() + script_name = os.path.basename(sys.argv[0]) + if verbose: - print sys.argv[0] + ": packages:", ", ".join(packages) + print script_name + ": packages:", ", ".join(packages) xul_apps = get_xul_apps() if verbose and len(xul_apps) > 0: - print sys.argv[0] + ": found %i Xul applications:" % (len(xul_apps)) + print script_name + ": found %i Xul applications:" % (len(xul_apps)) for xul_app in xul_apps: - print xul_app[0] + " " + xul_app[1] + " (" + xul_app[2] + ")" + print xul_app["id"] + ": " + xul_app["package"] + " (" + xul_app["sol"] + " to " + xul_app["eol"] + ")" for package in packages: - generate_substvars(xul_apps, package, verbose) + generate_substvars(script_name, xul_apps, package, verbose) |