51 |
51 |
from devflow import utils
|
52 |
52 |
|
53 |
53 |
|
|
54 |
DEFAULT_VERSION_FILE =\
|
|
55 |
"""__version__ = "%(DEVFLOW_VERSION)s"
|
|
56 |
__version_vcs_info__ = {
|
|
57 |
'branch': '%(DEVFLOW_BRANCH)s',
|
|
58 |
'revid': '%(DEVFLOW_REVISION_ID)s',
|
|
59 |
'revno': %(DEVFLOW_REVISION_NUMBER)s}
|
|
60 |
__version_user_email__ = "%(DEVFLOW_USER_EMAIL)s"
|
|
61 |
__version_user_name__ = "%(DEVFLOW_USER_NAME)s"
|
|
62 |
"""
|
|
63 |
|
|
64 |
|
54 |
65 |
def get_base_version(vcs_info):
|
55 |
66 |
"""Determine the base version from a file in the repository"""
|
56 |
67 |
|
... | ... | |
354 |
365 |
b = get_base_version(v)
|
355 |
366 |
mode = utils.get_build_mode()
|
356 |
367 |
version = python_version(b, v, mode)
|
357 |
|
vcs_info = """{
|
358 |
|
'branch': '%s',
|
359 |
|
'revid': '%s',
|
360 |
|
'revno': %s}""" % (v.branch, v.revid, v.revno)
|
361 |
|
content =\
|
362 |
|
"""__version__ = "%(version)s"
|
363 |
|
__version_info__ = %(version_info)s
|
364 |
|
__version_vcs_info__ = %(vcs_info)s
|
365 |
|
__version_user_email__ = "%(user_email)s"
|
366 |
|
__version_user_name__ = "%(user_name)s"
|
367 |
|
""" % dict(version=version, version_info=version.split("."),
|
368 |
|
vcs_info=vcs_info,
|
369 |
|
user_email=v.email,
|
370 |
|
user_name=v.name)
|
|
368 |
debian_version = debian_version_from_python_version(version)
|
|
369 |
env = {"DEVFLOW_VERSION": version,
|
|
370 |
"DEVFLOW_DEBIAN_VERSION": debian_version,
|
|
371 |
"DEVFLOW_BRANCH": v.branch,
|
|
372 |
"DEVFLOW_REVISION_ID": v.revid,
|
|
373 |
"DEVFLOW_REVISION_NUMBER": v.revno,
|
|
374 |
"DEVFLOW_USER_EMAIL": v.email,
|
|
375 |
"DEVFLOW_USER_NAME": v.name}
|
371 |
376 |
|
372 |
377 |
for _pkg_name, pkg_info in config['packages'].items():
|
373 |
|
version_filename = pkg_info['version_file']
|
374 |
|
if version_filename:
|
375 |
|
path = os.path.join(toplevel, version_filename)
|
|
378 |
version_filename = pkg_info.get('version_file')
|
|
379 |
if not version_filename:
|
|
380 |
continue
|
|
381 |
version_template = pkg_info.get('version_template')
|
|
382 |
if version_template:
|
|
383 |
vtemplate_file = os.path.join(toplevel, version_template)
|
|
384 |
try:
|
|
385 |
with file(vtemplate_file) as f:
|
|
386 |
content = f.read(-1) % env
|
|
387 |
except IOError as e:
|
|
388 |
if e.errno == 2:
|
|
389 |
raise RuntimeError("devflow.conf contains '%s' as a"
|
|
390 |
" version template file, but file does"
|
|
391 |
" not exists!" % vtemplate_file)
|
|
392 |
else:
|
|
393 |
raise
|
|
394 |
else:
|
|
395 |
content = DEFAULT_VERSION_FILE % env
|
|
396 |
with file(os.path.join(toplevel, version_filename), 'w+') as f:
|
376 |
397 |
log.info("Updating version file '%s'" % version_filename)
|
377 |
|
version_file = file(path, "w+")
|
378 |
|
version_file.write(content)
|
379 |
|
version_file.close()
|
|
398 |
f.write(content)
|
380 |
399 |
|
381 |
400 |
|
382 |
401 |
def bump_version_main():
|