aboutsummaryrefslogtreecommitdiffstats
path: root/layerindex/update.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-05-30 13:43:58 +1200
committerPaul Eggleton <paul.eggleton@linux.intel.com>2016-06-10 06:55:26 +1200
commitbf94b2f7e949ffbe806e69c8c4df1010dbf14265 (patch)
tree458072df21a74bd65ea98a523117dbdd31002061 /layerindex/update.py
parentc64e4c57a9158c8ae5e49f526c3ff87950d3a94e (diff)
downloadopenembedded-core-contrib-bf94b2f7e949ffbe806e69c8c4df1010dbf14265.tar.gz
openembedded-core-contrib-bf94b2f7e949ffbe806e69c8c4df1010dbf14265.tar.bz2
openembedded-core-contrib-bf94b2f7e949ffbe806e69c8c4df1010dbf14265.zip
update.py: allow updating all branches with one command
Allow updating multiple branches, and if no branches are specified, update all branches that have a new "updates_enabled" flag field set to True. This avoids the need to have a separate shell script which runs update.py for each branch (and thus has hardcoded knowledge of each active branch in the index, i.e. it needs to be kept up-to-date in addition to the database.) The migration will default updates_enabled to True for all branches so if you wish to take advantage of this functionality, the flag will need to be set to False for any branches that shouldn't be updated. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'layerindex/update.py')
-rwxr-xr-xlayerindex/update.py70
1 files changed, 38 insertions, 32 deletions
diff --git a/layerindex/update.py b/layerindex/update.py
index f7cb25cf22..ee4138df9e 100755
--- a/layerindex/update.py
+++ b/layerindex/update.py
@@ -57,8 +57,8 @@ def main():
%prog [options]""")
parser.add_option("-b", "--branch",
- help = "Specify branch to update",
- action="store", dest="branch", default='master')
+ help = "Specify branch(es) to update (use commas to separate multiple). Default is all enabled branches.",
+ action="store", dest="branch", default='')
parser.add_option("-l", "--layer",
help = "Specify layers to update (use commas to separate multiple). Default is all published layers.",
action="store", dest="layers")
@@ -92,14 +92,19 @@ def main():
utils.setup_django()
import settings
- from layerindex.models import LayerItem
+ from layerindex.models import Branch, LayerItem
logger.setLevel(options.loglevel)
- branch = utils.get_branch(options.branch)
- if not branch:
- logger.error("Specified branch %s is not valid" % options.branch)
- sys.exit(1)
+ if options.branch:
+ branches = options.branch.split(',')
+ for branch in branches:
+ if not utils.get_branch(branch):
+ logger.error("Specified branch %s is not valid" % branch)
+ sys.exit(1)
+ else:
+ branchquery = Branch.objects.filter(updates_enabled=True)
+ branches = [branch.name for branch in branchquery]
fetchdir = settings.LAYER_FETCH_DIR
if not fetchdir:
@@ -164,31 +169,32 @@ def main():
# We now do this by calling out to a separate script; doing otherwise turned out to be
# unreliable due to leaking memory (we're using bitbake internals in a manner in which
# they never get used during normal operation).
- for layer in layerquery:
- if layer.vcs_url in failedrepos:
- logger.info("Skipping update of layer %s as fetch of repository %s failed" % (layer.name, layer.vcs_url))
-
- urldir = layer.get_fetch_dir()
- repodir = os.path.join(fetchdir, urldir)
-
- cmd = 'python update_layer.py -l %s -b %s' % (layer.name, options.branch)
- if options.reload:
- cmd += ' --reload'
- if options.fullreload:
- cmd += ' --fullreload'
- if options.nocheckout:
- cmd += ' --nocheckout'
- if options.dryrun:
- cmd += ' -n'
- if options.loglevel == logging.DEBUG:
- cmd += ' -d'
- elif options.loglevel == logging.ERROR:
- cmd += ' -q'
- logger.debug('Running layer update command: %s' % cmd)
- ret = run_command_interruptible(cmd)
- if ret == 254:
- # Interrupted by user, break out of loop
- break
+ for branch in branches:
+ for layer in layerquery:
+ if layer.vcs_url in failedrepos:
+ logger.info("Skipping update of layer %s as fetch of repository %s failed" % (layer.name, layer.vcs_url))
+
+ urldir = layer.get_fetch_dir()
+ repodir = os.path.join(fetchdir, urldir)
+
+ cmd = 'python update_layer.py -l %s -b %s' % (layer.name, branch)
+ if options.reload:
+ cmd += ' --reload'
+ if options.fullreload:
+ cmd += ' --fullreload'
+ if options.nocheckout:
+ cmd += ' --nocheckout'
+ if options.dryrun:
+ cmd += ' -n'
+ if options.loglevel == logging.DEBUG:
+ cmd += ' -d'
+ elif options.loglevel == logging.ERROR:
+ cmd += ' -q'
+ logger.debug('Running layer update command: %s' % cmd)
+ ret = run_command_interruptible(cmd)
+ if ret == 254:
+ # Interrupted by user, break out of loop
+ break
finally:
utils.unlock_file(lockfile)