On Fri, 2026-05-15 at 09:36 +0000, Jamin Lin wrote:
> 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')))

This causes the repository to be silently (in most cases, since
bb.debug() output is not usually printed) dropped from the source_dates
array. Does this invalidate the returned source date epoch?

We may want a warning here instead of a debug print.

Also note that there may be other reasons for the `git log` command to
fail, and the output that identifies why it failed is likely to be in
stderr rather than stdout so we don't want to throw that way.

Best regards,

-- 
Paul Barker

Attachment: signature.asc
Description: This is a digitally signed message part

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#237259): 
https://lists.openembedded.org/g/openembedded-core/message/237259
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