summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-12-13 20:09:38 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-14 12:30:49 +0000
commit45adbe370908901d0d2e94b3c4daea821772e2ff (patch)
treeb4f7018bab13b4051618622934f4e2e21f5d71c7 /meta
parent5942a8dc7c0a7f157e4023201c66c0cf7f91550b (diff)
downloadpoky-45adbe370908901d0d2e94b3c4daea821772e2ff.tar.gz
classes/patch: move in logic to commit for additional tasks
If PATCHTOOL is "git", and PATCH_COMMIT_FUNCTIONS is set to "1", for additional tasks between do_unpack and do_patch, make a git commit. This logic was previously implemented in devtool itself, but it makes more sense for it to be implemented in the patch class since that's where the rest of the logic is for this (or in lib/oe/patch.py). It also makes it possible for this to work with tinfoil2. (From OE-Core rev: f24f59ea1d8bc335ea8576f6a346d0935f4a3548) 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')
-rw-r--r--meta/classes/patch.bbclass69
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
11inherit terminal 11inherit terminal
12 12
13python () {
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
45python 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
58python 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
13def src_patches(d, all=False, expand=True): 82def 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)