Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | import bb.siggen |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 2 | import oe |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3 | |
| 4 | def sstate_rundepfilter(siggen, fn, recipename, task, dep, depname, dataCache): |
| 5 | # Return True if we should keep the dependency, False to drop it |
| 6 | def isNative(x): |
| 7 | return x.endswith("-native") |
| 8 | def isCross(x): |
| 9 | return "-cross-" in x |
| 10 | def isNativeSDK(x): |
| 11 | return x.startswith("nativesdk-") |
| 12 | def isKernel(fn): |
| 13 | inherits = " ".join(dataCache.inherits[fn]) |
| 14 | return inherits.find("/module-base.bbclass") != -1 or inherits.find("/linux-kernel-base.bbclass") != -1 |
| 15 | def isPackageGroup(fn): |
| 16 | inherits = " ".join(dataCache.inherits[fn]) |
| 17 | return "/packagegroup.bbclass" in inherits |
| 18 | def isAllArch(fn): |
| 19 | inherits = " ".join(dataCache.inherits[fn]) |
| 20 | return "/allarch.bbclass" in inherits |
| 21 | def isImage(fn): |
| 22 | return "/image.bbclass" in " ".join(dataCache.inherits[fn]) |
| 23 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 24 | # (Almost) always include our own inter-task dependencies. |
| 25 | # The exception is the special do_kernel_configme->do_unpack_and_patch |
| 26 | # dependency from archiver.bbclass. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 27 | if recipename == depname: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 28 | if task == "do_kernel_configme" and dep.endswith(".do_unpack_and_patch"): |
| 29 | return False |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 30 | return True |
| 31 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 32 | # Exclude well defined recipe->dependency |
| 33 | if "%s->%s" % (recipename, depname) in siggen.saferecipedeps: |
| 34 | return False |
| 35 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 36 | # Check for special wildcard |
| 37 | if "*->%s" % depname in siggen.saferecipedeps and recipename != depname: |
| 38 | return False |
| 39 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 | # Don't change native/cross/nativesdk recipe dependencies any further |
| 41 | if isNative(recipename) or isCross(recipename) or isNativeSDK(recipename): |
| 42 | return True |
| 43 | |
| 44 | # Only target packages beyond here |
| 45 | |
| 46 | # allarch packagegroups are assumed to have well behaved names which don't change between architecures/tunes |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 47 | if isPackageGroup(fn) and isAllArch(fn) and not isNative(depname): |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 48 | return False |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 49 | |
| 50 | # Exclude well defined machine specific configurations which don't change ABI |
| 51 | if depname in siggen.abisaferecipes and not isImage(fn): |
| 52 | return False |
| 53 | |
| 54 | # Kernel modules are well namespaced. We don't want to depend on the kernel's checksum |
| 55 | # if we're just doing an RRECOMMENDS_xxx = "kernel-module-*", not least because the checksum |
| 56 | # is machine specific. |
| 57 | # Therefore if we're not a kernel or a module recipe (inheriting the kernel classes) |
| 58 | # and we reccomend a kernel-module, we exclude the dependency. |
| 59 | depfn = dep.rsplit(".", 1)[0] |
| 60 | if dataCache and isKernel(depfn) and not isKernel(fn): |
| 61 | for pkg in dataCache.runrecs[fn]: |
| 62 | if " ".join(dataCache.runrecs[fn][pkg]).find("kernel-module-") != -1: |
| 63 | return False |
| 64 | |
| 65 | # Default to keep dependencies |
| 66 | return True |
| 67 | |
| 68 | def sstate_lockedsigs(d): |
| 69 | sigs = {} |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 70 | types = (d.getVar("SIGGEN_LOCKEDSIGS_TYPES") or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 71 | for t in types: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 72 | siggen_lockedsigs_var = "SIGGEN_LOCKEDSIGS_%s" % t |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 73 | lockedsigs = (d.getVar(siggen_lockedsigs_var) or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 74 | for ls in lockedsigs: |
| 75 | pn, task, h = ls.split(":", 2) |
| 76 | if pn not in sigs: |
| 77 | sigs[pn] = {} |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 78 | sigs[pn][task] = [h, siggen_lockedsigs_var] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 79 | return sigs |
| 80 | |
| 81 | class SignatureGeneratorOEBasic(bb.siggen.SignatureGeneratorBasic): |
| 82 | name = "OEBasic" |
| 83 | def init_rundepcheck(self, data): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 84 | self.abisaferecipes = (data.getVar("SIGGEN_EXCLUDERECIPES_ABISAFE") or "").split() |
| 85 | self.saferecipedeps = (data.getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS") or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 86 | pass |
| 87 | def rundep_check(self, fn, recipename, task, dep, depname, dataCache = None): |
| 88 | return sstate_rundepfilter(self, fn, recipename, task, dep, depname, dataCache) |
| 89 | |
| 90 | class SignatureGeneratorOEBasicHash(bb.siggen.SignatureGeneratorBasicHash): |
| 91 | name = "OEBasicHash" |
| 92 | def init_rundepcheck(self, data): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 93 | self.abisaferecipes = (data.getVar("SIGGEN_EXCLUDERECIPES_ABISAFE") or "").split() |
| 94 | self.saferecipedeps = (data.getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS") or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 95 | self.lockedsigs = sstate_lockedsigs(data) |
| 96 | self.lockedhashes = {} |
| 97 | self.lockedpnmap = {} |
| 98 | self.lockedhashfn = {} |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 99 | self.machine = data.getVar("MACHINE") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 100 | self.mismatch_msgs = [] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 101 | self.unlockedrecipes = (data.getVar("SIGGEN_UNLOCKED_RECIPES") or |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 102 | "").split() |
| 103 | self.unlockedrecipes = { k: "" for k in self.unlockedrecipes } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 104 | pass |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 105 | |
| 106 | def tasks_resolved(self, virtmap, virtpnmap, dataCache): |
| 107 | # Translate virtual/xxx entries to PN values |
| 108 | newabisafe = [] |
| 109 | for a in self.abisaferecipes: |
| 110 | if a in virtpnmap: |
| 111 | newabisafe.append(virtpnmap[a]) |
| 112 | else: |
| 113 | newabisafe.append(a) |
| 114 | self.abisaferecipes = newabisafe |
| 115 | newsafedeps = [] |
| 116 | for a in self.saferecipedeps: |
| 117 | a1, a2 = a.split("->") |
| 118 | if a1 in virtpnmap: |
| 119 | a1 = virtpnmap[a1] |
| 120 | if a2 in virtpnmap: |
| 121 | a2 = virtpnmap[a2] |
| 122 | newsafedeps.append(a1 + "->" + a2) |
| 123 | self.saferecipedeps = newsafedeps |
| 124 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 125 | def rundep_check(self, fn, recipename, task, dep, depname, dataCache = None): |
| 126 | return sstate_rundepfilter(self, fn, recipename, task, dep, depname, dataCache) |
| 127 | |
| 128 | def get_taskdata(self): |
| 129 | data = super(bb.siggen.SignatureGeneratorBasicHash, self).get_taskdata() |
| 130 | return (data, self.lockedpnmap, self.lockedhashfn) |
| 131 | |
| 132 | def set_taskdata(self, data): |
| 133 | coredata, self.lockedpnmap, self.lockedhashfn = data |
| 134 | super(bb.siggen.SignatureGeneratorBasicHash, self).set_taskdata(coredata) |
| 135 | |
| 136 | def dump_sigs(self, dataCache, options): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 137 | sigfile = os.getcwd() + "/locked-sigs.inc" |
| 138 | bb.plain("Writing locked sigs to %s" % sigfile) |
| 139 | self.dump_lockedsigs(sigfile) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 140 | return super(bb.siggen.SignatureGeneratorBasicHash, self).dump_sigs(dataCache, options) |
| 141 | |
| 142 | def get_taskhash(self, fn, task, deps, dataCache): |
| 143 | h = super(bb.siggen.SignatureGeneratorBasicHash, self).get_taskhash(fn, task, deps, dataCache) |
| 144 | |
| 145 | recipename = dataCache.pkg_fn[fn] |
| 146 | self.lockedpnmap[fn] = recipename |
| 147 | self.lockedhashfn[fn] = dataCache.hashfn[fn] |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 148 | |
| 149 | unlocked = False |
| 150 | if recipename in self.unlockedrecipes: |
| 151 | unlocked = True |
| 152 | else: |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 153 | def get_mc(tid): |
| 154 | tid = tid.rsplit('.', 1)[0] |
| 155 | if tid.startswith('multiconfig:'): |
| 156 | elems = tid.split(':') |
| 157 | return elems[1] |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 158 | def recipename_from_dep(dep): |
| 159 | # The dep entry will look something like |
| 160 | # /path/path/recipename.bb.task, virtual:native:/p/foo.bb.task, |
| 161 | # ... |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 162 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 163 | fn = dep.rsplit('.', 1)[0] |
| 164 | return dataCache.pkg_fn[fn] |
| 165 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 166 | mc = get_mc(fn) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 167 | # If any unlocked recipe is in the direct dependencies then the |
| 168 | # current recipe should be unlocked as well. |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 169 | depnames = [ recipename_from_dep(x) for x in deps if mc == get_mc(x)] |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 170 | if any(x in y for y in depnames for x in self.unlockedrecipes): |
| 171 | self.unlockedrecipes[recipename] = '' |
| 172 | unlocked = True |
| 173 | |
| 174 | if not unlocked and recipename in self.lockedsigs: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 175 | if task in self.lockedsigs[recipename]: |
| 176 | k = fn + "." + task |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 177 | h_locked = self.lockedsigs[recipename][task][0] |
| 178 | var = self.lockedsigs[recipename][task][1] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 179 | self.lockedhashes[k] = h_locked |
| 180 | self.taskhash[k] = h_locked |
| 181 | #bb.warn("Using %s %s %s" % (recipename, task, h)) |
| 182 | |
| 183 | if h != h_locked: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 184 | self.mismatch_msgs.append('The %s:%s sig is computed to be %s, but the sig is locked to %s in %s' |
| 185 | % (recipename, task, h, h_locked, var)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 186 | |
| 187 | return h_locked |
| 188 | #bb.warn("%s %s %s" % (recipename, task, h)) |
| 189 | return h |
| 190 | |
| 191 | def dump_sigtask(self, fn, task, stampbase, runtime): |
| 192 | k = fn + "." + task |
| 193 | if k in self.lockedhashes: |
| 194 | return |
| 195 | super(bb.siggen.SignatureGeneratorBasicHash, self).dump_sigtask(fn, task, stampbase, runtime) |
| 196 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 197 | def dump_lockedsigs(self, sigfile, taskfilter=None): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 198 | types = {} |
| 199 | for k in self.runtaskdeps: |
| 200 | if taskfilter: |
| 201 | if not k in taskfilter: |
| 202 | continue |
| 203 | fn = k.rsplit(".",1)[0] |
| 204 | t = self.lockedhashfn[fn].split(" ")[1].split(":")[5] |
| 205 | t = 't-' + t.replace('_', '-') |
| 206 | if t not in types: |
| 207 | types[t] = [] |
| 208 | types[t].append(k) |
| 209 | |
| 210 | with open(sigfile, "w") as f: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 211 | l = sorted(types) |
| 212 | for t in l: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 213 | f.write('SIGGEN_LOCKEDSIGS_%s = "\\\n' % t) |
| 214 | types[t].sort() |
| 215 | sortedk = sorted(types[t], key=lambda k: self.lockedpnmap[k.rsplit(".",1)[0]]) |
| 216 | for k in sortedk: |
| 217 | fn = k.rsplit(".",1)[0] |
| 218 | task = k.rsplit(".",1)[1] |
| 219 | if k not in self.taskhash: |
| 220 | continue |
| 221 | f.write(" " + self.lockedpnmap[fn] + ":" + task + ":" + self.taskhash[k] + " \\\n") |
| 222 | f.write(' "\n') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 223 | f.write('SIGGEN_LOCKEDSIGS_TYPES_%s = "%s"' % (self.machine, " ".join(l))) |
| 224 | |
| 225 | def dump_siglist(self, sigfile): |
| 226 | with open(sigfile, "w") as f: |
| 227 | tasks = [] |
| 228 | for taskitem in self.taskhash: |
| 229 | (fn, task) = taskitem.rsplit(".", 1) |
| 230 | pn = self.lockedpnmap[fn] |
| 231 | tasks.append((pn, task, fn, self.taskhash[taskitem])) |
| 232 | for (pn, task, fn, taskhash) in sorted(tasks): |
| 233 | f.write('%s.%s %s %s\n' % (pn, task, fn, taskhash)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 234 | |
| 235 | def checkhashes(self, missed, ret, sq_fn, sq_task, sq_hash, sq_hashfn, d): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 236 | warn_msgs = [] |
| 237 | error_msgs = [] |
| 238 | sstate_missing_msgs = [] |
| 239 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 240 | for task in range(len(sq_fn)): |
| 241 | if task not in ret: |
| 242 | for pn in self.lockedsigs: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 243 | if sq_hash[task] in iter(self.lockedsigs[pn].values()): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 244 | if sq_task[task] == 'do_shared_workdir': |
| 245 | continue |
| 246 | sstate_missing_msgs.append("Locked sig is set for %s:%s (%s) yet not in sstate cache?" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 247 | % (pn, sq_task[task], sq_hash[task])) |
| 248 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 249 | checklevel = d.getVar("SIGGEN_LOCKEDSIGS_TASKSIG_CHECK") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 250 | if checklevel == 'warn': |
| 251 | warn_msgs += self.mismatch_msgs |
| 252 | elif checklevel == 'error': |
| 253 | error_msgs += self.mismatch_msgs |
| 254 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 255 | checklevel = d.getVar("SIGGEN_LOCKEDSIGS_SSTATE_EXISTS_CHECK") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 256 | if checklevel == 'warn': |
| 257 | warn_msgs += sstate_missing_msgs |
| 258 | elif checklevel == 'error': |
| 259 | error_msgs += sstate_missing_msgs |
| 260 | |
| 261 | if warn_msgs: |
| 262 | bb.warn("\n".join(warn_msgs)) |
| 263 | if error_msgs: |
| 264 | bb.fatal("\n".join(error_msgs)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 265 | |
| 266 | |
| 267 | # Insert these classes into siggen's namespace so it can see and select them |
| 268 | bb.siggen.SignatureGeneratorOEBasic = SignatureGeneratorOEBasic |
| 269 | bb.siggen.SignatureGeneratorOEBasicHash = SignatureGeneratorOEBasicHash |
| 270 | |
| 271 | |
| 272 | def find_siginfo(pn, taskname, taskhashlist, d): |
| 273 | """ Find signature data files for comparison purposes """ |
| 274 | |
| 275 | import fnmatch |
| 276 | import glob |
| 277 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 278 | if not taskname: |
| 279 | # We have to derive pn and taskname |
| 280 | key = pn |
| 281 | splitit = key.split('.bb.') |
| 282 | taskname = splitit[1] |
| 283 | pn = os.path.basename(splitit[0]).split('_')[0] |
| 284 | if key.startswith('virtual:native:'): |
| 285 | pn = pn + '-native' |
| 286 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 287 | hashfiles = {} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 288 | filedates = {} |
| 289 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 290 | def get_hashval(siginfo): |
| 291 | if siginfo.endswith('.siginfo'): |
| 292 | return siginfo.rpartition(':')[2].partition('_')[0] |
| 293 | else: |
| 294 | return siginfo.rpartition('.')[2] |
| 295 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 296 | # First search in stamps dir |
| 297 | localdata = d.createCopy() |
| 298 | localdata.setVar('MULTIMACH_TARGET_SYS', '*') |
| 299 | localdata.setVar('PN', pn) |
| 300 | localdata.setVar('PV', '*') |
| 301 | localdata.setVar('PR', '*') |
| 302 | localdata.setVar('EXTENDPE', '') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 303 | stamp = localdata.getVar('STAMP') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 304 | if pn.startswith("gcc-source"): |
| 305 | # gcc-source shared workdir is a special case :( |
| 306 | stamp = localdata.expand("${STAMPS_DIR}/work-shared/gcc-${PV}-${PR}") |
| 307 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 308 | filespec = '%s.%s.sigdata.*' % (stamp, taskname) |
| 309 | foundall = False |
| 310 | import glob |
| 311 | for fullpath in glob.glob(filespec): |
| 312 | match = False |
| 313 | if taskhashlist: |
| 314 | for taskhash in taskhashlist: |
| 315 | if fullpath.endswith('.%s' % taskhash): |
| 316 | hashfiles[taskhash] = fullpath |
| 317 | if len(hashfiles) == len(taskhashlist): |
| 318 | foundall = True |
| 319 | break |
| 320 | else: |
| 321 | try: |
| 322 | filedates[fullpath] = os.stat(fullpath).st_mtime |
| 323 | except OSError: |
| 324 | continue |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 325 | hashval = get_hashval(fullpath) |
| 326 | hashfiles[hashval] = fullpath |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 327 | |
| 328 | if not taskhashlist or (len(filedates) < 2 and not foundall): |
| 329 | # That didn't work, look in sstate-cache |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 330 | hashes = taskhashlist or ['?' * 32] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 331 | localdata = bb.data.createCopy(d) |
| 332 | for hashval in hashes: |
| 333 | localdata.setVar('PACKAGE_ARCH', '*') |
| 334 | localdata.setVar('TARGET_VENDOR', '*') |
| 335 | localdata.setVar('TARGET_OS', '*') |
| 336 | localdata.setVar('PN', pn) |
| 337 | localdata.setVar('PV', '*') |
| 338 | localdata.setVar('PR', '*') |
| 339 | localdata.setVar('BB_TASKHASH', hashval) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 340 | swspec = localdata.getVar('SSTATE_SWSPEC') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 341 | if taskname in ['do_fetch', 'do_unpack', 'do_patch', 'do_populate_lic', 'do_preconfigure'] and swspec: |
| 342 | localdata.setVar('SSTATE_PKGSPEC', '${SSTATE_SWSPEC}') |
| 343 | elif pn.endswith('-native') or "-cross-" in pn or "-crosssdk-" in pn: |
| 344 | localdata.setVar('SSTATE_EXTRAPATH', "${NATIVELSBSTRING}/") |
| 345 | sstatename = taskname[3:] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 346 | filespec = '%s_%s.*.siginfo' % (localdata.getVar('SSTATE_PKG'), sstatename) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 347 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 348 | matchedfiles = glob.glob(filespec) |
| 349 | for fullpath in matchedfiles: |
| 350 | actual_hashval = get_hashval(fullpath) |
| 351 | if actual_hashval in hashfiles: |
| 352 | continue |
| 353 | hashfiles[hashval] = fullpath |
| 354 | if not taskhashlist: |
| 355 | try: |
| 356 | filedates[fullpath] = os.stat(fullpath).st_mtime |
| 357 | except: |
| 358 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 359 | |
| 360 | if taskhashlist: |
| 361 | return hashfiles |
| 362 | else: |
| 363 | return filedates |
| 364 | |
| 365 | bb.siggen.find_siginfo = find_siginfo |
| 366 | |
| 367 | |
| 368 | def sstate_get_manifest_filename(task, d): |
| 369 | """ |
| 370 | Return the sstate manifest file path for a particular task. |
| 371 | Also returns the datastore that can be used to query related variables. |
| 372 | """ |
| 373 | d2 = d.createCopy() |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 374 | extrainf = d.getVarFlag("do_" + task, 'stamp-extra-info') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 375 | if extrainf: |
| 376 | d2.setVar("SSTATE_MANMACH", extrainf) |
| 377 | return (d2.expand("${SSTATE_MANFILEPREFIX}.%s" % task), d2) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 378 | |
| 379 | def find_sstate_manifest(taskdata, taskdata2, taskname, d, multilibcache): |
| 380 | d2 = d |
| 381 | variant = '' |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 382 | curr_variant = '' |
| 383 | if d.getVar("BBEXTENDCURR") == "multilib": |
| 384 | curr_variant = d.getVar("BBEXTENDVARIANT") |
| 385 | if "virtclass-multilib" not in d.getVar("OVERRIDES"): |
| 386 | curr_variant = "invalid" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 387 | if taskdata2.startswith("virtual:multilib"): |
| 388 | variant = taskdata2.split(":")[2] |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 389 | if curr_variant != variant: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 390 | if variant not in multilibcache: |
| 391 | multilibcache[variant] = oe.utils.get_multilib_datastore(variant, d) |
| 392 | d2 = multilibcache[variant] |
| 393 | |
| 394 | if taskdata.endswith("-native"): |
| 395 | pkgarchs = ["${BUILD_ARCH}"] |
| 396 | elif taskdata.startswith("nativesdk-"): |
| 397 | pkgarchs = ["${SDK_ARCH}_${SDK_OS}", "allarch"] |
| 398 | elif "-cross-canadian" in taskdata: |
| 399 | pkgarchs = ["${SDK_ARCH}_${SDK_ARCH}-${SDKPKGSUFFIX}"] |
| 400 | elif "-cross-" in taskdata: |
| 401 | pkgarchs = ["${BUILD_ARCH}_${TARGET_ARCH}"] |
| 402 | elif "-crosssdk" in taskdata: |
| 403 | pkgarchs = ["${BUILD_ARCH}_${SDK_ARCH}_${SDK_OS}"] |
| 404 | else: |
| 405 | pkgarchs = ['${MACHINE_ARCH}'] |
| 406 | pkgarchs = pkgarchs + list(reversed(d2.getVar("PACKAGE_EXTRA_ARCHS").split())) |
| 407 | pkgarchs.append('allarch') |
| 408 | pkgarchs.append('${SDK_ARCH}_${SDK_ARCH}-${SDKPKGSUFFIX}') |
| 409 | |
| 410 | for pkgarch in pkgarchs: |
| 411 | manifest = d2.expand("${SSTATE_MANIFESTS}/manifest-%s-%s.%s" % (pkgarch, taskdata, taskname)) |
| 412 | if os.path.exists(manifest): |
| 413 | return manifest, d2 |
| 414 | bb.warn("Manifest %s not found in %s (variant '%s')?" % (manifest, d2.expand(" ".join(pkgarchs)), variant)) |
| 415 | return None, d2 |
| 416 | |
| 417 | |