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