import dnf-plugins-core-4.0.21-14.el8

This commit is contained in:
CentOS Sources 2022-07-22 10:12:02 +00:00 committed by Stepan Oksanichenko
parent f42f4a10b8
commit ef207ee286
9 changed files with 390 additions and 1 deletions

View File

@ -0,0 +1,28 @@
From 76d7c9e2d2fa052cc6d9fab08af51c603d7e20e5 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Fri, 16 Jul 2021 12:52:03 +0200
Subject: [PATCH] Fix 'dnf copr enable' on Fedora 35
The output from linux_distribution() changed so it returns:
>>> distro.linux_distribution()
('Fedora Linux', '35', '')
---
plugins/copr.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/copr.py b/plugins/copr.py
index 7fc6c6f..235989b 100644
--- a/plugins/copr.py
+++ b/plugins/copr.py
@@ -430,7 +430,7 @@ Bugzilla. In case of problems, contact the owner of this repository.
dist = linux_distribution()
# Get distribution architecture
distarch = self.base.conf.substitutions['basearch']
- if "Fedora" in dist:
+ if any([name in dist for name in ["Fedora", "Fedora Linux"]]):
if "Rawhide" in dist:
chroot = ("fedora-rawhide-" + distarch)
# workaround for enabling repos in Rawhide when VERSION in os-release
--
2.36.1

View File

@ -0,0 +1,37 @@
From 517f0093218e3c23097d7e7e3f3d65930059ef82 Mon Sep 17 00:00:00 2001
From: Silvie Chlupova <sisi.chlupova@gmail.com>
Date: Thu, 12 Aug 2021 16:24:56 +0200
Subject: [PATCH] Disable dnf playground command
= changelog =
msg: playground command doesn't work
type: bugfix
related: https://bugzilla.redhat.com/show_bug.cgi?id=1955907
---
plugins/copr.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/plugins/copr.py b/plugins/copr.py
index 235989b..e1e7018 100644
--- a/plugins/copr.py
+++ b/plugins/copr.py
@@ -122,6 +122,8 @@ class CoprCommand(dnf.cli.Command):
parser.add_argument('arg', nargs='*')
def configure(self):
+ if self.cli.command.opts.command != "copr":
+ return
copr_hub = None
copr_plugin_config = ConfigParser()
config_files = []
@@ -680,6 +682,7 @@ class PlaygroundCommand(CoprCommand):
choices=['enable', 'disable', 'upgrade'])
def run(self):
+ raise dnf.exceptions.Error("Playground is temporarily unsupported")
subcommand = self.opts.subcommand[0]
chroot = self._guess_chroot()
if subcommand == "enable":
--
2.36.1

View File

@ -0,0 +1,29 @@
From 7f9d6809f7cb9ac48f11ef02a4e7c0cadeef9594 Mon Sep 17 00:00:00 2001
From: Silvie Chlupova <sisi.chlupova@gmail.com>
Date: Wed, 22 Sep 2021 22:35:21 +0200
Subject: [PATCH] Fix baseurl for centos stream chroot
= changelog =
msg: dnf copr enable on CentOS Stream should enable centos stream chroot, not epel 8
type: bugfix
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1994154
---
plugins/copr.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/plugins/copr.py b/plugins/copr.py
index e1e7018..c216408 100644
--- a/plugins/copr.py
+++ b/plugins/copr.py
@@ -457,6 +457,8 @@ Bugzilla. In case of problems, contact the owner of this repository.
chroot = ("opensuse-tumbleweed-{}".format(distarch))
else:
chroot = ("opensuse-leap-{0}-{1}".format(dist[1], distarch))
+ elif "CentOS Stream" in dist:
+ chroot = ("centos-stream-{0}-{1}".format(dist[1], distarch))
else:
chroot = ("epel-%s-x86_64" % dist[1].split(".", 1)[0])
return chroot
--
2.36.1

View File

@ -0,0 +1,42 @@
From a07db6dcd669eecb27b7ddbf1b85cd842bdcc35b Mon Sep 17 00:00:00 2001
From: Otto Urpelainen <oturpe@iki.fi>
Date: Wed, 6 Oct 2021 22:08:54 +0300
Subject: [PATCH] Silence a deprecation warning in plugins/copr.py
In version 1.6.0, the 'distro' package deprecated linux_distribution().
This causes a deprecation warning to printed to stdout
every time the user calls the copr plugin.
In order to avoid the printout
and to protect against possible removal in the future,
the function is reimplemented
using still supported functions from 'distro'.
= changelog =
msg: [copr] Avoid using deprecated function distro.linux_distribution()
type: bugfix
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2011550
---
plugins/copr.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/plugins/copr.py b/plugins/copr.py
index c216408..9f597dd 100644
--- a/plugins/copr.py
+++ b/plugins/copr.py
@@ -38,7 +38,11 @@ import rpm
# If that fails, attempt to import the deprecated implementation
# from the platform module.
try:
- from distro import linux_distribution, os_release_attr
+ from distro import name, version, codename, os_release_attr
+
+ # Re-implement distro.linux_distribution() to avoid a deprecation warning
+ def linux_distribution():
+ return (name(), version(), codename())
except ImportError:
def os_release_attr(_):
return ""
--
2.36.1

View File

@ -0,0 +1,49 @@
From bf230d570763acc6ccd4f4b3951f4b8325a8e4b8 Mon Sep 17 00:00:00 2001
From: Silvie Chlupova <sisi.chlupova@gmail.com>
Date: Fri, 3 Sep 2021 15:45:43 +0200
Subject: [PATCH] Shorter verification that the project exists
---
plugins/copr.py | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/plugins/copr.py b/plugins/copr.py
index 9f597dd..1539c0d 100644
--- a/plugins/copr.py
+++ b/plugins/copr.py
@@ -70,8 +70,10 @@ NO = set([_('no'), _('n'), ''])
if PY3:
from configparser import ConfigParser, NoOptionError, NoSectionError
+ from urllib.request import urlopen, HTTPError
else:
from ConfigParser import ConfigParser, NoOptionError, NoSectionError
+ from urllib2 import urlopen, HTTPError
@dnf.plugin.register_command
class CoprCommand(dnf.cli.Command):
@@ -478,17 +480,11 @@ Bugzilla. In case of problems, contact the owner of this repository.
if os.path.exists(repo_filename):
os.remove(repo_filename)
if '404' in str(e):
- if PY3:
- import urllib.request
- try:
- res = urllib.request.urlopen(self.copr_url + "/coprs/" + project_name)
- status_code = res.getcode()
- except urllib.error.HTTPError as e:
- status_code = e.getcode()
- else:
- import urllib
- res = urllib.urlopen(self.copr_url + "/coprs/" + project_name)
+ try:
+ res = urlopen(self.copr_url + "/coprs/" + project_name)
status_code = res.getcode()
+ except HTTPError as e:
+ status_code = e.getcode()
if str(status_code) != '404':
raise dnf.exceptions.Error(_("This repository does not have"
" any builds yet so you cannot enable it now."))
--
2.36.1

View File

