public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Ryan Hill <dirtyepic@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: [gentoo-dev]  Re: I want to steal your tools
Date: Mon, 04 Feb 2008 17:03:04 -0600	[thread overview]
Message-ID: <fo85jd$gld$1@ger.gmane.org> (raw)
In-Reply-To: <20080204235329.79637039@eusebe>

[-- Attachment #1: Type: text/plain, Size: 1839 bytes --]

Thomas de Grenier de Latour wrote:
> On 2008/02/04, Ryan Hill <dirtyepic@gentoo.org> 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, and
> then 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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2008-02-04 23:03 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-03  6:54 [gentoo-dev] I want to steal your tools Alec Warner
2008-02-03  7:10 ` Hans de Graaff
2008-02-03 12:48   ` [gentoo-dev] " Dirk Tilger
2008-02-03 18:01   ` [gentoo-dev] " Mart Raudsepp
2008-02-03  7:34 ` [gentoo-dev] " Christian Faulhammer
2008-02-03  7:56 ` [gentoo-dev] " Josh Saddler
2008-02-03 11:53   ` Drake Wyrm
2008-02-03 12:24 ` Fabian Groffen
2008-02-03 16:05 ` Duncan Coutts
2008-02-03 16:56 ` Ciaran McCreesh
2008-02-03 20:21 ` [gentoo-dev] " Ryan Hill
2008-02-03 23:35 ` [gentoo-dev] " Petteri Räty
2008-02-04 20:51 ` [gentoo-dev] " Ryan Hill
2008-02-04 21:59   ` Ryan Hill
2008-02-04 22:05     ` Ciaran McCreesh
2008-02-04 22:29       ` Vlastimil Babka
2008-02-04 22:42       ` Ryan Hill
2008-02-04 22:53   ` Thomas de Grenier de Latour
2008-02-04 23:03     ` Ryan Hill [this message]
2008-02-05  1:50   ` Heath N. Caldwell
2008-02-05  3:21     ` Ryan Hill
2008-02-05  5:06       ` Jeroen Roovers
2008-02-05 13:28       ` Santiago M. Mola

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='fo85jd$gld$1@ger.gmane.org' \
    --to=dirtyepic@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox