diff --git a/dnf/base.py b/dnf/base.py index f9d31b3..fe359fb 100644 --- a/dnf/base.py +++ b/dnf/base.py @@ -1162,6 +1162,9 @@ class Base(object): 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/doc/api_base.rst b/doc/api_base.rst index 5fd5b4c..618886d 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() diff --git a/doc/command_ref.rst b/doc/command_ref.rst index 369d10c..fa2bc51 100644 --- a/doc/command_ref.rst +++ b/doc/command_ref.rst @@ -1516,6 +1516,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: ------------ diff --git a/tests/test_base.py b/tests/test_base.py index 0d50516..8f807b7 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])