11 |
import errno |
import errno |
12 |
import tempfile |
import tempfile |
13 |
import shutil |
import shutil |
14 |
|
import rpm |
15 |
from sgmllib import SGMLParser |
from sgmllib import SGMLParser |
16 |
|
|
17 |
MEDIA="Core Release Source" |
MEDIA="Core Release Source" |
27 |
-1 if a < b |
-1 if a < b |
28 |
0 if a == b |
0 if a == b |
29 |
1 if a > b |
1 if a > b |
30 |
|
""" |
31 |
|
|
32 |
Logic from Bugzilla::Install::Util::vers_cmp""" |
return rpm.labelCompare(('1', a, '1'), ('1', b, '1')) |
|
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)) |
|
33 |
|
|
34 |
def get_latest_version(versions, max_version=None): |
def get_latest_version(versions, max_version=None): |
35 |
"""Gets the latest version number |
"""Gets the latest version number |
136 |
write_file(self.path, data) |
write_file(self.path, data) |
137 |
|
|
138 |
|
|
139 |
# Check RPM also agrees that version number has increased |
# Verify that RPM also agrees that version number has changed |
140 |
if self.version != version: |
if self.version != version: |
141 |
print "ERROR: Increased version to %s, but RPM doesn't agree!?!" % version |
print "ERROR: Increased version to %s, but RPM doesn't agree!?!" % version |
142 |
return False |
return False |