Skip to content

Commit eda58ff

Browse files
memshardedczoido
andauthored
conan config install-pkg conanconfig.yml and lockfiles (#4340)
* conan config install-pkg conanconfig.yml and lockfiles * Update reference/commands/config.rst Co-authored-by: Carlos Zoido <mrgalleta@gmail.com> * Update reference/commands/config.rst Co-authored-by: Carlos Zoido <mrgalleta@gmail.com> * Update reference/commands/config.rst Co-authored-by: Carlos Zoido <mrgalleta@gmail.com> --------- Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>
1 parent 0e8fc64 commit eda58ff

File tree

4 files changed

+92
-3
lines changed

4 files changed

+92
-3
lines changed

‎reference/commands/config.rst‎

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ To install a configuration from a Conan configuration package, it is possible:
157157
- ``conan config install-pkg`` always look in the server for the latest version or revision.
158158
- If the same version and revision was downloaded and installed from the server, ``conan config install-pkg`` will be a no-op unless ``--force`` is used, in this case the configuration will be overwritten.
159159

160-
It is also possible to make the version of the configuration affect all packages ``package_id`` and be part of the binary model, by activating the ``core.package_id:config_mode`` conf (this is also experimental), to any available mode, like ``minor_mode``.
160+
It is also possible to make the version of the configuration affect all packages ``package_id`` and be part of the binary model, by activating the ``core.package_id:config_mode`` conf (this is also experimental), to any available mode, like ``minor_mode``. Note that the order of the installation of packages in case multiple configuration packages are installed is important. This is why Conan will raise an error if the relative order of installed configuration packages changes as the result of installing updates for those configuration packages.
161+
161162

162163
As the ``conan config install-pkg`` command downloads the package from a Conan remote server, it can download from an already existing remote,
163164
or it can download from a Conan remote directly specifying the repository URL:
@@ -219,6 +220,56 @@ Then, developers could do:
219220
220221
And they will get the correct configuration for their platform.
221222

223+
.. seealso::
224+
225+
- If you lock installed configuration packages in a lockfile, you could use the
226+
:ref:`conan lock upgrade-config<reference_commands_lock_upgrade_config>` command
227+
to update such a lockfile.
228+
229+
230+
conanconfig.yml
231+
+++++++++++++++
232+
233+
The ``conan config install-pkg`` admits also as an input a yaml ``conanconfig.yml`` file that can contain more than one package requirement, something like:
234+
235+
.. code-block:: yaml
236+
237+
packages:
238+
- myconf_a/0.1
239+
- myconf_b/0.1
240+
- myconf_c/[>=1 <2]
241+
242+
243+
and be used like ``conan config install-pkg .`` or even just ``conan config install-pkg``.
244+
245+
The file also admits the definition of ``urls`` with the same meaning as the ``--url`` command line argument, to simplify the initial installation
246+
of configuration when doing a Conan setup:
247+
248+
.. code-block:: yaml
249+
:caption: conanconfig.yml
250+
251+
packages:
252+
- myconf_a/0.1
253+
- myconf_b/0.1
254+
- myconf_c/[>=1 <2]
255+
urls:
256+
- https://my/conan/remote/repo/url
257+
258+
259+
.. important::
260+
261+
When installing more than 1 configuration package, the order of installation is important, as the later installed packages can overwrite
262+
configuration files installed by the previous ones. Consequently, if you decide to make the configuration part of the packages ``package_id``
263+
via ``core.package_id:config_mode`` conf, the order is taken into account.
264+
265+
Then any installation or re-installation of packages or updates that change this order will be raised as an error. For example if
266+
after installing the configuration from the ``conanconfig.yml`` above we try to do a ``conan config install-pkg myconf_a/0.2``, that
267+
will be raised as an error, because that would make ``myconf_a`` to be the latest installed one, not the first.
268+
269+
But on the other hand, doing an update with the previous file will not be an error, because it will re-install the ``myconf_a``, ``myconf_b``
270+
and ``myconf_c`` in order. Likewise, doing an update only for ``myconf_c`` wouldn't be an error, because it is the last one and
271+
preserves the relative order.
272+
222273

223274
conan config list
224275
-----------------

‎reference/commands/lock.rst‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ In addition to these commands, most of the Conan commands that compute a graph,
1919
- :doc:`conan lock create <lock/create>`: Evaluates a dependency graph and save a lockfile
2020
- :doc:`conan lock merge <lock/merge>`: Merge several existing lockfiles into one
2121
- :doc:`conan lock update <lock/update>`: Manually update items from a lockfile
22-
- :doc:`conan lock update <lock/upgrade>`: (Experimental) Upgrade items from a lockfile
22+
- :doc:`conan lock upgrade <lock/upgrade>`: (Experimental) Upgrade items from a lockfile
23+
- :doc:`conan lock upgrade-config <lock/upgrade_config>`: (Experimental) Upgrade configuration packages from a lockfile
2324

2425

2526
.. autocommand::

‎reference/commands/lock/upgrade.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ conan lock upgrade
77
:command: conan lock upgrade -h
88

99

10-
The ``conan lock upgrade`` command is able to upgrade ``requires``, ``build_requires``, ``python_requires`` or ``config_requires`` items from an existing lockfile.
10+
The ``conan lock upgrade`` command is able to upgrade ``requires``, ``build_requires``, ``python_requires`` items from an existing lockfile.
1111

1212
For example, if we have the following ``conan.lock``:
1313

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.. _reference_commands_lock_upgrade_config:
2+
3+
conan lock upgrade-config
4+
=========================
5+
6+
7+
.. include:: ../../../common/experimental_warning.inc
8+
9+
.. autocommand::
10+
:command: conan lock upgrade-config -h
11+
12+
13+
The ``conan lock upgrade-config`` command is equivalent to the previous ``conan lock upgrade``, but tailored specifically
14+
to upgrade the ``config-requires`` packages that can be installed with ``conan config install-pkg``.
15+
16+
The upgrade can be done over individual requirements passed on the command line:
17+
18+
.. code-block:: bash
19+
20+
$ conan lock upgrade-config --requires=config/[*] --update-config-requires=config/*
21+
22+
Note that it is important to specify which packages are to be updated with ``--update-config-requires``, because
23+
it is possible that the lockfile contains more than one configuration package.
24+
25+
Also note that the upgrade of the lockfile doesn't change yet or install the configuration.
26+
Until a ``conan config install-pkg`` happens, the active and current configuration will not be updated.
27+
28+
It is also possible use a ``conanconfig.yml`` file as an input to the command:
29+
30+
.. code-block:: bash
31+
32+
$ conan lock upgrade-config . --update-config-requires=config/1.0
33+
34+
35+
.. seealso::
36+
37+
- See the :ref:`conan config install-pkg<reference_commands_conan_config_install_pkg>` command.

0 commit comments

Comments
 (0)