ginger-dev-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ginger-dev-list] [PATCH] [gingerbase] Fix Issue #2 - Support dnf for Fe


From: Lucio Correia
Subject: [Ginger-dev-list] [PATCH] [gingerbase] Fix Issue #2 - Support dnf for Fedora repositories and updates
Date: Wed, 2 Dec 2015 18:02:07 -0200

Repositories and Software Update were failing to load in Updates
tab because newer Fedora versions migrated to dnf as default
package manager. This patch fixes that by importing dnf instead
of yum in Fedora.

Signed-off-by: Lucio Correia <address@hidden>
---
 docs/README.md  |  9 ++++++---
 repositories.py | 12 ++++++++----
 swupdate.py     | 29 +++++++++++++++++------------
 3 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/docs/README.md b/docs/README.md
index 38d8553..ef9cf28 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -54,8 +54,11 @@ Install Dependencies
                         libxslt pyparted \
                         python-websockify python-configobj
 
-     # If using RHEL, install the following additional packages:
-     $ sudo yum install python-unittest2 python-ordereddict
+    # If using Fedora, install the following additional packages:
+    $ sudo yum install python2-dnf
+
+    # If using RHEL, install the following additional packages:
+    $ sudo yum install python-unittest2 python-ordereddict
 
     # These dependencies are only required if you want to run the tests:
     $ sudo yum install pyflakes python-pep8 python-requests
@@ -158,4 +161,4 @@ All patches are sent through our mailing list.  More 
information can be found at
 
 https://github.com/kimchi-project/ginger/wiki/Communications
 
-Patches should be sent using git-send-email to address@hidden
\ No newline at end of file
+Patches should be sent using git-send-email to address@hidden
diff --git a/repositories.py b/repositories.py
index 146d019..9fee19a 100644
--- a/repositories.py
+++ b/repositories.py
@@ -45,14 +45,18 @@ class Repositories(object):
     """
     def __init__(self):
         try:
-            __import__('yum')
+            __import__('dnf')
             self._pkg_mnger = YumRepo()
         except ImportError:
             try:
-                __import__('apt_pkg')
-                self._pkg_mnger = AptRepo()
+                __import__('yum')
+                self._pkg_mnger = YumRepo()
             except ImportError:
-                raise InvalidOperation('GGBREPOS0014E')
+                try:
+                    __import__('apt_pkg')
+                    self._pkg_mnger = AptRepo()
+                except ImportError:
+                    raise InvalidOperation('GGBREPOS0014E')
 
     def addRepository(self, params):
         """
diff --git a/swupdate.py b/swupdate.py
index bc8d721..e4fe26b 100644
--- a/swupdate.py
+++ b/swupdate.py
@@ -57,23 +57,28 @@ class SoftwareUpdate(object):
         # Get the distro of host machine and creates an object related to
         # correct package management system
         try:
-            __import__('yum')
+            __import__('dnf')
             wok_log.info("Loading YumUpdate features.")
             self._pkg_mnger = YumUpdate()
         except ImportError:
             try:
-                __import__('apt')
-                wok_log.info("Loading AptUpdate features.")
-                self._pkg_mnger = AptUpdate()
+                __import__('yum')
+                wok_log.info("Loading YumUpdate features.")
+                self._pkg_mnger = YumUpdate()
             except ImportError:
-                zypper_help = ["zypper", "--help"]
-                (stdout, stderr, returncode) = run_command(zypper_help)
-                if returncode == 0:
-                    wok_log.info("Loading ZypperUpdate features.")
-                    self._pkg_mnger = ZypperUpdate()
-                else:
-                    raise Exception("There is no compatible package manager "
-                                    "for this system.")
+                try:
+                    __import__('apt')
+                    wok_log.info("Loading AptUpdate features.")
+                    self._pkg_mnger = AptUpdate()
+                except ImportError:
+                    zypper_help = ["zypper", "--help"]
+                    (stdout, stderr, returncode) = run_command(zypper_help)
+                    if returncode == 0:
+                        wok_log.info("Loading ZypperUpdate features.")
+                        self._pkg_mnger = ZypperUpdate()
+                    else:
+                        raise Exception("There is no compatible package "
+                                        "manager for this system.")
 
     def _scanUpdates(self):
         """
-- 
1.9.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]