summaryrefslogtreecommitdiffstats
path: root/bin/egencache
diff options
context:
space:
mode:
authorMichał Górny <gentoo@mgorny.alt.pl>2010-08-26 19:13:16 +0200
committerZac Medico <zmedico@gentoo.org>2010-08-26 10:34:26 -0700
commitdc65c64849ef56398e77435cc87696922e0726a1 (patch)
tree610e55b7c802ae768cb70a5cd6e80d73bdb7b946 /bin/egencache
parentda50b12d4c6eeca8dda1f97e49163c611c2b78b2 (diff)
downloadportage-dc65c64849ef56398e77435cc87696922e0726a1.tar.gz
portage-dc65c64849ef56398e77435cc87696922e0726a1.tar.bz2
portage-dc65c64849ef56398e77435cc87696922e0726a1.zip
egencache: introduce the preliminary support for multiple actions.
Regroup the options, splitting them into 'Actions', 'Common' and action-specific options. Always check whether the 'update' action was chosen. Support catching multiple return codes.
Diffstat (limited to 'bin/egencache')
-rwxr-xr-xbin/egencache75
1 files changed, 45 insertions, 30 deletions
diff --git a/bin/egencache b/bin/egencache
index 0d9c4858d..f205a4906 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -1,5 +1,5 @@
#!/usr/bin/python
-# Copyright 2009 Gentoo Foundation
+# Copyright 2009-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from __future__ import print_function
@@ -41,40 +41,50 @@ if sys.hexversion >= 0x3000000:
long = int
def parse_args(args):
- usage = "egencache [options] --update [atom] ..."
+ usage = "egencache [options] <action> ... [atom] ..."
parser = optparse.OptionParser(usage=usage)
- parser.add_option("--update",
+
+ actions = optparse.OptionGroup(parser, 'Actions')
+ actions.add_option("--update",
action="store_true",
help="update metadata/cache/ (generate as necessary)")
- parser.add_option("--repo",
+ parser.add_option_group(actions)
+
+ common = optparse.OptionGroup(parser, 'Common options')
+ common.add_option("--repo",
action="store",
help="name of repo to operate on (default repo is located at $PORTDIR)")
- parser.add_option("--cache-dir",
- help="location of the metadata cache",
- dest="cache_dir")
- parser.add_option("--config-root",
+ common.add_option("--config-root",
help="location of portage config files",
dest="portage_configroot")
- parser.add_option("--jobs",
+ common.add_option("--portdir",
+ help="override the portage tree location",
+ dest="portdir")
+ common.add_option("--tolerant",
+ action="store_true",
+ help="exit successfully if only minor errors occurred")
+ common.add_option("--ignore-default-opts",
+ action="store_true",
+ help="do not use the EGENCACHE_DEFAULT_OPTS environment variable")
+ parser.add_option_group(common)
+
+ update = optparse.OptionGroup(parser, '--update options')
+ update.add_option("--cache-dir",
+ help="location of the metadata cache",
+ dest="cache_dir")
+ update.add_option("--jobs",
action="store",
help="max ebuild processes to spawn")
- parser.add_option("--load-average",
+ update.add_option("--load-average",
action="store",
help="max load allowed when spawning multiple jobs",
dest="load_average")
- parser.add_option("--portdir",
- help="override the portage tree location",
- dest="portdir")
- parser.add_option("--rsync",
+ update.add_option("--rsync",
action="store_true",
help="enable rsync stat collision workaround " + \
"for bug 139134 (use with --update)")
- parser.add_option("--tolerant",
- action="store_true",
- help="exit successfully if only minor errors occurred")
- parser.add_option("--ignore-default-opts",
- action="store_true",
- help="do not use the EGENCACHE_DEFAULT_OPTS environment variable")
+ parser.add_option_group(update)
+
options, args = parser.parse_args(args)
if options.jobs:
@@ -341,18 +351,23 @@ def egencache_main(args):
# Limit ebuilds to the specified repo.
portdb.porttrees = [repo_path]
- cp_iter = None
- if atoms:
- cp_iter = iter(atoms)
+ ret = [os.EX_OK]
+
+ if options.update:
+ cp_iter = None
+ if atoms:
+ cp_iter = iter(atoms)
+
+ gen_cache = GenCache(portdb, cp_iter=cp_iter,
+ max_jobs=options.jobs,
+ max_load=options.load_average,
+ rsync=options.rsync)
+ gen_cache.run()
+ ret.append(gen_cache.returncode)
- gen_cache = GenCache(portdb, cp_iter=cp_iter,
- max_jobs=options.jobs,
- max_load=options.load_average,
- rsync=options.rsync)
- gen_cache.run()
if options.tolerant:
- return os.EX_OK
- return gen_cache.returncode
+ return ret[0]
+ return max(ret)
if __name__ == "__main__":
portage._disable_legacy_globals()