summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog6
-rwxr-xr-xsrc/dh_xul-ext50
-rwxr-xr-xsrc/moz-version111
-rw-r--r--src/moz_version.py140
4 files changed, 187 insertions, 120 deletions
diff --git a/debian/changelog b/debian/changelog
index 6cbcc15..8aca0d7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -26,6 +26,10 @@ mozilla-devscripts (0.19) UNRELEASED; urgency=low
- add src/dh_xul-ext
- update src/Makefile
- update src/xpi.mk
+ - Move compare_versions from moz-version into separate module
+ - add src/moz_version.py
+ - update src/moz-version
+ - update src/dh_xul-ext
[ Alexander Sack <asac@ubuntu.com> ]
* dh_xul-ext:
@@ -35,7 +39,7 @@ mozilla-devscripts (0.19) UNRELEASED; urgency=low
- update src/dh_xul-ext
- update debian/control
- -- Benjamin Drung <bdrung@ubuntu.com> Sun, 13 Dec 2009 20:02:31 +0100
+ -- Benjamin Drung <bdrung@ubuntu.com> Thu, 17 Dec 2009 11:54:45 +0100
mozilla-devscripts (0.18) unstable; urgency=low
diff --git a/src/dh_xul-ext b/src/dh_xul-ext
index 8c8034a..17c8b68 100755
--- a/src/dh_xul-ext
+++ b/src/dh_xul-ext
@@ -26,6 +26,8 @@ import os
import subprocess
import sys
+from moz_version import compare_versions, convert_debian_to_moz_version
+
from rdflib import Namespace
from rdflib.Graph import Graph
@@ -34,6 +36,7 @@ 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.*"),
@@ -41,7 +44,7 @@ def get_xul_apps():
("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-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"):
@@ -79,7 +82,7 @@ def get_xul_apps():
xul_eol = line[line.find(":")+1:].strip()
return sorted(packages)
-def get_supported_apps(xul_apps, install_rdf, package):
+def get_supported_apps(xul_apps, install_rdf, package, verbose=False):
# create array of id_max_min triples
id_max_min = []
rdf_graph = Graph()
@@ -101,18 +104,33 @@ def get_supported_apps(xul_apps, install_rdf, package):
for target in results:
id_max_min.append (( str(target[0]), str(target[1]), str (target[2]) ))
-# TODO - figure out apps etc.
-## call parameters_
-## 1- target app id
-## 2- package name
-#CHECK_VERSION = $(shell \
-# moz-version -cs "$($(2)_eol)" ge $(call TARGET_VERSION,$(1),minVersion) && \
-# moz-version -cs "$($(2)_sol)" le $(call TARGET_VERSION,$(1),maxVersion) && \
-# echo $(2))
+ if verbose:
+ print "%s: %i supported XUL applications:" % (sys.argv[0], 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)
+ 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 verbose:
+ print "%s: %s supports %s." % (sys.argv[0], package, package_name)
+ elif verbose:
+ print "%s: %s does not support %s (any more)." % (sys.argv[0], package, package_name)
+ elif verbose:
+ print "%s: %s does not support %s (yet)." % (sys.argv[0], package, package_name)
+ 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)
-#XPI_RECOMMENDS = $(strip $(foreach id,$(XPI_TARGET_EMIDs), \
-# $(foreach package,$(packages_$(id)),$(call CHECK_VERSION,$(id),$(package)))))
- return ["firefox-3.5", "abrowser-3.5", "firefox-3.0"]
+ return supported_apps
def get_all_packages():
lines = open("debian/control").readlines()
@@ -168,7 +186,7 @@ def find_install_rdfs(package):
dirs = filter(lambda d: not os.path.islink(os.path.join(root, d)), dirs)
return install_rdfs
-def generate_substvars(xul_apps, package):
+def generate_substvars(xul_apps, package, verbose=False):
install_rdfs = find_install_rdfs(package)
if len(install_rdfs) == 0:
# this package does not contain a xul extension
@@ -189,7 +207,7 @@ def generate_substvars(xul_apps, package):
# remove existing varibles
lines = filter(lambda s: not s.startswith("xpi:"), lines)
- packages = get_supported_apps(xul_apps, install_rdf, package)
+ packages = get_supported_apps(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)
@@ -237,4 +255,4 @@ if __name__ == "__main__":
print xul_app[0] + " " + xul_app[1] + " (" + xul_app[2] + ")"
for package in packages:
- generate_substvars(xul_apps, package)
+ generate_substvars(xul_apps, package, verbose)
diff --git a/src/moz-version b/src/moz-version
index 512ab8d..ddf4ac5 100755
--- a/src/moz-version
+++ b/src/moz-version
@@ -20,108 +20,16 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
-# Reference: https://developer.mozilla.org/en/Toolkit_version_format
-
import getopt
import sys
+from moz_version import compare_versions
+
# error codes
COMMAND_LINE_SYNTAX_ERROR = 2
INVALID_COMPARATOR = 3
EMPTY_VERSION_STRING = 4
-def decode_part(part):
- """Decodes a version part (like 5pre4) to <number-a><string-b><number-c><string-d>"""
- subpart = [0,"",0,""]
-
- # Split <number-a>
- length = 0
- for i in xrange(len(part)):
- if part[i].isdigit() or part[i] in ("-"):
- length += 1
- else:
- break
- if length > 0:
- subpart[0] = int(part[0:length])
- part = part[length:]
-
- # Split <string-b>
- length = 0
- for i in xrange(len(part)):
- if not (part[i].isdigit() or part[i] in ("-")):
- length += 1
- else:
- break
- subpart[1] = part[0:length]
- part = part[length:]
-
- # Split <number-c>
- length = 0
- for i in xrange(len(part)):
- if part[i].isdigit() or part[i] in ("-"):
- length += 1
- else:
- break
- if length > 0:
- subpart[2] = int(part[0:length])
- subpart[3] = part[length:]
-
- # if string-b is a plus sign, number-a is incremented to be compatible with
- # the Firefox 1.0.x version format: 1.0+ is the same as 1.1pre
- if subpart[1] == "+":
- subpart[0] += 1
- subpart[1] = "pre"
-
- # if the version part is a single asterisk, it is interpreted as an
- # infinitely-large number: 1.5.0.* is the same as 1.5.0.(infinity)
- if subpart[1] == "*":
- subpart[0] = sys.maxint
- subpart[1] = ""
-
- return subpart
-
-def decode_version(version, verbose=False):
- """Decodes a version string like 1.1pre1a"""
- parts = version.split(".")
- decoded_parts = map(decode_part, parts)
- if verbose:
- print "I: Split %s up into %s." % (version, decoded_parts)
- return decoded_parts
-
-def compare_subpart((a, b)):
- # A string-part that exists is always less-then a nonexisting string-part
- if a == "":
- if b == "":
- return 0
- else:
- return 1
- elif b == "":
- if a == "":
- return 0
- else:
- return -1
- else:
- return cmp(a, b)
-
-def compare_part((x, y)):
- compared_subparts = filter(lambda x: x != 0, map(compare_subpart, zip(x, y)))
- if compared_subparts:
- return compared_subparts[0]
- else:
- return 0
-
-def compare_versions(a, b):
- if len(a) < len(b):
- a.extend((len(b) - len(a)) * [[0,"",0,""]])
- if len(b) < len(a):
- b.extend((len(a) - len(b)) * [[0,"",0,""]])
-
- result = filter(lambda x: x != 0, map(compare_part, zip(a, b)))
- if result:
- return result[0]
- else:
- return 0
-
comparators = ("lt", "le", "eq", "ne", "ge", "gt")
def moz_version_compare(version1, comparator, version2, silent=False, verbose=False):
@@ -141,21 +49,18 @@ def moz_version_compare(version1, comparator, version2, silent=False, verbose=Fa
symbol = {"lt": "<", "le": "<=", "eq": "=", "ne": "!=", "ge": ">=", "gt": ">"}
print "I: Comparing %s %s %s." % (version1, symbol[comparator], version2)
- a = decode_version(version1, verbose)
- b = decode_version(version2, verbose)
-
if comparator == "lt":
- return compare_versions(a, b) < 0
+ return compare_versions(version1, version2, verbose) < 0
elif comparator == "le":
- return compare_versions(a, b) <= 0
+ return compare_versions(version1, version2, verbose) <= 0
elif comparator == "eq":
- return compare_versions(a, b) == 0
+ return compare_versions(version1, version2, verbose) == 0
elif comparator == "ne":
- return compare_versions(a, b) != 0
+ return compare_versions(version1, version2, verbose) != 0
elif comparator == "ge":
- return compare_versions(a, b) >= 0
+ return compare_versions(version1, version2, verbose) >= 0
elif comparator == "gt":
- return compare_versions(a, b) > 0
+ return compare_versions(version1, version2, verbose) > 0
def usage(output):
diff --git a/src/moz_version.py b/src/moz_version.py
new file mode 100644
index 0000000..832d65f
--- /dev/null
+++ b/src/moz_version.py
@@ -0,0 +1,140 @@
+# Copyright (c) 2009 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:
+#
+# 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.
+
+# Reference: https://developer.mozilla.org/en/Toolkit_version_format
+
+import sys
+
+def decode_part(part):
+ """Decodes a version part (like 5pre4) to <number-a><string-b><number-c><string-d>"""
+ subpart = [0,"",0,""]
+
+ # Split <number-a>
+ length = 0
+ for i in xrange(len(part)):
+ if part[i].isdigit() or part[i] in ("-"):
+ length += 1
+ else:
+ break
+ if length > 0:
+ subpart[0] = int(part[0:length])
+ part = part[length:]
+
+ # Split <string-b>
+ length = 0
+ for i in xrange(len(part)):
+ if not (part[i].isdigit() or part[i] in ("-")):
+ length += 1
+ else:
+ break
+ subpart[1] = part[0:length]
+ part = part[length:]
+
+ # Split <number-c>
+ length = 0
+ for i in xrange(len(part)):
+ if part[i].isdigit() or part[i] in ("-"):
+ length += 1
+ else:
+ break
+ if length > 0:
+ subpart[2] = int(part[0:length])
+ subpart[3] = part[length:]
+
+ # if string-b is a plus sign, number-a is incremented to be compatible with
+ # the Firefox 1.0.x version format: 1.0+ is the same as 1.1pre
+ if subpart[1] == "+":
+ subpart[0] += 1
+ subpart[1] = "pre"
+
+ # if the version part is a single asterisk, it is interpreted as an
+ # infinitely-large number: 1.5.0.* is the same as 1.5.0.(infinity)
+ if subpart[1] == "*":
+ subpart[0] = sys.maxint
+ subpart[1] = ""
+
+ return subpart
+
+def decode_version(version, verbose=False):
+ """Decodes a version string like 1.1pre1a"""
+ parts = version.split(".")
+ decoded_parts = map(decode_part, parts)
+ if verbose:
+ print "I: Split %s up into %s." % (version, decoded_parts)
+ return decoded_parts
+
+def compare_subpart((a, b)):
+ # A string-part that exists is always less-then a nonexisting string-part
+ if a == "":
+ if b == "":
+ return 0
+ else:
+ return 1
+ elif b == "":
+ if a == "":
+ return 0
+ else:
+ return -1
+ else:
+ return cmp(a, b)
+
+def compare_part((x, y)):
+ compared_subparts = filter(lambda x: x != 0, map(compare_subpart, zip(x, y)))
+ if compared_subparts:
+ return compared_subparts[0]
+ else:
+ return 0
+
+def compare_versions(version1, version2, verbose=False):
+ a = decode_version(version1, verbose)
+ b = decode_version(version2, verbose)
+
+ if len(a) < len(b):
+ a.extend((len(b) - len(a)) * [[0,"",0,""]])
+ if len(b) < len(a):
+ b.extend((len(a) - len(b)) * [[0,"",0,""]])
+
+ result = filter(lambda x: x != 0, map(compare_part, zip(a, b)))
+ if result:
+ return result[0]
+ else:
+ return 0
+
+def extract_upstream_version(debian_version):
+ # remove last part separated by a dash (1.0-2 -> 1.0)
+ parts = debian_version.split('-')
+ if len(parts) > 1:
+ del parts[-1]
+ upstream_version = '-'.join(parts)
+
+ # compatibility: strip +nobinonly and +build
+ parts = upstream_version.split('+')
+ if len(parts) > 1 and parts[-1] == "nobinonly":
+ del parts[-1]
+ if len(parts) > 1 and parts[-1].startswith("build"):
+ del parts[-1]
+ upstream_version = '+'.join(parts)
+
+ return upstream_version
+
+def convert_debian_to_moz_version(debian_version, verbose=False):
+ upstream_version = extract_upstream_version(debian_version)
+ moz_version = upstream_version.replace("~", "")
+ return moz_version