forked from rpms/dnf-plugins-core
		
	import dnf-plugins-core-4.0.21-14.el8
This commit is contained in:
		
							parent
							
								
									6c09628205
								
							
						
					
					
						commit
						ef4b9869dd
					
				
							
								
								
									
										7024
									
								
								SOURCES/0012-Update-translations-RhBug-2017271.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7024
									
								
								SOURCES/0012-Update-translations-RhBug-2017271.patch
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -0,0 +1,48 @@ | ||||
| From e80f79b2f5e17a20065617c0b614b272dd53c57c Mon Sep 17 00:00:00 2001 | ||||
| From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com> | ||||
| Date: Thu, 26 May 2022 07:21:45 +0200 | ||||
| Subject: [PATCH] repomanage: Use modules only from repo they are handling | ||||
|  (RhBug:2072441) | ||||
| 
 | ||||
| = changelog =
 | ||||
| msg: [repomanage] Modules are used only when they belong to target repo | ||||
| type: bugfix | ||||
| resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2072441 | ||||
| ---
 | ||||
|  plugins/repomanage.py | 13 +++++++++---- | ||||
|  1 file changed, 9 insertions(+), 4 deletions(-) | ||||
| 
 | ||||
| diff --git a/plugins/repomanage.py b/plugins/repomanage.py
 | ||||
| index 989bd78..67a6fc7 100644
 | ||||
| --- a/plugins/repomanage.py
 | ||||
| +++ b/plugins/repomanage.py
 | ||||
| @@ -66,7 +66,8 @@ class RepoManageCommand(dnf.cli.Command):
 | ||||
|          keepnum = int(self.opts.keep) # the number of items to keep | ||||
|   | ||||
|          try: | ||||
| -            repo_conf = self.base.repos.add_new_repo("repomanage_repo", self.base.conf, baseurl=[self.opts.path])
 | ||||
| +            REPOMANAGE_REPOID = "repomanage_repo"
 | ||||
| +            repo_conf = self.base.repos.add_new_repo(REPOMANAGE_REPOID, self.base.conf, baseurl=[self.opts.path])
 | ||||
|              # Always expire the repo, otherwise repomanage could use cached metadata and give identical results | ||||
|              # for multiple runs even if the actual repo changed in the meantime | ||||
|              repo_conf._repo.expire() | ||||
| @@ -78,9 +79,13 @@ class RepoManageCommand(dnf.cli.Command):
 | ||||
|                  module_packages = self.base._moduleContainer.getModulePackages() | ||||
|   | ||||
|                  for module_package in module_packages: | ||||
| -                    all_modular_artifacts.update(module_package.getArtifacts())
 | ||||
| -                    module_dict.setdefault(module_package.getNameStream(), {}).setdefault(
 | ||||
| -                        module_package.getVersionNum(), []).append(module_package)
 | ||||
| +                    # Even though we load only REPOMANAGE_REPOID other modules can be loaded from system
 | ||||
| +                    # failsafe data automatically, we don't want them affecting repomanage results so ONLY
 | ||||
| +                    # use modules from REPOMANAGE_REPOID.
 | ||||
| +                    if module_package.getRepoID() == REPOMANAGE_REPOID:
 | ||||
| +                        all_modular_artifacts.update(module_package.getArtifacts())
 | ||||
| +                        module_dict.setdefault(module_package.getNameStream(), {}).setdefault(
 | ||||
| +                            module_package.getVersionNum(), []).append(module_package)
 | ||||
|   | ||||
|          except dnf.exceptions.RepoError: | ||||
|              rpm_list = [] | ||||
| -- 
 | ||||
| 2.36.1 | ||||
| 
 | ||||
							
								
								
									
										117
									
								
								SOURCES/0014-feat-repomanage-Add-new-option-oldonly.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										117
									
								
								SOURCES/0014-feat-repomanage-Add-new-option-oldonly.patch
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,117 @@ | ||||
| From eb1d6edf55c167d575ce3d16bd6349e382d05600 Mon Sep 17 00:00:00 2001 | ||||
| From: Masahiro Matsuya <mmatsuya@redhat.com> | ||||
| Date: Wed, 13 Apr 2022 18:42:03 +0900 | ||||
| Subject: [PATCH] feat(repomanage): Add new option --oldonly | ||||
| 
 | ||||
| = changelog =
 | ||||
| msg:           repomanage: Add new option --oldonly | ||||
| type:          enhancement | ||||
| resolves:      https://bugzilla.redhat.com/show_bug.cgi?id=2034736 | ||||
| resolves:      https://bugzilla.redhat.com/show_bug.cgi?id=2058676 | ||||
| ---
 | ||||
|  doc/repomanage.rst    |  3 +++ | ||||
|  plugins/repomanage.py | 46 ++++++++++++++++++++++++++++++++++++++++--- | ||||
|  2 files changed, 46 insertions(+), 3 deletions(-) | ||||
| 
 | ||||
| diff --git a/doc/repomanage.rst b/doc/repomanage.rst
 | ||||
| index e3171ef..3c01289 100644
 | ||||
