82 |
latest = version |
latest = version |
83 |
return latest |
return latest |
84 |
|
|
85 |
|
MAJOR_VERSIONS = { |
86 |
|
'NetworkManager': set(('0.9',)) |
87 |
|
'networkmanager': set(('0.9',)) |
88 |
|
} |
89 |
|
|
90 |
|
def get_majmin(version, module=None): |
91 |
|
nrs = version.split('.') |
92 |
|
|
93 |
|
if module and module in MAJOR_VERSIONS: |
94 |
|
module_versions = [version.split(".") for version in MAJOR_VERSIONS[module]] |
95 |
|
|
96 |
|
nrstest = nrs[:] |
97 |
|
|
98 |
|
while len(nrstest) >= 2: |
99 |
|
if nrstest in module_versions: |
100 |
|
return (".".join(nrs[:len(nrstest)]), nrs[len(nrstest)]) |
101 |
|
|
102 |
|
nrstest.pop() |
103 |
|
|
104 |
|
return (nrs[0], nrs[1]) |
105 |
|
|
106 |
|
|
107 |
def get_safe_max_version(version): |
def get_safe_max_version(version): |
108 |
if not re_majmin.match(version): |
if not re_majmin.match(version): |
109 |
return None |
return None |
115 |
else: |
else: |
116 |
return "%d.%d" % (majmin_nr[0], majmin_nr[1] + 2) |
return "%d.%d" % (majmin_nr[0], majmin_nr[1] + 2) |
117 |
|
|
118 |
def judge_version_increase(version_old, version_new): |
def judge_version_increase(version_old, version_new, module=None): |
119 |
"""Judge quality of version increase: |
"""Judge quality of version increase: |
120 |
|
|
121 |
Returns a tuple containing judgement and message |
Returns a tuple containing judgement and message |
138 |
return (-3, "Version %s is older than current version %s!" % (version_new, version_old)) |
return (-3, "Version %s is older than current version %s!" % (version_new, version_old)) |
139 |
|
|
140 |
# Version is newer, but we don't want to see if it follows the GNOME versioning scheme |
# Version is newer, but we don't want to see if it follows the GNOME versioning scheme |
141 |
majmins = [re_majmin.sub(r'\1', ver) for ver in versions if re_majmin.match(ver) is not None] |
majmins = [get_majmin(ver, module) for ver in versions if re_majmin.match(ver) is not None] |
142 |
|
|
143 |
if len(majmins) == 1: |
if len(majmins) == 1: |
144 |
return (-1, "Version number scheme changes: %s" % (", ".join(versions))) |
return (-1, "Version number scheme changes: %s" % (", ".join(versions))) |
158 |
# 1.1.x -> 1.1.x or 1.0.x -> 1.0.x |
# 1.1.x -> 1.1.x or 1.0.x -> 1.0.x |
159 |
return (10, None) |
return (10, None) |
160 |
|
|
|
# More detailed analysis needed, so figure out the numbers |
|
|
majmin_nrs = [map(long, ver.split('.')) for ver in majmins] |
|
|
|
|
161 |
# Check/ensure major version number is the same |
# Check/ensure major version number is the same |
162 |
if majmin_nrs[0][0] != majmin_nrs[1][0]: |
if majmins[0][0] != majmins[1][0]: |
163 |
# 1.0.x -> 2.0.x |
# 1.0.x -> 2.0.x |
164 |
return (1, "Major version number increase") |
return (1, "Major version number increase") |
165 |
|
|
166 |
# Minor indicates stable/unstable |
# Minor indicates stable/unstable |
167 |
devstate = (majmin_nrs[0][1] % 2 == 0, majmin_nrs[1][1] % 2 == 0) |
devstate = (long(majmins[0][1]) % 2 == 0, long(majmins[1][1]) % 2 == 0) |
168 |
|
|
169 |
# Upgrading to unstable is weird |
# Upgrading to unstable is weird |
170 |
if not devstate[1]: |
if not devstate[1]: |
277 |
re_update_version = re.compile(r'^(?P<pre>Version:\s*)(?P<version>.+)(?P<post>\s*)$', re.MULTILINE + re.IGNORECASE) |
re_update_version = re.compile(r'^(?P<pre>Version:\s*)(?P<version>.+)(?P<post>\s*)$', re.MULTILINE + re.IGNORECASE) |
278 |
re_update_release = re.compile(r'^(?P<pre>Release:\s*)(?P<release>%mkrel \d+)(?P<post>\s*)$', re.MULTILINE + re.IGNORECASE) |
re_update_release = re.compile(r'^(?P<pre>Release:\s*)(?P<release>%mkrel \d+)(?P<post>\s*)$', re.MULTILINE + re.IGNORECASE) |
279 |
|
|
280 |
def __init__(self, path): |
def __init__(self, path, module=None): |
281 |
self.path = path |
self.path = path |
282 |
self.cwd = os.path.dirname(path) |
self.cwd = os.path.dirname(path) |
283 |
|
self.module = module |
284 |
|
|
285 |
@property |
@property |
286 |
def version(self): |
def version(self): |
643 |
|
|
644 |
# Determine version from spec file |
# Determine version from spec file |
645 |
try: |
try: |
646 |
packages[package] = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)).version |
packages[package] = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package), module=upstream).version |
647 |
except subprocess.CalledProcessError: |
except subprocess.CalledProcessError: |
648 |
raise ValueError("Multiple packages found and cannot determine version of %s" % package) |
raise ValueError("Multiple packages found and cannot determine version of %s" % package) |
649 |
|
|
689 |
if show_version or only_diff_version: |
if show_version or only_diff_version: |
690 |
cwd = os.path.join(root, package) |
cwd = os.path.join(root, package) |
691 |
try: |
try: |
692 |
spec_version = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)).version |
spec_version = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package), module=module).version |
693 |
except subprocess.CalledProcessError: |
except subprocess.CalledProcessError: |
694 |
spec_version = 'N/A' |
spec_version = 'N/A' |
695 |
|
|
837 |
sys.exit(1) |
sys.exit(1) |
838 |
|
|
839 |
# SpecFile class handles the actual version+release change |
# SpecFile class handles the actual version+release change |
840 |
s = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)) |
# XXX - module should reflect upstream name, this gives it the package name |
841 |
|
s = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package), module=package) |
842 |
print "%s => %s" % (s.version, options.version) |
print "%s => %s" % (s.version, options.version) |
843 |
if not s.update(options.version, force=options.force): |
if not s.update(options.version, force=options.force): |
844 |
sys.exit(1) |
sys.exit(1) |