Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

USE flags - list all packets who have a special one

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
13 posts • Page 1 of 1
Author
Message
Jesore
Apprentice
Apprentice
User avatar
Posts: 232
Joined: Wed Jul 17, 2002 4:32 pm
Location: Nürnberg Germany

USE flags - list all packets who have a special one

  • Quote

Post by Jesore » Sun Aug 01, 2004 9:11 am

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: Select all

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
Top
c0balt
Guru
Guru
User avatar
Posts: 441
Joined: Sun Jul 04, 2004 12:45 pm
Location: Germany

  • Quote

Post by c0balt » Sun Aug 01, 2004 10:17 am

i guess thats what
/usr/portage/profile/use.local.desc
is for :D
Top
Jesore
Apprentice
Apprentice
User avatar
Posts: 232
Joined: Wed Jul 17, 2002 4:32 pm
Location: Nürnberg Germany

  • Quote

Post by Jesore » Sun Aug 01, 2004 11:20 am

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
Top
tomk
Bodhisattva
Bodhisattva
User avatar
Posts: 7221
Joined: Tue Sep 23, 2003 1:41 pm
Location: Sat in front of my computer

  • Quote

Post by tomk » Mon Aug 02, 2004 6:35 am

For the global USE flags have a look at /usr/portage/profiles/use.desc or here.
Search | Read | [topic=119906]Answer[/topic] | [topic=28820]Report[/topic] | [topic=160179]Strip[/topic]
Top
Jesore
Apprentice
Apprentice
User avatar
Posts: 232
Joined: Wed Jul 17, 2002 4:32 pm
Location: Nürnberg Germany

  • Quote

Post by Jesore » Mon Aug 02, 2004 7:47 am

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: Select all

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
Top
pYrania
Retired Dev
Retired Dev
User avatar
Posts: 650
Joined: Sun Oct 27, 2002 8:19 pm
Location: Cologne - Germany
Contact:
Contact pYrania
Website

  • Quote

Post by pYrania » Mon Aug 02, 2004 7:53 am

when it does what you need, where is the problem?
there is no other way than recursive grepping over your tree.
Markus Nigbur
Top
xmit
Apprentice
Apprentice
User avatar
Posts: 158
Joined: Wed Apr 02, 2003 10:45 pm
Location: Hamburg, Germany

  • Quote

Post by xmit » Mon Aug 02, 2004 8:33 am

Jesore,
I found this script helpful:
http://forums.gentoo.org/viewtopic.php? ... =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
Top
Jesore
Apprentice
Apprentice
User avatar
Posts: 232
Joined: Wed Jul 17, 2002 4:32 pm
Location: Nürnberg Germany

  • Quote

Post by Jesore » Mon Aug 02, 2004 11:28 am

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.
Top
Jesore
Apprentice
Apprentice
User avatar
Posts: 232
Joined: Wed Jul 17, 2002 4:32 pm
Location: Nürnberg Germany

  • Quote

Post by Jesore » Mon Aug 02, 2004 11:32 am

xmit wrote:Jesore,
I found this script helpful:
http://forums.gentoo.org/viewtopic.php? ... =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: Select all

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
Top
singular
n00b
n00b
User avatar
Posts: 54
Joined: Sat Jun 07, 2003 3:34 am
Contact:
Contact singular
Website

  • Quote

Post by singular » Tue Aug 03, 2004 5:32 am

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: Select all

#!/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.
Top
Jesore
Apprentice
Apprentice
User avatar
Posts: 232
Joined: Wed Jul 17, 2002 4:32 pm
Location: Nürnberg Germany

  • Quote

Post by Jesore » Fri Aug 06, 2004 6:48 am

Thanks, that helps.

Jesore
Top
kpoman
Apprentice
Apprentice
User avatar
Posts: 209
Joined: Thu May 15, 2003 5:30 pm
Location: Buenos Aires, Argentina
Contact:
Contact kpoman
Website

  • Quote

Post by kpoman » Mon Aug 23, 2004 10:20 pm

there is also the ufed tool which can be very practical ! :) good luck!
please, help me, pity on me :'(
Top
duderonomy
Guru
Guru
Posts: 349
Joined: Sat Mar 20, 2004 7:51 pm
Location: SF Bay Area

  • Quote

Post by duderonomy » Mon Feb 12, 2007 9:30 am

see:
http://forums.gentoo.org/viewtopic-t-353919.html
Top
Post Reply

13 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy