Blame SOURCES/dnf-plugin-spacewalk-2.8.5-5-el8-to-dnf-plugin-spacewalk-2.8.5-6-el8.patch

906f4e
diff --git a/dnf-plugin-spacewalk-revert-to-1.0.patch b/dnf-plugin-spacewalk-revert-to-1.0.patch
906f4e
deleted file mode 100644
906f4e
index 0a2d6ec..0000000
906f4e
--- a/dnf-plugin-spacewalk-revert-to-1.0.patch
906f4e
+++ /dev/null
906f4e
@@ -1,90 +0,0 @@
906f4e
-diff --git a/client/rhel/dnf-plugin-spacewalk/spacewalk.py b/client/rhel/dnf-plugin-spacewalk/spacewalk.py
906f4e
-index 72ac31e..269f94f 100644
906f4e
---- a/client/rhel/dnf-plugin-spacewalk/spacewalk.py
906f4e
-+++ b/client/rhel/dnf-plugin-spacewalk/spacewalk.py
906f4e
-@@ -28,7 +28,6 @@ import librepo
906f4e
- import os
906f4e
- import sys
906f4e
- from copy import copy
906f4e
--from dnf.conf.config import PRIO_PLUGINCONFIG
906f4e
-
906f4e
- # up2date libs are in non-standard path
906f4e
- sys.path.append("/usr/share/rhn/")
906f4e
-@@ -40,6 +39,7 @@ from rhn.i18n import ustr
906f4e
- from up2date_client import up2dateErrors
906f4e
- 
906f4e
- STORED_CHANNELS_NAME = '_spacewalk.json'
906f4e
-+PLUGIN_CONF = 'spacewalk'
906f4e
- 
906f4e
- RHN_DISABLED    = _("Spacewalk based repositories will be disabled.")
906f4e
- CHANNELS_DISABLED = _("Spacewalk channel support will be disabled.")
906f4e
-@@ -66,11 +66,11 @@ class Spacewalk(dnf.Plugin):
906f4e
-         self.connected_to_spacewalk = False
906f4e
-         self.up2date_cfg = {}
906f4e
-         self.conf = copy(self.base.conf)
906f4e
--        self.parser = self.read_config(self.conf)
906f4e
-+        self.parser = self.read_config(self.conf, PLUGIN_CONF)
906f4e
-         if "main" in self.parser.sections():
906f4e
-             options = self.parser.items("main")
906f4e
-             for (key, value) in options:
906f4e
--                self.conf._set_value(key, value, PRIO_PLUGINCONFIG)
906f4e
-+                setattr(self.conf, key, value)
906f4e
-         if not self.conf.enabled:
906f4e
-             return
906f4e
-         logger.debug('initialized Spacewalk plugin')
906f4e
-@@ -142,9 +142,9 @@ class Spacewalk(dnf.Plugin):
906f4e
-             if channel_id in self.parser.sections():
906f4e
-                 options = self.parser.items(channel_id)
906f4e
-                 for (key, value) in options:
906f4e
--                    conf._set_value(key, value, PRIO_PLUGINCONFIG)
906f4e
-+                    setattr(conf, key, value)
906f4e
-             repo = SpacewalkRepo(channel_dict, {
906f4e
--                                    'conf'      : self.base.conf,
906f4e
-+                                    'cachedir'  : self.base.conf.cachedir,
906f4e
-                                     'proxy'     : proxy_url,
906f4e
-                                     'timeout'   : conf.timeout,
906f4e
-                                     'sslcacert' : sslcacert,
906f4e
-@@ -212,7 +212,7 @@ class  SpacewalkRepo(dnf.repo.Repo):
906f4e
- 
906f4e
-     def __init__(self, channel, opts):
906f4e
-         super(SpacewalkRepo, self).__init__(ustr(channel['label']),
906f4e
--                                            opts.get('conf'))
906f4e
-+                                            opts.get('cachedir'))
906f4e
-         # dnf stuff
906f4e
-         self.name = ustr(channel['name'])
906f4e
-         self.baseurl = [ url + '/GET-REQ/' + self.id for url in channel['url']]
906f4e
-diff --git a/client/rhel/dnf-plugin-spacewalk/actions/packages.py b/client/rhel/dnf-plugin-spacewalk/actions/packages.py
906f4e
-index 86ab72b..5516d1c 100644
906f4e
---- a/client/rhel/dnf-plugin-spacewalk/actions/packages.py
906f4e
-+++ b/client/rhel/dnf-plugin-spacewalk/actions/packages.py
906f4e
-@@ -125,7 +125,7 @@ def update(package_list, cache_only=None):
906f4e
-         else:
906f4e
-             ret = (0, "Requested packages already installed", {})
906f4e
-         # workaround for RhBug:1218071
906f4e
--        base._plugins._unload()
906f4e
-+        base._plugins.unload()
906f4e
-         base.close()
906f4e
-         return ret
906f4e
- 
906f4e
-@@ -271,8 +271,10 @@ def _dnf_base(load_system_repo=True, load_available_repos=True):
906f4e
-     # initialize dnf
906f4e
-     base = dnf.Base()
906f4e
- 
906f4e
--    if not base._plugins.plugins:
906f4e
--        base.init_plugins()
906f4e
-+    # this is actually workaround for RhBug:1218071
906f4e
-+    if not base._plugins.plugins and base.conf.plugins:
906f4e
-+        base._plugins.load(base.conf.pluginpath, [])
906f4e
-+        base._plugins.run_init(base)
906f4e
-     if load_available_repos:
906f4e
-         base.read_all_repos()
906f4e
-     base.fill_sack(load_system_repo=True, load_available_repos=True)
906f4e
-@@ -335,7 +335,7 @@ def _dnf_transaction(base, install=[], remove=[], full_update=False,
906f4e
-         return (status, message, data)
906f4e
-     finally:
906f4e
-         # workaround for RhBug:1218071
906f4e
--        base._plugins._unload()
906f4e
-+        base._plugins.unload()
906f4e
-         base.close()
906f4e
- 
906f4e
-     return (0, "Update Succeeded", {})
906f4e
diff --git a/dnf-plugin-spacewalk.spec b/dnf-plugin-spacewalk.spec
906f4e
index 41ff4e5..17df012 100644
906f4e
--- a/dnf-plugin-spacewalk.spec
906f4e
+++ b/dnf-plugin-spacewalk.spec
906f4e
@@ -12,18 +12,14 @@
906f4e
 Summary: DNF plugin for Spacewalk
906f4e
 Name: dnf-plugin-spacewalk
906f4e
 Version: 2.8.5
906f4e
-Release: 5%{?dist}
906f4e
+Release: 6%{?dist}
906f4e
 License: GPLv2
906f4e
 Source0: https://github.com/spacewalkproject/spacewalk/archive/%{name}-%{version}.tar.gz
906f4e
 URL:     https://github.com/spacewalkproject/spacewalk
906f4e
 BuildArch: noarch
906f4e
 
906f4e
 Requires: %{pythonX}-%{name} = %{version}-%{release}
906f4e
-%if 0%{?fedora} && 0%{?fedora} <= 25
906f4e
-Requires: dnf >= 0.5.3
906f4e
-%else
906f4e
 Requires: dnf >= 2.0.0
906f4e
-%endif
906f4e
 Requires: dnf-plugins-core
906f4e
 Requires: librepo >= 1.7.15
906f4e
 %if 0%{?fedora}
906f4e
@@ -63,9 +59,6 @@ Python 3 specific files for %{name}.
906f4e
 %setup -q
906f4e
 
906f4e
 %build
906f4e
-%if 0%{?fedora} && 0%{?fedora} <= 25
906f4e
-patch -p4 < dnf-plugin-spacewalk-revert-to-1.0.patch
906f4e
-%endif
906f4e
 
906f4e
 %install
906f4e
 install -d %{buildroot}%{_sysconfdir}/dnf/plugins/
906f4e
@@ -117,6 +110,10 @@ install -m 644 actions/errata.py %{buildroot}%{python3_sitelib}/rhn/actions/
906f4e
 %endif
906f4e
 
906f4e
 %changelog
906f4e
+* Tue Oct 16 2018 Tomas Kasparek <tkasparek@redhat.com> 2.8.5-6
906f4e
+- spec cleanup (no more builds on Fedora <= 25) (michael.mraka@redhat.com)
906f4e
+- Resolves: #1637980 - fixed plugin for dnf > 3.6.0 (michael.mraka@redhat.com)
906f4e
+
906f4e
 * Tue Jul 24 2018 Tomas Kasparek <tkasparek@redhat.com> 2.8.5-5
906f4e
 - Related: #1581665 - provide useful symlinks to a manpage
906f4e
   (tkasparek@redhat.com)
906f4e
diff --git a/spacewalk.py b/spacewalk.py
906f4e
index add5d34..e0b418b 100644
906f4e
--- a/spacewalk.py
906f4e
+++ b/spacewalk.py
906f4e
@@ -242,7 +242,13 @@ class  SpacewalkRepo(dnf.repo.Repo):
906f4e
         else:
906f4e
             self.disable()
906f4e
 
906f4e
-    def add_http_headers(self, handle):
906f4e
+        if hasattr(self, '_repo'):
906f4e
+            # dnf > 3.6.0
906f4e
+            http_headers = self.create_http_headers()
906f4e
+            if http_headers:
906f4e
+                self._repo.setHttpHeaders(http_headers)
906f4e
+
906f4e
+    def create_http_headers(self):
906f4e
         http_headers = []
906f4e
         for header in self.needed_headers:
906f4e
             if not header in self.login_info:
906f4e
@@ -257,12 +263,15 @@ class  SpacewalkRepo(dnf.repo.Repo):
906f4e
                 http_headers.append("%s: %s" % (header, self.login_info[header]))
906f4e
         if not self.force_http:
906f4e
             http_headers.append("X-RHN-Transport-Capability: follow-redirects=3")
906f4e
-        if http_headers:
906f4e
-            handle.setopt(librepo.LRO_HTTPHEADER, http_headers)
906f4e
+
906f4e
+        return http_headers
906f4e
 
906f4e
     def _handle_new_remote(self, destdir, mirror_setup=True):
906f4e
+        # this function is called only on dnf < 3.6.0 (up to Fedora 29)
906f4e
         handle = super(SpacewalkRepo, self)._handle_new_remote(destdir, mirror_setup)
906f4e
-        self.add_http_headers(handle)
906f4e
+        http_headers = self.create_http_headers()
906f4e
+        if http_headers:
906f4e
+            handle.setopt(librepo.LRO_HTTPHEADER, http_headers)
906f4e
         return handle
906f4e
 
906f4e