summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenjamin Drung <bdrung@debian.org>2011-10-11 22:40:18 +0200
committerBenjamin Drung <bdrung@debian.org>2011-10-11 22:40:18 +0200
commitcc52fe459c05b2588f635d5bf90ff9eaddb1f0f1 (patch)
treed48eba3781f76301ab08aa6b11c6f9bf0e154f24 /src
parent8fb443911fb0f874d94a9501c08911a793f4ee50 (diff)
Add ${xpi:Breaks} for versioned package dependency for maximum XUL application version.
LP: #839130
Diffstat (limited to 'src')
-rwxr-xr-xsrc/dh_xul-ext16
-rw-r--r--src/moz_version.py71
2 files changed, 76 insertions, 11 deletions
diff --git a/src/dh_xul-ext b/src/dh_xul-ext
index 876d43e..c7328de 100755
--- a/src/dh_xul-ext
+++ b/src/dh_xul-ext
@@ -21,7 +21,8 @@ import os
import subprocess
import sys
-from moz_version import compare_versions, convert_moz_to_debian_version
+from moz_version import (compare_versions, convert_moz_to_debian_version,
+ moz_to_next_debian_version)
import RDF
@@ -43,6 +44,17 @@ class XulApp(object):
return self.xul_id + ": " + self.package + " (" + self.sol + " to " + \
self.eol + ")"
+ def get_breaks(self):
+ """Return a string for ${xpi:Breaks} for the XUL application."""
+ breaks = []
+ if self.min_version:
+ deb_min_version = convert_moz_to_debian_version(self.min_version)
+ breaks.append(self.package + " (<< " + deb_min_version + ")")
+ if self.max_version:
+ deb_max_version = moz_to_next_debian_version(self.max_version)
+ breaks.append(self.package + " (>= " + deb_max_version + ")")
+ return ", ".join(breaks)
+
def get_eol(self):
return self.eol
@@ -297,6 +309,8 @@ def generate_substvars(script_name, xul_apps, package, verbose=False):
else:
lines.append("xpi:Depends=" + " | ".join(packages) + "\n")
lines.append("xpi:Recommends=\n")
+ packages = [a.get_breaks() for a in supported_apps]
+ lines.append("xpi:Breaks=" + ", ".join(sorted(packages)) + "\n")
packages = [a.get_package() for a in supported_apps]
lines.append("xpi:Enhances=" + ", ".join(sorted(packages)) + "\n")
packages = get_provided_package_names(package, supported_apps)
diff --git a/src/moz_version.py b/src/moz_version.py
index ce21f7f..c4cebed 100644
--- a/src/moz_version.py
+++ b/src/moz_version.py
@@ -128,6 +128,19 @@ def extract_upstream_version(debian_version):
return upstream_version
+def _convert_part_to_debian(part):
+ """Converts a Mozilla version part (like 5pre4) to a Debian version."""
+ (number_a, string_b, number_c, string_d) = part
+ debian_version = ""
+ if string_d != "":
+ debian_version = "~" + string_d
+ if number_c != 0 or string_d != "":
+ debian_version = str(number_c) + debian_version
+ if string_b != "":
+ debian_version = "~" + string_b + debian_version
+ debian_version = str(number_a) + debian_version
+ return debian_version
+
def convert_debian_to_moz_version(debian_version, verbose=False):
upstream_version = extract_upstream_version(debian_version)
@@ -145,16 +158,54 @@ def convert_debian_to_moz_version(debian_version, verbose=False):
def convert_moz_to_debian_version(moz_version, epoch=0, verbose=False):
parts = decode_version(moz_version, verbose)
# tranform parts
- for i in xrange(len(parts)):
- (number_a, string_b, number_c, string_d) = parts[i]
- part = ""
- if string_d != "":
- part = "~" + string_d
- if number_c != 0 or string_d != "":
- part = str(number_c) + part
- if string_b != "":
- part = "~" + string_b + part
- parts[i] = str(number_a) + part
+ parts = [_convert_part_to_debian(p) for p in parts]
+ debian_version = ".".join(parts)
+ if epoch != 0:
+ debian_version = str(epoch) + ":" + debian_version
+ return debian_version
+
+def moz_to_next_debian_version(moz_version, epoch=0, verbose=False):
+ """Convert a given Mozilla version to the next Debian version.
+
+ Compared to convert_moz_to_debian_version it does following:
+ * append 0 to a trailing letter, or
+ * append + to a trailing number, or
+ * replace a trailing * with +.
+
+ Examples:
+ 9.0a => 9.0~a0
+ 9.0a1 => 9.0~a1+
+ 9.0 => 9.0+
+ 9.0.* => 9.0.+
+ """
+ parts = decode_version(moz_version, verbose)
+ # tranform last parts
+ (number_a, string_b, number_c, string_d) = parts[-1]
+ last_part = ""
+ if string_d != "":
+ last_part = "~" + string_d + "0"
+ if number_c != 0 or string_d != "":
+ if last_part:
+ last_part = str(number_c) + last_part
+ else:
+ if number_c == sys.maxint:
+ last_part = "+"
+ else:
+ last_part = str(number_c) + "+"
+ if string_b != "":
+ if last_part:
+ last_part = "~" + string_b + last_part
+ else:
+ last_part = "~" + string_b + "0"
+ if last_part:
+ last_part = str(number_a) + last_part
+ else:
+ if number_a == sys.maxint:
+ last_part = "+"
+ else:
+ last_part = str(number_a) + "+"
+
+ parts = [_convert_part_to_debian(p) for p in parts[:-1]] + [last_part]
debian_version = ".".join(parts)
if epoch != 0:
debian_version = str(epoch) + ":" + debian_version