--- mga-gnome/trunk/mga-gnome 2012/02/24 10:35:05 3044 +++ mga-gnome/trunk/mga-gnome 2012/02/24 12:26:02 3045 @@ -11,6 +11,7 @@ import errno import tempfile import shutil +import rpm from sgmllib import SGMLParser MEDIA="Core Release Source" @@ -26,35 +27,9 @@ -1 if a < b 0 if a == b 1 if a > b + """ - Logic from Bugzilla::Install::Util::vers_cmp""" - A = re_version.findall(a.lstrip('0')) - B = re_version.findall(b.lstrip('0')) - - while A and B: - a = A.pop(0) - b = B.pop(0) - - if a == b: - continue - elif a == '-': - return -1 - elif b == '-': - return 1 - elif a == '.': - return -1 - elif b == '.': - return 1 - elif a.isdigit() and b.isdigit(): - c = cmp(a, b) if (a.startswith('0') or b.startswith('0')) else cmp(int(a, 10), int(b, 10)) - if c: - return c - else: - c = cmp(a.upper(), b.upper()) - if c: - return c - - return cmp(len(A), len(B)) + return rpm.labelCompare(('1', a, '1'), ('1', b, '1')) def get_latest_version(versions, max_version=None): """Gets the latest version number @@ -161,7 +136,7 @@ write_file(self.path, data) - # Check RPM also agrees that version number has increased + # Verify that RPM also agrees that version number has changed if self.version != version: print "ERROR: Increased version to %s, but RPM doesn't agree!?!" % version return False