From 56bfb889bb966ad4ee2568369d0f643cb4ef7afc Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 29 Feb 2012 12:16:04 -0800 Subject: [PATCH] Added update of git and fix for rc generation. --- devstack/downloader.py | 33 ++++++++++++++++----------------- devstack/progs/actions.py | 5 +---- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/devstack/downloader.py b/devstack/downloader.py index 62c5a175..664e3dea 100644 --- a/devstack/downloader.py +++ b/devstack/downloader.py @@ -26,28 +26,27 @@ LOG = logging.getLogger("devstack.downloader") EXT_REG = re.compile(r"^(.*?)\.git\s*$", re.IGNORECASE) GIT_MASTER_BRANCH = "master" GIT_CACHE_DIR_ENV = "GIT_CACHE_DIR" - - -def _git_cache_download(storewhere, uri, branch=None): - cdir = env.get_key(GIT_CACHE_DIR_ENV) - if cdir and sh.isdir(cdir): - #TODO actually do the cache... - pass - return False +CLONE_CMD = ["git", "clone"] +CHECKOUT_CMD = ['git', 'checkout'] +PULL_CMD = ['git', 'pull'] def _gitdownload(storewhere, uri, branch=None): - dirsmade = sh.mkdirslist(storewhere) - LOG.info("Downloading from %s to %s" % (uri, storewhere)) - #check if already done - if _git_cache_download(storewhere, uri, branch): - return dirsmade - #have to do it... - cmd = ["git", "clone"] + [uri, storewhere] - sh.execute(*cmd) + dirsmade = list() + if sh.isdir(storewhere): + LOG.info("Updating %s" % (uri, storewhere)) + cmd = CHECKOUT_CMD + [GIT_MASTER_BRANCH] + sh.execute(*cmd, cwd=storewhere) + cmd = PULL_CMD + sh.execute(*cmd, cwd=storewhere) + else: + LOG.info("Downloading from %s to %s" % (uri, storewhere)) + dirsmade.extend(sh.mkdirslist(storewhere)) + cmd = CLONE_CMD + [uri, storewhere] + sh.execute(*cmd) if branch and branch != GIT_MASTER_BRANCH: LOG.info("Adjusting git branch to %s" % (branch)) - cmd = ['git', 'checkout'] + [branch] + cmd = CHECKOUT_CMD + [branch] sh.execute(*cmd, cwd=storewhere) return dirsmade diff --git a/devstack/progs/actions.py b/devstack/progs/actions.py index 551bcdce..34502647 100644 --- a/devstack/progs/actions.py +++ b/devstack/progs/actions.py @@ -29,7 +29,7 @@ LOG = logging.getLogger("devstack.progs.actions") _REVERSE_ACTIONS = [settings.UNINSTALL, settings.STOP] # For these actions we will attempt to make an rc file if it does not exist -_RC_FILE_MAKE_ACTIONS = [settings.INSTALL, settings.START] +_RC_FILE_MAKE_ACTIONS = [settings.INSTALL] # The order of which uninstalls happen + message of what is happening (before and after) UNINSTALL_ORDERING = [ @@ -204,7 +204,6 @@ class ActionRunner(object): preq_runner = ActionRunner(self.distro, preq_action, self.directory, self.cfg, self.pkg_manager, components=preq_components, **self.kargs) - preq_runner.rc_file = self.rc_file preq_runner.run() def _pre_run(self, instances, component_order): @@ -231,8 +230,6 @@ class ActionRunner(object): creator = env_rc.RcGenerator(self.cfg) contents = creator.generate() sh.write_file(self.rc_file, contents) - if self.rc_file: - self.rc_file = None def _run_instances(self, instances, component_order): component_order = self._apply_reverse(component_order)