summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-02-11 14:13:28 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-11 12:33:02 +0000
commitddfe74447b3a50ae0b3533ace0e2b41e04a57bff (patch)
treee40e28043cf8d4f789435e343c1b8e797c7874ae
parente36cb6c718587111af80bb41843b29f5c043095d (diff)
downloadpoky-ddfe74447b3a50ae0b3533ace0e2b41e04a57bff.tar.gz
devtool: commit for extra tasks that modify source when extracting
When extracting source for a recipe, if there are additional custom tasks run that make changes to the source, create a commit in the generated git branch so they are contained. This is particularly useful for tasks that come before do_patch since otherwise the changes might get incorporated in the first applied patch, but otherwise it helps avoid the tree being dirty at any point. Fixes [YOCTO #7626]. (From OE-Core rev: 997a77d9b20af1778b804778e5d8c8a7424f7582) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oe/patch.py3
-rw-r--r--scripts/lib/devtool/standard.py48
2 files changed, 38 insertions, 13 deletions
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index 4e77168dab..2464efdbe5 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -264,6 +264,7 @@ class PatchTree(PatchSet):
264 264
265class GitApplyTree(PatchTree): 265class GitApplyTree(PatchTree):
266 patch_line_prefix = '%% original patch' 266 patch_line_prefix = '%% original patch'
267 ignore_commit_prefix = '%% ignore'
267 268
268 def __init__(self, dir, d): 269 def __init__(self, dir, d):
269 PatchTree.__init__(self, dir, d) 270 PatchTree.__init__(self, dir, d)
@@ -384,6 +385,8 @@ class GitApplyTree(PatchTree):
384 if line.startswith(GitApplyTree.patch_line_prefix): 385 if line.startswith(GitApplyTree.patch_line_prefix):
385 outfile = line.split()[-1].strip() 386 outfile = line.split()[-1].strip()
386 continue 387 continue
388 if line.startswith(GitApplyTree.ignore_commit_prefix):
389 continue
387 patchlines.append(line) 390 patchlines.append(line)
388 if not outfile: 391 if not outfile:
389 outfile = os.path.basename(srcfile) 392 outfile = os.path.basename(srcfile)
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 390d98fd55..262ba0989b 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -393,6 +393,38 @@ class BbTaskExecutor(object):
393 self.executed.append(func) 393 self.executed.append(func)
394 394
395 395
396class PatchTaskExecutor(BbTaskExecutor):
397 def __init__(self, rdata):
398 self.check_git = False
399 super(PatchTaskExecutor, self).__init__(rdata)
400
401 def exec_func(self, func, report):
402 from oe.patch import GitApplyTree
403 srcsubdir = self.rdata.getVar('S', True)
404 haspatches = False
405 if func == 'do_patch':
406 patchdir = os.path.join(srcsubdir, 'patches')
407 if os.path.exists(patchdir):
408 if os.listdir(patchdir):
409 haspatches = True
410 else:
411 os.rmdir(patchdir)
412
413 super(PatchTaskExecutor, self).exec_func(func, report)
414 if self.check_git and os.path.exists(srcsubdir):
415 if func == 'do_patch':
416 if os.path.exists(patchdir):
417 shutil.rmtree(patchdir)
418 if haspatches:
419 stdout, _ = bb.process.run('git status --porcelain patches', cwd=srcsubdir)
420 if stdout:
421 bb.process.run('git checkout patches', cwd=srcsubdir)
422
423 stdout, _ = bb.process.run('git status --porcelain', cwd=srcsubdir)
424 if stdout:
425 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)
426
427
396def _prep_extract_operation(config, basepath, recipename): 428def _prep_extract_operation(config, basepath, recipename):
397 """HACK: Ugly workaround for making sure that requirements are met when 429 """HACK: Ugly workaround for making sure that requirements are met when
398 trying to extract a package. Returns the tinfoil instance to be used.""" 430 trying to extract a package. Returns the tinfoil instance to be used."""
@@ -477,7 +509,7 @@ def _extract_source(srctree, keep_temp, devbranch, sync, d):
477 # We don't want to move the source to STAGING_KERNEL_DIR here 509 # We don't want to move the source to STAGING_KERNEL_DIR here
478 crd.setVar('STAGING_KERNEL_DIR', '${S}') 510 crd.setVar('STAGING_KERNEL_DIR', '${S}')
479 511
480 task_executor = BbTaskExecutor(crd) 512 task_executor = PatchTaskExecutor(crd)
481 513
482 crd.setVar('EXTERNALSRC_forcevariable', '') 514 crd.setVar('EXTERNALSRC_forcevariable', '')
483 515
@@ -491,6 +523,8 @@ def _extract_source(srctree, keep_temp, devbranch, sync, d):
491 task_executor.exec_func('do_kernel_checkout', False) 523 task_executor.exec_func('do_kernel_checkout', False)
492 srcsubdir = crd.getVar('S', True) 524 srcsubdir = crd.getVar('S', True)
493 525
526 task_executor.check_git = True
527
494 # Move local source files into separate subdir 528 # Move local source files into separate subdir
495 recipe_patches = [os.path.basename(patch) for patch in 529 recipe_patches = [os.path.basename(patch) for patch in
496 oe.recipeutils.get_recipe_patches(crd)] 530 oe.recipeutils.get_recipe_patches(crd)]
@@ -524,13 +558,6 @@ def _extract_source(srctree, keep_temp, devbranch, sync, d):
524 558
525 scriptutils.git_convert_standalone_clone(srcsubdir) 559 scriptutils.git_convert_standalone_clone(srcsubdir)
526 560
527 patchdir = os.path.join(srcsubdir, 'patches')
528 haspatches = False
529 if os.path.exists(patchdir):
530 if os.listdir(patchdir):
531 haspatches = True
532 else:
533 os.rmdir(patchdir)
534 # Make sure that srcsubdir exists 561 # Make sure that srcsubdir exists
535 bb.utils.mkdirhier(srcsubdir) 562 bb.utils.mkdirhier(srcsubdir)
536 if not os.path.exists(srcsubdir) or not os.listdir(srcsubdir): 563 if not os.path.exists(srcsubdir) or not os.listdir(srcsubdir):
@@ -550,11 +577,6 @@ def _extract_source(srctree, keep_temp, devbranch, sync, d):
550 577
551 bb.process.run('git tag -f devtool-patched', cwd=srcsubdir) 578 bb.process.run('git tag -f devtool-patched', cwd=srcsubdir)
552 579
553 if os.path.exists(patchdir):
554 shutil.rmtree(patchdir)
555 if haspatches:
556 bb.process.run('git checkout patches', cwd=srcsubdir)
557
558 if bb.data.inherits_class('kernel-yocto', d): 580 if bb.data.inherits_class('kernel-yocto', d):
559 # Store generate and store kernel config 581 # Store generate and store kernel config
560 logger.info('Generating kernel config') 582 logger.info('Generating kernel config')