diff mbox series

[1/4] base/bitbake.conf: Introduce UNPACKDIR

Message ID 20240501215643.3386307-1-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit e022d62ba917790af2121da57646271ef17c03fa
Headers show
Series [1/4] base/bitbake.conf: Introduce UNPACKDIR | expand

Commit Message

Richard Purdie May 1, 2024, 9:56 p.m. UTC
Having the unpack directory hardcoded to WORKDIR makes it really hard to
make any changes to the unpack process to try and allow for cleanup for example.

As a first step toward unraveling the intertwined location usages, add a
variable, UNPACKDIR which is where the fetcher is asked to unpack fetched
sources. It defaults to the existing value of WORKDIR at this point.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes-global/base.bbclass | 4 ++--
 meta/conf/bitbake.conf           | 1 +
 meta/lib/oe/reproducible.py      | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

Comments

Marko, Peter May 2, 2024, 6:49 a.m. UTC | #1
I wonder if it we could name it "U" instead of "UNPACKDIR".
It will be mostly used on the same places as all the other short names like S/B/T...

Peter
Richard Purdie May 2, 2024, 7:47 a.m. UTC | #2
On Thu, 2024-05-02 at 06:49 +0000, Marko, Peter wrote:
> I wonder if it we could name it "U" instead of "UNPACKDIR".
> It will be mostly used on the same places as all the other short
> names like S/B/T...

Personally, I do like the idea but I'm not sure it aids
readability/discoverability of the code.

I've assumed people would shoot down the idea as the short vars do have
a relatively negative following but if the majority were in favour...

We could force an audit of all WORKDIR references by changing it to W
too :) (I'm only half joking).

Cheers,

Richard
Alexander Kanavin May 2, 2024, 9:33 a.m. UTC | #3
On Thu, 2 May 2024 at 09:48, Richard Purdie via lists.openembedded.org
<richard.purdie=linuxfoundation.org@lists.openembedded.org> wrote:
> Personally, I do like the idea but I'm not sure it aids
> readability/discoverability of the code.
>
> I've assumed people would shoot down the idea as the short vars do have
> a relatively negative following but if the majority were in favour...
>
> We could force an audit of all WORKDIR references by changing it to W
> too :) (I'm only half joking).

I think one-letter variables belong only in counters used by nested
for loops or code doing pure math and everywhere else one should take
the trouble to spell them out. It's a relic of archaic computers and
mathematicians programming them.

Alex
diff mbox series

Patch

diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass
index 0999b42daaa..066f3848f7c 100644
--- a/meta/classes-global/base.bbclass
+++ b/meta/classes-global/base.bbclass
@@ -153,7 +153,7 @@  python base_do_fetch() {
 }
 
 addtask unpack after do_fetch
-do_unpack[dirs] = "${WORKDIR}"
+do_unpack[dirs] = "${UNPACKDIR}"
 
 do_unpack[cleandirs] = "${@d.getVar('S') if os.path.normpath(d.getVar('S')) != os.path.normpath(d.getVar('WORKDIR')) else os.path.join('${S}', 'patches')}"
 
@@ -164,7 +164,7 @@  python base_do_unpack() {
 
     try:
         fetcher = bb.fetch2.Fetch(src_uri, d)
-        fetcher.unpack(d.getVar('WORKDIR'))
+        fetcher.unpack(d.getVar('UNPACKDIR'))
     except bb.fetch2.BBFetchException as e:
         bb.fatal("Bitbake Fetcher Error: " + repr(e))
 }
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index ba8bd5f975f..b2c500d8739 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -405,6 +405,7 @@  STAMP = "${STAMPS_DIR}/${MULTIMACH_TARGET_SYS}/${PN}/${PV}"
 STAMPCLEAN = "${STAMPS_DIR}/${MULTIMACH_TARGET_SYS}/${PN}/*-*"
 BASE_WORKDIR ?= "${TMPDIR}/work"
 WORKDIR = "${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}/${PN}/${PV}"
+UNPACKDIR ??= "${WORKDIR}"
 T = "${WORKDIR}/temp"
 D = "${WORKDIR}/image"
 S = "${WORKDIR}/${BP}"
diff --git a/meta/lib/oe/reproducible.py b/meta/lib/oe/reproducible.py
index 448befce332..a9f717159e3 100644
--- a/meta/lib/oe/reproducible.py
+++ b/meta/lib/oe/reproducible.py
@@ -120,7 +120,7 @@  def get_source_date_epoch_from_git(d, sourcedir):
     return int(p.stdout.decode('utf-8'))
 
 def get_source_date_epoch_from_youngest_file(d, sourcedir):
-    if sourcedir == d.getVar('WORKDIR'):
+    if sourcedir == d.getVar('UNPACKDIR'):
        # These sources are almost certainly not from a tarball
        return None