From 255d6c76134d314f74a92f6f5882ca53bcb6630d Mon Sep 17 00:00:00 2001 From: memsharded Date: Tue, 20 Jun 2023 12:30:37 +0200 Subject: [PATCH 1/2] remove pkg-lists --- examples/commands/pkglists.rst | 33 +++++++++++++++++++++++++++++++++ reference/commands/download.rst | 3 +++ reference/commands/remove.rst | 21 +++++++++++++++------ reference/commands/upload.rst | 3 +++ 4 files changed, 54 insertions(+), 6 deletions(-) diff --git a/examples/commands/pkglists.rst b/examples/commands/pkglists.rst index c75125c8003b..474e2f8d67f8 100644 --- a/examples/commands/pkglists.rst +++ b/examples/commands/pkglists.rst @@ -173,4 +173,37 @@ We can compute a package list from this file, and then upload those artifacts to $ conan upload --list=pkglist.json -r=myremote -c +Removing packages lists +----------------------- + +It is also possible to first ``conan list`` and create a list of things to remove, and then remove them: + +.. code-block:: bash + + # Removes everything from the cache + $ conan list *#* --format=json > pkglist.json + $ conan remove --list=pkglist.json -c + +Note that in this case, the default patterns are different in ``list`` and ``remove``, because of the destructive nature of ``conan remove``: + +- When a recipe is passed to ``remove`` like ``conan remove zlib/1.2.13`` will remove the recipe of ``zlib/1.2.13`` and all of its binaries, because the binaries cannot live without the recipe. +- When a ``package_id`` is passed, like ``conan remove zlib/1.2.13:package_id``, then that specific ``package_id`` will be removed, but the recipe will not + +Then the pattern to remove everything will be different if we call directly ``conan remove`` or if we call first ``conan list``, for example: + +.. code-block:: bash + + # Removes everything from the cache + $ conan remove * + # OR via list, we need to explicitly include all revisions + $ conan list *#* --format=json > pkglist.json + $ conan remove --list=pkglist.json -c + + # Removes only the binaries from the cache (leave recipes) + $ conan remove *:* + # OR via list, we need to explicitly include all revisions + $ conan list *#*:* --format=json > pkglist.json + $ conan remove --list=pkglist.json -c + + For more information see the :ref:`Reference commands section` \ No newline at end of file diff --git a/reference/commands/download.rst b/reference/commands/download.rst index 58b39cf70f89..4c4105f85e46 100644 --- a/reference/commands/download.rst +++ b/reference/commands/download.rst @@ -86,3 +86,6 @@ If you just want to download the packages belonging to a specific setting, use t .. code-block:: bash $ conan download "zlib/1.2.13#*" -r foo --package-query="os=Linux and arch=x86" + + +If the ``--format=json`` formatter is specified, the result will be a "PackageList", compatible with other Conan commands, for example the ``conan upload`` command, so it is possible to concatenate a ``download + upload``, using the generated json file. See the :ref:`Packages Lists examples`. diff --git a/reference/commands/remove.rst b/reference/commands/remove.rst index 9f215f92c1b7..47e9188aed94 100644 --- a/reference/commands/remove.rst +++ b/reference/commands/remove.rst @@ -4,9 +4,9 @@ conan remove .. code-block:: text $ conan remove -h - usage: conan remove [-h] [-v [V]] [-c] [-p PACKAGE_QUERY] - [-r REMOTE] - reference + usage: conan remove [-h] [-v [V]] [-f FORMAT] [-c] [-p PACKAGE_QUERY] + [-r REMOTE] [-l LIST] + [pattern] Remove recipes or packages from local cache or a remote. @@ -17,8 +17,10 @@ conan remove - If a package reference is specified, it will remove only the package. positional arguments: - reference Recipe reference or package reference, can contain * - aswildcard at any reference field. e.g: lib/* + pattern A pattern in the form + 'pkg/version#revision:package_id#revision', e.g: + zlib/1.2.13:* means all binaries for zlib/1.2.13. If + revision is not specified, it is assumed latest one. optional arguments: -h, --help show this help message and exit @@ -26,13 +28,15 @@ conan remove verbose to more verbose: -vquiet, -verror, -vwarning, -vnotice, -vstatus, -v or -vverbose, -vv or -vdebug, -vvv or -vtrace + -f FORMAT, --format FORMAT + Select the output format: json -c, --confirm Remove without requesting a confirmation -p PACKAGE_QUERY, --package-query PACKAGE_QUERY Remove all packages (empty) or provide a query: os=Windows AND (arch=x86 OR compiler=gcc) -r REMOTE, --remote REMOTE Will remove from the specified remote - + -l LIST, --list LIST Package list file The ``conan remove`` command removes recipes and packages from the local cache or from a specified remote. Depending on the patterns specified as argument, it is possible to @@ -40,6 +44,11 @@ remove a complete package, or just remove the binaries, leaving still the recipe available. You can also use the keyword ``!latest`` in the revision part of the pattern to avoid removing the latest recipe or package revision of a certain Conan package. +It has 2 possible and mutually exclusive inputs: + +- The ``conan remove `` pattern-based matching of recipes. +- The ``conan remove --list=`` that will remove the artifacts specified in the ``pkglist`` json file + There are other commands like :command:`conan list` (see the patterns documentation there :ref:`reference_commands_list`), :command:`conan upload` and :command:`conan download`, that take the same patterns. diff --git a/reference/commands/upload.rst b/reference/commands/upload.rst index f86317f83c67..fb099b546e13 100644 --- a/reference/commands/upload.rst +++ b/reference/commands/upload.rst @@ -58,6 +58,9 @@ It has 2 possible and mutually exclusive inputs: - The ``conan upload --list=`` that will upload the artifacts specified in the ``pkglist`` json file +If the ``--format=json`` formatter is specified, the result will be a "PackageList", compatible with other Conan commands, for example the ``conan remove`` command, so it is possible to concatenate different commands using the generated json file. See the :ref:`Packages Lists examples`. + + Read more --------- From f792de25aabf15ae9180108b39a17ac90bd20e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Rinc=C3=B3n=20Blanco?= Date: Tue, 20 Jun 2023 16:30:31 +0200 Subject: [PATCH 2/2] Update examples/commands/pkglists.rst --- examples/commands/pkglists.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/commands/pkglists.rst b/examples/commands/pkglists.rst index 474e2f8d67f8..c817fba2054e 100644 --- a/examples/commands/pkglists.rst +++ b/examples/commands/pkglists.rst @@ -186,7 +186,7 @@ It is also possible to first ``conan list`` and create a list of things to remov Note that in this case, the default patterns are different in ``list`` and ``remove``, because of the destructive nature of ``conan remove``: -- When a recipe is passed to ``remove`` like ``conan remove zlib/1.2.13`` will remove the recipe of ``zlib/1.2.13`` and all of its binaries, because the binaries cannot live without the recipe. +- When a recipe is passed to ``remove`` like ``conan remove zlib/1.2.13``, it will remove the recipe of ``zlib/1.2.13`` and all of its binaries, because the binaries cannot live without the recipe. - When a ``package_id`` is passed, like ``conan remove zlib/1.2.13:package_id``, then that specific ``package_id`` will be removed, but the recipe will not Then the pattern to remove everything will be different if we call directly ``conan remove`` or if we call first ``conan list``, for example: