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

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