Gentoo Archives: gentoo-portage-dev

From: Lucian Poston <lucianposton@×××××.com>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] search functionality in emerge
Date: Sun, 23 Nov 2008 16:56:54
In Reply to: Re: [gentoo-portage-dev] search functionality in emerge by Emma Strubell
1 > Thanks for the replies! I know there are a couple programs out there that
2 > basically already do what I'm looking to do... Unfortunately I wasn't aware
3 > of these pre-existing utilities until after I submitted my project proposal
4 > to my professor. So, I'm looking to implement a better search myself.
5 > Preferably by editing the existing portage code, not writing a separate
6 > program. So if anyone can offer any help regarding the actual implementation
7 > of search in portage, I would greatly appreciate it!
9 Most of the search implementation is in
10 /usr/lib/portage/pym/_emerge/ in class search. The class's
11 execute() method simply iterates over all packages (and descriptions
12 and package sets) and matches against the searchkey. You might need
13 to look into pym/portage/dbapi/ for portdbapi as well.
15 If you intend to index and support fast regex lookup, then you need to
16 do some fancy indexing, which I'm not terribly familiar with. You
17 could follow in the steps of eix[1] or other indexed search utilities
18 and design some sort of index layout, which is easier than the
19 following thought. You might consider implementing a suffix trie or
20 similar that has sublinear regexp lookup and marshalling the structure
21 for the index. I couldn't find a python implementation for something
22 like this, but here is a general trie class[2] that you might start
23 with if you go that route. There is a perl module[3],
24 Tie::Hash::Regex, that does that, but properly implementing that in
25 python would be a chore. :)
27 That project sounds interesting and fun. Good luck!
29 Lucian Poston
31 [1]
32 [2]
33 [3]


Subject Author
Re: [gentoo-portage-dev] search functionality in emerge Emma Strubell <emma.strubell@×××××.com>