summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-08-29 20:40:38 +1200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-03 23:45:52 +0100
commit4b4387455c62cf19fa3d215a11b5d0b1211d4570 (patch)
tree8c42428ddfb65fbd8b9ba7a7ef0632fff0e7bcdf
parente5f61f85c550646bc7e26a1fe6d9df080864ef48 (diff)
downloadpoky-4b4387455c62cf19fa3d215a11b5d0b1211d4570.tar.gz
lib/oe/patch: commit with a dummy user/email when PATCHTOOL=git
When using PATCHTOOL = "git", the user of the system is not really the committer - it's the build system itself. Thus, specify "dummy" values for username and email instead of using the user's configured values. Various parts of the devtool code that need to make commits have also been updated to use the same logic. This allows PATCHTOOL = "git" and devtool to be used on systems where git user.name / user.email has not been set (on versions of git where it doesn't default a value under this circumstance). If you want to return to the old behaviour where the externally configured user name / email are used, set the following in your local.conf: PATCH_GIT_USER_NAME = "" PATCH_GIT_USER_EMAIL = "" Fixes [YOCTO #8703]. (From OE-Core rev: 765a9017eaf77ea3204fb10afb8181629680bd82) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/patch.bbclass3
-rw-r--r--meta/lib/oe/patch.py24
-rw-r--r--scripts/lib/devtool/__init__.py7
-rw-r--r--scripts/lib/devtool/standard.py19
-rw-r--r--scripts/lib/devtool/upgrade.py4
5 files changed, 42 insertions, 15 deletions
diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
index 3d22ad8381..1f6927be04 100644
--- a/meta/classes/patch.bbclass
+++ b/meta/classes/patch.bbclass
@@ -5,6 +5,9 @@ QUILTRCFILE ?= "${STAGING_ETCDIR_NATIVE}/quiltrc"
5 5
6PATCHDEPENDENCY = "${PATCHTOOL}-native:do_populate_sysroot" 6PATCHDEPENDENCY = "${PATCHTOOL}-native:do_populate_sysroot"
7 7
8PATCH_GIT_USER_NAME ?= "OpenEmbedded"
9PATCH_GIT_USER_EMAIL ?= "oe.patch@oe"
10
8inherit terminal 11inherit terminal
9 12
10def src_patches(d, all = False ): 13def src_patches(d, all = False ):
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index af3adec140..cad50157dd 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -281,6 +281,8 @@ class GitApplyTree(PatchTree):
281 281
282 def __init__(self, dir, d): 282 def __init__(self, dir, d):
283 PatchTree.__init__(self, dir, d) 283 PatchTree.__init__(self, dir, d)
284 self.commituser = d.getVar('PATCH_GIT_USER_NAME', True)
285 self.commitemail = d.getVar('PATCH_GIT_USER_EMAIL', True)
284 286
285 @staticmethod 287 @staticmethod
286 def extractPatchHeader(patchfile): 288 def extractPatchHeader(patchfile):
@@ -348,7 +350,17 @@ class GitApplyTree(PatchTree):
348 return outlines, author, date, subject 350 return outlines, author, date, subject
349 351
350 @staticmethod 352 @staticmethod
351 def prepareCommit(patchfile): 353 def gitCommandUserOptions(cmd, commituser=None, commitemail=None, d=None):
354 if d:
355 commituser = d.getVar('PATCH_GIT_USER_NAME', True)
356 commitemail = d.getVar('PATCH_GIT_USER_EMAIL', True)
357 if commituser:
358 cmd += ['-c', 'user.name="%s"' % commituser]
359 if commitemail:
360 cmd += ['-c', 'user.email="%s"' % commitemail]
361
362 @staticmethod
363 def prepareCommit(patchfile, commituser=None, commitemail=None):
352 """ 364 """
353 Prepare a git commit command line based on the header from a patch file 365 Prepare a git commit command line based on the header from a patch file
354 (typically this is useful for patches that cannot be applied with "git am" due to formatting) 366 (typically this is useful for patches that cannot be applied with "git am" due to formatting)
@@ -380,7 +392,9 @@ class GitApplyTree(PatchTree):
380 for line in outlines: 392 for line in outlines:
381 tf.write(line) 393 tf.write(line)
382 # Prepare git command 394 # Prepare git command
383 cmd = ["git", "commit", "-F", tmpfile] 395 cmd = ["git"]
396 GitApplyTree.gitCommandUserOptions(cmd, commituser, commitemail)
397 cmd += ["commit", "-F", tmpfile]
384 # git doesn't like plain email addresses as authors 398 # git doesn't like plain email addresses as authors
385 if author and '<' in author: 399 if author and '<' in author:
386 cmd.append('--author="%s"' % author) 400 cmd.append('--author="%s"' % author)
@@ -456,7 +470,9 @@ class GitApplyTree(PatchTree):
456 try: 470 try:
457 patchfilevar = 'PATCHFILE="%s"' % os.path.basename(patch['file']) 471 patchfilevar = 'PATCHFILE="%s"' % os.path.basename(patch['file'])
458 try: 472 try:
459 shellcmd = [patchfilevar, "git", "--work-tree=%s" % reporoot, "am", "-3", "--keep-cr", "-p%s" % patch['strippath']] 473 shellcmd = [patchfilevar, "git", "--work-tree=%s" % reporoot]
474 self.gitCommandUserOptions(shellcmd, self.commituser, self.commitemail)
475 shellcmd += ["am", "-3", "--keep-cr", "-p%s" % patch['strippath']]
460 return _applypatchhelper(shellcmd, patch, force, reverse, run) 476 return _applypatchhelper(shellcmd, patch, force, reverse, run)
461 except CmdError: 477 except CmdError:
462 # Need to abort the git am, or we'll still be within it at the end 478 # Need to abort the git am, or we'll still be within it at the end
@@ -486,7 +502,7 @@ class GitApplyTree(PatchTree):
486 shellcmd = ["git", "reset", "HEAD", self.patchdir] 502 shellcmd = ["git", "reset", "HEAD", self.patchdir]
487 output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) 503 output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
488 # Commit the result 504 # Commit the result
489 (tmpfile, shellcmd) = self.prepareCommit(patch['file']) 505 (tmpfile, shellcmd) = self.prepareCommit(patch['file'], self.commituser, self.commitemail)
490 try: 506 try:
491 shellcmd.insert(0, patchfilevar) 507 shellcmd.insert(0, patchfilevar)
492 output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) 508 output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
diff --git a/scripts/lib/devtool/__init__.py b/scripts/lib/devtool/__init__.py
index 216b7c345a..b432e3d44e 100644
--- a/scripts/lib/devtool/__init__.py
+++ b/scripts/lib/devtool/__init__.py
@@ -196,15 +196,18 @@ def use_external_build(same_dir, no_same_dir, d):
196 b_is_s = False 196 b_is_s = False
197 return b_is_s 197 return b_is_s
198 198
199def setup_git_repo(repodir, version, devbranch, basetag='devtool-base'): 199def setup_git_repo(repodir, version, devbranch, basetag='devtool-base', d=None):
200 """ 200 """
201 Set up the git repository for the source tree 201 Set up the git repository for the source tree
202 """ 202 """
203 import bb.process 203 import bb.process
204 import oe.patch
204 if not os.path.exists(os.path.join(repodir, '.git')): 205 if not os.path.exists(os.path.join(repodir, '.git')):
205 bb.process.run('git init', cwd=repodir) 206 bb.process.run('git init', cwd=repodir)
206 bb.process.run('git add .', cwd=repodir) 207 bb.process.run('git add .', cwd=repodir)
207 commit_cmd = ['git', 'commit', '-q'] 208 commit_cmd = ['git']
209 oe.patch.GitApplyTree.gitCommandUserOptions(commit_cmd, d=d)
210 commit_cmd += ['commit', '-q']
208 stdout, _ = bb.process.run('git status --porcelain', cwd=repodir) 211 stdout, _ = bb.process.run('git status --porcelain', cwd=repodir)
209 if not stdout: 212 if not stdout:
210 commit_cmd.append('--allow-empty') 213 commit_cmd.append('--allow-empty')
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 6874224417..0d5a42197b 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -212,19 +212,19 @@ def add(args, config, basepath, workspace):
212 for fn in os.listdir(recipedir): 212 for fn in os.listdir(recipedir):
213 _add_md5(config, recipename, os.path.join(recipedir, fn)) 213 _add_md5(config, recipename, os.path.join(recipedir, fn))
214 214
215 tinfoil = setup_tinfoil(config_only=True, basepath=basepath)
216 rd = oe.recipeutils.parse_recipe(tinfoil.cooker, recipefile, None)
217 if not rd:
218 return 1
219
215 if args.fetchuri and not args.no_git: 220 if args.fetchuri and not args.no_git:
216 setup_git_repo(srctree, args.version, 'devtool') 221 setup_git_repo(srctree, args.version, 'devtool', d=tinfoil.config_data)
217 222
218 initial_rev = None 223 initial_rev = None
219 if os.path.exists(os.path.join(srctree, '.git')): 224 if os.path.exists(os.path.join(srctree, '.git')):
220 (stdout, _) = bb.process.run('git rev-parse HEAD', cwd=srctree) 225 (stdout, _) = bb.process.run('git rev-parse HEAD', cwd=srctree)
221 initial_rev = stdout.rstrip() 226 initial_rev = stdout.rstrip()
222 227
223 tinfoil = setup_tinfoil(config_only=True, basepath=basepath)
224 rd = oe.recipeutils.parse_recipe(tinfoil.cooker, recipefile, None)
225 if not rd:
226 return 1
227
228 if args.src_subdir: 228 if args.src_subdir:
229 srctree = os.path.join(srctree, args.src_subdir) 229 srctree = os.path.join(srctree, args.src_subdir)
230 230
@@ -420,7 +420,10 @@ class BbTaskExecutor(object):
420 420
421class PatchTaskExecutor(BbTaskExecutor): 421class PatchTaskExecutor(BbTaskExecutor):
422 def __init__(self, rdata): 422 def __init__(self, rdata):
423 import oe.patch
423 self.check_git = False 424 self.check_git = False
425 self.useroptions = []
426 oe.patch.GitApplyTree.gitCommandUserOptions(self.useroptions, d=rdata)
424 super(PatchTaskExecutor, self).__init__(rdata) 427 super(PatchTaskExecutor, self).__init__(rdata)
425 428
426 def exec_func(self, func, report): 429 def exec_func(self, func, report):
@@ -447,7 +450,7 @@ class PatchTaskExecutor(BbTaskExecutor):
447 450
448 stdout, _ = bb.process.run('git status --porcelain', cwd=srcsubdir) 451 stdout, _ = bb.process.run('git status --porcelain', cwd=srcsubdir)
449 if stdout: 452 if stdout:
450 bb.process.run('git add .; git commit -a -m "Committing changes from %s\n\n%s"' % (func, GitApplyTree.ignore_commit_prefix + ' - from %s' % func), cwd=srcsubdir) 453 bb.process.run('git add .; git %s commit -a -m "Committing changes from %s\n\n%s"' % (' '.join(self.useroptions), func, GitApplyTree.ignore_commit_prefix + ' - from %s' % func), cwd=srcsubdir)
451 454
452 455
453def _prep_extract_operation(config, basepath, recipename, tinfoil=None): 456def _prep_extract_operation(config, basepath, recipename, tinfoil=None):
@@ -592,7 +595,7 @@ def _extract_source(srctree, keep_temp, devbranch, sync, d):
592 "doesn't use any source or the correct source " 595 "doesn't use any source or the correct source "
593 "directory could not be determined" % pn) 596 "directory could not be determined" % pn)
594 597
595 setup_git_repo(srcsubdir, crd.getVar('PV', True), devbranch) 598 setup_git_repo(srcsubdir, crd.getVar('PV', True), devbranch, d=d)
596 599
597 (stdout, _) = bb.process.run('git rev-parse HEAD', cwd=srcsubdir) 600 (stdout, _) = bb.process.run('git rev-parse HEAD', cwd=srcsubdir)
598 initial_rev = stdout.rstrip() 601 initial_rev = stdout.rstrip()
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py
index fc2f919383..a5063f57a9 100644
--- a/scripts/lib/devtool/upgrade.py
+++ b/scripts/lib/devtool/upgrade.py
@@ -227,7 +227,9 @@ def _extract_new_source(newpv, srctree, no_patch, srcrev, branch, keep_temp, tin
227 for f in stdout.splitlines(): 227 for f in stdout.splitlines():
228 __run('git add "%s"' % f) 228 __run('git add "%s"' % f)
229 229
230 __run('git commit -q -m "Commit of upstream changes at version %s" --allow-empty' % newpv) 230 useroptions = []
231 oe.patch.GitApplyTree.gitCommandUserOptions(useroptions, d=rd)
232 __run('git %s commit -q -m "Commit of upstream changes at version %s" --allow-empty' % (' '.join(useroptions), newpv))
231 __run('git tag -f devtool-base-%s' % newpv) 233 __run('git tag -f devtool-base-%s' % newpv)
232 234
233 (stdout, _) = __run('git rev-parse HEAD') 235 (stdout, _) = __run('git rev-parse HEAD')