diff options
Diffstat (limited to 'meta/classes/devtool-source.bbclass')
| -rw-r--r-- | meta/classes/devtool-source.bbclass | 56 |
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 | ||
| 154 | python devtool_post_patch() { | 154 | python 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 | ||
