When EXTERNALSRC contains multiple nested git repositories (from
multiple SRC_URI git entries with different destsuffix values),
find_git_repositories() walks into sub-repos and
get_source_date_epoch_from_git() subsequently fails with exit code 128
when running 'git log -1' inside them.

Two fixes:
- Stop os.walk recursion when a .git entry is found (dirs[:] = []) to
  avoid descending into nested repos.
- Change 'git log -1' from check=True to check=False with explicit
  error handling, so a failing nested repo is skipped gracefully
  instead of raising CalledProcessError and aborting do_unpack.

Signed-off-by: Jamin Lin <[email protected]>
---
 meta/lib/oe/reproducible.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/meta/lib/oe/reproducible.py b/meta/lib/oe/reproducible.py
index a80376010a..6bb25da55a 100644
--- a/meta/lib/oe/reproducible.py
+++ b/meta/lib/oe/reproducible.py
@@ -82,6 +82,7 @@ def find_git_repositories(d, sourcedir):
         for root, dirs, files in os.walk(mainpath, topdown=True):
             if '.git' in dirs or '.git' in files:
                 git_repositories.append(root)
+                dirs[:] = []  # don't recurse into nested git repos (multiple 
SRC_URI destsuffix)
 
     if not git_repositories:
         bb.warn('Failed to find any git repositories in UNPACKDIR or S')
@@ -105,7 +106,10 @@ def get_source_date_epoch_from_git(d, sourcedir):
 
         bb.debug(1, "git repository: %s" % repo_path)
         p = subprocess.run(['git', '-C', repo_path, 'log', '-1', 
'--pretty=%ct'],
-                           check=True, stdout=subprocess.PIPE)
+                           check=False, stdout=subprocess.PIPE, 
stderr=subprocess.STDOUT)
+        if p.returncode != 0:
+            bb.debug(1, "git log failed for %s (exit %d): %s" % (repo_path, 
p.returncode, p.stdout.decode('utf-8')))
+            continue
         source_dates.append(int(p.stdout.decode('utf-8')))
 
     if source_dates:
-- 
2.43.0
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#237075): 
https://lists.openembedded.org/g/openembedded-core/message/237075
Mute This Topic: https://lists.openembedded.org/mt/119327123/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to