Thomas de Grenier de Latour wrote:
On 2008/02/04, Ryan Hill <[EMAIL PROTECTED]> wrote:Can someone provide a tool that given a package name simply prints the category or cat/pkg, or if ambiguous, prints the multiple cat/pkgs or returns an error code? I don't care what it's written in as long as it's relatively quick.As long as you're only interrested in stuffs from the Portage tree, and not overlays, and you have portage-utils installed along with its post-sync hook, you can use one of this function: find_cat1() { qsearch -CsN "^${1}$" } find_cat2() { sed -n "\\|/${1}/|s:/[^/]*\$::p" "${PORTDIR}"/.ebuild.x \ | uniq } Note that find_cat1() is case-insensitive, probably not what you want. And without portage-utils' ebuilds cache, this works too: find_cat3() { pushd "${PORTDIR}" >/dev/null ls -1d $(sed "s:\$:/${1}:" profiles/categories) 2>/dev/null popd >/dev/null } Here are some benchs (real time, with 1 run from cold I/O cache, andthen 100 runs also from cold I/O cache, with "fuse" as argument):* find_cat1: - 0m0.972s - 0m25.967s (No real advantage... that's not the primary target of this applet.) * find_cat2: - 0m0.237s - 0m3.746s (Acceptable in both cases.) * find_cat3: - 0m2.319s - 0m2.607s (Really slow on first run, but really fast once the tree as been walked. May be a good choice in some contexts.)
Perfect! I'll tinker with these and see what I come up with. Thanks. -- fonts, by design, by neglect gcc-porting, for a fact or just for effect wxwindows @ gentoo EFFD 380E 047A 4B51 D2BD C64F 8AA8 8346 F9A4 0662
signature.asc
Description: OpenPGP digital signature