From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 59E00138010 for ; Fri, 31 Aug 2012 16:38:05 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1A60BE01F1; Fri, 31 Aug 2012 16:37:56 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id B4945E01F1 for ; Fri, 31 Aug 2012 16:37:56 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C3A8C33D8F4 for ; Fri, 31 Aug 2012 16:37:55 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 81778E543C for ; Fri, 31 Aug 2012 16:37:54 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1346430842.821fe40222e75ba08e5456577321fa5d1f12e69a.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/portageq X-VCS-Directories: bin/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 821fe40222e75ba08e5456577321fa5d1f12e69a X-VCS-Branch: master Date: Fri, 31 Aug 2012 16:37:54 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 290e21a4-b62e-4062-b305-e9be54b22eb8 X-Archives-Hash: ee156efd12dbfd0dfa5521f9be1c0f23 commit: 821fe40222e75ba08e5456577321fa5d1f12e69a Author: Gregory M. Turner ameritech net> AuthorDate: Fri Aug 31 16:34:02 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri Aug 31 16:34:02 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=821fe402 portageq: clarify meaning of uses_root o s/uses_root/uses_eroot/g -- This name was chosen before its meaning was changed; update it to reflect its purporse. o Fix a left-over "" arg-doc that never got updated to "" o If a provided eroot argument was shorter than the ${EPREFIX}, portageq was truncating it down to nothing and activating relative root, which means this became equivalent to an explicit argument of "${PWD}/${EPREFIX}/". This is obviously wrong; and a simple case of failing to sanity-check inputs from an interface that changed in a backward-incompatible way. There's no provision in portageq to query EROOT's that don't end in ${EPREFIX}; so if the user makes such a request, instead of doing something pathological, dump a helpful error message and bail with a nonzero exit code. Signed-off-by: Gregory M. Turner ameritech.net> --- bin/portageq | 49 +++++++++++++++++++++++++++++-------------------- 1 files changed, 29 insertions(+), 20 deletions(-) diff --git a/bin/portageq b/bin/portageq index d9abb0b..eeea277 100755 --- a/bin/portageq +++ b/bin/portageq @@ -125,7 +125,7 @@ def has_version(argv): portage.writemsg("ERROR: Invalid atom: '%s'\n" % argv[1], noiselevel=-1) return 2 -has_version.uses_root = True +has_version.uses_eroot = True def best_version(argv): @@ -166,7 +166,7 @@ def best_version(argv): print(portage.best(mylist)) except KeyError: return 1 -best_version.uses_root = True +best_version.uses_eroot = True def mass_best_version(argv): @@ -182,7 +182,7 @@ def mass_best_version(argv): print(pack+":"+portage.best(mylist)) except KeyError: return 1 -mass_best_version.uses_root = True +mass_best_version.uses_eroot = True def metadata(argv): if (len(argv) < 4): @@ -216,7 +216,7 @@ Available keys: %s """ % ','.join(sorted(x for x in portage.auxdbkeys \ if not x.startswith('UNUSED_'))) -metadata.uses_root = True +metadata.uses_eroot = True def contents(argv): """ @@ -238,7 +238,7 @@ def contents(argv): treetype="vartree", vartree=vartree) writemsg_stdout(''.join('%s\n' % x for x in sorted(db.getcontents())), noiselevel=-1) -contents.uses_root = True +contents.uses_eroot = True def owners(argv): """ []+ @@ -319,7 +319,7 @@ def owners(argv): return 0 return 1 -owners.uses_root = True +owners.uses_eroot = True def is_protected(argv): """ @@ -366,7 +366,7 @@ def is_protected(argv): return 0 return 1 -is_protected.uses_root = True +is_protected.uses_eroot = True def filter_protected(argv): """ @@ -426,7 +426,7 @@ def filter_protected(argv): return 0 -filter_protected.uses_root = True +filter_protected.uses_eroot = True def best_visible(argv): """ [pkgtype] @@ -508,11 +508,11 @@ def best_visible(argv): writemsg_stdout("\n", noiselevel=-1) return 1 -best_visible.uses_root = True +best_visible.uses_eroot = True def mass_best_visible(argv): - """ [] []+ + """ [] []+ Returns category/package-version (without .ebuild). The pkgtype argument defaults to "ebuild" if unspecified, otherwise it must be one of ebuild, binary, or installed. @@ -535,7 +535,7 @@ def mass_best_visible(argv): best_visible([root, pkgtype, pack]) except KeyError: return 1 -mass_best_visible.uses_root = True +mass_best_visible.uses_eroot = True def all_best_visible(argv): @@ -552,7 +552,7 @@ def all_best_visible(argv): mybest=portage.best(portage.db[argv[0]]["porttree"].dbapi.match(pkg)) if mybest: print(mybest) -all_best_visible.uses_root = True +all_best_visible.uses_eroot = True def match(argv): @@ -601,7 +601,7 @@ def match(argv): results = vardb.match(atom) for cpv in results: print(cpv) -match.uses_root = True +match.uses_eroot = True def expand_virtual(argv): """ @@ -637,7 +637,7 @@ def expand_virtual(argv): return os.EX_OK -expand_virtual.uses_root = True +expand_virtual.uses_eroot = True def vdb_path(argv): """ @@ -733,7 +733,7 @@ def get_repos(argv): return 2 print(" ".join(portage.db[argv[0]]["porttree"].dbapi.getRepositories())) -get_repos.uses_root = True +get_repos.uses_eroot = True def get_repo_path(argv): """ + @@ -748,7 +748,7 @@ def get_repo_path(argv): path = "" print(path) -get_repo_path.uses_root = True +get_repo_path.uses_eroot = True def list_preserved_libs(argv): """ @@ -771,7 +771,7 @@ def list_preserved_libs(argv): msg.append('\n') writemsg_stdout(''.join(msg), noiselevel=-1) return rValue -list_preserved_libs.uses_root = True +list_preserved_libs.uses_eroot = True #----------------------------------------------------------------------------- # @@ -860,8 +860,8 @@ def main(): usage(sys.argv) sys.exit(os.EX_USAGE) function = globals()[cmd] - uses_root = getattr(function, "uses_root", False) and len(sys.argv) > 2 - if uses_root: + uses_eroot = getattr(function, "uses_eroot", False) and len(sys.argv) > 2 + if uses_eroot: if not os.path.isdir(sys.argv[2]): sys.stderr.write("Not a directory: '%s'\n" % sys.argv[2]) sys.stderr.write("Run portageq with --help for info\n") @@ -869,10 +869,19 @@ def main(): sys.exit(os.EX_USAGE) eprefix = portage.const.EPREFIX eroot = portage.util.normalize_path(sys.argv[2]) + if eprefix: + if not eroot.endswith(eprefix): + sys.stderr.write("ERROR: This version of portageq" + " only supports s ending in" + " '%s'. The provided , '%s'," + " doesn't.\n" % (eprefix, eroot)); + sys.stderr.flush() + sys.exit(os.EX_USAGE) root = eroot[:1-len(eprefix)] else: root = eroot + os.environ["ROOT"] = root args = sys.argv[2:] @@ -881,7 +890,7 @@ def main(): args[i] = portage._unicode_decode(args[i]) try: - if uses_root: + if uses_eroot: args[0] = portage.settings['EROOT'] retval = function(args) if retval: