Commit bec4bf12 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Add devflow.conf configuration file

parent 8334fb57
[ packages ]
[[ devflow ]]
version_file = "devflow/version.py"
......@@ -37,6 +37,7 @@ import sys
from optparse import OptionParser
from collections import namedtuple
from sh import mktemp, cd, rm, git_dch, python
from configobj import ConfigObj
from devflow import versioning
......@@ -162,8 +163,9 @@ def main():
raise RuntimeError(red("Repository %s is dirty." % toplevel))
# Get packages from configuration file
config_file = options.config_file or os.path.join(toplevel, "autopkg.conf")
packages = get_packages_to_build(config_file)
config_file = options.config_file or os.path.join(toplevel, "devflow.conf")
config = ConfigObj(config_file)
packages = config['packages'].keys()
print_green("Will build the following packages:\n" + "\n".join(packages))
# Clone the repo
......@@ -293,23 +295,6 @@ def main():
print_green("git push %s %s" % (remote, obj))
def get_packages_to_build(config_file):
config_file = os.path.abspath(config_file)
try:
f = open(config_file)
except IOError as e:
raise IOError("Can not access configuration file '%s': %s"
% (config_file, e.strerror))
lines = [l.strip() for l in f.readlines()]
l = [l for l in lines if not l.startswith("#")]
f.close()
if not l:
raise RuntimeError("Configuration file '%s' is empty."
" No packages to build." % config_fule)
return l
def create_temp_directory(suffix):
create_dir_cmd = mktemp("-d", "/tmp/" + suffix + "-XXXXX")
return create_dir_cmd.stdout.strip()
......
......@@ -42,6 +42,7 @@ import git
from distutils import log
from collections import namedtuple
from configobj import ConfigObj
# Branch types:
......@@ -427,24 +428,20 @@ def user_info():
return "%s@%s" % (getpass.getuser(), socket.getfqdn())
def update_version(module, name="version", root="."):
def update_version():
"""
Generate or replace version.py as a submodule of `module`.
This is a helper to generate/replace a version.py file containing version
information as a submodule of passed `module`.
This is a helper to generate/replace version files containing version
information.
"""
paths = [root] + module.split(".") + ["%s.py" % name]
module_filename = os.path.join(*paths)
config = ConfigObj("devflow.conf")
v = vcs_info()
if not v:
# Return early if not in development environment
log.error("Can not compute version outside of a git repository."
" Will not update %s version file" % module_filename)
return
raise RuntimeError("Can not compute version outside of a git"
" repository.")
b = base_version(v)
mode = build_mode()
version = python_version(b, v, mode)
......@@ -456,10 +453,12 @@ __version_user_info__ = "%(user_info)s"
vcs_info=pprint.PrettyPrinter().pformat(dict(v._asdict())),
user_info=user_info())
module_file = file(module_filename, "w+")
module_file.write(content)
module_file.close()
return module_filename
for pkg_name, pkg_info in config['packages'].items():
version_filename = pkg_info['version_file']
log.info("Updating version file '%s'" % version_filename)
version_file = file(version_filename, "w+")
version_file.write(content)
version_file.close()
def bump_version_main():
......
......@@ -178,6 +178,7 @@ setup(
'console_scripts': [
'devflow-version=devflow.versioning:main',
'devflow-bump-version=devflow.versioning:bump_version_main',
'devflow-update-version=devflow.versioning:update_version',
'devflow-autopkg=devflow.autopkg:main',
],
},
......
......@@ -32,17 +32,14 @@
#or implied, of GRNET S.A.
import sys
import os
try:
from devflow import versioning
except ImportError:
raise RuntimeError("devflow is build dependency")
HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
def main():
versioning.update_version("devflow", "version", HERE)
versioning.update_version()
if __name__ == "__main__":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment