Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 204324
Collapse All | Expand All

(-)equery.orig (-2 / +71 lines)
Lines 1569-1574 Link Here
1569
			   "  " + pp.localoption("-p, --portage-tree") + "	  - also search in portage tree (" + gentoolkit.settings["PORTDIR"] + ")\n" + \
1569
			   "  " + pp.localoption("-p, --portage-tree") + "	  - also search in portage tree (" + gentoolkit.settings["PORTDIR"] + ")\n" + \
1570
			   "  " + pp.localoption("-o, --overlay-tree") + "	  - also search in overlay tree (" + gentoolkit.settings["PORTDIR_OVERLAY"] + ")\n"
1570
			   "  " + pp.localoption("-o, --overlay-tree") + "	  - also search in overlay tree (" + gentoolkit.settings["PORTDIR_OVERLAY"] + ")\n"
1571
1571
1572
class CmdFindPkgsInOverlay(Command):
1573
	def __init__(self):
1574
		self.defaultOpts = {}
1575
	def parseArgs(self, args):
1576
		query = ""
1577
		need_help = 0
1578
		opts = self.defaultOpts
1579
		skip = 0
1580
1581
                for i in xrange(len(args)):
1582
			if skip:
1583
				skip -= 1
1584
				continue
1585
                        x = args[i]
1586
1587
                        if x in ["-h","--help"]:
1588
                                need_help = 1
1589
                                break
1590
                        else:
1591
                                query = x
1592
1593
                if need_help or query == "":
1594
                        print_info(0, self.longHelp())
1595
                        sys.exit(-1)
1596
1597
                return (query, opts)
1598
1599
1600
	def perform(self, args):
1601
		(query, opts)  = self.parseArgs(args)
1602
		self.overlay = query
1603
		packages = portage.db["/"]["vartree"].dbapi.cpv_all()
1604
		found = []
1605
		count = 0
1606
		count_unknown = 0
1607
		# in the loop I'd like to use aux_get from the dbapi, but it isn't implemented yet
1608
		for i in xrange(len(packages)):
1609
			pkgpath = portage.root + portage.VDB_PATH + "/" + packages[i]
1610
			repofile = pkgpath + "/repository"
1611
			if os.path.exists(pkgpath):
1612
				count+=1
1613
				if os.path.exists(repofile):
1614
					ofile=open(repofile,"r")
1615
					repo = ofile.readline().rstrip()
1616
					if repo == self.overlay:
1617
						found.append(packages[i])
1618
					ofile.close()
1619
				else:
1620
					count_unknown+=1
1621
			else:
1622
				print "Something went terrible wrong, your portage / python install is screwed"
1623
				print "Your system thinkgs it has files installed, but they aren't there"
1624
				die("dbapi.cpv_all() reporting items not in portage.VDB_PATH")
1625
		for i in xrange(len(found)):
1626
			print found[i]
1627
		print "\n-====-\n\nCouldn't identifiy " + str(count_unknown) + " packages out of " + str(count)
1628
1629
	def shortHelp(self):
1630
		return pp.pkgquery("overlay") + " - Finds packages installed from " + pp.pkgquery("overlay") 
1631
1632
	def longHelp(self):
1633
		return "Find all packages that have been installed from the overlay" + \
1634
                                "\n" + \
1635
                                "Syntax:\n" + \
1636
                                "  " + pp.command("inoverlay") + pp.pkgquery(" overlay")	
1637
1638
1572
#
1639
#
1573
# Command line tokens to commands mapping
1640
# Command line tokens to commands mapping
1574
#
1641
#
Lines 1586-1592 Link Here
1586
	"check" : CmdCheckIntegrity(),
1653
	"check" : CmdCheckIntegrity(),
1587
	"stats" : CmdDisplayStatistics(),
1654
	"stats" : CmdDisplayStatistics(),
1588
	"glsa" : CmdListGLSAs(),
1655
	"glsa" : CmdListGLSAs(),
1589
	"which": CmdWhich()
1656
	"which": CmdWhich(),
1657
	"inoverlay": CmdFindPkgsInOverlay()
1590
	}
1658
	}
1591
1659
1592
# Short command line tokens
1660
# Short command line tokens
Lines 1604-1610 Link Here
1604
	"s" : "size",
1672
	"s" : "size",
1605
	"t" : "stats",
1673
	"t" : "stats",
1606
	"u" : "uses",
1674
	"u" : "uses",
1607
	"w" : "which"
1675
	"w" : "which",
1676
	"o" : "inoverlay"
1608
}
1677
}
1609
1678
1610
from gentoolkit import Config
1679
from gentoolkit import Config

Return to bug 204324