| --- a/doc/repomanage.rst
 | ||||
| +++ b/doc/repomanage.rst
 | ||||
| @@ -47,6 +47,9 @@ The following options set what packages are displayed. These options are mutuall
 | ||||
|  ``--old`` | ||||
|      Show older packages (for a package or a stream show all versions except the newest one). | ||||
|   | ||||
| +``--oldonly``
 | ||||
| +    Show older packages (same as --old, but exclude the newest packages even when it's included in the older stream versions).
 | ||||
| +
 | ||||
|  ``--new`` | ||||
|      Show newest packages. | ||||
|   | ||||
| diff --git a/plugins/repomanage.py b/plugins/repomanage.py
 | ||||
| index 67a6fc7..d23497a 100644
 | ||||
| --- a/plugins/repomanage.py
 | ||||
| +++ b/plugins/repomanage.py
 | ||||
| @@ -57,6 +57,12 @@ class RepoManageCommand(dnf.cli.Command):
 | ||||
|      def run(self): | ||||
|          if self.opts.new and self.opts.old: | ||||
|              raise dnf.exceptions.Error(_("Pass either --old or --new, not both!")) | ||||
| +        if self.opts.new and self.opts.oldonly:
 | ||||
| +            raise dnf.exceptions.Error(_("Pass either --oldonly or --new, not both!"))
 | ||||
| +        if self.opts.old and self.opts.oldonly:
 | ||||
| +            raise dnf.exceptions.Error(_("Pass either --old or --oldonly, not both!"))
 | ||||
| +        if not self.opts.old and not self.opts.oldonly:
 | ||||
| +            self.opts.new = True
 | ||||
|   | ||||
|          verfile = {} | ||||
|          pkgdict = {} | ||||
| @@ -123,8 +129,7 @@ class RepoManageCommand(dnf.cli.Command):
 | ||||
|          # modular packages | ||||
|          keepnum_latest_stream_artifacts = set() | ||||
|   | ||||
| -        # if new
 | ||||
| -        if not self.opts.old:
 | ||||
| +        if self.opts.new:
 | ||||
|              # regular packages | ||||
|              for (n, a) in pkgdict.keys(): | ||||
|                  evrlist = pkgdict[(n, a)] | ||||
| @@ -146,7 +151,6 @@ class RepoManageCommand(dnf.cli.Command):
 | ||||
|                      for stream in streams_by_version[i]: | ||||
|                          keepnum_latest_stream_artifacts.update(set(stream.getArtifacts())) | ||||
|   | ||||
| -
 | ||||
|          if self.opts.old: | ||||
|              # regular packages | ||||
|              for (n, a) in pkgdict.keys(): | ||||
| @@ -169,6 +173,40 @@ class RepoManageCommand(dnf.cli.Command):
 | ||||
|                      for stream in streams_by_version[i]: | ||||
|                          keepnum_latest_stream_artifacts.update(set(stream.getArtifacts())) | ||||
|   | ||||
| +        if self.opts.oldonly:
 | ||||
| +            # regular packages
 | ||||
| +            for (n, a) in pkgdict.keys():
 | ||||
| +                evrlist = pkgdict[(n, a)]
 | ||||
| +
 | ||||
| +                oldevrs = evrlist[:-keepnum]
 | ||||
| +
 | ||||
| +                for package in oldevrs:
 | ||||
| +                    nevra = self._package_to_nevra(package)
 | ||||
| +                    for fpkg in verfile[nevra]:
 | ||||
| +                        outputpackages.append(fpkg)
 | ||||
| +
 | ||||
| +            # modular packages
 | ||||
| +            keepnum_newer_stream_artifacts = set()
 | ||||
| +
 | ||||
| +            for streams_by_version in module_dict.values():
 | ||||
| +                sorted_stream_versions = sorted(streams_by_version.keys())
 | ||||
| +
 | ||||
| +                new_sorted_stream_versions = sorted_stream_versions[-keepnum:]
 | ||||
| +
 | ||||
| +                for i in new_sorted_stream_versions:
 | ||||
| +                    for stream in streams_by_version[i]:
 | ||||
| +                        keepnum_newer_stream_artifacts.update(set(stream.getArtifacts()))
 | ||||
| +
 | ||||
| +            for streams_by_version in module_dict.values():
 | ||||
| +                sorted_stream_versions = sorted(streams_by_version.keys())
 | ||||
| +
 | ||||
| +                old_sorted_stream_versions = sorted_stream_versions[:-keepnum]
 | ||||
| +
 | ||||
| +                for i in old_sorted_stream_versions:
 | ||||
| +                    for stream in streams_by_version[i]:
 | ||||
| +                        for artifact in stream.getArtifacts():
 | ||||
| +                            if artifact not in keepnum_newer_stream_artifacts:
 | ||||
| +                                keepnum_latest_stream_artifacts.add(artifact)
 | ||||
|   | ||||
|          modular_packages = [self._package_to_path(x) for x in query.filter(pkg__eq=query.filter(nevra_strict=keepnum_latest_stream_artifacts)).available()] | ||||
|          outputpackages = outputpackages + modular_packages | ||||
| @@ -183,6 +221,8 @@ class RepoManageCommand(dnf.cli.Command):
 | ||||
|      def set_argparser(parser): | ||||
|          parser.add_argument("-o", "--old", action="store_true", | ||||
|                              help=_("Print the older packages")) | ||||
| +        parser.add_argument("-O", "--oldonly", action="store_true",
 | ||||
| +                            help=_("Print the older packages. Exclude the newest packages."))
 | ||||
|          parser.add_argument("-n", "--new", action="store_true", | ||||
|                              help=_("Print the newest packages")) | ||||
|          parser.add_argument("-s", "--space", action="store_true", | ||||
| -- 
 | ||||
| 2.36.1 | ||||
| 
 | ||||
| @ -0,0 +1,28 @@ | ||||
| From b4e0cafe70680db24ab3611e0fd4dd95c8311ccc Mon Sep 17 00:00:00 2001 | ||||
| From: Jaroslav Mracek <jmracek@redhat.com> | ||||
| Date: Tue, 26 Apr 2022 11:23:41 +0200 | ||||
| Subject: [PATCH] Skip all non rpm tsi for transaction_action plugins | ||||
|  (rhbug:2023652) | ||||
| 
 | ||||
| It prevent traceback in output when reason change is in transaction | ||||
| ---
 | ||||
|  plugins/post-transaction-actions.py | 3 +++ | ||||
|  1 file changed, 3 insertions(+) | ||||
| 
 | ||||
| diff --git a/plugins/post-transaction-actions.py b/plugins/post-transaction-actions.py
 | ||||
| index 05a7841..1520c26 100644
 | ||||
| --- a/plugins/post-transaction-actions.py
 | ||||
| +++ b/plugins/post-transaction-actions.py
 | ||||
| @@ -115,6 +115,9 @@ class PostTransactionActions(dnf.Plugin):
 | ||||
|                  in_ts_items.append(ts_item) | ||||
|              elif ts_item.action in dnf.transaction.BACKWARD_ACTIONS: | ||||
|                  out_ts_items.append(ts_item) | ||||
| +            else:
 | ||||
| +                #  The action is not rpm change. It can be a reason change, therefore we can skip that item
 | ||||
| +                continue
 | ||||
|              all_ts_items.append(ts_item) | ||||
|   | ||||
|          commands_to_run = [] | ||||
| -- 
 | ||||
| 2.36.1 | ||||
| 
 | ||||
							
								
								
									
										28
									
								
								SOURCES/0016-Fix-dnf-copr-enable-on-Fedora-35.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								SOURCES/0016-Fix-dnf-copr-enable-on-Fedora-35.patch
									
									
									
									
									
										Normal 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 | ||||
| 
 | ||||
							
								
								
									
										37
									
								
								SOURCES/0017-Disable-dnf-playground-command.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								SOURCES/0017-Disable-dnf-playground-command.patch
									
									
									
									
									
										Normal 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 | ||||
| 
 | ||||
							
								
								
									
										29
									
								
								SOURCES/0018-Fix-baseurl-for-centos-stream-chroot.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								SOURCES/0018-Fix-baseurl-for-centos-stream-chroot.patch
									
									
									
									
									
										Normal 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 | ||||
| 
 | ||||
| @ -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 | ||||
| 
 | ||||
| @ -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 | ||||
| 
 | ||||
							
								
								
									
										114
									
								
								SOURCES/0021-Better-error-message-for-dnf-copr-enable.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										114
									
								
								SOURCES/0021-Better-error-message-for-dnf-copr-enable.patch
									
									
									
									
									
										Normal 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 | ||||
| 
 | ||||
| @ -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 | ||||
| 
 | ||||
| @ -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 | ||||
| 
 | ||||
| @ -34,7 +34,7 @@ | ||||
| 
 | ||||
| Name:           dnf-plugins-core | ||||
| Version:        4.0.21 | ||||
| Release:        10%{?dist} | ||||
| Release:        14%{?dist} | ||||
| Summary:        Core Plugins for DNF | ||||
| License:        GPLv2+ | ||||
| URL:            https://github.com/rpm-software-management/dnf-plugins-core | ||||
| @ -50,6 +50,19 @@ Patch8:         0008-versionlock-fix-multi-pkg-lock-RhBug2013324.patch | ||||
| Patch9:         0009-Update-documentation-for-adding-specific-version-RhBug2013332.patch | ||||
| Patch10:        0010-needs-restarting-Fix-wrong-boot-time-RhBug1960437.patch | ||||
| Patch11:        0011-Add-new-command-modulesync-RhBug1868047.patch | ||||
| 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 | ||||
| BuildRequires:  cmake | ||||
| @ -793,6 +806,24 @@ 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 | ||||
| - Skip all non rpm tsi for transaction_action plugins | ||||
| - Update translations | ||||
| 
 | ||||
| * Fri Jan 14 2022 Pavla Kratochvilova <pkratoch@redhat.com> - 4.0.21-10 | ||||
| - Rebuild with new release number | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user