[kirkstone][master][PATCH] externalsrc: fix host git >=2.38.1


Adrian Freihofer
 

This is a fix for 0533edac277080e1bd130c14df0cbac61ba01a0c.

If the externalsrc directory is a git repository without submodules
git config --file .gitmodules --get-regexp path
exits with 1. This leads to a subprocess.CalledProcessError exception:

bb.data_smart.ExpansionError: Failure expanding variable do_compile[file-checksums],
expression was ${@srctree_hash_files(d)} which triggered exception
CalledProcessError: Command '['git', 'config', '--file', '.gitmodules',
'--get-regexp', 'path']' returned non-zero exit status 1.
The variable dependency chain for the failure is: do_compile[file-checksums]

Signed-off-by: Adrian Freihofer <adrian.freihofer@...>
---
meta/classes/externalsrc.bbclass | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/meta/classes/externalsrc.bbclass b/meta/classes/externalsrc.bbclass
index 75fb91bcb0..2f2e00aab4 100644
--- a/meta/classes/externalsrc.bbclass
+++ b/meta/classes/externalsrc.bbclass
@@ -231,15 +231,18 @@ def srctree_hash_files(d, srcdir=None):
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")
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")
+ try:
+ 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")
+ except subprocess.CalledProcessError:
+ pass
sha1 = hashlib.sha1(git_sha1.encode("utf-8")).hexdigest()
with open(oe_hash_file, 'w') as fobj:
fobj.write(sha1)
--
2.38.1


Adrian Freihofer
 

Hi

As of today, Fedora 36 is considered a stable host distribution.
However, without this patch externalsrc or devtool modify is unusable
on Fedora 36, at least for me and one of my colleagues.
So I thought, will ask about the status of this patch.

Tnank you and regards,
Adrian

On Thu, 2022-11-17 at 22:39 +0100, Adrian Freihofer via
lists.openembedded.org wrote:
This is a fix for 0533edac277080e1bd130c14df0cbac61ba01a0c.

If the externalsrc directory is a git repository without submodules
  git config --file .gitmodules --get-regexp path
exits with 1. This leads to a subprocess.CalledProcessError
exception:

bb.data_smart.ExpansionError: Failure expanding variable
do_compile[file-checksums],
  expression was ${@srctree_hash_files(d)} which triggered exception
  CalledProcessError: Command '['git', 'config', '--file',
'.gitmodules',
  '--get-regexp', 'path']' returned non-zero exit status 1.
The variable dependency chain for the failure is: do_compile[file-
checksums]

Signed-off-by: Adrian Freihofer <adrian.freihofer@...>
---
 meta/classes/externalsrc.bbclass | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/meta/classes/externalsrc.bbclass
b/meta/classes/externalsrc.bbclass
index 75fb91bcb0..2f2e00aab4 100644
--- a/meta/classes/externalsrc.bbclass
+++ b/meta/classes/externalsrc.bbclass
@@ -231,15 +231,18 @@ def srctree_hash_files(d, srcdir=None):
             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")
             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")
+                try:
+                    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")
+                except subprocess.CalledProcessError:
+                    pass
             sha1 = hashlib.sha1(git_sha1.encode("utf-
8")).hexdigest()
         with open(oe_hash_file, 'w') as fobj:
             fobj.write(sha1)



Adrian Freihofer
 

Please ignore this patch. The fix sent by Peter
https://lists.openembedded.org/g/openembedded-core/topic/95382667#174061
is better.

On Tue, 2022-11-29 at 17:26 +0000, Adrian Freihofer wrote:
Hi

As of today, Fedora 36 is considered a stable host distribution.
However, without this patch externalsrc or devtool modify is unusable
on Fedora 36, at least for me and one of my colleagues.
So I thought, will ask about the status of this patch.

Tnank you and regards,
Adrian

On Thu, 2022-11-17 at 22:39 +0100, Adrian Freihofer via
lists.openembedded.org wrote:
This is a fix for 0533edac277080e1bd130c14df0cbac61ba01a0c.

If the externalsrc directory is a git repository without submodules
  git config --file .gitmodules --get-regexp path
exits with 1. This leads to a subprocess.CalledProcessError
exception:

bb.data_smart.ExpansionError: Failure expanding variable
do_compile[file-checksums],
  expression was ${@srctree_hash_files(d)} which triggered
exception
  CalledProcessError: Command '['git', 'config', '--file',
'.gitmodules',
  '--get-regexp', 'path']' returned non-zero exit status 1.
The variable dependency chain for the failure is: do_compile[file-
checksums]

Signed-off-by: Adrian Freihofer <adrian.freihofer@...>
---
 meta/classes/externalsrc.bbclass | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/meta/classes/externalsrc.bbclass
b/meta/classes/externalsrc.bbclass
index 75fb91bcb0..2f2e00aab4 100644
--- a/meta/classes/externalsrc.bbclass
+++ b/meta/classes/externalsrc.bbclass
@@ -231,15 +231,18 @@ def srctree_hash_files(d, srcdir=None):
             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")
             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")
+                try:
+                    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")
+                except subprocess.CalledProcessError:
+                    pass
             sha1 = hashlib.sha1(git_sha1.encode("utf-
8")).hexdigest()
         with open(oe_hash_file, 'w') as fobj:
             fobj.write(sha1)