Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 91757 | Differences between
and this patch

Collapse All | Expand All

(-)bin/equery-edit1 (-2 / +65 lines)
Lines 1402-1407 Link Here
1402
			   "  " + pp.localoption("-p, --portage-tree") + "	  - also search in portage tree (" + gentoolkit.settings["PORTDIR"] + ")\n" + \
1402
			   "  " + pp.localoption("-p, --portage-tree") + "	  - also search in portage tree (" + gentoolkit.settings["PORTDIR"] + ")\n" + \
1403
			   "  " + pp.localoption("-o, --overlay-tree") + "	  - also search in overlay tree (" + gentoolkit.settings["PORTDIR_OVERLAY"] + ")\n"
1403
			   "  " + pp.localoption("-o, --overlay-tree") + "	  - also search in overlay tree (" + gentoolkit.settings["PORTDIR_OVERLAY"] + ")\n"
1404
1404
1405
class CmdBaseDirectory(Command):
1406
	"""Display the path to a given package's base directory in the portage tree,
1407
	   that would be used by Portage with the current configuration."""
1408
	def __init__(self):
1409
		self.default_opts = { }
1410
1411
	def parseArgs(self, args):
1412
1413
		query = ""
1414
		need_help = 0
1415
		opts = self.default_opts
1416
		skip = 0
1417
		
1418
		for i in xrange(len(args)):
1419
1420
			if skip:
1421
				skip -= 1
1422
				continue
1423
			x = args[i]
1424
			
1425
			if x in ["-h","--help"]:
1426
				need_help = 1
1427
				break
1428
			else:
1429
				query = x
1430
1431
		if need_help or query == "":
1432
			print_info(0, self.longHelp())
1433
			sys.exit(-1)
1434
			
1435
		return (query, opts)
1436
				
1437
	def perform(self, args):
1438
		(query, opts) = self.parseArgs(args)
1439
1440
		matches = gentoolkit.find_packages(query, True)
1441
		
1442
		if matches:
1443
			non_overlay_found = False
1444
			
1445
			for pkg in matches:
1446
				if not pkg.is_overlay():
1447
					print_info(0, os.path.normpath(pkg.get_package_path()))
1448
					non_overlay_found = True
1449
					break
1450
1451
			if not non_overlay_found:
1452
				# Package is only in an overlay.  Print the path of one of them
1453
				print_info(0, os.path.normpath(matches[0].get_package_path()))
1454
		else:
1455
			print_error("No masked or unmasked packages found for " + pp.pkgquery(query))
1456
					
1457
	def shortHelp(self):
1458
		return pp.pkgquery("pkgspec") + " - print path to portage tree base directory for package " + pp.pkgquery("pkgspec")
1459
	def longHelp(self):
1460
		return "Print full path to a given package's base directory in the portage tree" + \
1461
			"\n" + \
1462
			"Syntax:\n" + \
1463
			"  " + pp.command("basedir ") + pp.pkgquery("pkgspec")
1464
1465
1405
#
1466
#
1406
# Command line tokens to commands mapping
1467
# Command line tokens to commands mapping
1407
#
1468
#
Lines 1419-1425 Link Here
1419
	"check" : CmdCheckIntegrity(),
1480
	"check" : CmdCheckIntegrity(),
1420
	"stats" : CmdDisplayStatistics(),
1481
	"stats" : CmdDisplayStatistics(),
1421
	"glsa" : CmdListGLSAs(),
1482
	"glsa" : CmdListGLSAs(),
1422
	"which": CmdWhich()
1483
	"which": CmdWhich(),
1484
	"basedir": CmdBaseDirectory()
1423
	}
1485
	}
1424
1486
1425
# Short command line tokens
1487
# Short command line tokens
Lines 1437-1443 Link Here
1437
	"s" : "size",
1499
	"s" : "size",
1438
	"t" : "stats",
1500
	"t" : "stats",
1439
	"u" : "uses",
1501
	"u" : "uses",
1440
	"w" : "which"
1502
	"w" : "which",
1503
	"r" : "basedir"
1441
}
1504
}
1442
1505
1443
from gentoolkit import Config
1506
from gentoolkit import Config

Return to bug 91757