diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2012-06-18 16:45:35 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-06-21 13:10:32 +0100 |
commit | 5bd11a9bf329217f312076f347b045b5c09f19b2 (patch) | |
tree | 83714e56d5ba70a16cac099af85f7674300b1ba1 /bitbake | |
parent | abc0bef595bbedf1fea8c6e0b1dc0c0becdd5b17 (diff) | |
download | poky-5bd11a9bf329217f312076f347b045b5c09f19b2.tar.gz |
bitbake: bitbake: ensure -f causes dependent tasks to be re-run
If -f is specified, force dependent tasks to be re-run next time. This
works by changing the force behaviour so that instead of deleting the
task's stamp, we write a "taint" file into the stamps directory, which
will alter the taskhash randomly and thus trigger the task to re-run
next time we evaluate whether or not that should be done as well as
influencing the taskhashes of any dependent tasks so that they are
similarly re-triggered. As a bonus because we write this file as
<stamp file name>.taskname.taint, the existing code which deletes the
stamp files in OE's do_clean will already handle removing it.
This means you can now do the following:
bitbake somepackage
[ change the source code in the package's WORKDIR ]
bitbake -c compile -f somepackage
bitbake somepackage
and the result will be that all of the tasks that depend on do_compile
(do_install, do_package, etc.) will be re-run in the last step.
Note that to operate in the manner described above you need full hashing
enabled (i.e. BB_SIGNATURE_HANDLER must be set to a signature handler
that inherits from BasicHash). If this is not the case, -f will just
delete the stamp for the specified task as it did before.
This fix is required for [YOCTO #2615] and [YOCTO #2256].
(Bitbake rev: f7b55a94226f9acd985f87946e26d01bd86a35bb)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/build.py | 18 | ||||
-rw-r--r-- | bitbake/lib/bb/cooker.py | 6 | ||||
-rw-r--r-- | bitbake/lib/bb/runqueue.py | 12 | ||||
-rw-r--r-- | bitbake/lib/bb/siggen.py | 35 |
4 files changed, 62 insertions, 9 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index a9ba02d34f..a0a7dd4e12 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py | |||
@@ -494,6 +494,24 @@ def del_stamp(task, d, file_name = None): | |||
494 | stamp = stamp_internal(task, d, file_name) | 494 | stamp = stamp_internal(task, d, file_name) |
495 | bb.utils.remove(stamp) | 495 | bb.utils.remove(stamp) |
496 | 496 | ||
497 | def write_taint(task, d, file_name = None): | ||
498 | """ | ||
499 | Creates a "taint" file which will force the specified task and its | ||
500 | dependents to be re-run the next time by influencing the value of its | ||
501 | taskhash. | ||
502 | (d can be a data dict or dataCache) | ||
503 | """ | ||
504 | import uuid | ||
505 | if file_name: | ||
506 | taintfn = d.stamp[file_name] + '.' + task + '.taint' | ||
507 | else: | ||
508 | taintfn = d.getVar('STAMP', True) + '.' + task + '.taint' | ||
509 | bb.utils.mkdirhier(os.path.dirname(taintfn)) | ||
510 | # The specific content of the taint file is not really important, | ||
511 | # we just need it to be random, so a random UUID is used | ||
512 | with open(taintfn, 'w') as taintf: | ||
513 | taintf.write(str(uuid.uuid4())) | ||
514 | |||
497 | def stampfile(taskname, d, file_name = None): | 515 | def stampfile(taskname, d, file_name = None): |
498 | """ | 516 | """ |
499 | Return the stamp for a given task | 517 | Return the stamp for a given task |
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 928b6009aa..9b8d4b23e5 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -1066,10 +1066,10 @@ class BBCooker: | |||
1066 | self.status.rundeps[fn] = [] | 1066 | self.status.rundeps[fn] = [] |
1067 | self.status.runrecs[fn] = [] | 1067 | self.status.runrecs[fn] = [] |
1068 | 1068 | ||
1069 | # Remove stamp for target if force mode active | 1069 | # Invalidate task for target if force mode active |
1070 | if self.configuration.force: | 1070 | if self.configuration.force: |
1071 | logger.verbose("Remove stamp %s, %s", task, fn) | 1071 | logger.verbose("Invalidate task %s, %s", task, fn) |
1072 | bb.build.del_stamp('do_%s' % task, self.status, fn) | 1072 | bb.parse.siggen.invalidate_task('do_%s' % task, self.status, fn) |
1073 | 1073 | ||
1074 | # Setup taskdata structure | 1074 | # Setup taskdata structure |
1075 | taskdata = bb.taskdata.TaskData(self.configuration.abort) | 1075 | taskdata = bb.taskdata.TaskData(self.configuration.abort) |
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py index d925b4c2b7..28eb072bee 100644 --- a/bitbake/lib/bb/runqueue.py +++ b/bitbake/lib/bb/runqueue.py | |||
@@ -705,6 +705,12 @@ class RunQueueData: | |||
705 | continue | 705 | continue |
706 | self.runq_setscene.append(task) | 706 | self.runq_setscene.append(task) |
707 | 707 | ||
708 | # Invalidate task if force mode active | ||
709 | if self.cooker.configuration.force: | ||
710 | for (fn, target) in self.target_pairs: | ||
711 | logger.verbose("Invalidate task %s, %s", target, fn) | ||
712 | bb.parse.siggen.invalidate_task(target, self.dataCache, fn) | ||
713 | |||
708 | # Interate over the task list and call into the siggen code | 714 | # Interate over the task list and call into the siggen code |
709 | dealtwith = set() | 715 | dealtwith = set() |
710 | todeal = set(range(len(self.runq_fnid))) | 716 | todeal = set(range(len(self.runq_fnid))) |
@@ -731,12 +737,6 @@ class RunQueueData: | |||
731 | deps.append(depidentifier) | 737 | deps.append(depidentifier) |
732 | self.hash_deps[identifier] = deps | 738 | self.hash_deps[identifier] = deps |
733 | 739 | ||
734 | # Remove stamps for targets if force mode active | ||
735 | if self.cooker.configuration.force: | ||
736 | for (fn, target) in self.target_pairs: | ||
737 | logger.verbose("Remove stamp %s, %s", target, fn) | ||
738 | bb.build.del_stamp(target, self.dataCache, fn) | ||
739 | |||
740 | return len(self.runq_fnid) | 740 | return len(self.runq_fnid) |
741 | 741 | ||
742 | def dump_data(self, taskQueue): | 742 | def dump_data(self, taskQueue): |
diff --git a/bitbake/lib/bb/siggen.py b/bitbake/lib/bb/siggen.py index c4b7c3992e..0fb2642529 100644 --- a/bitbake/lib/bb/siggen.py +++ b/bitbake/lib/bb/siggen.py | |||
@@ -50,6 +50,10 @@ class SignatureGenerator(object): | |||
50 | def dump_sigtask(self, fn, task, stampbase, runtime): | 50 | def dump_sigtask(self, fn, task, stampbase, runtime): |
51 | return | 51 | return |
52 | 52 | ||
53 | def invalidate_task(self, task, d, fn): | ||
54 | bb.build.del_stamp(task, d, fn) | ||
55 | |||
56 | |||
53 | class SignatureGeneratorBasic(SignatureGenerator): | 57 | class SignatureGeneratorBasic(SignatureGenerator): |
54 | """ | 58 | """ |
55 | """ | 59 | """ |
@@ -153,6 +157,15 @@ class SignatureGeneratorBasic(SignatureGenerator): | |||
153 | return False | 157 | return False |
154 | return True | 158 | return True |
155 | 159 | ||
160 | def read_taint(self, fn, task, stampbase): | ||
161 | taint = None | ||
162 | try: | ||
163 | with open(stampbase + '.' + task + '.taint', 'r') as taintf: | ||
164 | taint = taintf.read() | ||
165 | except IOError: | ||
166 | pass | ||
167 | return taint | ||
168 | |||
156 | def get_taskhash(self, fn, task, deps, dataCache): | 169 | def get_taskhash(self, fn, task, deps, dataCache): |
157 | k = fn + "." + task | 170 | k = fn + "." + task |
158 | data = dataCache.basetaskhash[k] | 171 | data = dataCache.basetaskhash[k] |
@@ -173,6 +186,11 @@ class SignatureGeneratorBasic(SignatureGenerator): | |||
173 | for (f,cs) in checksums: | 186 | for (f,cs) in checksums: |
174 | self.file_checksum_values[k][f] = cs | 187 | self.file_checksum_values[k][f] = cs |
175 | data = data + cs | 188 | data = data + cs |
189 | |||
190 | taint = self.read_taint(fn, task, dataCache.stamp[fn]) | ||
191 | if taint: | ||
192 | data = data + taint | ||
193 | |||
176 | h = hashlib.md5(data).hexdigest() | 194 | h = hashlib.md5(data).hexdigest() |
177 | self.taskhash[k] = h | 195 | self.taskhash[k] = h |
178 | #d.setVar("BB_TASKHASH_task-%s" % task, taskhash[task]) | 196 | #d.setVar("BB_TASKHASH_task-%s" % task, taskhash[task]) |
@@ -214,6 +232,10 @@ class SignatureGeneratorBasic(SignatureGenerator): | |||
214 | for dep in data['runtaskdeps']: | 232 | for dep in data['runtaskdeps']: |
215 | data['runtaskhashes'][dep] = self.taskhash[dep] | 233 | data['runtaskhashes'][dep] = self.taskhash[dep] |
216 | 234 | ||
235 | taint = self.read_taint(fn, task, stampbase) | ||
236 | if taint: | ||
237 | data['taint'] = taint | ||
238 | |||
217 | with open(sigfile, "wb") as f: | 239 | with open(sigfile, "wb") as f: |
218 | p = pickle.Pickler(f, -1) | 240 | p = pickle.Pickler(f, -1) |
219 | p.dump(data) | 241 | p.dump(data) |
@@ -245,6 +267,9 @@ class SignatureGeneratorBasicHash(SignatureGeneratorBasic): | |||
245 | h = self.basehash[k] | 267 | h = self.basehash[k] |
246 | return ("%s.%s.%s.%s" % (stampbase, taskname, h, extrainfo)).rstrip('.') | 268 | return ("%s.%s.%s.%s" % (stampbase, taskname, h, extrainfo)).rstrip('.') |
247 | 269 | ||
270 | def invalidate_task(self, task, d, fn): | ||
271 | bb.build.write_taint(task, d, fn) | ||
272 | |||
248 | def dump_this_task(outfile, d): | 273 | def dump_this_task(outfile, d): |
249 | import bb.parse | 274 | import bb.parse |
250 | fn = d.getVar("BB_FILENAME", True) | 275 | fn = d.getVar("BB_FILENAME", True) |
@@ -357,6 +382,13 @@ def compare_sigfiles(a, b): | |||
357 | for dep in changed: | 382 | for dep in changed: |
358 | print "Hash for dependent task %s changed from %s to %s" % (dep, a[dep], b[dep]) | 383 | print "Hash for dependent task %s changed from %s to %s" % (dep, a[dep], b[dep]) |
359 | 384 | ||
385 | |||
386 | a_taint = a_data.get('taint', None) | ||
387 | b_taint = b_data.get('taint', None) | ||
388 | if a_taint != b_taint: | ||
389 | print "Taint (by forced/invalidated task) changed from %s to %s" % (a_taint, b_taint) | ||
390 | |||
391 | |||
360 | def dump_sigfile(a): | 392 | def dump_sigfile(a): |
361 | p1 = pickle.Unpickler(open(a, "rb")) | 393 | p1 = pickle.Unpickler(open(a, "rb")) |
362 | a_data = p1.load() | 394 | a_data = p1.load() |
@@ -384,3 +416,6 @@ def dump_sigfile(a): | |||
384 | if 'runtaskhashes' in a_data: | 416 | if 'runtaskhashes' in a_data: |
385 | for dep in a_data['runtaskhashes']: | 417 | for dep in a_data['runtaskhashes']: |
386 | print "Hash for dependent task %s is %s" % (dep, a_data['runtaskhashes'][dep]) | 418 | print "Hash for dependent task %s is %s" % (dep, a_data['runtaskhashes'][dep]) |
419 | |||
420 | if 'taint' in a_data: | ||
421 | print "Tainted (by forced/invalidated task): %s" % a_data['taint'] | ||