All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] devtool: account for sources in UNPACKDIR
@ 2025-04-24 11:10 Alexander Kanavin
  2025-04-24 11:10 ` [PATCH 2/4] tcf-agent: update SRC_URI to https://gitlab.eclipse.org Alexander Kanavin
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Alexander Kanavin @ 2025-04-24 11:10 UTC (permalink / raw)
  To: openembedded-core; +Cc: Alexander Kanavin

From: Alexander Kanavin <alex@linutronix.de>

There's a couple of assumptions in devtool that sources
are always in a directory under WORKDIR; this is no longer
the case since introduction of UNPACKDIR: some recipes
are starting to use

S = "${UNPACKDIR}/git"

or similar, and so the logic to determine source locations
needs to be tweaked accordingly.

The issue is that oe-core has no concept of 'top level source
path' (S points to where the build is started from, inside that
top level location), and yet devtool needs to know that in order
to move the complete source tree correctly to a workspace (and possibly
other uses).

And so devtool performs convoluted path calculations from WORKDIR and S;
now this has been extended to include UNPACKDIR and became more convoluted
but hopefully it won't get any worse.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 meta/classes/devtool-source.bbclass |  8 ++++++--
 scripts/lib/devtool/ide_sdk.py      |  2 +-
 scripts/lib/devtool/standard.py     | 25 +++++++++++++++++++------
 scripts/lib/devtool/upgrade.py      |  2 +-
 4 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/meta/classes/devtool-source.bbclass b/meta/classes/devtool-source.bbclass
index 9762003ba75..d4e307e886b 100644
--- a/meta/classes/devtool-source.bbclass
+++ b/meta/classes/devtool-source.bbclass
@@ -92,9 +92,13 @@ python devtool_post_unpack() {
             for fname in local_files:
                 f.write('%s\n' % fname)
 
-    if os.path.dirname(srcsubdir) != workdir:
+    if srcsubdir.startswith(unpackdir) and srcsubdir != unpackdir:
+        srcparentdir = unpackdir
+    else:
+        srcparentdir = workdir
+    if os.path.dirname(srcsubdir) != srcparentdir:
         # Handle if S is set to a subdirectory of the source
-        srcsubdir = os.path.join(workdir, os.path.relpath(srcsubdir, workdir).split(os.sep)[0])
+        srcsubdir = os.path.join(srcparentdir, os.path.relpath(srcsubdir, srcparentdir).split(os.sep)[0])
 
     scriptutils.git_convert_standalone_clone(srcsubdir)
 
diff --git a/scripts/lib/devtool/ide_sdk.py b/scripts/lib/devtool/ide_sdk.py
index f8cf65f4a84..e1717bc4ab5 100755
--- a/scripts/lib/devtool/ide_sdk.py
+++ b/scripts/lib/devtool/ide_sdk.py
@@ -334,7 +334,7 @@ class RecipeModified:
         self.srctree = workspace[workspacepn]['srctree']
         # Need to grab this here in case the source is within a subdirectory
         self.real_srctree = get_real_srctree(
-            self.srctree, recipe_d.getVar('S'), recipe_d.getVar('WORKDIR'))
+            self.srctree, recipe_d.getVar('S'), recipe_d.getVar('WORKDIR'), recipe_d.getVar('UNPACKDIR'))
         self.bbappend = workspace[workspacepn]['bbappend']
 
         self.ide_sdk_dir = os.path.join(
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index cdfdba43eef..9a8f990d84a 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -625,7 +625,12 @@ def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, works
                 srcsubdir = f.read()
         except FileNotFoundError as e:
             raise DevtoolError('Something went wrong with source extraction - the devtool-source class was not active or did not function correctly:\n%s' % str(e))
-        srcsubdir_rel = os.path.relpath(srcsubdir, os.path.join(tempdir, 'workdir'))
+        unpackdir = d.getVar('UNPACKDIR')
+        if d.getVar('S').startswith(d.getVar('UNPACKDIR')):
+            srcparentdir = os.path.relpath(d.getVar('UNPACKDIR'), d.getVar('WORKDIR'))
+        else:
+            srcparentdir = ''
+        srcsubdir_rel = os.path.relpath(srcsubdir, os.path.join(tempdir, 'workdir', srcparentdir))
 
         # Check if work-shared is empty, if yes
         # find source and copy to work-shared
@@ -742,14 +747,22 @@ def get_staging_kbranch(srcdir):
         staging_kbranch = "".join(branch.split('\n')[0])
     return staging_kbranch
 
-def get_real_srctree(srctree, s, workdir):
+def get_real_srctree(srctree, s, workdir, unpackdir):
     # Check that recipe isn't using a shared workdir
     s = os.path.abspath(s)
     workdir = os.path.abspath(workdir)
-    if s.startswith(workdir) and s != workdir and os.path.dirname(s) != workdir:
+    unpackdir = os.path.abspath(unpackdir)
+
+    if s.startswith(workdir) and s != workdir:
         # Handle if S is set to a subdirectory of the source
-        srcsubdir = os.path.relpath(s, workdir).split(os.sep, 1)[1]
-        srctree = os.path.join(srctree, srcsubdir)
+        if s.startswith(unpackdir) and s != unpackdir:
+            srcparentdir = unpackdir
+        else:
+            srcparentdir = workdir
+
+        if os.path.dirname(s) != srcparentdir:
+            srcsubdir = os.path.relpath(s, srcparentdir).split(os.sep, 1)[1]
+            srctree = os.path.join(srctree, srcsubdir)
     return srctree
 
 def modify(args, config, basepath, workspace):
@@ -907,7 +920,7 @@ def modify(args, config, basepath, workspace):
 
         # Need to grab this here in case the source is within a subdirectory
         srctreebase = srctree
-        srctree = get_real_srctree(srctree, rd.getVar('S'), rd.getVar('WORKDIR'))
+        srctree = get_real_srctree(srctree, rd.getVar('S'), rd.getVar('WORKDIR'), rd.getVar('UNPACKDIR'))
 
         bb.utils.mkdirhier(os.path.dirname(appendfile))
         with open(appendfile, 'w') as f:
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py
index 0dace1fb240..e584e03e17c 100644
--- a/scripts/lib/devtool/upgrade.py
+++ b/scripts/lib/devtool/upgrade.py
@@ -571,7 +571,7 @@ def upgrade(args, config, basepath, workspace):
         else:
             srctree = standard.get_default_srctree(config, pn)
 
-        srctree_s = standard.get_real_srctree(srctree, rd.getVar('S'), rd.getVar('WORKDIR'))
+        srctree_s = standard.get_real_srctree(srctree, rd.getVar('S'), rd.getVar('WORKDIR'), rd.getVar('UNPACKDIR'))
 
         # try to automatically discover latest version and revision if not provided on command line
         if not args.version and not args.srcrev:
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2025-04-30 10:20 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-24 11:10 [PATCH 1/4] devtool: account for sources in UNPACKDIR Alexander Kanavin
2025-04-24 11:10 ` [PATCH 2/4] tcf-agent: update SRC_URI to https://gitlab.eclipse.org Alexander Kanavin
2025-04-24 11:10 ` [PATCH 3/4] libarchive: correct upstream version check Alexander Kanavin
2025-04-24 11:10 ` [PATCH 4/4] libunwind: use github-releases class to determine latest versions Alexander Kanavin
2025-04-24 11:32 ` [OE-core] [PATCH 1/4] devtool: account for sources in UNPACKDIR Richard Purdie
2025-04-24 11:44   ` Alexander Kanavin
2025-04-24 12:13     ` Richard Purdie
     [not found]     ` <18394019E7982924.8448@lists.openembedded.org>
2025-04-24 12:14       ` Richard Purdie
2025-04-24 12:41         ` Alexander Kanavin
2025-04-24 13:50           ` Richard Purdie
2025-04-24 17:36             ` Adrian Freihofer
2025-04-24 19:49               ` Alexander Kanavin
2025-04-24 19:36             ` Alexander Kanavin
2025-04-24 20:34               ` Richard Purdie
2025-04-25  8:33                 ` Alexander Kanavin
2025-04-25  9:31                   ` Richard Purdie
2025-04-25 17:29                     ` Alexander Kanavin
2025-04-30 10:20                       ` Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.