View previous topic :: View next topic |
Author |
Message |
Jesore Apprentice
Joined: 17 Jul 2002 Posts: 232 Location: Nürnberg Germany
|
Posted: Sun Aug 01, 2004 9:11 am Post subject: USE flags - list all packets who have a special one |
|
|
The topic pretty much says it - I want to be able to search through all ebuilds for those who make use of a specific USE flag. For all already installed I would do a
Code: | emerge -pve world | grep flag |
but without I'm pretty much clueless - besides doing a recursive grep. I'm sure there must be a more elegant way to do this.
Jesore |
|
Back to top |
|
|
c0balt Guru
Joined: 04 Jul 2004 Posts: 441 Location: Germany
|
Posted: Sun Aug 01, 2004 10:17 am Post subject: |
|
|
i guess thats what
/usr/portage/profile/use.local.desc
is for |
|
Back to top |
|
|
Jesore Apprentice
Joined: 17 Jul 2002 Posts: 232 Location: Nürnberg Germany
|
Posted: Sun Aug 01, 2004 11:20 am Post subject: |
|
|
That's only for local use flags - flags that are only used for one single packet. The interesting flags, like mysql, are not included there.
Jesore |
|
Back to top |
|
|
tomk Bodhisattva
Joined: 23 Sep 2003 Posts: 7221 Location: Sat in front of my computer
|
Posted: Mon Aug 02, 2004 6:35 am Post subject: |
|
|
For the global USE flags have a look at /usr/portage/profiles/use.desc or here. _________________ Search | Read | Answer | Report | Strip |
|
Back to top |
|
|
Jesore Apprentice
Joined: 17 Jul 2002 Posts: 232 Location: Nürnberg Germany
|
Posted: Mon Aug 02, 2004 7:47 am Post subject: |
|
|
Ok, I'll try to describe what was the problem again. I need to know what ebuilds make use of a specific flag, the basic descriptions of the flags are nothing new and don't help in my special case. All I wanted to know is, wether there is an official resource or a tool that does it.
What I now basically did was :
Code: | cd /usr/portage && grep -e 'IUSE=".*mysql.*"' -R * | cut -d "/" -f 2 |
It doesn't look very pretty, but it does what's needed.
Jesore |
|
Back to top |
|
|
pYrania Retired Dev
Joined: 27 Oct 2002 Posts: 650 Location: Cologne - Germany
|
Posted: Mon Aug 02, 2004 7:53 am Post subject: |
|
|
when it does what you need, where is the problem?
there is no other way than recursive grepping over your tree. _________________ Markus Nigbur |
|
Back to top |
|
|
xmit Apprentice
Joined: 02 Apr 2003 Posts: 158 Location: Hamburg, Germany
|
|
Back to top |
|
|
Jesore Apprentice
Joined: 17 Jul 2002 Posts: 232 Location: Nürnberg Germany
|
Posted: Mon Aug 02, 2004 11:28 am Post subject: |
|
|
pYrania wrote: | when it does what you need, where is the problem?
there is no other way than recursive grepping over your tree. |
All I did was asking if there is a tool I might have not seen (like in gentoolkit). Never mind. |
|
Back to top |
|
|
Jesore Apprentice
Joined: 17 Jul 2002 Posts: 232 Location: Nürnberg Germany
|
Posted: Mon Aug 02, 2004 11:32 am Post subject: |
|
|
Thanks, but this script just covers INSTALLED ebuilds
Code: | emerge -pev world | grep flag |
does the same.
Besides, German woudln't have been the problem. Have a look below my avatar
Greetings to Hamburg.
Jesore |
|
Back to top |
|
|
singular n00b
Joined: 07 Jun 2003 Posts: 54
|
Posted: Tue Aug 03, 2004 5:32 am Post subject: |
|
|
Here is a python script to search either the whole tree or just the installed portion for packages with specific useflags.
You will also need to have gentoolkit installed to use it.
Code: |
#!/usr/bin/python
############################################################
# finduse: Python script to search Portage database for
# packages that can make use of specific useflags.
#
# Requirements:
# Python v2.3 or better is required for the optparse module.
# Gentoolkit
#
# Licence: GPL
# Author : Robert Morris (singular) robert@twilightsedge.com
#############################################################
import sys
from optparse import OptionParser
# Make sure gentoolkit module is in the path
sys.path.insert(0, "/usr/lib/gentoolkit/pym")
import gentoolkit
def filter_packages(pkglist, useflag, enabled=1):
"""Filter packages based on if the useflag was enabled or disabled."""
result = []
for pkg in pkglist:
use = pkg.get_use_flags()
if (enabled and useflag in use)\
or (not enabled and not useflag in use):
result.append(pkg)
return result
def find_packages(useflag, installedonly=0):
"""Walk through the portage tree and return all packages that can
make use of a specific useflag.
"""
result = []
# First we'll get a list of all category/package pairs listed
# in portage, or just the ones installed if requested.
if installedonly:
pkglist = gentoolkit.vartree.getallnodes()
else:
pkglist = gentoolkit.porttree.getallnodes()
# Next we walk through the list and see if they have the useflag.
for catpkg in pkglist:
matches = gentoolkit.find_packages(catpkg)
for pkg in matches:
use = pkg.get_env_var("IUSE")
if (useflag in use) and (not installedonly or pkg.is_installed()):
result.append(pkg)
return result
def print_packages(packages, useflag, with_versions=0, verbose=0):
"""Prints out the packages found during the search.
The verbose option also displays if the useflag was enabled or not.
"""
pkglist = []
for pkg in packages:
if with_versions:
name = pkg.get_cpv()
else:
name = pkg.get_category() + "/" + pkg.get_name()
# If we don't need version numbers we'll
# trim the list to avoid duplicates.
if name in pkglist:
continue
pkglist.append(name)
if verbose:
enabled = ["-", "+"][useflag in pkg.get_use_flags()]
print "%s [%s%s]" % (name, enabled, useflag)
else:
print name
def main():
usage="""usage: %prog [OPTIONS] USEFLAG
Search Portage database for packages that make use of USEFLAG."""
parser = OptionParser(usage=usage)
parser.add_option("-d", "--disabled",
action="store_const",
const=1,
default=0,
dest="disabled",
help="find packages with USEFLAG disabled. Implies -i")
parser.add_option("-e", "--enabled",
action="store_const",
const=1,
default=0,
dest="enabled",
help="find packages with USEFLAG enabled. Implies -i")
parser.add_option("-i", "--installed",
action="store_const",
const=1,
default=0,
dest="installed",
help="search only installed packages.")
parser.add_option("-v", "--verbose",
action="store_const",
const=1,
default=0,
dest="verbose",
help="verbose output.")
parser.add_option("-w", "--with-versions",
action="store_const",
const=1,
default=0,
dest="with_versions",
help="print version numbers.")
(options, args) = parser.parse_args()
if len(args) != 1:
parser.error("incorrect number of arguments")
if options.enabled or options.disabled:
options.installed = 1
useflag = args[0]
pkgs = find_packages(useflag, options.installed)
if options.enabled ^ options.disabled:
enabled = options.enabled and not options.disabled
pkgs = filter_packages(pkgs, useflag, enabled)
print_packages(pkgs, useflag, options.with_versions, options.verbose)
if __name__ == "__main__":
main()
|
Last edited by singular on Sun Dec 19, 2004 7:26 pm; edited 1 time in total |
|
Back to top |
|
|
Jesore Apprentice
Joined: 17 Jul 2002 Posts: 232 Location: Nürnberg Germany
|
Posted: Fri Aug 06, 2004 6:48 am Post subject: |
|
|
Thanks, that helps.
Jesore |
|
Back to top |
|
|
kpoman Apprentice
Joined: 15 May 2003 Posts: 209 Location: Buenos Aires, Argentina
|
Posted: Mon Aug 23, 2004 10:20 pm Post subject: |
|
|
there is also the ufed tool which can be very practical ! good luck! _________________ please, help me, pity on me :'( |
|
Back to top |
|
|
duderonomy Guru
Joined: 20 Mar 2004 Posts: 349 Location: SF Bay Area
|
|
Back to top |
|
|
|