diff --git a/blivet/tasks/availability.py b/blivet/tasks/availability.py index b310cbed3..53182953c 100644 --- a/blivet/tasks/availability.py +++ b/blivet/tasks/availability.py @@ -21,8 +21,7 @@ import abc from distutils.version import LooseVersion -import rpm -import six +import hawkey from six import add_metaclass @@ -136,19 +135,19 @@ def __init__(self, package=None): @property def packageVersion(self): - """ Returns the version of the package. + """ Returns the version of the installed package. :returns: the package version :rtype: LooseVersion + :raises AvailabilityError: on failure to obtain package version """ - ts = rpm.TransactionSet() - info = ts.dbMatch("provides", self.package.package_name) - if len(info) == 0: + sack = hawkey.Sack() + sack.load_system_repo() + query = hawkey.Query(sack).filter(name=self.package.package_name, latest=True) + packages = query.run() + if len(packages) != 1: raise AvailabilityError("Could not determine package version for %s" % self.package.package_name) - version = next(info)['version'] - if six.PY3: - version = version.decode() - return LooseVersion(version) + return LooseVersion(packages[0].version) def availabilityErrors(self, resource): if self._availabilityErrors is not None and CACHE_AVAILABILITY: diff --git a/python-blivet.spec b/python-blivet.spec index 9d499be6f..e8429a00b 100644 --- a/python-blivet.spec +++ b/python-blivet.spec @@ -43,7 +43,7 @@ Requires: libselinux-python Requires: libblockdev >= %{libblockdevver} Requires: libblockdev-plugins-all >= %{libblockdevver} Requires: libselinux-python -Requires: rpm-python +Requires: python-hawkey %description The python-blivet package is a python module for examining and modifying @@ -65,7 +65,7 @@ Requires: util-linux >= %{utillinuxver} Requires: dosfstools Requires: e2fsprogs >= %{e2fsver} Requires: lsof -Requires: rpm-python3 +Requires: python3-hawkey %description -n python3-%{realname} The python3-%{realname} is a python3 package for examining and modifying storage