diff options
author | Hongxu Jia <hongxu.jia@windriver.com> | 2014-09-11 16:30:16 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-09-17 22:00:25 +0100 |
commit | abf0e7e53fd645494b545f002762c3ce5ad407d4 (patch) | |
tree | 52a58288ed0e28214fe125199ea4a873d3bcc1c3 /meta/lib/oe | |
parent | a08d7dc9b2aca452b61ef8d1215aaf2497396e27 (diff) | |
download | poky-abf0e7e53fd645494b545f002762c3ce5ad407d4.tar.gz |
sstatesig: Improve the support for locked down sstate cache usage
Add code in the sstate hash validation code to ensure it really did
install these from sstate since if it didn't should to warn/abort
the build. The judgment condition is:
1) If a build is replaced by locked sstate-cache, it will triger a
warn/error;
2) If objects are not used from the locked cache, it will triger a
warn/error;
3) Use SIGGEN_LOCKEDSIGS_CHECK_LEVEL variable controls whether this
is just a warning or a fatal error or nothing to report.
[YOCTO #6639]
(From OE-Core rev: 305912dce61c4fed0cbf631aa98a9e6f29db88e4)
(From OE-Core rev: 1683815695f39d4bad352348913f927ac8a1bcf5)
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe')
-rw-r--r-- | meta/lib/oe/sstatesig.py | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/meta/lib/oe/sstatesig.py b/meta/lib/oe/sstatesig.py index add26193bc..a108761972 100644 --- a/meta/lib/oe/sstatesig.py +++ b/meta/lib/oe/sstatesig.py | |||
@@ -92,6 +92,7 @@ class SignatureGeneratorOEBasicHash(bb.siggen.SignatureGeneratorBasicHash): | |||
92 | self.lockedpnmap = {} | 92 | self.lockedpnmap = {} |
93 | self.lockedhashfn = {} | 93 | self.lockedhashfn = {} |
94 | self.machine = data.getVar("MACHINE", True) | 94 | self.machine = data.getVar("MACHINE", True) |
95 | self.mismatch_msgs = [] | ||
95 | pass | 96 | pass |
96 | def rundep_check(self, fn, recipename, task, dep, depname, dataCache = None): | 97 | def rundep_check(self, fn, recipename, task, dep, depname, dataCache = None): |
97 | return sstate_rundepfilter(self, fn, recipename, task, dep, depname, dataCache) | 98 | return sstate_rundepfilter(self, fn, recipename, task, dep, depname, dataCache) |
@@ -109,18 +110,24 @@ class SignatureGeneratorOEBasicHash(bb.siggen.SignatureGeneratorBasicHash): | |||
109 | return super(bb.siggen.SignatureGeneratorBasicHash, self).dump_sigs(dataCache, options) | 110 | return super(bb.siggen.SignatureGeneratorBasicHash, self).dump_sigs(dataCache, options) |
110 | 111 | ||
111 | def get_taskhash(self, fn, task, deps, dataCache): | 112 | def get_taskhash(self, fn, task, deps, dataCache): |
113 | h = super(bb.siggen.SignatureGeneratorBasicHash, self).get_taskhash(fn, task, deps, dataCache) | ||
114 | |||
112 | recipename = dataCache.pkg_fn[fn] | 115 | recipename = dataCache.pkg_fn[fn] |
113 | self.lockedpnmap[fn] = recipename | 116 | self.lockedpnmap[fn] = recipename |
114 | self.lockedhashfn[fn] = dataCache.hashfn[fn] | 117 | self.lockedhashfn[fn] = dataCache.hashfn[fn] |
115 | if recipename in self.lockedsigs: | 118 | if recipename in self.lockedsigs: |
116 | if task in self.lockedsigs[recipename]: | 119 | if task in self.lockedsigs[recipename]: |
117 | k = fn + "." + task | 120 | k = fn + "." + task |
118 | h = self.lockedsigs[recipename][task] | 121 | h_locked = self.lockedsigs[recipename][task] |
119 | self.lockedhashes[k] = h | 122 | self.lockedhashes[k] = h_locked |
120 | self.taskhash[k] = h | 123 | self.taskhash[k] = h_locked |
121 | #bb.warn("Using %s %s %s" % (recipename, task, h)) | 124 | #bb.warn("Using %s %s %s" % (recipename, task, h)) |
122 | return h | 125 | |
123 | h = super(bb.siggen.SignatureGeneratorBasicHash, self).get_taskhash(fn, task, deps, dataCache) | 126 | if h != h_locked: |
127 | self.mismatch_msgs.append('The %s:%s sig (%s) changed, use locked sig %s to instead' | ||
128 | % (recipename, task, h, h_locked)) | ||
129 | |||
130 | return h_locked | ||
124 | #bb.warn("%s %s %s" % (recipename, task, h)) | 131 | #bb.warn("%s %s %s" % (recipename, task, h)) |
125 | return h | 132 | return h |
126 | 133 | ||
@@ -130,8 +137,11 @@ class SignatureGeneratorOEBasicHash(bb.siggen.SignatureGeneratorBasicHash): | |||
130 | return | 137 | return |
131 | super(bb.siggen.SignatureGeneratorBasicHash, self).dump_sigtask(fn, task, stampbase, runtime) | 138 | super(bb.siggen.SignatureGeneratorBasicHash, self).dump_sigtask(fn, task, stampbase, runtime) |
132 | 139 | ||
133 | def dump_lockedsigs(self): | 140 | def dump_lockedsigs(self, sigfile=None): |
134 | bb.plain("Writing locked sigs to " + os.getcwd() + "/locked-sigs.inc") | 141 | if not sigfile: |
142 | sigfile = os.getcwd() + "/locked-sigs.inc" | ||
143 | |||
144 | bb.plain("Writing locked sigs to %s" % sigfile) | ||
135 | types = {} | 145 | types = {} |
136 | for k in self.runtaskdeps: | 146 | for k in self.runtaskdeps: |
137 | fn = k.rsplit(".",1)[0] | 147 | fn = k.rsplit(".",1)[0] |
@@ -140,11 +150,11 @@ class SignatureGeneratorOEBasicHash(bb.siggen.SignatureGeneratorBasicHash): | |||
140 | types[t] = [] | 150 | types[t] = [] |
141 | types[t].append(k) | 151 | types[t].append(k) |
142 | 152 | ||
143 | with open("locked-sigs.inc", "w") as f: | 153 | with open(sigfile, "w") as f: |
144 | for t in types: | 154 | for t in types: |
145 | f.write('SIGGEN_LOCKEDSIGS_%s = "\\\n' % t) | 155 | f.write('SIGGEN_LOCKEDSIGS_%s = "\\\n' % t) |
146 | types[t].sort() | 156 | types[t].sort() |
147 | sortedk = sorted(types[t], key=lambda k: self.lockedpnmap[k.rsplit(".",1)[0]]) | 157 | sortedk = sorted(types[t], key=lambda k: self.lockedpnmap[k.rsplit(".",1)[0]]) |
148 | for k in sortedk: | 158 | for k in sortedk: |
149 | fn = k.rsplit(".",1)[0] | 159 | fn = k.rsplit(".",1)[0] |
150 | task = k.rsplit(".",1)[1] | 160 | task = k.rsplit(".",1)[1] |
@@ -155,17 +165,18 @@ class SignatureGeneratorOEBasicHash(bb.siggen.SignatureGeneratorBasicHash): | |||
155 | f.write('SIGGEN_LOCKEDSIGS_TYPES_%s = "%s"' % (self.machine, " ".join(types.keys()))) | 165 | f.write('SIGGEN_LOCKEDSIGS_TYPES_%s = "%s"' % (self.machine, " ".join(types.keys()))) |
156 | 166 | ||
157 | def checkhashes(self, missed, ret, sq_fn, sq_task, sq_hash, sq_hashfn, d): | 167 | def checkhashes(self, missed, ret, sq_fn, sq_task, sq_hash, sq_hashfn, d): |
158 | enforce = (d.getVar("SIGGEN_ENFORCE_LOCKEDSIGS", True) or "1") == "1" | 168 | checklevel = d.getVar("SIGGEN_LOCKEDSIGS_CHECK_LEVEL", True) |
159 | msgs = [] | ||
160 | for task in range(len(sq_fn)): | 169 | for task in range(len(sq_fn)): |
161 | if task not in ret: | 170 | if task not in ret: |
162 | for pn in self.lockedsigs: | 171 | for pn in self.lockedsigs: |
163 | if sq_hash[task] in self.lockedsigs[pn].itervalues(): | 172 | if sq_hash[task] in self.lockedsigs[pn].itervalues(): |
164 | msgs.append("Locked sig is set for %s:%s (%s) yet not in sstate cache?" % (pn, sq_task[task], sq_hash[task])) | 173 | self.mismatch_msgs.append("Locked sig is set for %s:%s (%s) yet not in sstate cache?" |
165 | if msgs and enforce: | 174 | % (pn, sq_task[task], sq_hash[task])) |
166 | bb.fatal("\n".join(msgs)) | 175 | |
167 | elif msgs: | 176 | if self.mismatch_msgs and checklevel == 'warn': |
168 | bb.warn("\n".join(msgs)) | 177 | bb.warn("\n".join(self.mismatch_msgs)) |
178 | elif self.mismatch_msgs and checklevel == 'error': | ||
179 | bb.fatal("\n".join(self.mismatch_msgs)) | ||
169 | 180 | ||
170 | 181 | ||
171 | # Insert these classes into siggen's namespace so it can see and select them | 182 | # Insert these classes into siggen's namespace so it can see and select them |