[Yum-devel] [PATCH] remove RPMDBPackageSack.installed()

Panu Matilainen pmatilai at laiskiainen.org
Thu Oct 4 10:01:53 UTC 2007


On Thu, 4 Oct 2007, Tim Lauridsen wrote:

> Florian Festi wrote:
>> Hi!
>> 
>> While creating the new test frame work I came across several minor issues. 
>> One problem is the existence of the RPMDBPackageSack.installed() method. It 
>> is currently only supported by the RPMDBPackageSack class. This doesn't 
>> allow to replace the rpmdb with an inmemory PackageSack. Seth already 
>> rejected the idea of just moving the method to the base class as 
>> "installed" doesn't make any sense for non RpmDB sacks.
>> 
>> As I really dislike inconsistent APIs I'd like to suggest to just remove 
>> the usage of that method from the code. There are just 7 places in yum and 
>> one place in yum-utils where it is used and it is nothing more than a tiny 
>> convenience wrapper. In fact it can be replaced quite easily by 
>> .searchNevra() - one of our work horse methods. The attached patches remove 
>> the usage of the method and add an deprecation warning (feel free to ignore 
>> that if we want to keep the method).
>> 
>> Florian
>> 
>> PS: The patch also fixes a small issue when running without repositories 
>> which simplifies setting up the test cases.
>> ------------------------------------------------------------------------
>> 
>> _______________________________________________
>> Yum-devel mailing list
>> > Yum-devel at linux.duke.edu
>> https://lists.dulug.duke.edu/mailman/listinfo/yum-devel
> RPMDBPackageSack.installed() make the code look better and make it easier to 
> understand.
>
> self.rpmdb.installed(po)
>
> Look much better then 
> self.rpmdb.searchNevra(po.name, po.epoch, po.version, po.release, po.arch)
>
> Removing the installed() method is a API breakage and there is other API 
> users out there (yumex, pirut, pungi, revisor, PackageKit etc)
>
> and api users (like me) hate this kind of breakage :)
>
> from an API users point of view, he/she want to simple and easy to use API, 
> and in this case 'installed(po)' is much better than 
> 'self.rpmdb.searchNevra(n,e,v,r,a)', there have also been done a lot of work 
> to replace n,e,v,r,a tuples with po object, this is a step backwards.

The problem with installed() is just that it's the wrong term for this - 
make it exists() and it'll make sense for all the package sack types. 
Whether a package is installed or not is just a question whether it exists 
in rpmdb or not, if you want to keep API compat just make 
rpmdb.installed() a wrapper for exists().

Somewhat related, IMO the installed() method belongs to the package, not 
sack object. So something like

for pkg in installable:
     if self.rpmdb.installed(po=pkg):
        # do stuff

would become

for pkg in installable:
     if pkg.installed():
        # do stuff

..but that's another story, dunno how feasible it'd be within yum 
currently (sorry I haven't been paying that much attention lately)

 	- Panu -





More information about the Yum-devel mailing list