From 7392dfc29d33f04223cd6b58e59dea98ddfe44a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eduard=20=C4=8Cuba?= <ecuba@redhat.com>
Date: Mon, 23 Oct 2017 12:35:24 +0200
Subject: [PATCH] support for DNF 2.8

Dnf 2.8 introduces unified software database which changes some non-API
calls
---
 dnfdaemon.spec                      |  4 +---
 python/dnfdaemon/server/__init__.py | 14 +++++---------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/dnfdaemon.spec b/dnfdaemon.spec
index 8a916e9..3404519 100644
--- a/dnfdaemon.spec
+++ b/dnfdaemon.spec
@@ -1,5 +1,5 @@
 %global dnf_org org.baseurl.Dnf
-%global dnf_version 2.5.0
+%global dnf_version 2.8.0
 %global dnf_nocompat 3.0
 
 Name:           dnfdaemon
@@ -255,5 +255,3 @@ fi
 - fix refactor issue (timlau@fedoraproject.org)
 - api: merged GetPackages with GetPackageWithAttributes.
   (timlau@fedoraproject.org)
-
-
diff --git a/python/dnfdaemon/server/__init__.py b/python/dnfdaemon/server/__init__.py
index 4a89242..b35383f 100644
--- a/python/dnfdaemon/server/__init__.py
+++ b/python/dnfdaemon/server/__init__.py
@@ -255,12 +255,7 @@ class DnfDaemonBase(dbus.service.Object, DownloadCallback):
                 # get the dnf group obj
                 grp = self.base.comps.group_by_pattern(obj.name)
                 if grp:
-                    # FIXME: no dnf API to get if group is installed
-                    p_grp = self.base._group_persistor.group(grp.id)
-                    if p_grp:
-                        installed = p_grp.installed
-                    else:
-                        installed = False
+                    installed = self.base.history.group.group_installed(grp.id)
                     elem = (grp.id, grp.ui_name,
                             grp.ui_description, installed)
                     cat_grps.append(elem)
@@ -687,11 +682,12 @@ class DnfDaemonBase(dbus.service.Object, DownloadCallback):
         result = []
         tx = self.base.history.old([tid], complete_transactions_only=False)
         result = []
-        for pkg in tx[0].trans_data:
+        for pkg in tx[0].packages():
             values = [pkg.name, pkg.epoch, pkg.version,
-                      pkg.release, pkg.arch, pkg.ui_from_repo]
+                      pkg.release, pkg.arch, pkg.ui_from_repo()]
             pkg_id = ",".join(values)
-            elem = (pkg_id, pkg.state, pkg.state_installed)
+            installed = True if pkg.state in dnf.history.INSTALLING_STATES else False
+            elem = (pkg_id, pkg.state, pkg.state_installed, installed)
             result.append(elem)
         value = json.dumps(result)
         return value
-- 
GitLab