Skip to contentSkip to conversation

Discourage using do_cleansstate and do_cleanall

PATCH Applied Luca Ceresoli 3 participants 5 messages Feb 28, 2024 – Feb 29, 2024

lore
Share & tools
lore
#0 lore raw

v3 cover Discourage using do_cleansstate and do_cleanall

do_cleansstate and do_cleanall can generate build failures. Document this and discourage using them.

---
Changes in v3:
- fix typos
- add missing '-c'
- mention DL_DIR and SSTATE_DIR
- reword sentence using the version proposed by Quentin
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- improved the do_cleanall patch to show it applies also without a
shared DL_DIR
- add new patch for do_cleansstate
- Link to v1: https://lore.kernel.org/yocto-docs/[email protected]

---
Luca Ceresoli (2):
ref-manual: tasks: do_cleanall: recommend using '-f' instead
ref-manual: tasks: do_cleansstate: recommend using '-f' instead for a shared sstate

 documentation/ref-manual/tasks.rst | 38 +++++++++++++++++++++++++++++++++++---
 1 file changed, 35 insertions(+), 3 deletions(-)

---
base-commit: 6571eb02cbd5c2b96df0f279f25b63255ab7eac4
change-id: 20240227-clean-tasks-notes-56899a5abdf6

Best regards,

Signature · 1 line
Luca Ceresoli <[email protected]>
#1 lore raw

PATCH v3 1/2 ref-manual: tasks: do_cleanall: recommend using '-f' instead

do_cleanall can produce failures when used in legitimate cases, such as with recipe variants (foo and foo-native) or a shared DL_DIR. This is why it is forbidden when writing tests that will run on the autobuilders
(https://docs.yoctoproject.org/test-manual/intro.html?highlight=cleanall#considerations-when-writing-tests).

Reword the documentation to clearly discourage, provide a safe alternative (bitbake -f -c fetch), and the rationale with an example.

---
 documentation/ref-manual/tasks.rst | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)
documentation/ref-manual/tasks.rst +23 -3
index 0db960b22f80..7a0915c6e57a 100644
@@ -470,9 +470,29 @@ You can run this task using BitBake as follows::
 
    $ bitbake -c cleanall recipe
 
-Typically, you would not normally use the :ref:`ref-tasks-cleanall` task. Do so only
-if you want to start fresh with the :ref:`ref-tasks-fetch`
-task.
+You should never use the :ref:`ref-tasks-cleanall` task in a normal
+scenario. If you want to start fresh with the :ref:`ref-tasks-fetch` task,
+use instead::
+
+  $ bitbake -f -c fetch recipe
+
+.. note::
+
+   The reason to prefer ``bitbake -f -c fetch`` is that the
+   :ref:`ref-tasks-cleanall` task would break in some cases, such as::
+
+      $ bitbake -c fetch    recipe
+      $ bitbake -c cleanall recipe-native
+      $ bitbake -c unpack   recipe
+
+   because after step 1 there is a stamp file for the
+   :ref:`ref-tasks-fetch` task of ``recipe``, and it won't be removed at
+   step 2 because step 2 uses a different work directory. So the unpack task
+   at step 3 will try to extract the downloaded archive and fail as it has
+   been deleted in step 2.
+
+   Note that this also applies to bitbake from concurrent processes when a
+   shared download directory (:term:`DL_DIR`) is setup.
 
 .. _ref-tasks-cleansstate:
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH v3 2/2 ref-manual: tasks: do_cleansstate: recommend using '-f' instead for a shared sstate

In reply to Luca Ceresoli

do_cleansstat can produce build errors when using a shared sstate cache.

Add a note to clearly discourage, provide a safe alternative (bitbake -f), and the rationale.

---
 documentation/ref-manual/tasks.rst | 12 ++++++++++++
 1 file changed, 12 insertions(+)
documentation/ref-manual/tasks.rst +12 -0
index 7a0915c6e57a..79469bc37221 100644
@@ -514,6 +514,18 @@ When you run the :ref:`ref-tasks-cleansstate` task, the OpenEmbedded build syste
 no longer uses any sstate. Consequently, building the recipe from
 scratch is guaranteed.
 
+.. note::
+
+   Using :ref:`ref-tasks-cleansstate` with a shared :term:`SSTATE_DIR` is
+   not recommended because it could trigger an error during the build of a
+   separate bitbake instance. This is because the builds check sstate "up
+   front" but download the files later, so it if is deleted in the
+   meantime, it will cause an error but not a total failure as it will
+   rebuild it.
+
+   The reliable and preferred way to force a new build is to use ``bitbake
+   -f`` instead.
+
 .. note::
 
    The :ref:`ref-tasks-cleansstate` task cannot remove sstate from a remote sstate
Signature · 1 line
2.34.1
Reviewed-by on v3 2/2
#3 lore raw

Re: [PATCH v3 2/2] ref-manual: tasks: do_cleansstate: recommend using '-f' instead for a shared sstate

Hi Luca,

Quoted 6 lines · Luca Ceresoli

do_cleansstat can produce build errors when using a shared sstate cache.

Add a note to clearly discourage, provide a safe alternative (bitbake -f), and the rationale.

In poky:

$ git log --oneline --grep "Proposed-by" | wc -l
2
$ git log --oneline --grep "Suggested-by" | wc -l
46

https://git-scm.com/docs/SubmittingPatches#sign-off also only mentions Suggested-by as a trailer.

Not really important, it just surprised me to see this trailer for the first time :)

For the whole series,

Thanks,
Quentin

#4 lore raw

Re: [docs] [PATCH v3 2/2] ref-manual: tasks: do_cleansstate: recommend using '-f' instead for a shared sstate

Luca, Quentin,

Many thanks for the patches and reviews!

Quoted 12 lines · Quentin Schulz via lists.yoctoproject.org

Hi Luca,

Quoted 7 lines · Luca Ceresoli

do_cleansstat can produce build errors when using a shared sstate cache.

Add a note to clearly discourage, provide a safe alternative (bitbake -f),
and the rationale.

In poky:

Quoted 8 lines
$ git log --oneline --grep "Proposed-by" | wc -l
2
$ git log --oneline --grep "Suggested-by" | wc -l
46

https://git-scm.com/docs/SubmittingPatches#sign-off also only mentions Suggested-by as a trailer.

Not really important, it just surprised me to see this trailer for the first time :)

I fixed this in the commit.

Quoted 4 lines

For the whole series,

Merged into "master-next"
Thanks again.
Michael.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com