@ -0,0 +1,114 @@
From 1d097d0e4ecfef78aec5d760278b44d5f3192cdc Mon Sep 17 00:00:00 2001
From: Silvie Chlupova <sisi.chlupova@gmail.com>
Date: Mon, 2 Aug 2021 15:04:17 +0200
Subject: [PATCH] Better error message for dnf copr enable
= changelog =
msg: show better error message if the command dnf copr enable fails
type: enhancement
---
plugins/copr.py | 63 +++++++++++++++++++++++++++++++------------------
1 file changed, 40 insertions(+), 23 deletions(-)
diff --git a/plugins/copr.py b/plugins/copr.py
index 1539c0d..721c010 100644
--- a/plugins/copr.py
+++ b/plugins/copr.py
@@ -27,6 +27,8 @@ import re
import shutil
import stat
import sys
+import base64
+import json
from dnfpluginscore import _, logger
import dnf
@@ -70,10 +72,10 @@ NO = set([_('no'), _('n'), ''])
if PY3:
from configparser import ConfigParser, NoOptionError, NoSectionError
- from urllib.request import urlopen, HTTPError
+ from urllib.request import urlopen, HTTPError, URLError
else:
from ConfigParser import ConfigParser, NoOptionError, NoSectionError
- from urllib2 import urlopen, HTTPError
+ from urllib2 import urlopen, HTTPError, URLError
@dnf.plugin.register_command
class CoprCommand(dnf.cli.Command):
@@ -475,28 +477,40 @@ Bugzilla. In case of problems, contact the owner of this repository.
api_path = "/coprs/{0}/repo/{1}/dnf.repo?arch={2}".format(project_name, short_chroot, arch)
try:
- f = self.base.urlopen(self.copr_url + api_path, mode='w+')
- except IOError as e:
+ response = urlopen(self.copr_url + api_path)
if os.path.exists(repo_filename):
os.remove(repo_filename)
- if '404' in str(e):
- try:
- res = urlopen(self.copr_url + "/coprs/" + project_name)
- status_code = res.getcode()
- except HTTPError as e:
- status_code = e.getcode()
- if str(status_code) != '404':
- raise dnf.exceptions.Error(_("This repository does not have"
- " any builds yet so you cannot enable it now."))
- else:
- raise dnf.exceptions.Error(_("Such repository does not exist."))
- raise
-
- for line in f:
- if re.match(r"\[copr:", line):
- repo_filename = os.path.join(self.base.conf.get_reposdir,
- "_" + line[1:-2] + ".repo")
- break
+ except HTTPError as e:
+ if e.code != 404:
+ error_msg = _("Request to {0} failed: {1} - {2}").format(self.copr_url + api_path, e.code, str(e))
+ raise dnf.exceptions.Error(error_msg)
+ error_msg = _("It wasn't possible to enable this project.\n")
+ error_data = e.headers.get("Copr-Error-Data")
+ if error_data:
+ error_data_decoded = base64.b64decode(error_data).decode('utf-8')
+ error_data_decoded = json.loads(error_data_decoded)
+ error_msg += _("Repository '{0}' does not exist in project '{1}'.").format(
+ '-'.join(self.chroot_parts), project_name)
+ if error_data_decoded.get("available chroots"):
+ error_msg += _("\nAvailable repositories: ") + ', '.join(
+ "'{}'".format(x) for x in error_data_decoded["available chroots"])
+ error_msg += _("\n\nIf you want to enable a non-default repository, use the following command:\n"
+ " 'dnf copr enable {0} <repository>'\n"
+ "But note that the installed repo file will likely need a manual "
+ "modification.").format(project_name)
+ raise dnf.exceptions.Error(error_msg)
+ else:
+ error_msg += _("Project {0} does not exist.").format(project_name)
+ raise dnf.exceptions.Error(error_msg)
+ except URLError as e:
+ error_msg = _("Failed to connect to {0}: {1}").format(self.copr_url + api_path, e.reason.strerror)
+ raise dnf.exceptions.Error(error_msg)
+
+ # Try to read the first line, and detect the repo_filename from that (override the repo_filename value).
+ first_line = response.readline()
+ line = first_line.decode("utf-8")
+ if re.match(r"\[copr:", line):
+ repo_filename = os.path.join(self.base.conf.get_reposdir, "_" + line[1:-2] + ".repo")
# if using default hub, remove possible old repofile
if self.copr_url == self.default_url:
@@ -507,7 +521,10 @@ Bugzilla. In case of problems, contact the owner of this repository.
if os.path.exists(old_repo_filename):
os.remove(old_repo_filename)
- shutil.copy2(f.name, repo_filename)
+ with open(repo_filename, 'wb') as f:
+ f.write(first_line)
+ for line in response.readlines():
+ f.write(line)
os.chmod(repo_filename, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
def _runtime_deps_warning(self, copr_username, copr_projectname):
--
2.36.1

View File

@ -0,0 +1,33 @@
From b2d019658ebb40606e1a9efcb2233a8e38834410 Mon Sep 17 00:00:00 2001
From: Alexander Sosedkin <asosedkin@redhat.com>
Date: Thu, 7 Oct 2021 19:08:47 +0200
Subject: [PATCH] copr: allow specifying protocol as part of --hub
This way it doesn't try to connect to
https://http//url if --hub started with http://.
---
plugins/copr.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/plugins/copr.py b/plugins/copr.py
index 721c010..297210b 100644
--- a/plugins/copr.py
+++ b/plugins/copr.py
@@ -198,8 +198,12 @@ class CoprCommand(dnf.cli.Command):
self.copr_hostname += ":" + port
if not self.copr_url:
- self.copr_hostname = copr_hub
- self.copr_url = self.default_protocol + "://" + copr_hub
+ if '://' not in copr_hub:
+ self.copr_hostname = copr_hub
+ self.copr_url = self.default_protocol + "://" + copr_hub
+ else:
+ self.copr_hostname = copr_hub.split('://', 1)[1]
+ self.copr_url = copr_hub
def _read_config_item(self, config, hub, section, default):
try:
--
2.36.1

View File

@ -0,0 +1,37 @@
From 4b0001d0f13598369ec2e6a800af519e8c3a334c Mon Sep 17 00:00:00 2001
From: Carl George <carl@george.computer>
Date: Mon, 27 Jun 2022 23:12:05 -0500
Subject: [PATCH] copr: Guess EPEL chroots for CentOS Stream (RhBug:2058471)
Packages built in epel-9 chroots are almost always compatible with
CentOS Stream 9. Not having the copr plugin guess this chroot is
causing user friction. Users are creating epel-9 chroots expecting them
to work for both CentOS Stream 9 and RHEL 9. When they get reports
about `dnf copr enable` not working, they try to add a centos-stream-9
chroot, only to discover the dependencies they need from EPEL are not
available.
Instead of making the majority of CentOS Stream users include an
explicit chroot argument, let's reserve that workaround only for the
people that don't want their CentOS Stream systems picking the EPEL
chroot.
---
plugins/copr.py | 2 --
1 file changed, 2 deletions(-)
diff --git a/plugins/copr.py b/plugins/copr.py
index 297210b..16946b7 100644
--- a/plugins/copr.py
+++ b/plugins/copr.py
@@ -469,8 +469,6 @@ Bugzilla. In case of problems, contact the owner of this repository.
chroot = ("opensuse-tumbleweed-{}".format(distarch))
else:
chroot = ("opensuse-leap-{0}-{1}".format(dist[1], distarch))
- elif "CentOS Stream" in dist:
- chroot = ("centos-stream-{0}-{1}".format(dist[1], distarch))
else:
chroot = ("epel-%s-x86_64" % dist[1].split(".", 1)[0])
return chroot
--
2.36.1

View File

@ -34,7 +34,7 @@
Name: dnf-plugins-core
Version: 4.0.21
Release: 12%{?dist}
Release: 14%{?dist}
Summary: Core Plugins for DNF
License: GPLv2+
URL: https://github.com/rpm-software-management/dnf-plugins-core
@ -54,6 +54,14 @@ Patch12: 0012-Update-translations-RhBug-2017271.patch
Patch13: 0013-repomanage-Use-modules-only-from-repo-they-are-handl.patch
Patch14: 0014-feat-repomanage-Add-new-option-oldonly.patch
Patch15: 0015-Skip-all-non-rpm-tsi-for-transaction_action-plugins-.patch
Patch16: 0016-Fix-dnf-copr-enable-on-Fedora-35.patch
Patch17: 0017-Disable-dnf-playground-command.patch
Patch18: 0018-Fix-baseurl-for-centos-stream-chroot.patch
Patch19: 0019-Silence-a-deprecation-warning-in-plugins-copr.py.patch
Patch20: 0020-Shorter-verification-that-the-project-exists.patch
Patch21: 0021-Better-error-message-for-dnf-copr-enable.patch
Patch22: 0022-copr-allow-specifying-protocol-as-part-of-hub.patch
Patch23: 0023-copr-Guess-EPEL-chroots-for-CentOS-Stream-RhBug-2058.patch
BuildArch: noarch
@ -798,6 +806,18 @@ ln -sf %{_mandir}/man1/%{yum_utils_subpackage_name}.1.gz %{buildroot}%{_mandir}/
%endif
%changelog
* Tue Jul 19 2022 Lukas Hrazky <lhrazky@redhat.com> - 4.0.21-14
- [copr] Guess EPEL chroots for CentOS Stream
* Tue Jun 14 2022 Lukas Hrazky <lhrazky@redhat.com> - 4.0.21-13
- [copr] Fix 'dnf copr enable' on Fedora 35
- [copr] Disable dnf playground command
- [copr] Fix baseurl for centos stream chroot
- [copr] Silence a deprecation warning in plugins/copr.py
- [copr] Shorter verification that the project exists
- [copr] Better error message for dnf copr enable
- [copr] allow specifying protocol as part of --hub
* Tue Jun 14 2022 Lukas Hrazky <lhrazky@redhat.com> - 4.0.21-12
- [repomanage] Use modules only from repo they are handling
- [repomanage] Add new option --oldonly