Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Searching the Portage tree by description
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
delta407
Bodhisattva
Bodhisattva


Joined: 23 Apr 2002
Posts: 2876
Location: Chicago, IL

PostPosted: Tue Jun 18, 2002 5:09 am    Post subject: Searching the Portage tree by description Reply with quote

This thread gave me an idea for searching the Portage tree for a description matching a certain keyword or regular expression. Thus, the Über-description-search-command-thingy was born (mainly because I had too much time on my hands). It goes through your Portage tree, finds the newest version of all your ebuild files, extracts the DESCRIPTION field, and places it inside a file entitled "ebuild-descriptions".

Code:
for dir in `find /usr/portage -type d ! -name files -mindepth 2`; do ls $dir/*.ebuild 2>/dev/null | head -n 1; done > /tmp/ebuilds; for eb in `cat /tmp/ebuilds`; do DESC=`grep DESCRIPTION\= $eb | awk -F"=" '$3 == "" { print $2 }'`; echo `basename $eb`: $DESC; done | sort > ebuild-descriptions; rm /tmp/ebuilds


Note that this command takes up a lot of space on the screen. The complexity apparent in the command visually is also apparent in the execution time. :D Be warned, this command takes an unusually long time to run, simply because it's doing all kinds of stuff and I haven't bothered to optimize it.

Anyway, the descriptions are in a file -- now what? You can search it for specific keywords, and since it's just in a single normal "flat" file, searching is really fast. Say you wanted to search for burning software, you might run a case-insensitive search for "burn".

Code:
$ grep -i burn ebuild-descriptions
arson-0.9.5-r1.ebuild: "A KDE frontend to CD burning and CD ripping tools."
cdrdao-1.1.5-r1.ebuild: "Burn CDs in disk-at-once mode -- with optional GUI frontend"


Great! Let's count how many apps relate to KDE, and just for good measure, let's compare that with GNOME.

Code:
echo KDE: `grep -ic kde ebuild-descriptions`; echo GNOME: `grep -ic gnome ebuild-descriptions`
KDE: 156
GNOME: 113


And there you have it. It's been proven; KDE beats GNOME. Err... I mean, this method is an effective way to search your ebuilds for keywords quickly and easily. :D
Back to top
View user's profile Send private message
jahgu
n00b
n00b


Joined: 20 Jun 2002
Posts: 61
Location: Southborough, MA

PostPosted: Fri Jun 21, 2002 1:26 am    Post subject: Reply with quote

hey, that's really cool.
Back to top
View user's profile Send private message
TheHaas
n00b
n00b


Joined: 13 Jun 2002
Posts: 61

PostPosted: Fri Jun 21, 2002 3:10 pm    Post subject: (more robust?) Python version Reply with quote

delta407,

That's a pretty nice trick. This gave me the idea to make a python version that is perhaps more accurate. Maybe

It's long, so I won't post it here, but I will post a link:

http://users.binary.net/thehaas/searchport.py.gz

un-gzip it, and here is the syntax:
Code:

searchport.py --build -- build the "database" (default file to "portdesc.db")
searchport.py -h or --help -- get command line help
searchport.py <anything else> -- search the db for that string (non-case sensitive)


you can also do similar trick that delta407 did:
Code:


171 gideon:~/prog/searchport > echo KDE: `grep -ic kde portdesc.db`; echo GNOME: `grep -ci gnome portdesc.db`
KDE: 229
GNOME: 310



Hmm, for me GNOME is better. :D

Actually, I discovered something with this script . . .there are a lot of corrurpt ebuilds for the KDE (My script breaks open the ebuild files). If they are corruprt, my script throws out a message and moves to the next.
Back to top
View user's profile Send private message
delta407
Bodhisattva
Bodhisattva


Joined: 23 Apr 2002
Posts: 2876
Location: Chicago, IL

PostPosted: Fri Jun 21, 2002 4:20 pm    Post subject: Reply with quote

Your KDE vs. Gnome are off. You're counting multiple versions of each Gnome application, which have more releases because there's more bugfixes because there's more bugs. ;) And as far as KDE "corrupt" ebuilds; they're not corrupt, they're simply lacking a description. They are independent ebuilds, though, and deserve to be includeed in the count. :D

And as far as accurate; I just rebuilt ebuild-descriptions to re-run my above listed test.

Code:
$ ./searchport.py burn
$ grep -i burn /usr/ebuild-descriptions
arson-0.9.5-r1.ebuild: "A KDE frontend to CD burning and CD ripping tools."
cdrdao-1.1.5-r1.ebuild: "Burn CDs in disk-at-once mode -- with optional GUI frontend"
merlin-cpufire-0.1.0.ebuild: "Gnome applet that displays CPU usage as burning fire"


searchport produced no output, ebuild-descriptions produced three. Additionally, grep was faster. :D

BTW, grep -i burn portdesc.db produced:
Code:
merlin-cpufire-0.1.0.ebuild|"Gnome applet that displays CPU usage as burning fire"
arson-0.9.5-r1.ebuild|"A KDE frontend to CD burning and CD ripping tools."
cdrdao-1.1.5-r1.ebuild|"Burn CDs in disk-at-once mode -- with optional GUI frontend"


One more thing -- my search database is sorted. :D
Back to top
View user's profile Send private message
alec
Apprentice
Apprentice


Joined: 19 Apr 2002
Posts: 270
Location: Here

PostPosted: Sun Jun 23, 2002 3:07 pm    Post subject: Reply with quote

For further simplification, copy this somewhere and make it executable:

Code:
grep -i ${1} /path/to/ebuild-descriptions


I put it in my /usr/bin and called it esearch. Now I just run 'esearch foo' and get my results :)

For even tastier results, edit delta's script to make the ebuild-descriptions in one place (i.e., add /path/to/) and run it as a cron job.
Back to top
View user's profile Send private message
lain iwakura
Apprentice
Apprentice


Joined: 09 May 2002
Posts: 176
Location: sd, ca

PostPosted: Tue Jul 02, 2002 9:21 am    Post subject: Reply with quote

very cool. they should add this type of feature to portage.
:stating the obvious: 8O
_________________
[resident anime junkie] -- not just a linux freak.
Back to top
View user's profile Send private message
phienix
n00b
n00b


Joined: 09 Jul 2002
Posts: 24
Location: Germany, Telgte near by Münster

PostPosted: Wed Jul 10, 2002 4:51 pm    Post subject: mh how can i use this now ;) Reply with quote

mh how can i use this now ;)
_________________
linux isn't the non-plus-ultra
Back to top
View user's profile Send private message
arkane
l33t
l33t


Joined: 30 Apr 2002
Posts: 918
Location: Phoenix, AZ

PostPosted: Thu Jul 11, 2002 3:56 am    Post subject: Re: Searching the Portage tree by description Reply with quote

WOW... very nice.
I have to look in the "tips n tricks" forum more often...
I just copied that, changed ebuild-descriptions to /var/db/ebuild-descrions, and put it into a file called /usr/sbin/delta.
That name seemed almost appropriate for what it does :D
made a script in /usr/sbin called delta-find that does the grep'ing.

delta407 wrote:
This thread gave me an idea for searching the Portage tree for a description matching a certain keyword or regular expression. Thus, the Über-description-search-command-thingy was born (mainly because I had too much time on my hands). It goes through your Portage tree, finds the newest version of all your ebuild files, extracts the DESCRIPTION field, and places it inside a file entitled "ebuild-descriptions".

Code:
for dir in `find /usr/portage -type d ! -name files -mindepth 2`; do ls $dir/*.ebuild 2>/dev/null | head -n 1; done > /tmp/ebuilds; for eb in `cat /tmp/ebuilds`; do DESC=`grep DESCRIPTION\= $eb | awk -F"=" '$3 == "" { print $2 }'`; echo `basename $eb`: $DESC; done | sort > ebuild-descriptions; rm /tmp/ebuilds


Note that this command takes up a lot of space on the screen. The complexity apparent in the command visually is also apparent in the execution time. :D Be warned, this command takes an unusually long time to run, simply because it's doing all kinds of stuff and I haven't bothered to optimize it.

Anyway, the descriptions are in a file -- now what? You can search it for specific keywords, and since it's just in a single normal "flat" file, searching is really fast. Say you wanted to search for burning software, you might run a case-insensitive search for "burn".

Code:
$ grep -i burn ebuild-descriptions
arson-0.9.5-r1.ebuild: "A KDE frontend to CD burning and CD ripping tools."
cdrdao-1.1.5-r1.ebuild: "Burn CDs in disk-at-once mode -- with optional GUI frontend"


Great! Let's count how many apps relate to KDE, and just for good measure, let's compare that with GNOME.

Code:
echo KDE: `grep -ic kde ebuild-descriptions`; echo GNOME: `grep -ic gnome ebuild-descriptions`
KDE: 156
GNOME: 113


And there you have it. It's been proven; KDE beats GNOME. Err... I mean, this method is an effective way to search your ebuilds for keywords quickly and easily. :D
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks 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