Hello community,

here is the log from the commit of package dnf-plugins-core for 
openSUSE:Factory checked in at 2019-02-20 14:10:28
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/dnf-plugins-core (Old)
 and      /work/SRC/openSUSE:Factory/.dnf-plugins-core.new.28833 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "dnf-plugins-core"

Wed Feb 20 14:10:28 2019 rev:5 rq:673182 version:4.0.3

Changes:
--------
--- /work/SRC/openSUSE:Factory/dnf-plugins-core/dnf-plugins-core.changes        
2018-04-24 15:34:27.747328378 +0200
+++ 
/work/SRC/openSUSE:Factory/.dnf-plugins-core.new.28833/dnf-plugins-core.changes 
    2019-02-20 14:10:37.762953491 +0100
@@ -1,0 +2,25 @@
+Mon Feb 11 01:08:46 UTC 2019 - Neal Gompa <[email protected]>
+
+- Temporarily drop needs-restarting files from dnf-utils until
+  zypper splits them out into zypper-needs-restarting subpackage
+  (gh#openSUSE/zypper#254)
+- Add conflicts to yum-changelog and zypper-needs-restarting to
+  dnf-utils
+
+-------------------------------------------------------------------
+Thu Feb  7 07:49:25 UTC 2019 - Neal Gompa <[email protected]>
+
+- Rebase to version 4.0.3:
+  + Compatible with DNF 4.0.0+
+  + Reworked COPR plugin
+  + New changelogs and repodiff plugins/subcommands
+- Drop Python 2 subpackages
+- Drop unneeded patches:
+  * 0001-copr-Add-openSUSE-support.patch
+  * dnf-plugins-core-2.1.5-Fix-detection-of-Python-2.patch
+- Backport fixes from upstream to build and run plugins
+  * 0001-Fix-traceback-when-local-rpm-url-is-passed.patch
+  * 0002-reposync-fix-up-path-traversal-prevention.patch
+  * 0003-doc-Use-the-correct-sphinx-build-binary-for-Python-2.patch
+
+-------------------------------------------------------------------

Old:
----
  0001-copr-Add-openSUSE-support.patch
  dnf-plugins-core-2.1.5-Fix-detection-of-Python-2.patch
  dnf-plugins-core-2.1.5.tar.gz

New:
----
  0001-Fix-traceback-when-local-rpm-url-is-passed.patch
  0002-reposync-fix-up-path-traversal-prevention.patch
  0003-doc-Use-the-correct-sphinx-build-binary-for-Python-2.patch
  dnf-plugins-core-4.0.3.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ dnf-plugins-core.spec ++++++
++++ 603 lines (skipped)
++++ between /work/SRC/openSUSE:Factory/dnf-plugins-core/dnf-plugins-core.spec
++++ and 
/work/SRC/openSUSE:Factory/.dnf-plugins-core.new.28833/dnf-plugins-core.spec

++++++ 0001-Fix-traceback-when-local-rpm-url-is-passed.patch ++++++
>From 2d61e843048d49052af93e377796a3b850cdf89c Mon Sep 17 00:00:00 2001
From: Marek Blaha <[email protected]>
Date: Thu, 13 Dec 2018 08:19:40 +0100
Subject: [PATCH 1/3] Fix traceback when local rpm / url is passed

$ dnf download acpi-1.7-9.fc28.x86_64.rpm
Last metadata expiration check: 0:20:41 ago on Thu 25 Oct 2018 01:27:34 AM EDT.
Traceback (most recent call last):
  File "/usr/bin/dnf", line 98, in <module>
    main.user_main(MAPPING[command] + args, exit_code=True)
  File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 179, in 
user_main
    errcode = main(args)
  File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 64, in main
    return _main(base, args, cli_class, option_parser_class)
  File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 99, in _main
    return cli_run(cli, base)
  File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 115, in cli_run
    cli.run()
  File "/usr/lib/python3.6/site-packages/dnf/cli/cli.py", line 1055, in run
    return self.command.run()
  File "/usr/lib/python3.6/site-packages/dnf-plugins/download.py", line 116, in 
run
    self._do_downloads(pkgs)  # download rpms
  File "/usr/lib/python3.6/site-packages/dnf-plugins/download.py", line 128, in 
_do_downloads
    pkg_list.sort(key=lambda x: (x.repo.priority, x.repo.cost))
  File "/usr/lib/python3.6/site-packages/dnf-plugins/download.py", line 128, in 
<lambda>
    pkg_list.sort(key=lambda x: (x.repo.priority, x.repo.cost))
  File "/usr/lib/python3.6/site-packages/dnf/package.py", line 158, in repo
    return self.base.repos[self.reponame]
KeyError: '@commandline'

https://bugzilla.redhat.com/show_bug.cgi?id=1642791
---
 plugins/download.py    | 42 ++++++++++++++++++++++++++++++------------
 tests/support.py       |  1 +
 tests/test_download.py | 10 +++++-----
 3 files changed, 36 insertions(+), 17 deletions(-)

diff --git a/plugins/download.py b/plugins/download.py
index 91a66b9..792c828 100644
--- a/plugins/download.py
+++ b/plugins/download.py
@@ -103,14 +103,16 @@ class DownloadCommand(dnf.cli.Command):
         # If user asked for just urls then print them and we're done
         if self.opts.url:
             for pkg in pkgs:
-                url = pkg.remote_location(schemes=self.opts.urlprotocols)
-                if url:
-                    print(url)
-                else:
-                    msg = _("Failed to get mirror for package: %s") % pkg.name
-                    if self.base.conf.strict:
-                        raise dnf.exceptions.Error(msg)
-                    logger.warning(msg)
+                # command line repo packages do not have .remote_location
+                if pkg.repoid != hawkey.CMDLINE_REPO_NAME:
+                    url = pkg.remote_location(schemes=self.opts.urlprotocols)
+                    if url:
+                        print(url)
+                    else:
+                        msg = _("Failed to get mirror for package: %s") % 
pkg.name
+                        if self.base.conf.strict:
+                            raise dnf.exceptions.Error(msg)
+                        logger.warning(msg)
             return
         else:
             self._do_downloads(pkgs)  # download rpms
@@ -124,11 +126,28 @@ class DownloadCommand(dnf.cli.Command):
             pkg_dict.setdefault(str(pkg), []).append(pkg)
 
         to_download = []
+        cmdline = []
         for pkg_list in pkg_dict.values():
+            pkgs_cmdline = [pkg for pkg in pkg_list
+                            if pkg.repoid == hawkey.CMDLINE_REPO_NAME]
+            if pkgs_cmdline:
+                cmdline.append(pkgs_cmdline[0])
+                continue
             pkg_list.sort(key=lambda x: (x.repo.priority, x.repo.cost))
             to_download.append(pkg_list[0])
-        self.base.download_packages(to_download, self.base.output.progress)
-        locations = sorted([pkg.localPkg() for pkg in to_download])
+        if to_download:
+            self.base.download_packages(to_download, self.base.output.progress)
+        if cmdline:
+            # command line repo packages are either local files or already 
downloaded urls
+            # just copy them to the destination
+            for pkg in cmdline:
+                # python<3.4 shutil module does not raise SameFileError, check 
manually
+                src = pkg.localPkg()
+                dst = os.path.join(self.base.conf.destdir, 
os.path.basename(src))
+                if os.path.samefile(src, dst):
+                    continue
+                shutil.copy(src, self.base.conf.destdir)
+        locations = sorted([pkg.localPkg() for pkg in to_download + cmdline])
         return locations
 
     def _get_pkg_objs_rpms(self, pkg_specs):
@@ -236,8 +255,7 @@ class DownloadCommand(dnf.cli.Command):
         is_url = schemes and schemes in ('http', 'ftp', 'file', 'https')
         if is_url or (pkg_spec.endswith('.rpm') and os.path.isfile(pkg_spec)):
             pkgs = self.base.add_remote_rpms([pkg_spec], 
progress=self.base.output.progress)
-            pkg_spec = 
"{0.name}-{0.epoch}:{0.version}-{0.release}.{0.arch}".format(pkgs[0])
-
+            return self.base.sack.query().filterm(pkg=pkgs)
         subj = dnf.subject.Subject(pkg_spec)
         q = subj.get_best_query(self.base.sack)
         q = q.available()
diff --git a/tests/support.py b/tests/support.py
index 01825ae..c98651d 100644
--- a/tests/support.py
+++ b/tests/support.py
@@ -211,6 +211,7 @@ class PkgStub:
         self.release = r
         self.arch = a
         self.epoch = e
+        self.repoid = repo_id
         self.reponame = repo_id
         self.src_name = src_name
         self.repo = repo
diff --git a/tests/test_download.py b/tests/test_download.py
index 3af234e..d0d64fb 100644
--- a/tests/test_download.py
+++ b/tests/test_download.py
@@ -70,6 +70,10 @@ class QueryStub(object):
         self._filter = kwargs
         return self
 
+    def filterm(self, **kwargs):
+        self._filter = kwargs
+        return self
+
     def _stub_filter(self, **kwargs):
         results = self._all
 
@@ -262,11 +266,7 @@ class DownloadCommandTest(unittest.TestCase):
     def test_get_query_with_local_rpm(self):
         try:
             (fs, rpm_path) = tempfile.mkstemp('foobar-99.99-1.x86_64.rpm')
-            # b/c self.cmd.cli.base.add_remote_rpms is a mock object it
-            # will not update the available packages while testing.
-            # it is expected to hit this exception
-            with self.assertRaises(dnf.exceptions.PackageNotFoundError):
-                self.cmd._get_query(rpm_path)
+            self.cmd._get_query(rpm_path)
             self.cmd.cli.base.add_remote_rpms.assert_called_with([rpm_path], 
progress=None)
         finally:
             os.remove(rpm_path)
-- 
2.20.1

++++++ 0002-reposync-fix-up-path-traversal-prevention.patch ++++++
>From 0631f863ec7948484df10f5dc16c774d5815326a Mon Sep 17 00:00:00 2001
From: Michal Domonkos <[email protected]>
Date: Thu, 3 Jan 2019 15:58:06 +0100
Subject: [PATCH 2/3] reposync: fix-up path traversal prevention

Previously, pkg_download_path() would still pass if the target path was
a "sibling" of the destination directory.

Example:

  repo_target = '/tmp/myrepo'
  pkg_download_path = '../myrepo2/evil_file'
  ...
  # final path that passes the check:
  pkg_download_path = '/tmp/myrepo2/evil_file'
                      # ^ this is a superstring of repo_target!

This commit prevents that by making sure repo_target ends with a path
separator before it is passed to startswith().  We achieve that by
simply using join() with an empty string (see python docs).

In addition, normpath() is replaced by realpath() to account for
symlinks that could also carry us outside repo_target.

Resolves RHEL-8 bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1600722
---
 plugins/reposync.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/plugins/reposync.py b/plugins/reposync.py
index 29b911e..0d72f55 100644
--- a/plugins/reposync.py
+++ b/plugins/reposync.py
@@ -32,7 +32,7 @@ import dnf.cli
 
 def _pkgdir(intermediate, target):
     cwd = dnf.i18n.ucd(os.getcwd())
-    return os.path.normpath(os.path.join(cwd, intermediate, target))
+    return os.path.realpath(os.path.join(cwd, intermediate, target))
 
 
 class RPMPayloadLocation(dnf.repo.RPMPayload):
@@ -118,9 +118,12 @@ class RepoSyncCommand(dnf.cli.Command):
 
     def pkg_download_path(self, pkg):
         repo_target = self.repo_target(pkg.repo)
-        pkg_download_path = os.path.normpath(
+        pkg_download_path = os.path.realpath(
             os.path.join(repo_target, pkg.location))
-        if not pkg_download_path.startswith(repo_target):
+        # join() ensures repo_target ends with a path separator (otherwise the
+        # check would pass if pkg_download_path was a "sibling" path component
+        # of repo_target that has the same prefix).
+        if not pkg_download_path.startswith(os.path.join(repo_target, '')):
             raise dnf.exceptions.Error(
                 _("Download target '{}' is outside of download path 
'{}'.").format(
                     pkg_download_path, repo_target))
-- 
2.20.1

++++++ 0003-doc-Use-the-correct-sphinx-build-binary-for-Python-2.patch ++++++
>From 35568fea8fdedfe4134dea2e26637c5070d24448 Mon Sep 17 00:00:00 2001
From: Neal Gompa <[email protected]>
Date: Sun, 6 Jan 2019 21:15:22 -0500
Subject: [PATCH 3/3] doc: Use the correct sphinx-build binary for Python 2 or
 Python 3

When trying to build dnf-plugins-core purely as a Python 3 package,
man page generation fails because sphinx-build cannot be found, due
to python3-sphinx not providing that binary.
---
 doc/CMakeLists.txt | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 0c24597..e67f42e 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -1,11 +1,18 @@
 # html and man documentation are separate targets, apparently there's no way to
 # tell sphinx-build to do them both in one go:
+
+if (${PYTHON_VERSION_MAJOR} STREQUAL "2")
+    SET(SPHINX_BUILD_NAME "sphinx-build")
+else()
+    SET(SPHINX_BUILD_NAME "sphinx-build-3")
+endif()
+
 ADD_CUSTOM_TARGET (doc-html
-                 PYTHONPATH=${CMAKE_SOURCE_DIR} sphinx-build -b html
+                 PYTHONPATH=${CMAKE_SOURCE_DIR} ${SPHINX_BUILD_NAME} -b html
                  ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
                  COMMENT "Building html documentation")
 ADD_CUSTOM_TARGET (doc-man
-                 PYTHONPATH=${CMAKE_SOURCE_DIR} sphinx-build -b man
+                 PYTHONPATH=${CMAKE_SOURCE_DIR} ${SPHINX_BUILD_NAME} -b man
                  ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
                  COMMENT "Building manpage documentation")
 ADD_CUSTOM_TARGET (doc)
-- 
2.20.1

++++++ dnf-plugins-core-2.1.5.tar.gz -> dnf-plugins-core-4.0.3.tar.gz ++++++
++++ 26944 lines of diff (skipped)


Reply via email to