>  From the API (pydoc pkg.client.image) I can read:
> 
>       |  has_version_installed(self, fmri)
>       |      Check that the version given in the FMRI or a successor is
>       |      installed in the current image.
>       |
>       |  is_installed(self, fmri)
>       |      Check that the exact version given in the FMRI is installed
>       |      in the current image.
> 
> So my understanding is that for any fmri the function 
> has_version_installed(self, fmri) should return True if *any* version of 
> package is installed

It turns out that the function is a little more complicated than that.

        def has_version_installed(self, fmri):
                """Check that the version given in the FMRI or a successor is
                installed in the current image."""

                try:
                        v = self.get_version_installed(fmri)
                except LookupError:
                        return False

                if v.is_successor(fmri):
                        return True

                return False

has_version_installed() looks to see if the FMRI supplied is actually
installed.  If it is, we compare the FMRI of the installed package
against the FMRI supplied as an argument to has_version_installed.
fmri.is_successor() will only return true if the package we found with
get_version_installed() matches the FMRI argument by name and authority.
If these conditions are met, then we'll return true if the found FMRI's
version doesn't exist, or if it is greater than or equal to the version
of the fmri passed into is_successor.  

> and is_installed(self, fmri) should return true only and only if there
> is exact given version installed.

That's my understanding of how this works too.

> So my point is that has_version_installed returns True *only* when there 
> is the newest version installed. In this case when I will call:
> has_version_installed(pkg://sun.com/[EMAIL 
> PROTECTED],5.11-0.75:20071031T175830Z)
> it will return True
> and
> has_version_installed(pkg://sun.com/[EMAIL 
> PROTECTED],5.11-0.75:20071114T203812Z)
> will return False

In this case, has_version_installed should only return true if the FMRI
that is installed is newer than the FMRI that is passed in as an
argument.  Since the 200711 version is newer and isn't installed,
passing that as an argument would cause has_version_installed to return
false.  Keep in mind, has_version_installed() is used in the imageplan
when we evaluate FMRIs.  Its job is to verify that the package that it
is about to install isn't already on the system, if it is, don't install
it.  In that particular case, we're only interested in the package that
was requested and any newer installed versions.

The name has_version_installed() could certainly be confusing.

-j

_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to