Skip to content

Commit

Permalink
Update SystemPackageTool conan-io/conan#5026
Browse files Browse the repository at this point in the history
- Add new section explaning about setting parameter

Signed-off-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
uilianries committed May 24, 2019
1 parent e532270 commit 0440be7
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions reference/conanfile/methods.rst
Original file line number Diff line number Diff line change
Expand Up @@ -565,23 +565,25 @@ SystemPackageTool

.. code-block:: python
def SystemPackageTool(tool=None)
def SystemPackageTool(runner=None, os_info=None, tool=None, recommends=False, output=None, settings=None)
Available tool classes: **AptTool**, **YumTool**, **BrewTool**, **PkgTool**, **PkgUtilTool**, **ChocolateyTool**,
**PacManTool**.

Methods:
- **add_repository(repository, repo_key=None)**: Add ``repository`` address in your current repo list.
- **update()**: Updates the system package manager database. It's called automatically from the ``install()`` method by default.
- **install(packages, update=True, force=False)**: Installs the ``packages`` (could be a list or a string). If ``update`` is True it
will execute ``update()`` first if it's needed. The packages won't be installed if they are already installed at least of ``force``
parameter is set to True. If ``packages`` is a list the first available package will be picked (short-circuit like logical **or**).
**Note**: This list of packages is intended for providing **alternative** names for the same package, to account for small variations
of the name for the same package in different distros. To install different packages, one call to ``install()`` per package is necessary.
- **installed(package_name)**: Verify if ``package_name`` is actually installed. It returns ``True`` if it is installed, otherwise ``False``.

The use of ``sudo`` in the internals of the ``install()`` and ``update()`` methods is controlled by the ``CONAN_SYSREQUIRES_SUDO``
environment variable, so if the users don't need sudo permissions, it is easy to opt-in/out.

When the environemtn variable ``CONAN_SYSREQUIRES_SUDO`` is not defined, Conan will try to use :command:`sudo` if the following conditions are met:
When the environment variable ``CONAN_SYSREQUIRES_SUDO`` is not defined, Conan will try to use :command:`sudo` if the following conditions are met:

- :command:`sudo` is available in the ``PATH``.
- The platform name is ``posix`` and the UID (user id) is not ``0``
Expand All @@ -596,6 +598,28 @@ packages have the same system requirements, just add the following line to your
self.global_system_requirements=True
if ...
To install multi-arch packages it is possible passing the desired architecture manually according
your package manager:

.. code-block:: python
name = "foobar"
platforms = {"x86_64": "amd64", "x86": "i386"}
installer = SystemPackageTool(tool=AptTool())
installer.install("%s:%s" % (name, platforms[self.settings.arch]))
However, it requires a boilerplate which could be automatically solved by your settings:

.. code-block:: python
installer = SystemPackageTool(settings=self.settings)
installer.install(name)
The ``SystemPackageTool`` is adapted to support possible prefixes and suffixes, according to the
instance of the package manager. It validates whether your current settings are configured for
cross-building, and if so, it will update the package name to be installed according to
``self.settings.arch``.

.. _method_imports:

imports()
Expand Down

0 comments on commit 0440be7

Please sign in to comment.