chantra / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

Blame SOURCES/0007-Shell-restriction-with-local-packages.patch

878112
From 2e78e3006ca8b640028b98afd2ccaa5d26ead7e3 Mon Sep 17 00:00:00 2001
878112
From: Jaroslav Mracek <jmracek@redhat.com>
878112
Date: Tue, 3 Dec 2019 09:09:20 +0100
878112
Subject: [PATCH 1/3] [doc] Add note about limitation of the shell command
878112
878112
---
878112
 doc/command_ref.rst | 5 +++++
878112
 1 file changed, 5 insertions(+)
878112
878112
diff --git a/doc/command_ref.rst b/doc/command_ref.rst
878112
index 24e08efdb2..cc27f57bba 100644
878112
--- a/doc/command_ref.rst
878112
+++ b/doc/command_ref.rst
878112
@@ -1515,6 +1515,11 @@ Shell Command
878112
         * reset: reset the transaction
878112
         * run: resolve and run the transaction
878112
 
878112
+    Note that all local packages must be used in the first shell transaction subcommand (e.g.
878112
+    `install /tmp/nodejs-1-1.x86_64.rpm /tmp/acpi-1-1.noarch.rpm`) otherwise an error will occur.
878112
+    Any `disable`, `enable`, and `reset` module operations (e.g. `module enable nodejs`) must also
878112
+    be performed before any other shell transaction subcommand is used.
878112
+
878112
 .. _swap_command-label:
878112
 
878112
 ------------
878112
878112
From 9e1958f3695b50f3c49f9aa2a8a113bbf660d62c Mon Sep 17 00:00:00 2001
878112
From: Jaroslav Mracek <jmracek@redhat.com>
878112
Date: Tue, 3 Dec 2019 09:31:49 +0100
878112
Subject: [PATCH 2/3] Prevent adding remote packages when goal is not empty
878112
 (RhBug:1773483)
878112
878112
Adding remote packages by add_remote_rpms() when goal is not empty
878112
results in transaction that is completely broken, because elements in
878112
transaction get different meaning.
878112
878112
https://bugzilla.redhat.com/show_bug.cgi?id=1773483
878112
---
878112
 dnf/base.py        | 3 +++
878112
 tests/test_base.py | 1 +
878112
 2 files changed, 4 insertions(+)
878112
878112
diff --git a/dnf/base.py b/dnf/base.py
878112
index 8091ca0366..c4ea04181a 100644
878112
--- a/dnf/base.py
878112
+++ b/dnf/base.py
878112
@@ -1162,6 +1162,9 @@ def add_remote_rpms(self, path_list, strict=True, progress=None):
878112
         pkgs = []
878112
         if not path_list:
878112
             return pkgs
878112
+        if self._goal.req_length():
878112
+            raise dnf.exceptions.Error(
878112
+                _("Cannot add local packages, because transaction job already exists"))
878112
         pkgs_error = []
878112
         for path in path_list:
878112
             if not os.path.exists(path) and '://' in path:
878112
diff --git a/tests/test_base.py b/tests/test_base.py
878112
index 0d50516d2f..8f807b7c13 100644
878112
--- a/tests/test_base.py
878112
+++ b/tests/test_base.py
878112
@@ -168,6 +168,7 @@ class MockBaseTest(tests.support.DnfBaseTestCase):
878112
     """Test the Base methods that need a Sack."""
878112
 
878112
     REPOS = ["main"]
878112
+    INIT_SACK = True
878112
 
878112
     def test_add_remote_rpms(self):
878112
         pkgs = self.base.add_remote_rpms([tests.support.TOUR_50_PKG_PATH])
878112
878112
From 575ef19433909d3bf7d90e5e4b36f912a472b517 Mon Sep 17 00:00:00 2001
878112
From: Jaroslav Mracek <jmracek@redhat.com>
878112
Date: Wed, 4 Dec 2019 13:17:26 +0100
878112
Subject: [PATCH 3/3] [doc] Describe the new behavior of Base.add_remote_rpms()
878112
878112
---
878112
 doc/api_base.rst | 15 ++++++++++-----
878112
 1 file changed, 10 insertions(+), 5 deletions(-)
878112
878112
diff --git a/doc/api_base.rst b/doc/api_base.rst
878112
index 5fd5b4cc99..618886d0cd 100644
878112
--- a/doc/api_base.rst
878112
+++ b/doc/api_base.rst
878112
@@ -33,6 +33,10 @@
878112
 
878112
     An instance of :class:`dnf.conf.Conf`, concentrates all the different configuration options. :meth:`__init__` initializes this to usable defaults.
878112
 
878112
+  .. attribute:: goal
878112
+
878112
+    An instance of :class:`dnf.goal.Goal` that this :class:`Base<dnf.Base>` object is using.
878112
+
878112
   .. attribute:: repos
878112
 
878112
     A :class:`dnf.repodict.RepoDict` instance, this member object contains all the repositories available.
878112
@@ -51,11 +55,12 @@
878112
 
878112
   .. method:: add_remote_rpms(path_list, strict=True, progress=None)
878112
 
878112
-    Add RPM files at list `path_list` to the :attr:`sack` and return the list of respective
878112
-    :class:`dnf.package.Package` instances. Does the download to a temporary files for each path if
878112
-    `path` is a remote URL. Raises :exc:`IOError` if there are problems obtaining during reading
878112
-    files and `strict=True`. `progress`, if given, should be a :class:`.DownloadProgress` and can be
878112
-    used by the caller to monitor the progress of the download.
878112
+    This function must be called before anything is added to the :attr:`goal`. Adds RPM files
878112
+    in path_list to the :attr:`sack` and return the list of respective :class:`dnf.package.Package`
878112
+    instances. Downloads the RPMs to a temporary file for each path if it is a remote URL.
878112
+    Raises :exc:`IOError` if there are `IO` problems with files and `strict=True`. Raises
878112
+    :exc:`dnf.exceptions.Error` if the :attr:`goal` is not empty. `progress`, if given, should be a
878112
+    :class:`.DownloadProgress` instance which can be used to monitor the progress of the download.
878112
 
878112
   .. method:: close()
878112