richardphibel / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

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

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