Bug 8703

Summary: PATCHTOOL = git, triggers error user.name/user.email unset
Product: [Build System, Metadata & Runtime] BitBake Reporter: Gunnar A / gunnarx <bugzilla.ga>
Component: bitbakeAssignee: Paul Eggleton <bluelightning>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: bluelightning, bugzilla.ga, poky.bs.watcher, poky.watcher, randy.e.witt, randy.macleod, ross.burton
Version: unspecified   
Target Milestone: 2.2   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Yes (doc changes required)

Description Gunnar A / gunnarx 2015-11-18 18:15:30 UTC
Preconditions/Environment
-------------------------

1. A project in which a bb file sets PATCHTOOL = "git", and includes some patches to apply

2. The user account has NOT provided user.name and user.email using git config --global user.name 

Triggering Action/Cause
-----------------------
bitbake <anything that includes the recipe>

Expectation
-----------
Successful build

Actual Result
-------------
do_patch operation fails

== STEPS TO REPRODUCE:

1. git clone poky

2. git checkout master 
(1b25a709915... - 18 Nov 2015)

3. Pick a random recipe that has a patch file,

   poky/meta/recipes-extended/tar/tar_1.28.bb

4. Edit tar_1.28.bb and add:

PATCHTOOL = 'git'

5. bitbake tar

After around 200 of the 657 tasks we finally get 
to tar, with the following result:

-----
ERROR: Command Error: exit status: 128  Output:

*** Please tell me who you are.

Run

    git config --global user.email "you@example.com"
    git config --global user.name "Your Name"

    to set your account's default identity.
    Omit --global to set the identity only in this repository.

    fatal: unable to auto-detect email address (got 'user@lifebook.(none)')
    ERROR: Function failed: patch_do_patch
    ERROR: Logfile of failure stored in:
    /tmp/poky/build/tmp/work/i586-poky-linux/tar/1.28-r0/temp/log.do_patch.22758
    ERROR: Task 1 (/tmp/poky/meta/recipes-extended/tar/tar_1.28.bb,
          do_patch) failed with exit code '1'
------

== ANALYSIS/COMMENTS:

As far as I can see, bitbake uses git-am to apply the patches(?) This requires user.name/email to be set.  If they are not set globally by the user they are not in the git repository checked out by Yocto.

This is similar to a previous bug but the fix may have missed that it also occurs for git apply situations.  I am failing to find the bug report if there was one, but here is the relevant commit:

http://git.openembedded.org/openembedded-core/commit/?id=f62255bfa6c5a322c867b7c4ea5686ea7bfab3fe


Reproducibility
---------------
1/1

Where:
n = total number of attempts
m = number of times the phenomenon is visible
Comment 1 Paul Eggleton 2015-11-18 18:20:26 UTC
I'm not entirely sure defaulting the name/password in this instance is appropriate. What would you default it to? My opinion is that the easiest way to deal with this is simply to set up your global git configuration with a name/password and then it's not a problem.
Comment 2 Gunnar A / gunnarx 2015-11-19 09:25:40 UTC
(In reply to comment #1)

I have the opposite opinion so far.  When faced with this situation I sense
that these commits are done "by" the Yocto/Bitbake system, rather than by
me personally.  That's a matter of opinion of course.

Paul Eggleton 2015-11-18 18:20:26 UTC wrote:
> What would you default it to

I have no preference.  In the buildhistory case something was made up.

Paul, do you feel this is different from the buildhistory case?  Couldn't
the same reasoning have applied there?

> My opinion is that the easiest way to deal with this is simply to set up
> your global git configuration with a name/password and then it's not a
> problem"

"your" could mean many things of course, but I get the sense you see this
as a kind of personal meaning -  that I am personally running bitbake on my
personal machine.   The steps to reproduce were simplified but the context
is this:  This was noticed in an automated build situation and not before
that - presumably because most users that trigger the build manually have a
global config set up which ends up being used.

On a clean machine for automated builds running under some non-personal
user account the git global config doesn't exist (unless we make that a
requirement).  So it boils down to, do we want git config --global
user.name / email to be a prerequisite for running Yocto/Bitbake?  I feel
it would add another thing to the minimal requirements for bootstrapping a
Yocto build - it's something external that doesn't belong to the build or
the build system.

Personally I feel like this is a problem that we could avoid triggering,
but it's up to maintainers to decide of course.
Comment 3 Gunnar A / gunnarx 2015-11-19 09:26:30 UTC
Are there compromises? Ideas? Any clean way to add this config to a project's
meta-data (globally, not per recipe).  Can someone suggest a clean pattern
everyone could follow in their project metadata so it doesn't become a
dependency on the machine you run it on?  Inherit some class when setting
PATCHTOOL?
Comment 4 Paul Eggleton 2015-11-30 22:10:34 UTC
I'm looking at a simple fix for this at the moment - it does require patching meta/lib/oe/patch.py.

The most obvious workaround is simply to not use PATCHTOOL = "git" in automated scenarios where you might not have git user.email/user.name configured.
Comment 5 Paul Eggleton 2016-08-29 08:43:35 UTC
Patch posted for review:

https://patchwork.openembedded.org/series/2093/
Comment 7 Randy Witt 2016-09-20 22:02:31 UTC
*** Bug 10148 has been marked as a duplicate of this bug. ***