--- bin/equery-edit1 2005-05-07 02:11:19.000000000 +0000 +++ bin/equery-edit 2005-05-07 02:39:10.000000000 +0000 @@ -1402,6 +1402,67 @@ " " + pp.localoption("-p, --portage-tree") + " - also search in portage tree (" + gentoolkit.settings["PORTDIR"] + ")\n" + \ " " + pp.localoption("-o, --overlay-tree") + " - also search in overlay tree (" + gentoolkit.settings["PORTDIR_OVERLAY"] + ")\n" +class CmdBaseDirectory(Command): + """Display the path to a given package's base directory in the portage tree, + that would be used by Portage with the current configuration.""" + def __init__(self): + self.default_opts = { } + + def parseArgs(self, args): + + query = "" + need_help = 0 + opts = self.default_opts + skip = 0 + + for i in xrange(len(args)): + + if skip: + skip -= 1 + continue + x = args[i] + + if x in ["-h","--help"]: + need_help = 1 + break + else: + query = x + + if need_help or query == "": + print_info(0, self.longHelp()) + sys.exit(-1) + + return (query, opts) + + def perform(self, args): + (query, opts) = self.parseArgs(args) + + matches = gentoolkit.find_packages(query, True) + + if matches: + non_overlay_found = False + + for pkg in matches: + if not pkg.is_overlay(): + print_info(0, os.path.normpath(pkg.get_package_path())) + non_overlay_found = True + break + + if not non_overlay_found: + # Package is only in an overlay. Print the path of one of them + print_info(0, os.path.normpath(matches[0].get_package_path())) + else: + print_error("No masked or unmasked packages found for " + pp.pkgquery(query)) + + def shortHelp(self): + return pp.pkgquery("pkgspec") + " - print path to portage tree base directory for package " + pp.pkgquery("pkgspec") + def longHelp(self): + return "Print full path to a given package's base directory in the portage tree" + \ + "\n" + \ + "Syntax:\n" + \ + " " + pp.command("basedir ") + pp.pkgquery("pkgspec") + + # # Command line tokens to commands mapping # @@ -1419,7 +1480,8 @@ "check" : CmdCheckIntegrity(), "stats" : CmdDisplayStatistics(), "glsa" : CmdListGLSAs(), - "which": CmdWhich() + "which": CmdWhich(), + "basedir": CmdBaseDirectory() } # Short command line tokens @@ -1437,7 +1499,8 @@ "s" : "size", "t" : "stats", "u" : "uses", - "w" : "which" + "w" : "which", + "r" : "basedir" } from gentoolkit import Config