From d0672a5194176b5b91d58681e4b86f154b4d6f20 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 18 Mar 2013 01:32:41 -0700 Subject: [PATCH] portageq: visiblity filter for pquery mode --- bin/portageq | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/bin/portageq b/bin/portageq index f91ec8112..c320dbac7 100755 --- a/bin/portageq +++ b/bin/portageq @@ -964,6 +964,8 @@ class HerdMatcher(object): def pquery(parser, pquery_option_groups, opts, args): portdb = portage.db[portage.root]['porttree'].dbapi + root_config = RootConfig(portdb.settings, + portage.db[portage.root], None) need_metadata = False extended_syntax = False @@ -997,6 +999,9 @@ def pquery(parser, pquery_option_groups, opts, args): need_metadata = False extended_syntax = False + if not opts.no_filters: + need_metadata = True + xml_matchers = [] if opts.maintainer_email: maintainer_emails = [] @@ -1059,6 +1064,7 @@ def pquery(parser, pquery_option_groups, opts, args): cpv_list = portdb.cp_list(cp, mytree=[repo.location]) if atoms: for cpv in cpv_list: + pkg = None for atom in atoms: if atom.repo is not None and \ atom.repo != repo.name: @@ -1066,8 +1072,23 @@ def pquery(parser, pquery_option_groups, opts, args): if not portage.match_from_list(atom, [cpv]): continue if need_metadata: - cpv = portdb._pkg_str(cpv, repo.name) - if not portage.match_from_list(atom, [cpv]): + if pkg is None: + try: + metadata = dict(zip( + Package.metadata_keys, + portdb.aux_get(cpv, + Package.metadata_keys, + myrepo=repo.name))) + except KeyError: + continue + pkg = Package(built=False, cpv=cpv, + installed=False, metadata=metadata, + root_config=root_config, + type_name="ebuild") + + if not (opts.no_filters or pkg.visible): + continue + if not portage.match_from_list(atom, [pkg]): continue matches.append(cpv) break @@ -1106,6 +1127,8 @@ def main(argv): repo_optgroup = optparse.OptionGroup(parser, 'Repository matching options') + repo_optgroup.add_option("--no-filters", action="store_true", + help="no visibility filters (ACCEPT_KEYWORDS, package masking, etc)") repo_optgroup.add_option("--repo", action="store", help="repo to use (default is PORTDIR if omitted)") repo_optgroup.add_option("--all-repos", action="store_true", -- 2.26.2