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>
This commit is contained in:
Paul Eggleton
2016-02-11 14:13:28 +13:00
committed by Richard Purdie
parent e36cb6c718
commit ddfe74447b
2 changed files with 38 additions and 13 deletions

View File

@@ -393,6 +393,38 @@ class BbTaskExecutor(object):
self.executed.append(func)
class PatchTaskExecutor(BbTaskExecutor):
def __init__(self, rdata):
self.check_git = False
super(PatchTaskExecutor, self).__init__(rdata)
def exec_func(self, func, report):
from oe.patch import GitApplyTree
srcsubdir = self.rdata.getVar('S', True)
haspatches = False
if func == 'do_patch':
patchdir = os.path.join(srcsubdir, 'patches')
if os.path.exists(patchdir):
if os.listdir(patchdir):
haspatches = True
else:
os.rmdir(patchdir)
super(PatchTaskExecutor, self).exec_func(func, report)
if self.check_git and os.path.exists(srcsubdir):
if func == 'do_patch':
if os.path.exists(patchdir):
shutil.rmtree(patchdir)
if haspatches:
stdout, _ = bb.process.run('git status --porcelain patches', cwd=srcsubdir)
if stdout:
bb.process.run('git checkout patches', cwd=srcsubdir)
stdout, _ = bb.process.run('git status --porcelain', cwd=srcsubdir)
if stdout:
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)
def _prep_extract_operation(config, basepath, recipename):
"""HACK: Ugly workaround for making sure that requirements are met when
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):
# We don't want to move the source to STAGING_KERNEL_DIR here
crd.setVar('STAGING_KERNEL_DIR', '${S}')
task_executor = BbTaskExecutor(crd)
task_executor = PatchTaskExecutor(crd)
crd.setVar('EXTERNALSRC_forcevariable', '')
@@ -491,6 +523,8 @@ def _extract_source(srctree, keep_temp, devbranch, sync, d):
task_executor.exec_func('do_kernel_checkout', False)
srcsubdir = crd.getVar('S', True)
task_executor.check_git = True
# Move local source files into separate subdir
recipe_patches = [os.path.basename(patch) for patch in
oe.recipeutils.get_recipe_patches(crd)]
@@ -524,13 +558,6 @@ def _extract_source(srctree, keep_temp, devbranch, sync, d):
scriptutils.git_convert_standalone_clone(srcsubdir)
patchdir = os.path.join(srcsubdir, 'patches')
haspatches = False
if os.path.exists(patchdir):
if os.listdir(patchdir):
haspatches = True
else:
os.rmdir(patchdir)
# Make sure that srcsubdir exists
bb.utils.mkdirhier(srcsubdir)
if not os.path.exists(srcsubdir) or not os.listdir(srcsubdir):
@@ -550,11 +577,6 @@ def _extract_source(srctree, keep_temp, devbranch, sync, d):
bb.process.run('git tag -f devtool-patched', cwd=srcsubdir)
if os.path.exists(patchdir):
shutil.rmtree(patchdir)
if haspatches:
bb.process.run('git checkout patches', cwd=srcsubdir)
if bb.data.inherits_class('kernel-yocto', d):
# Store generate and store kernel config
logger.info('Generating kernel config')