Yocto Project Documentation
 help / color / mirror / Atom feed
From: "Antonin Godard" <antonin.godard@bootlin.com>
To: "Quentin Schulz" <quentin.schulz@cherry.de>,
	<docs@lists.yoctoproject.org>
Cc: "Thomas Petazzoni" <thomas.petazzoni@bootlin.com>
Subject: Re: [docs] [PATCH 6/6] ref-manual/variables: improve the UNPACKDIR documentation
Date: Mon, 24 Feb 2025 11:53:37 +0100	[thread overview]
Message-ID: <D80MBXN4BSZF.2OK87WROBFBJP@bootlin.com> (raw)
In-Reply-To: <f4db28cd-1701-49ba-8c90-938128fe61df@cherry.de>

Hi Quentin,

On Thu Feb 20, 2025 at 5:41 PM CET, Quentin Schulz wrote:
> Hi Antonin,
>
> On 2/18/25 10:12 AM, Antonin Godard via lists.yoctoproject.org wrote:
>> It was clear why UNPACKDIR was introduced at first, and what is the
>> recommended way of setting S and UNPACKDIR for a clean separation of the
>> source code and WORKDIR. Add documentation for this in the reference
>> manual.
>> 
>> Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
>> ---
>>   documentation/ref-manual/variables.rst | 39 +++++++++++++++++++++++++++++++++-
>>   1 file changed, 38 insertions(+), 1 deletion(-)
>> 
>> diff --git a/documentation/ref-manual/variables.rst b/documentation/ref-manual/variables.rst
>> index adbef69d8f39d33be87c5db6688a807156540410..d970fc21f69fe35830a9d6b5a28da7cb257c0709 100644
>> --- a/documentation/ref-manual/variables.rst
>> +++ b/documentation/ref-manual/variables.rst
>> @@ -10035,9 +10035,46 @@ system and gives an overview of their function and contents.
>>   
>>      :term:`UNPACKDIR`
>>         This variable, used by the :ref:`ref-classes-base` class,
>> -      specifies where fetches sources should be unpacked by the
>> +      specifies where fetched sources should be unpacked by the
>>         :ref:`ref-tasks-unpack` task.
>>   
>> +      Although the default value of this directory is
>> +      ``${WORKDIR}/sources-unpack``, the recommended way of setting
>> +      :term:`UNPACKDIR` and :term:`S` is::
>> +
>> +         S = "${WORKDIR}/sources"
>> +         UNPACKDIR = "${S}"
>> +
>
> Mmmm I think this is an issue, because we then show a non-recommended 
> configuration in the SVG in the previous patches where UNPACKDIR != S.

I'd rather show the default definitions in the figures, because there's no
guarantee that a recipe will define UNPACKDIR and S that way.

It also feels weird to me that a recommended approach is not the default, but it
is probably related to backward compatiblity, that would be my guess.

>> +      This allows the source code to be safely unpacked and patched in a
>> +      separate directory.
>> +
>
> I think I know where you want to go with this, but the first time I read 
> this I didn't understand it. UNPACKDIR = S in the example above, why 
> does this say the source code is unpacked and patched (implying two 
> steps/stages) in a separate directory then?

I wanted to say that the code is unpacked and patched in the same directory, but
separate from the WORKDIR. I should probably rephrase or remove this sentence to
avoid adding confusion.

> I think this is because we used to put everything from the fetcher into
> WORKDIR and there were unexpected leftovers between builds and UNPACKDIR 
> now is a separate directory for the fetcher to put everything it does 
> in, instead of WORKDIR?

Yes, I think that's it.

> I'm not sure we need to document how messed up it was in the past rather 
> just what this does now?

So I guess we can go with the sentence removal. However I think we'd probably
want to keep the recommended assignment.

