Example #1
0
 def package(self):
     # Form a 'fake' rpm package that
     # can be used to compare against
     # other rpm packages using the
     # standard rpm routines
     my_pkg = PackageObject()
     my_pkg.name = self.name
     if self.version is not None:
         my_pkg.version = str(self.version)
     return my_pkg
 def package(self):
     # Form a 'fake' rpm package that
     # can be used to compare against
     # other rpm packages using the
     # standard rpm routines
     my_pkg = PackageObject()
     my_pkg.name = self.name
     if self.version is not None:
         my_pkg.version = str(self.version)
     return my_pkg
Example #3
0
def get_installed(name, version=None):
    # This seems needed...
    # otherwise 'cannot open Packages database in /var/lib/rpm' starts to happen
    with sh.Rooted(True):
        yb = _make_yum_base()
        pkg_obj = yb.doPackageLists(pkgnarrow='installed',
                                    ignore_case=True, patterns=[name])
    whats_installed = pkg_obj.installed
    if not whats_installed:
        return None
    # Compare whats installed to a fake package that will
    # represent what might be installed...
    fake_pkg = PackageObject()
    fake_pkg.name = name
    if version:
        fake_pkg.version = str(version)
    for installed_pkg in whats_installed:
        if installed_pkg.verGE(fake_pkg):
            return installed_pkg
    return None