summaryrefslogtreecommitdiffstats
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
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-11-11 12:14:27 +0000
commit125e0b72b7b419368761ffbbf38987f91af4523b (patch)
tree82028e3ca3c653e516429731bbe9b90184f33a06 /meta/classes/devtool-source.bbclass
parent9a80078e4b8e01d9bb49288f214f40e8497aa3ac (diff)
downloadpoky-125e0b72b7b419368761ffbbf38987f91af4523b.tar.gz
devtool: implement conditional patch handling
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]. (From OE-Core rev: aa87603d1ffd695027847f4df75c0406cf4e14d8) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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() {
152} 152}
153 153
154python devtool_post_patch() { 154python devtool_post_patch() {
155 import shutil
155 tempdir = d.getVar('DEVTOOL_TEMPDIR') 156 tempdir = d.getVar('DEVTOOL_TEMPDIR')
156 with open(os.path.join(tempdir, 'srcsubdir'), 'r') as f: 157 with open(os.path.join(tempdir, 'srcsubdir'), 'r') as f:
157 srcsubdir = f.read() 158 srcsubdir = f.read()
159 with open(os.path.join(tempdir, 'initial_rev'), 'r') as f:
160 initial_rev = f.read()
161
162 def rm_patches():
163 patches_dir = os.path.join(srcsubdir, 'patches')
164 if os.path.exists(patches_dir):
165 shutil.rmtree(patches_dir)
166 # Restore any "patches" directory that was actually part of the source tree
167 try:
168 bb.process.run('git checkout -- patches', cwd=srcsubdir)
169 except bb.process.ExecutionError:
170 pass
171
172 extra_overrides = d.getVar('DEVTOOL_EXTRA_OVERRIDES')
173 if extra_overrides:
174 extra_override_list = extra_overrides.split(':')
175 devbranch = d.getVar('DEVTOOL_DEVBRANCH')
176 default_overrides = d.getVar('OVERRIDES').split(':')
177 no_overrides = []
178 # First, we may have some overrides that are referred to in the recipe set in
179 # our configuration, so we need to make a branch that excludes those
180 for override in default_overrides:
181 if override not in extra_override_list:
182 no_overrides.append(override)
183 if default_overrides != no_overrides:
184 # Some overrides are active in the current configuration, so
185 # we need to create a branch where none of the overrides are active
186 bb.process.run('git checkout %s -b devtool-no-overrides' % initial_rev, cwd=srcsubdir)
187 # Run do_patch function with the override applied
188 localdata = bb.data.createCopy(d)
189 localdata.setVar('OVERRIDES', ':'.join(no_overrides))
190 bb.build.exec_func('do_patch', localdata)
191 rm_patches()
192 # Now we need to reconcile the dev branch with the no-overrides one
193 # (otherwise we'd likely be left with identical commits that have different hashes)
194 bb.process.run('git checkout %s' % devbranch, cwd=srcsubdir)
195 bb.process.run('git rebase devtool-no-overrides', cwd=srcsubdir)
196 else:
197 bb.process.run('git checkout %s -b devtool-no-overrides' % devbranch, cwd=srcsubdir)
198
199 for override in extra_override_list:
200 localdata = bb.data.createCopy(d)
201 if override in default_overrides:
202 bb.process.run('git branch devtool-override-%s %s' % (override, devbranch), cwd=srcsubdir)
203 else:
204 # Reset back to the initial commit on a new branch
205 bb.process.run('git checkout %s -b devtool-override-%s' % (initial_rev, override), cwd=srcsubdir)
206 # Run do_patch function with the override applied
207 localdata.appendVar('OVERRIDES', ':%s' % override)
208 bb.build.exec_func('do_patch', localdata)
209 rm_patches()
210 # Now we need to reconcile the new branch with the no-overrides one
211 # (otherwise we'd likely be left with identical commits that have different hashes)
212 bb.process.run('git rebase devtool-no-overrides', cwd=srcsubdir)
213 bb.process.run('git checkout %s' % devbranch, cwd=srcsubdir)
158 bb.process.run('git tag -f devtool-patched', cwd=srcsubdir) 214 bb.process.run('git tag -f devtool-patched', cwd=srcsubdir)
159} 215}
160 216