diff mbox series

[01/10] devtool: process local files only for the main branch

Message ID 20221229160110.255775-1-alex@linutronix.de
State Accepted, archived
Commit 3a8654b860fa98f94e80c3c3fff359ffed14bbe7
Headers show
Series [01/10] devtool: process local files only for the main branch | expand

Commit Message

Alexander Kanavin Dec. 29, 2022, 4:01 p.m. UTC
devtool modify/upgrade are not currently equipped to handle conditional local files
in SRC_URI, and provide only the main no-override set in a workspace under
source/component/oe-local-files/ (this is done via meta/classes/devtool-source.bbclass).

On the other hand, updating the changes from workspace into a recipe
is run iteratively against all overrides; this works for patches (as they
all are directed into their own override branches in the workspace
git source tree), but breaks down when trying to match local files
in a workspace against local files in overridden SRC_URI lists, resulting in
bad recipe breakage.

Implementing multiple sets of local files is significant work; let's for now
simply not touch local files in recipes except when on the no-override variant.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 scripts/lib/devtool/standard.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Richard Purdie Dec. 29, 2022, 5:18 p.m. UTC | #1
On Thu, 2022-12-29 at 17:01 +0100, Alexander Kanavin wrote:
> devtool modify/upgrade are not currently equipped to handle conditional local files
> in SRC_URI, and provide only the main no-override set in a workspace under
> source/component/oe-local-files/ (this is done via meta/classes/devtool-source.bbclass).
> 
> On the other hand, updating the changes from workspace into a recipe
> is run iteratively against all overrides; this works for patches (as they
> all are directed into their own override branches in the workspace
> git source tree), but breaks down when trying to match local files
> in a workspace against local files in overridden SRC_URI lists, resulting in
> bad recipe breakage.
> 
> Implementing multiple sets of local files is significant work; let's for now
> simply not touch local files in recipes except when on the no-override variant.
> 
> Signed-off-by: Alexander Kanavin <alex@linutronix.de>
> ---
>  scripts/lib/devtool/standard.py | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
> index f46ce34ad1..f3349f98e9 100644
> --- a/scripts/lib/devtool/standard.py
> +++ b/scripts/lib/devtool/standard.py
> @@ -1409,6 +1409,18 @@ def _export_local_files(srctree, rd, destdir, srctreebase):
>      updated = OrderedDict()
>      added = OrderedDict()
>      removed = OrderedDict()
> +
> +    # Get current branch and return early with empty lists
> +    # if on one of the override branches
> +    # (local files are provided only for the main branch and processing
> +    # them against lists from recipe overrides will result in mismatches
> +    # and broken modifications to recipes).
> +    stdout, _ = bb.process.run('git rev-parse --abbrev-ref HEAD',
> +                               cwd=srctree)
> +    branchname = stdout.rstrip()
> +    if branchname.startswith(override_branch_prefix):
> +        return (updated, added, removed)
> +
>      local_files_dir = os.path.join(srctreebase, 'oe-local-files')
>      git_files = _git_ls_tree(srctree)
>      if 'oe-local-files' in git_files:

Is there something we should be adding to the devtool tests to cover
this issue?

Cheers,

Richard
Alexander Kanavin Dec. 29, 2022, 8:49 p.m. UTC | #2
On Thu, 29 Dec 2022 at 18:18, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:

> Is there something we should be adding to the devtool tests to cover
> this issue?

There is, yes. There's a set of tests in
meta/lib/oeqa/selftest/cases/devtool.py which deal specifically with
handling local files:
test_devtool_update_recipe_local_files
test_devtool_update_recipe_local_files_2
test_devtool_update_recipe_local_files_3

I'll modify them so that they fail without the patch and pass with it.

Alex
diff mbox series

Patch

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index f46ce34ad1..f3349f98e9 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -1409,6 +1409,18 @@  def _export_local_files(srctree, rd, destdir, srctreebase):
     updated = OrderedDict()
     added = OrderedDict()
     removed = OrderedDict()
+
+    # Get current branch and return early with empty lists
+    # if on one of the override branches
+    # (local files are provided only for the main branch and processing
+    # them against lists from recipe overrides will result in mismatches
+    # and broken modifications to recipes).
+    stdout, _ = bb.process.run('git rev-parse --abbrev-ref HEAD',
+                               cwd=srctree)
+    branchname = stdout.rstrip()
+    if branchname.startswith(override_branch_prefix):
+        return (updated, added, removed)
+
     local_files_dir = os.path.join(srctreebase, 'oe-local-files')
     git_files = _git_ls_tree(srctree)
     if 'oe-local-files' in git_files: