public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Thomas de Grenier de Latour <degrenier@easyconnect.fr>
To: gentoo-dev@lists.gentoo.org
Subject: Re: [gentoo-dev]  Re: I want to steal your tools
Date: Mon, 4 Feb 2008 23:53:29 +0100	[thread overview]
Message-ID: <20080204235329.79637039@eusebe> (raw)
In-Reply-To: <fo7trr$lrf$1@ger.gmane.org>

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.)

-- 
TGL.
-- 
gentoo-dev@lists.gentoo.org mailing list



  parent reply	other threads:[~2008-02-04 22:54 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 [this message]
2008-02-04 23:03     ` Ryan Hill
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=20080204235329.79637039@eusebe \
    --to=degrenier@easyconnect.fr \
    --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