diff options
-rw-r--r-- | meta/classes/patch.bbclass | 69 | ||||
-rw-r--r-- | scripts/lib/devtool/standard.py | 37 |
2 files changed, 70 insertions, 36 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) |
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py index 87d3f5dc04..06c508c838 100644 --- a/scripts/lib/devtool/standard.py +++ b/scripts/lib/devtool/standard.py | |||
@@ -442,41 +442,6 @@ class BbTaskExecutor(object): | |||
442 | self.executed.append(func) | 442 | self.executed.append(func) |
443 | 443 | ||
444 | 444 | ||
445 | class PatchTaskExecutor(BbTaskExecutor): | ||
446 | def __init__(self, rdata): | ||
447 | import oe.patch | ||
448 | self.check_git = False | ||
449 | self.useroptions = [] | ||
450 | oe.patch.GitApplyTree.gitCommandUserOptions(self.useroptions, d=rdata) | ||
451 | super(PatchTaskExecutor, self).__init__(rdata) | ||
452 | |||
453 | def exec_func(self, func, report): | ||
454 | from oe.patch import GitApplyTree | ||
455 | srcsubdir = self.rdata.getVar('S', True) | ||
456 | haspatches = False | ||
457 | if func == 'do_patch': | ||
458 | patchdir = os.path.join(srcsubdir, 'patches') | ||
459 | if os.path.exists(patchdir): | ||
460 | if os.listdir(patchdir): | ||
461 | haspatches = True | ||
462 | else: | ||
463 | os.rmdir(patchdir) | ||
464 | |||
465 | super(PatchTaskExecutor, self).exec_func(func, report) | ||
466 | if self.check_git and os.path.exists(srcsubdir): | ||
467 | if func == 'do_patch': | ||
468 | if os.path.exists(patchdir): | ||
469 | shutil.rmtree(patchdir) | ||
470 | if haspatches: | ||
471 | stdout, _ = bb.process.run('git status --porcelain patches', cwd=srcsubdir) | ||
472 | if stdout: | ||
473 | bb.process.run('git checkout patches', cwd=srcsubdir) | ||
474 | |||
475 | stdout, _ = bb.process.run('git status --porcelain', cwd=srcsubdir) | ||
476 | if stdout: | ||
477 | bb.process.run('git add .; git %s commit -a -m "Committing changes from %s\n\n%s"' % (' '.join(self.useroptions), func, GitApplyTree.ignore_commit_prefix + ' - from %s' % func), cwd=srcsubdir) | ||
478 | |||
479 | |||
480 | def _prep_extract_operation(config, basepath, recipename, tinfoil=None): | 445 | def _prep_extract_operation(config, basepath, recipename, tinfoil=None): |
481 | """HACK: Ugly workaround for making sure that requirements are met when | 446 | """HACK: Ugly workaround for making sure that requirements are met when |
482 | trying to extract a package. Returns the tinfoil instance to be used.""" | 447 | trying to extract a package. Returns the tinfoil instance to be used.""" |
@@ -563,7 +528,7 @@ def _extract_source(srctree, keep_temp, devbranch, sync, d): | |||
563 | # We don't want to move the source to STAGING_KERNEL_DIR here | 528 | # We don't want to move the source to STAGING_KERNEL_DIR here |
564 | crd.setVar('STAGING_KERNEL_DIR', '${S}') | 529 | crd.setVar('STAGING_KERNEL_DIR', '${S}') |
565 | 530 | ||
566 | task_executor = PatchTaskExecutor(crd) | 531 | task_executor = BbTaskExecutor(crd) |
567 | 532 | ||
568 | crd.setVar('EXTERNALSRC_forcevariable', '') | 533 | crd.setVar('EXTERNALSRC_forcevariable', '') |
569 | 534 | ||