[Yum-devel] RFC: Package object comparison -- do we need a slight change?
Jeremy Katz
katzj at redhat.com
Thu Oct 12 02:22:46 UTC 2006
On Wed, 2006-10-11 at 22:19 -0400, seth vidal wrote:
> On Wed, 2006-10-11 at 22:08 -0400, Jeremy Katz wrote:
> > So, as it stands right now, we have nice and rich comparison operators
> > for packages. foo-1.0-1 < foo-2.0-1 works nicely, etc. The problem
> > starts to come in when we get to equality with multiple arches. Should
> > foo-1.0-1.i386 == foo-1.0-1.x86_64? Right now, the answer is yes, but
> > that breaks trying to see if a specific package is already found in a
> > list and other such cases.
> >
> > So, the options (I can think of) are basically
> > a) Live with it -- if you're trying to check if a package is in a list
> > or if two packages are actually the same, you have to do equality and
> > then an arch check. I think this kind of breaks the principle of least
> > surprise and is likely to lead to bugs in API users[1]
> > b) Make the change so that equality of packages also takes into account
> > arch[2]. This would be a slight semantic change, but I'm not sure I can
> > think of a case where this _wouldn't_ be what you expect
>
> so if someone says:
> if po == po2:
> foo()
> if po > po2:
> bar()
> if po < po2:
> baz()
>
> all of the above could return false. which seems, counter-intuitive to me.
I don't know of any way to avoid _something_ being counter-intuitive.
The question (in my eyes anyway) is mainly "what is the _most_ likely
case". I mean, I guess we could also go the route of pulling the
equality comparison operators entirely, but I don't think I could slip
that into FC6 at this point, which means that we're likely going to end
up with people thinking they're there :/
> I get where you're coming from about the comparison - I'm just worried
> about the next requested step:
> - take arch into account when dealing with < > comparisons
I thought about it when we first brought it up and I think we even
talked about it. Arguably, we should add it for consistency as it only
makes things "more" correct. The problem comes in (slightly) with
multiarch where you might want to install both equal version but
different arch'd packages. From a quick look, though, we'd actually be
safe to do so.
[snip]
> It almost feels like we should never allow rich comparison against
> non-matching archs. Which might be an argument for how to keep someone
> from doing this accidentally.
I'm not sure how you keep people from doing it, though -- except by not
having the comparison operators at all. And I think we might be stuck
there now :/
Jeremy
More information about the Yum-devel
mailing list