diff mbox series

[dunfell] externalsrc: git submodule--helper list unsupported

Message ID 20221006092257.67313-1-sven@svenschwermer.de
State Accepted, archived
Commit 6c50d83af0af677c2dff864ac40c580ae446372b
Headers show
Series [dunfell] externalsrc: git submodule--helper list unsupported | expand

Commit Message

Sven Oct. 6, 2022, 9:22 a.m. UTC
From: John Edward Broadbent <jebr@google.com>

Git has removed support for "git submodule--helper list".
https://github.com/git/git/commit/31955475d1c283120d5d84247eb3fd55d9f5fdd9

This change provides an alternate method for gathering the submodules
information.

Tested:
Build recipes with and without submodules

Signed-off-by: Carson Labrado <clabrado@google.com>
Signed-off-by: John Edward Broadbent <jebr@google.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 6d9364e5f3535954f65cbbc694ee7933ac1d664f)
---

Notes:
    With git 2.38.0 externalsrc does not work anymore. I hope, we can
    backport this fix to stable branches as well.

 meta/classes/externalsrc.bbclass | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

Comments

Michael Opdenacker Oct. 6, 2022, 9:30 a.m. UTC | #1
Hi Seven,

On 06.10.22 11:22, Sven via lists.openembedded.org wrote:
> From: John Edward Broadbent <jebr@google.com>
>
> Git has removed support for "git submodule--helper list".
> https://github.com/git/git/commit/31955475d1c283120d5d84247eb3fd55d9f5fdd9
>
> This change provides an alternate method for gathering the submodules
> information.
>
> Tested:
> Build recipes with and without submodules
>
> Signed-off-by: Carson Labrado <clabrado@google.com>
> Signed-off-by: John Edward Broadbent <jebr@google.com>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> (cherry picked from commit 6d9364e5f3535954f65cbbc694ee7933ac1d664f)
> ---
>
> Notes:
>      With git 2.38.0 externalsrc does not work anymore. I hope, we can
>      backport this fix to stable branches as well.
>
>   meta/classes/externalsrc.bbclass | 19 ++++++++++---------
>   1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/meta/classes/externalsrc.bbclass b/meta/classes/externalsrc.bbclass
> index 0e0a3ae89c..291fcf5653 100644
> --- a/meta/classes/externalsrc.bbclass
> +++ b/meta/classes/externalsrc.bbclass


Thanks for the patch, but it doesn't apply.
I guess you should re-apply to the openembedded-core repository first, 
which has different paths.

Thanks again
Michael.
Michael Opdenacker Oct. 6, 2022, 9:31 a.m. UTC | #2
Hi again Sven

On 06.10.22 11:30, Michael Opdenacker via lists.openembedded.org wrote:
> Hi Seven,


Sorry for the typo on your name!
Michael.
Michael Opdenacker Oct. 6, 2022, 9:35 a.m. UTC | #3
On 06.10.22 11:30, Michael Opdenacker via lists.openembedded.org wrote:
>
> Thanks for the patch, but it doesn't apply.
> I guess you should re-apply to the openembedded-core repository first, 
> which has different paths.


My bad, it does apply indeed to the "dunfell" branch.
Apologies for the noise
Michael.
diff mbox series

Patch

diff --git a/meta/classes/externalsrc.bbclass b/meta/classes/externalsrc.bbclass
index 0e0a3ae89c..291fcf5653 100644
--- a/meta/classes/externalsrc.bbclass
+++ b/meta/classes/externalsrc.bbclass
@@ -225,15 +225,16 @@  def srctree_hash_files(d, srcdir=None):
             env['GIT_INDEX_FILE'] = tmp_index.name
             subprocess.check_output(['git', 'add', '-A', '.'], cwd=s_dir, env=env)
             git_sha1 = subprocess.check_output(['git', 'write-tree'], cwd=s_dir, env=env).decode("utf-8")
-            submodule_helper = subprocess.check_output(['git', 'submodule--helper', 'list'], cwd=s_dir, env=env).decode("utf-8")
-            for line in submodule_helper.splitlines():
-                module_dir = os.path.join(s_dir, line.rsplit(maxsplit=1)[1])
-                if os.path.isdir(module_dir):
-                    proc = subprocess.Popen(['git', 'add', '-A', '.'], cwd=module_dir, env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
-                    proc.communicate()
-                    proc = subprocess.Popen(['git', 'write-tree'], cwd=module_dir, env=env, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
-                    stdout, _ = proc.communicate()
-                    git_sha1 += stdout.decode("utf-8")
+            if os.path.exists(".gitmodules"):
+                submodule_helper = subprocess.check_output(["git", "config", "--file", ".gitmodules", "--get-regexp", "path"], cwd=s_dir, env=env).decode("utf-8")
+                for line in submodule_helper.splitlines():
+                    module_dir = os.path.join(s_dir, line.rsplit(maxsplit=1)[1])
+                    if os.path.isdir(module_dir):
+                        proc = subprocess.Popen(['git', 'add', '-A', '.'], cwd=module_dir, env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+                        proc.communicate()
+                        proc = subprocess.Popen(['git', 'write-tree'], cwd=module_dir, env=env, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
+                        stdout, _ = proc.communicate()
+                        git_sha1 += stdout.decode("utf-8")
             sha1 = hashlib.sha1(git_sha1.encode("utf-8")).hexdigest()
         with open(oe_hash_file, 'w') as fobj:
             fobj.write(sha1)