diff options
author | Michał Górny <gentoo@mgorny.alt.pl> | 2010-08-28 16:46:17 +0200 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-08-28 07:46:48 -0700 |
commit | 5445f5a9e4a8af26d5a2a159365318c46de22f71 (patch) | |
tree | 4b53aea5fa0e16d639ff0e599ea85f43207e8ca3 | |
parent | 297225486d6887a03f9c4ae7a3105afe3ba0711e (diff) | |
download | portage-5445f5a9e4a8af26d5a2a159365318c46de22f71.tar.gz portage-5445f5a9e4a8af26d5a2a159365318c46de22f71.tar.bz2 portage-5445f5a9e4a8af26d5a2a159365318c46de22f71.zip |
Support specifying an alternate output file for --update-use-local-desc.
-rwxr-xr-x | bin/egencache | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/bin/egencache b/bin/egencache index b8c2c82a2..5ae15bc4f 100755 --- a/bin/egencache +++ b/bin/egencache @@ -97,6 +97,12 @@ def parse_args(args): "for bug 139134 (use with --update)") parser.add_option_group(update) + uld = optparse.OptionGroup(parser, '--update-use-local-desc options') + uld.add_option("--use-local-desc-output", + help="output file for use.local.desc data (or '-' for stdout)", + dest="uld_output") + parser.add_option_group(uld) + options, args = parser.parse_args(args) if options.jobs: @@ -307,28 +313,36 @@ class GenCache(object): level=logging.ERROR, noiselevel=-1) class GenUseLocalDesc(object): - def __init__(self, portdb): + def __init__(self, portdb, output=None): self.returncode = os.EX_OK self._portdb = portdb + self._output = output def run(self): repo_path = self._portdb.porttrees[0] - prof_path = os.path.join(repo_path, 'profiles') - desc_path = os.path.join(prof_path, 'use.local.desc') ops = {'<':0, '<=':1, '=':2, '>=':3, '>':4} - try: - os.mkdir(prof_path) - except OSError: - pass - try: - output = open(desc_path, 'w') - except IOError as e: - writemsg_level( - "ERROR: failed to open output file: %s\n" % (e,), - level=logging.ERROR, noiselevel=-1) - self.returncode |= 2 - return + if self._output is None or self._output != '-': + if self._output is None: + prof_path = os.path.join(repo_path, 'profiles') + desc_path = os.path.join(prof_path, 'use.local.desc') + try: + os.mkdir(prof_path) + except OSError: + pass + else: + desc_path = self._output + + try: + output = open(desc_path, 'w') + except IOError as e: + writemsg_level( + "ERROR: failed to open output file: %s\n" % (e,), + level=logging.ERROR, noiselevel=-1) + self.returncode |= 2 + return + else: + output = sys.stdout output.write(''' # This file is deprecated as per GLEP 56 in favor of metadata.xml. Please add @@ -483,7 +497,8 @@ def egencache_main(args): ret.append(gen_cache.returncode) if options.update_use_local_desc: - gen_desc = GenUseLocalDesc(portdb) + gen_desc = GenUseLocalDesc(portdb, + output=options.uld_output) gen_desc.run() ret.append(gen_desc.returncode) |