Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
USE flags - list all packets who have a special one
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Jesore
Apprentice
Apprentice


Joined: 17 Jul 2002
Posts: 232
Location: Nürnberg Germany

PostPosted: Sun Aug 01, 2004 9:11 am    Post subject: USE flags - list all packets who have a special one Reply with quote

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
View user's profile Send private message
c0balt
Guru
Guru


Joined: 04 Jul 2004
Posts: 441
Location: Germany

PostPosted: Sun Aug 01, 2004 10:17 am    Post subject: Reply with quote

i guess thats what
/usr/portage/profile/use.local.desc
is for :D
Back to top
View user's profile Send private message
Jesore
Apprentice
Apprentice


Joined: 17 Jul 2002
Posts: 232
Location: Nürnberg Germany

PostPosted: Sun Aug 01, 2004 11:20 am    Post subject: Reply with quote

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
View user's profile Send private message
tomk
Bodhisattva
Bodhisattva


Joined: 23 Sep 2003
Posts: 7221
Location: Sat in front of my computer

PostPosted: Mon Aug 02, 2004 6:35 am    Post subject: Reply with quote

For the global USE flags have a look at /usr/portage/profiles/use.desc or here.
_________________
Search | Read | Answer | Report | Strip
Back to top
View user's profile Send private message
Jesore
Apprentice
Apprentice


Joined: 17 Jul 2002
Posts: 232
Location: Nürnberg Germany

PostPosted: Mon Aug 02, 2004 7:47 am    Post subject: Reply with quote

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
View user's profile Send private message
pYrania
Retired Dev
Retired Dev


Joined: 27 Oct 2002
Posts: 650
Location: Cologne - Germany

PostPosted: Mon Aug 02, 2004 7:53 am    Post subject: Reply with quote

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
View user's profile Send private message
xmit
Apprentice
Apprentice


Joined: 02 Apr 2003
Posts: 158
Location: Hamburg, Germany

PostPosted: Mon Aug 02, 2004 8:33 am    Post subject: Reply with quote

Jesore,
I found this script helpful:
https://forums.gentoo.org/viewtopic.php?t=198369&highlight=flagusers
You do need to understand german to use it. Type 'flagusers GNOME' and it lists all packages that make use of the flag GNOME.

mg
Back to top
View user's profile Send private message
Jesore
Apprentice
Apprentice


Joined: 17 Jul 2002
Posts: 232
Location: Nürnberg Germany

PostPosted: Mon Aug 02, 2004 11:28 am    Post subject: Reply with quote

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
View user's profile Send private message
Jesore
Apprentice
Apprentice


Joined: 17 Jul 2002
Posts: 232
Location: Nürnberg Germany

PostPosted: Mon Aug 02, 2004 11:32 am    Post subject: Reply with quote

xmit wrote:
Jesore,
I found this script helpful:
https://forums.gentoo.org/viewtopic.php?t=198369&highlight=flagusers
You do need to understand german to use it. Type 'flagusers GNOME' and it lists all packages that make use of the flag GNOME.

mg


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
View user's profile Send private message
singular
n00b
n00b


Joined: 07 Jun 2003
Posts: 54

PostPosted: Tue Aug 03, 2004 5:32 am    Post subject: Reply with quote

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
View user's profile Send private message
Jesore
Apprentice
Apprentice


Joined: 17 Jul 2002
Posts: 232
Location: Nürnberg Germany

PostPosted: Fri Aug 06, 2004 6:48 am    Post subject: Reply with quote

Thanks, that helps.

Jesore
Back to top
View user's profile Send private message
kpoman
Apprentice
Apprentice


Joined: 15 May 2003
Posts: 209
Location: Buenos Aires, Argentina

PostPosted: Mon Aug 23, 2004 10:20 pm    Post subject: Reply with quote

there is also the ufed tool which can be very practical ! :) good luck!
_________________
please, help me, pity on me :'(
Back to top
View user's profile Send private message
duderonomy
Guru
Guru


Joined: 20 Mar 2004
Posts: 349
Location: SF Bay Area

PostPosted: Mon Feb 12, 2007 9:30 am    Post subject: Reply with quote

see:
https://forums.gentoo.org/viewtopic-t-353919.html
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum