diff options
-rw-r--r-- | meta/classes/sstate.bbclass | 3 | ||||
-rw-r--r-- | meta/lib/oe/sstatesig.py | 74 | ||||
-rwxr-xr-x | scripts/gen-lockedsig-cache | 40 |
3 files changed, 117 insertions, 0 deletions
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass index 6f1cfb27d9..d3e251c0bf 100644 --- a/meta/classes/sstate.bbclass +++ b/meta/classes/sstate.bbclass | |||
@@ -713,6 +713,9 @@ def sstate_checkhashes(sq_fn, sq_task, sq_hash, sq_hashfn, d): | |||
713 | evdata['found'].append( (sq_fn[task], sq_task[task], sq_hash[task], sstatefile ) ) | 713 | evdata['found'].append( (sq_fn[task], sq_task[task], sq_hash[task], sstatefile ) ) |
714 | bb.event.fire(bb.event.MetadataEvent("MissedSstate", evdata), d) | 714 | bb.event.fire(bb.event.MetadataEvent("MissedSstate", evdata), d) |
715 | 715 | ||
716 | if hasattr(bb.parse.siggen, "checkhashes"): | ||
717 | bb.parse.siggen.checkhashes(missed, ret, sq_fn, sq_task, sq_hash, sq_hashfn, d) | ||
718 | |||
716 | return ret | 719 | return ret |
717 | 720 | ||
718 | BB_SETSCENE_DEPVALID = "setscene_depvalid" | 721 | BB_SETSCENE_DEPVALID = "setscene_depvalid" |
diff --git a/meta/lib/oe/sstatesig.py b/meta/lib/oe/sstatesig.py index 4188873c20..7b860c5b0d 100644 --- a/meta/lib/oe/sstatesig.py +++ b/meta/lib/oe/sstatesig.py | |||
@@ -61,6 +61,16 @@ def sstate_rundepfilter(siggen, fn, recipename, task, dep, depname, dataCache): | |||
61 | # Default to keep dependencies | 61 | # Default to keep dependencies |
62 | return True | 62 | return True |
63 | 63 | ||
64 | def sstate_lockedsigs(d): | ||
65 | sigs = {} | ||
66 | lockedsigs = (d.getVar("SIGGEN_LOCKEDSIGS", True) or "").split() | ||
67 | for ls in lockedsigs: | ||
68 | pn, task, h = ls.split(":", 2) | ||
69 | if pn not in sigs: | ||
70 | sigs[pn] = {} | ||
71 | sigs[pn][task] = h | ||
72 | return sigs | ||
73 | |||
64 | class SignatureGeneratorOEBasic(bb.siggen.SignatureGeneratorBasic): | 74 | class SignatureGeneratorOEBasic(bb.siggen.SignatureGeneratorBasic): |
65 | name = "OEBasic" | 75 | name = "OEBasic" |
66 | def init_rundepcheck(self, data): | 76 | def init_rundepcheck(self, data): |
@@ -75,10 +85,74 @@ class SignatureGeneratorOEBasicHash(bb.siggen.SignatureGeneratorBasicHash): | |||
75 | def init_rundepcheck(self, data): | 85 | def init_rundepcheck(self, data): |
76 | self.abisaferecipes = (data.getVar("SIGGEN_EXCLUDERECIPES_ABISAFE", True) or "").split() | 86 | self.abisaferecipes = (data.getVar("SIGGEN_EXCLUDERECIPES_ABISAFE", True) or "").split() |
77 | self.saferecipedeps = (data.getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS", True) or "").split() | 87 | self.saferecipedeps = (data.getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS", True) or "").split() |
88 | self.lockedsigs = sstate_lockedsigs(data) | ||
89 | self.lockedhashes = {} | ||
90 | self.lockedpnmap = {} | ||
78 | pass | 91 | pass |
79 | def rundep_check(self, fn, recipename, task, dep, depname, dataCache = None): | 92 | def rundep_check(self, fn, recipename, task, dep, depname, dataCache = None): |
80 | return sstate_rundepfilter(self, fn, recipename, task, dep, depname, dataCache) | 93 | return sstate_rundepfilter(self, fn, recipename, task, dep, depname, dataCache) |
81 | 94 | ||
95 | def get_taskdata(self): | ||
96 | data = super(bb.siggen.SignatureGeneratorBasicHash, self).get_taskdata() | ||
97 | return (data, self.lockedpnmap) | ||
98 | |||
99 | def set_taskdata(self, data): | ||
100 | coredata, self.lockedpnmap = data | ||
101 | super(bb.siggen.SignatureGeneratorBasicHash, self).set_taskdata(coredata) | ||
102 | |||
103 | def dump_sigs(self, dataCache, options): | ||
104 | self.dump_lockedsigs() | ||
105 | return super(bb.siggen.SignatureGeneratorBasicHash, self).dump_sigs(dataCache, options) | ||
106 | |||
107 | def get_taskhash(self, fn, task, deps, dataCache): | ||
108 | recipename = dataCache.pkg_fn[fn] | ||
109 | self.lockedpnmap[fn] = recipename | ||
110 | if recipename in self.lockedsigs: | ||
111 | if task in self.lockedsigs[recipename]: | ||
112 | k = fn + "." + task | ||
113 | h = self.lockedsigs[recipename][task] | ||
114 | self.lockedhashes[k] = h | ||
115 | self.taskhash[k] = h | ||
116 | #bb.warn("Using %s %s %s" % (recipename, task, h)) | ||
117 | return h | ||
118 | h = super(bb.siggen.SignatureGeneratorBasicHash, self).get_taskhash(fn, task, deps, dataCache) | ||
119 | #bb.warn("%s %s %s" % (recipename, task, h)) | ||
120 | return h | ||
121 | |||
122 | def dump_sigtask(self, fn, task, stampbase, runtime): | ||
123 | k = fn + "." + task | ||
124 | if k in self.lockedhashes: | ||
125 | return | ||
126 | super(bb.siggen.SignatureGeneratorBasicHash, self).dump_sigtask(fn, task, stampbase, runtime) | ||
127 | |||
128 | def dump_lockedsigs(self): | ||
129 | bb.plain("Writing locked sigs to " + os.getcwd() + "/locked-sigs.inc") | ||
130 | with open("locked-sigs.inc", "w") as f: | ||
131 | f.write('SIGGEN_LOCKEDSIGS = "\\\n') | ||
132 | #for fn in self.taskdeps: | ||
133 | for k in self.runtaskdeps: | ||
134 | #k = fn + "." + task | ||
135 | fn = k.rsplit(".",1)[0] | ||
136 | task = k.rsplit(".",1)[1] | ||
137 | if k not in self.taskhash: | ||
138 | continue | ||
139 | f.write(" " + self.lockedpnmap[fn] + ":" + task + ":" + self.taskhash[k] + " \\\n") | ||
140 | f.write(' "\n') | ||
141 | |||
142 | def checkhashes(self, missed, ret, sq_fn, sq_task, sq_hash, sq_hashfn, d): | ||
143 | enforce = (d.getVar("SIGGEN_ENFORCE_LOCKEDSIGS", True) or "1") == "1" | ||
144 | msgs = [] | ||
145 | for task in range(len(sq_fn)): | ||
146 | if task not in ret: | ||
147 | for pn in self.lockedsigs: | ||
148 | if sq_hash[task] in self.lockedsigs[pn].itervalues(): | ||
149 | msgs.append("Locked sig is set for %s:%s (%s) yet not in sstate cache?" % (pn, sq_task[task], sq_hash[task])) | ||
150 | if msgs and enforce: | ||
151 | bb.fatal("\n".join(msgs)) | ||
152 | elif msgs: | ||
153 | bb.warn("\n".join(msgs)) | ||
154 | |||
155 | |||
82 | # Insert these classes into siggen's namespace so it can see and select them | 156 | # Insert these classes into siggen's namespace so it can see and select them |
83 | bb.siggen.SignatureGeneratorOEBasic = SignatureGeneratorOEBasic | 157 | bb.siggen.SignatureGeneratorOEBasic = SignatureGeneratorOEBasic |
84 | bb.siggen.SignatureGeneratorOEBasicHash = SignatureGeneratorOEBasicHash | 158 | bb.siggen.SignatureGeneratorOEBasicHash = SignatureGeneratorOEBasicHash |
diff --git a/scripts/gen-lockedsig-cache b/scripts/gen-lockedsig-cache new file mode 100755 index 0000000000..dfb282efd4 --- /dev/null +++ b/scripts/gen-lockedsig-cache | |||
@@ -0,0 +1,40 @@ | |||
1 | #!/usr/bin/env python | ||
2 | # | ||
3 | # gen-lockedsig-cache <locked-sigs.inc> <input-cachedir> <output-cachedir> | ||
4 | # | ||
5 | |||
6 | import os | ||
7 | import sys | ||
8 | import glob | ||
9 | import shutil | ||
10 | import errno | ||
11 | |||
12 | def mkdir(d): | ||
13 | try: | ||
14 | os.makedirs(d) | ||
15 | except OSError as e: | ||
16 | if e.errno != errno.EEXIST: | ||
17 | raise e | ||
18 | |||
19 | if len(sys.argv) < 3: | ||
20 | print("Incorrect number of arguments specified") | ||
21 | sys.exit(1) | ||
22 | |||
23 | sigs = [] | ||
24 | with open(sys.argv[1]) as f: | ||
25 | for l in f.readlines(): | ||
26 | if ":" in l: | ||
27 | sigs.append(l.split(":")[2].split()[0]) | ||
28 | |||
29 | files = set() | ||
30 | for s in sigs: | ||
31 | p = sys.argv[2] + "/" + s[:2] + "/*" + s + "*" | ||
32 | files |= set(glob.glob(p)) | ||
33 | p = sys.argv[2] + "/*/" + s[:2] + "/*" + s + "*" | ||
34 | files |= set(glob.glob(p)) | ||
35 | |||
36 | for f in files: | ||
37 | dst = f.replace(sys.argv[2], sys.argv[3]) | ||
38 | mkdir(os.path.dirname(dst)) | ||
39 | os.link(f, dst) | ||
40 | |||