>> +      .. note::
>> +
>> +         In some cases, the :term:`UNPACKDIR` directory only holds the sources
>> +         temporarily. When the first directory after :term:`WORKDIR` in the
>> +         :term:`S` variable is matched in :term:`UNPACKDIR`, the directory
>> +         in :term:`UNPACKDIR` is moved to the :term:`WORKDIR` directory.
>> +
>> +         For example, let's represent the :term:`UNPACKDIR` directory
>> +         for the ``foobar`` recipe after extraction as follows::
>> +
>> +            ${WORKDIR}/sources-unpack/foobar-1.0.0/...
>> +
>> +         And the variable :term:`S` for this recipe defined as::
>> +
>> +            S = "${WORKDIR}/${BP}"
>> +
>> +         Where :term:`BP` expands to ``foobar-1.0.0``.
>> +
>> +         Since the first directory of :term:`S` after :term:`WORKDIR`
>> +         (``foobar-1.0.0``) matches the directory ``foobar-1.0.0`` under
>> +         ``sources-unpack``, the latter is moved to the :term:`WORKDIR`
>> +         directory. The final location of the source code will then be
>> +         ``${WORKDIR}/foobar-1.0.0``.
>> +
>> +         This behavior was added for compatibility for recipes that do not set
>> +         the :term:`UNPACKDIR` and :term:`S` variable in the recommended way.
>> +
>
> I've read this 5 times now, it may be too late for my brain today but I 
> am not sure I got it :)
>
> Let me try to reword it just to make sure I understood/got it right?
>
> If UNPACKDIR differs from S, but the name of the directory (dirA) where 
> sources are unpacked in UNPACKDIR matches the basename of the directory 
> used for S, then the content of UNPACKDIR/dirA is moved into S?

That's it. And it is a pain to describe textually. I'd take any recommendations
for improving it.

> If that's right, what really happens? Is UNPACKDIR variable modified to 
> point to S once the move is done? When is this happening?

No, UNPACKDIR isn't modified. This move is repeated at the end of the do_unpack
task, each time. See:
https://git.openembedded.org/openembedded-core/tree/meta/classes-global/base.bbclass#n158

I may consider removing that note entirely depending on how useful it is to
document a backwards-compatibility behavior.

Antonin

-- 
Antonin Godard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


      reply	other threads:[~2025-02-24 10:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-18  9:11 [PATCH 0/6] Updates around the UNPACKDIR variable Antonin Godard
2025-02-18  9:11 ` [PATCH 1/6] overview-manual: convert source-fetching.png to svg and fix UNPACKDIR Antonin Godard
2025-02-20 16:03   ` [docs] " Quentin Schulz
2025-02-18  9:11 ` [PATCH 2/6] overview-manual: convert patching.png to svg Antonin Godard
2025-02-20 16:05   ` [docs] " Quentin Schulz
2025-02-18  9:11 ` [PATCH 3/6] overview-manual: convert configuration-compile-autoreconf.png " Antonin Godard
2025-02-20 16:13   ` [docs] " Quentin Schulz
2025-02-24  9:19     ` Antonin Godard
2025-02-24 10:26       ` Quentin Schulz
2025-02-24 10:37         ` Antonin Godard
2025-02-18  9:11 ` [PATCH 4/6] overview-manual: convert analysis-for-package-splitting.png " Antonin Godard
2025-02-20 16:18   ` [docs] " Quentin Schulz
2025-02-24 10:44     ` Antonin Godard
2025-02-24 10:48       ` Quentin Schulz
2025-02-18  9:12 ` [PATCH 5/6] overview-manual: add UNPACKDIR in the directory description Antonin Godard
2025-02-20 16:22   ` [docs] " Quentin Schulz
2025-02-18  9:12 ` [PATCH 6/6] ref-manual/variables: improve the UNPACKDIR documentation Antonin Godard
2025-02-20 16:41   ` [docs] " Quentin Schulz
2025-02-24 10:53     ` Antonin Godard [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D80MBXN4BSZF.2OK87WROBFBJP@bootlin.com \
    --to=antonin.godard@bootlin.com \
    --cc=docs@lists.yoctoproject.org \
    --cc=quentin.schulz@cherry.de \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox