summaryrefslogtreecommitdiff
path: root/scripts/lib
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:32:55 +0000
commit997a77d9b20af1778b804778e5d8c8a7424f7582 (patch)
treee26abfecdb2042b2b07da9ddf2db42596d817dbe /scripts/lib
parent58adb3904c18acefd0da319e32f66ebca72eeaac (diff)
downloadopenembedded-core-997a77d9b20af1778b804778e5d8c8a7424f7582.tar.gz
openembedded-core-997a77d9b20af1778b804778e5d8c8a7424f7582.tar.bz2
openembedded-core-997a77d9b20af1778b804778e5d8c8a7424f7582.zip
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]. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/devtool/standard.py48
1 files changed, 35 insertions, 13 deletions
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):
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')