diff mbox series

[v1,2/2] reproducible: Handle nested git repos in find_git_repositories

Message ID 20260515093615.126849-3-jamin_lin@aspeedtech.com
State Under Review
Headers show
Series oe: Fix build failures with multiple git SRC_URI entries | expand

Commit Message

Jamin Lin May 15, 2026, 9:36 a.m. UTC
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 <jamin_lin@aspeedtech.com>
---
 meta/lib/oe/reproducible.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

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: