diff options
Diffstat (limited to 'meta/classes/patch.bbclass')
| -rw-r--r-- | meta/classes/patch.bbclass | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass index 2c1f58cbdc..7ebae282b6 100644 --- a/meta/classes/patch.bbclass +++ b/meta/classes/patch.bbclass | |||
| @@ -10,6 +10,75 @@ PATCH_GIT_USER_EMAIL ?= "oe.patch@oe" | |||
| 10 | 10 | ||
| 11 | inherit terminal | 11 | inherit terminal |
| 12 | 12 | ||
| 13 | python () { | ||
| 14 | if d.getVar('PATCHTOOL', True) == 'git' and d.getVar('PATCH_COMMIT_FUNCTIONS', True) == '1': | ||
| 15 | tasks = list(filter(lambda k: d.getVarFlag(k, "task", True), d.keys())) | ||
| 16 | extratasks = [] | ||
| 17 | def follow_chain(task, endtask, chain=None): | ||
| 18 | if not chain: | ||
| 19 | chain = [] | ||
| 20 | chain.append(task) | ||
| 21 | for othertask in tasks: | ||
| 22 | if othertask == task: | ||
| 23 | continue | ||
| 24 | if task == endtask: | ||
| 25 | for ctask in chain: | ||
| 26 | if ctask not in extratasks: | ||
| 27 | extratasks.append(ctask) | ||
| 28 | else: | ||
| 29 | deps = d.getVarFlag(othertask, 'deps', False) | ||
| 30 | if task in deps: | ||
| 31 | follow_chain(othertask, endtask, chain) | ||
| 32 | chain.pop() | ||
| 33 | follow_chain('do_unpack', 'do_patch') | ||
| 34 | try: | ||
| 35 | extratasks.remove('do_unpack') | ||
| 36 | except ValueError: | ||
| 37 | # For some recipes do_unpack doesn't exist, ignore it | ||
| 38 | pass | ||
| 39 | |||
| 40 | d.appendVarFlag('do_patch', 'prefuncs', ' patch_task_patch_prefunc') | ||
| 41 | for task in extratasks: | ||
| 42 | d.appendVarFlag(task, 'postfuncs', ' patch_task_postfunc') | ||
| 43 | } | ||
| 44 | |||
| 45 | python patch_task_patch_prefunc() { | ||
| 46 | # Prefunc for do_patch | ||
| 47 | func = d.getVar('BB_RUNTASK', True) | ||
| 48 | srcsubdir = d.getVar('S', True) | ||
| 49 | |||
| 50 | patchdir = os.path.join(srcsubdir, 'patches') | ||
| 51 | if os.path.exists(patchdir): | ||
| 52 | if os.listdir(patchdir): | ||
| 53 | d.setVar('PATCH_HAS_PATCHES_DIR', '1') | ||
| 54 | else: | ||
| 55 | os.rmdir(patchdir) | ||
| 56 | } | ||
| 57 | |||
| 58 | python patch_task_postfunc() { | ||
| 59 | # Prefunc for task functions between do_unpack and do_patch | ||
| 60 | import oe.patch | ||
| 61 | import shutil | ||
| 62 | func = d.getVar('BB_RUNTASK', True) | ||
| 63 | srcsubdir = d.getVar('S', True) | ||
| 64 | |||
| 65 | if os.path.exists(srcsubdir): | ||
| 66 | if func == 'do_patch': | ||
| 67 | haspatches = (d.getVar('PATCH_HAS_PATCHES_DIR', True) == '1') | ||
| 68 | patchdir = os.path.join(srcsubdir, 'patches') | ||
| 69 | if os.path.exists(patchdir): | ||
| 70 | shutil.rmtree(patchdir) | ||
| 71 | if haspatches: | ||
| 72 | stdout, _ = bb.process.run('git status --porcelain patches', cwd=srcsubdir) | ||
| 73 | if stdout: | ||
| 74 | bb.process.run('git checkout patches', cwd=srcsubdir) | ||
| 75 | stdout, _ = bb.process.run('git status --porcelain .', cwd=srcsubdir) | ||
| 76 | if stdout: | ||
| 77 | useroptions = [] | ||
| 78 | oe.patch.GitApplyTree.gitCommandUserOptions(useroptions, d=d) | ||
| 79 | bb.process.run('git add .; git %s commit -a -m "Committing changes from %s\n\n%s"' % (' '.join(useroptions), func, oe.patch.GitApplyTree.ignore_commit_prefix + ' - from %s' % func), cwd=srcsubdir) | ||
| 80 | } | ||
| 81 | |||
| 13 | def src_patches(d, all=False, expand=True): | 82 | def src_patches(d, all=False, expand=True): |
| 14 | workdir = d.getVar('WORKDIR', True) | 83 | workdir = d.getVar('WORKDIR', True) |
| 15 | fetch = bb.fetch2.Fetch([], d) | 84 | fetch = bb.fetch2.Fetch([], d) |
