aboutsummaryrefslogtreecommitdiffstats
path: root/meta/classes/devtool-source.bbclass
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2017-10-31 16:48:05 +1300
committerPaul Eggleton <paul.eggleton@linux.intel.com>2017-11-09 14:51:41 +1300
commit75d99de26f786dd62d3e04cc8cc438fd66ca421b (patch)
treed35cd3e2dd4e9e342403d757c676817f154383fe /meta/classes/devtool-source.bbclass
parent7cd22161ae6fe44d0471408e0ca9d3cb5e7b2878 (diff)
downloadopenembedded-core-contrib-75d99de26f786dd62d3e04cc8cc438fd66ca421b.tar.gz
devtool: implement conditional patch handlingpaule/devtool31-oe
If you have a recipe that uses overrides to conditionally extend SRC_URI to add additional patches, then you will often need to update those patches if you're making other changes to the source tree (for example if you're upgrading the underlying source). Make this possible with devtool by creating devtool-override-* branches for each override that conditionally appends/prepends SRC_URI, and have devtool update-recipe / finish check each branch out in turn and update the corresponding patches. A current example of a recipe that does this is the quota recipe - it applies an additional patch if musl is the selected C library (i.e. libc-musl is in OVERRIDES). Note that use of this functionality does require some care - in particular, updates to patches that appear on the main branch (named "devtool" by default) should be made there and not only on one of the specific devtool-override-* branches that are created for each override. The recommended procedure is to make the changes you want to make to the main branch first, then check out and rebase each devtool-override-* branch, testing each one by activating the corresponding configuration, and then finally run devtool finish. Fixes [YOCTO #11516]. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'meta/classes/devtool-source.bbclass')
-rw-r--r--meta/classes/devtool-source.bbclass56
1 files changed, 56 insertions, 0 deletions
diff --git a/meta/classes/devtool-source.bbclass b/meta/classes/devtool-source.bbclass
index 8f5bc86b2e..56882a41d8 100644
--- a/meta/classes/devtool-source.bbclass
+++ b/meta/classes/devtool-source.bbclass
@@ -152,9 +152,65 @@ python devtool_pre_patch() {
}
python devtool_post_patch() {
+ import shutil
tempdir = d.getVar('DEVTOOL_TEMPDIR')
with open(os.path.join(tempdir, 'srcsubdir'), 'r') as f:
srcsubdir = f.read()
+ with open(os.path.join(tempdir, 'initial_rev'), 'r') as f:
+ initial_rev = f.read()
+
+ def rm_patches():
+ patches_dir = os.path.join(srcsubdir, 'patches')
+ if os.path.exists(patches_dir):
+ shutil.rmtree(patches_dir)
+ # Restore any "patches" directory that was actually part of the source tree
+ try:
+ bb.process.run('git checkout -- patches', cwd=srcsubdir)
+ except bb.process.ExecutionError:
+ pass
+
+ extra_overrides = d.getVar('DEVTOOL_EXTRA_OVERRIDES')
+ if extra_overrides:
+ extra_override_list = extra_overrides.split(':')
+ devbranch = d.getVar('DEVTOOL_DEVBRANCH')
+ default_overrides = d.getVar('OVERRIDES').split(':')
+ no_overrides = []
+ # First, we may have some overrides that are referred to in the recipe set in
+ # our configuration, so we need to make a branch that excludes those
+ for override in default_overrides:
+ if override not in extra_override_list:
+ no_overrides.append(override)
+ if default_overrides != no_overrides:
+ # Some overrides are active in the current configuration, so
+ # we need to create a branch where none of the overrides are active
+ bb.process.run('git checkout %s -b devtool-no-overrides' % initial_rev, cwd=srcsubdir)
+ # Run do_patch function with the override applied
+ localdata = bb.data.createCopy(d)
+ localdata.setVar('OVERRIDES', ':'.join(no_overrides))
+ bb.build.exec_func('do_patch', localdata)
+ rm_patches()
+ # Now we need to reconcile the dev branch with the no-overrides one
+ # (otherwise we'd likely be left with identical commits that have different hashes)
+ bb.process.run('git checkout %s' % devbranch, cwd=srcsubdir)
+ bb.process.run('git rebase devtool-no-overrides', cwd=srcsubdir)
+ else:
+ bb.process.run('git checkout %s -b devtool-no-overrides' % devbranch, cwd=srcsubdir)
+
+ for override in extra_override_list:
+ localdata = bb.data.createCopy(d)
+ if override in default_overrides:
+ bb.process.run('git branch devtool-override-%s %s' % (override, devbranch), cwd=srcsubdir)
+ else:
+ # Reset back to the initial commit on a new branch
+ bb.process.run('git checkout %s -b devtool-override-%s' % (initial_rev, override), cwd=srcsubdir)
+ # Run do_patch function with the override applied
+ localdata.appendVar('OVERRIDES', ':%s' % override)
+ bb.build.exec_func('do_patch', localdata)
+ rm_patches()
+ # Now we need to reconcile the new branch with the no-overrides one
+ # (otherwise we'd likely be left with identical commits that have different hashes)
+ bb.process.run('git rebase devtool-no-overrides', cwd=srcsubdir)
+ bb.process.run('git checkout %s' % devbranch, cwd=srcsubdir)
bb.process.run('git tag -f devtool-patched', cwd=srcsubdir)
}