Patchwork [2/7] combo-layer: allow component pull to be done separately

login
register
mail settings
Submitter Paul Eggleton
Date July 31, 2012, 12:06 a.m.
Message ID <1e8c185d75f8c5bf3c3c386bae597361af89fc4f.1343693147.git.paul.eggleton@linux.intel.com>
Download mbox | patch
Permalink /patch/33337/
State Accepted
Commit 61983b2191253b24117b63f586d5aac00c7eb48e
Headers show

Comments

Paul Eggleton - July 31, 2012, 12:06 a.m.
* Add a -n option to disable component repo pull during update
* Add a 'pull' action to pull the component repos only

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 scripts/combo-layer |   51 +++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 39 insertions(+), 12 deletions(-)

Patch

diff --git a/scripts/combo-layer b/scripts/combo-layer
index b1a9dca..554ac06 100755
--- a/scripts/combo-layer
+++ b/scripts/combo-layer
@@ -181,12 +181,7 @@  def check_patch(patchfile):
         of.close()
         os.rename(patchfile + '.tmp', patchfile)
 
-def action_update(conf, args):
-    """
-        update the component repos
-        generate the patch list
-        apply the generated patches
-    """
+def get_repos(conf, args):
     repos = []
     if len(args) > 1:
         for arg in args[1:]:
@@ -202,15 +197,48 @@  def action_update(conf, args):
     if not repos:
         repos = conf.repos
 
+    return repos
+
+def action_pull(conf, args):
+    """
+        update the component repos only
+    """
+    repos = get_repos(conf, args)
+
     # make sure all repos are clean
     for name in repos:
         check_repo_clean(conf.repos[name]['local_repo_dir'])
+
+    for name in repos:
+        repo = conf.repos[name]
+        ldir = repo['local_repo_dir']
+        branch = repo.get('branch', "master")
+        runcmd("git checkout %s" % branch, ldir)
+        logger.info("git pull for component repo %s in %s ..." % (name, ldir))
+        output=runcmd("git pull", ldir)
+        logger.info(output)
+
+def action_update(conf, args):
+    """
+        update the component repos
+        generate the patch list
+        apply the generated patches
+    """
+    repos = get_repos(conf, args)
+
+    # make sure combo repo is clean
     check_repo_clean(os.getcwd())
 
     import uuid
     patch_dir = "patch-%s" % uuid.uuid4()
     os.mkdir(patch_dir)
 
+    # Step 1: update the component repos
+    if conf.nopull:
+        logger.info("Skipping pull (-n)")
+    else:
+        action_pull(conf, args)
+
     for name in repos:
         repo = conf.repos[name]
         ldir = repo['local_repo_dir']
@@ -218,12 +246,6 @@  def action_update(conf, args):
         branch = repo.get('branch', "master")
         repo_patch_dir = os.path.join(os.getcwd(), patch_dir, name)
 
-        # Step 1: update the component repo
-        runcmd("git checkout %s" % branch, ldir)
-        logger.info("git pull for component repo %s in %s ..." % (name, ldir))
-        output=runcmd("git pull", ldir)
-        logger.info(output)
-
         # Step 2: generate the patch list and store to patch dir
         logger.info("generating patches for %s" % name)
         if dest_dir != ".":
@@ -369,6 +391,7 @@  def action_error(conf, args):
 actions = {
     "init": action_init,
     "update": action_update,
+    "pull": action_pull,
     "splitpatch": action_splitpatch,
 }
 
@@ -382,6 +405,7 @@  Create and update a combination layer repository from multiple component reposit
 Action:
   init                 initialise the combo layer repo
   update [components]  get patches from component repos and apply them to the combo repo
+  pull [components]    just pull component repos only
   splitpatch [commit]  generate commit patch and split per component, default commit is HEAD""")
 
     parser.add_option("-c", "--conf", help = "specify the config file (conf/combo-layer.conf is the default).",
@@ -393,6 +417,9 @@  Action:
     parser.add_option("-D", "--debug", help = "output debug information",
                action = "store_true", dest = "debug", default = False)
 
+    parser.add_option("-n", "--no-pull", help = "skip pulling component repos during update",
+               action = "store_true", dest = "nopull", default = False)
+
     options, args = parser.parse_args(sys.argv)
 
     # Dispatch to action handler