summaryrefslogtreecommitdiff
path: root/src/moz_version.py
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/moz_version.py
parent8fb443911fb0f874d94a9501c08911a793f4ee50 (diff)
Add ${xpi:Breaks} for versioned package dependency for maximum XUL application version.
LP: #839130
Diffstat (limited to 'src/moz_version.py')
-rw-r--r--src/moz_version.py71
1 files changed, 61 insertions, 10 deletions
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