[packagekit] extremely quick search for available package names matching a pattern

Sebastian Heinlein sebi at glatzor.de
Mon Apr 15 00:33:20 PDT 2013


Am 2013-04-14 03:14, schrieb Lukas Vacek:
> Hello there,
>
> I am developing a Gnome Shell extension which shows available
> software to install. The user can type, for example, "opent" and then
> just click "openttd" to install the package. It's pretty decent. :-)
> https://extensions.gnome.org/extension/95/appsearch/ [1]
>
> This works all fine on Debian/Ubuntu using "apt-cache pkgnames [
> prefix ]". I am doing my best to support PackageKit as well but
> getting the results fast enough is a bit problematic.
>
> At the moment I use "pkcon -p resolve <search_term>" which is very
> quick and works fine, however, this works only for exact matches.
>
> I have experimented with "pkcon -p search name <search_term>" and
> indeed it works fine but it's just too slow for this use case :-( ...
> it can take up to several  (sometimes more than 5) seconds to get
> results.
>
> Is there a faster way to get all available packages with names
> matching a pattern? (No need for regex or so, actually, just prefix
> match will do)

The speed of the query depends on the backend implementation. You will 
see different results for the differnet backends. So you should design 
your extension having in mind that the search could take some seconds.

The PackageKit compatibilty layer of aptdaemon which is shipped in 
Ubuntu by default makes optionally use of the Xapian Apt Index. So you 
even get a stemmer if you search for details. Perhaps this could also be 
an idea for the APTcc backend, too.


More information about the PackageKit mailing list