summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/sstatesig.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oe/sstatesig.py')
-rw-r--r--meta/lib/oe/sstatesig.py161
1 files changed, 161 insertions, 0 deletions
diff --git a/meta/lib/oe/sstatesig.py b/meta/lib/oe/sstatesig.py
new file mode 100644
index 0000000000..852fb7e64a
--- /dev/null
+++ b/meta/lib/oe/sstatesig.py
@@ -0,0 +1,161 @@
1import bb.siggen
2
3def sstate_rundepfilter(siggen, fn, recipename, task, dep, depname, dataCache):
4 # Return True if we should keep the dependency, False to drop it
5 def isNative(x):
6 return x.endswith("-native")
7 def isCross(x):
8 return x.endswith("-cross") or x.endswith("-cross-initial") or x.endswith("-cross-intermediate")
9 def isNativeSDK(x):
10 return x.startswith("nativesdk-")
11 def isKernel(fn):
12 inherits = " ".join(dataCache.inherits[fn])
13 return inherits.find("module-base.bbclass") != -1 or inherits.find("linux-kernel-base.bbclass") != -1
14
15 # Always include our own inter-task dependencies
16 if recipename == depname:
17 return True
18
19 # Quilt (patch application) changing isn't likely to affect anything
20 excludelist = ['quilt-native', 'subversion-native', 'git-native']
21 if depname in excludelist and recipename != depname:
22 return False
23
24 # Don't change native/cross/nativesdk recipe dependencies any further
25 if isNative(recipename) or isCross(recipename) or isNativeSDK(recipename):
26 return True
27
28 # Only target packages beyond here
29
30 # Drop native/cross/nativesdk dependencies from target recipes
31 if isNative(depname) or isCross(depname) or isNativeSDK(depname):
32 return False
33
34 # Exclude well defined machine specific configurations which don't change ABI
35 if depname in siggen.abisaferecipes:
36 return False
37
38 # Exclude well defined recipe->dependency
39 if "%s->%s" % (recipename, depname) in siggen.saferecipedeps:
40 return False
41
42 # Kernel modules are well namespaced. We don't want to depend on the kernel's checksum
43 # if we're just doing an RRECOMMENDS_xxx = "kernel-module-*", not least because the checksum
44 # is machine specific.
45 # Therefore if we're not a kernel or a module recipe (inheriting the kernel classes)
46 # and we reccomend a kernel-module, we exclude the dependency.
47 depfn = dep.rsplit(".", 1)[0]
48 if dataCache and isKernel(depfn) and not isKernel(fn):
49 for pkg in dataCache.runrecs[fn]:
50 if " ".join(dataCache.runrecs[fn][pkg]).find("kernel-module-") != -1:
51 return False
52
53 # Default to keep dependencies
54 return True
55
56class SignatureGeneratorOEBasic(bb.siggen.SignatureGeneratorBasic):
57 name = "OEBasic"
58 def init_rundepcheck(self, data):
59 self.abisaferecipes = (data.getVar("SIGGEN_EXCLUDERECIPES_ABISAFE", True) or "").split()
60 self.saferecipedeps = (data.getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS", True) or "").split()
61 pass
62 def rundep_check(self, fn, recipename, task, dep, depname, dataCache = None):
63 return sstate_rundepfilter(self, fn, recipename, task, dep, depname, dataCache)
64
65class SignatureGeneratorOEBasicHash(bb.siggen.SignatureGeneratorBasicHash):
66 name = "OEBasicHash"
67 def init_rundepcheck(self, data):
68 self.abisaferecipes = (data.getVar("SIGGEN_EXCLUDERECIPES_ABISAFE", True) or "").split()
69 self.saferecipedeps = (data.getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS", True) or "").split()
70 pass
71 def rundep_check(self, fn, recipename, task, dep, depname, dataCache = None):
72 return sstate_rundepfilter(self, fn, recipename, task, dep, depname, dataCache)
73
74# Insert these classes into siggen's namespace so it can see and select them
75bb.siggen.SignatureGeneratorOEBasic = SignatureGeneratorOEBasic
76bb.siggen.SignatureGeneratorOEBasicHash = SignatureGeneratorOEBasicHash
77
78
79def find_siginfo(pn, taskname, taskhashlist, d):
80 """ Find signature data files for comparison purposes """
81
82 import fnmatch
83 import glob
84
85 if taskhashlist:
86 hashfiles = {}
87
88 if not taskname:
89 # We have to derive pn and taskname
90 key = pn
91 splitit = key.split('.bb.')
92 taskname = splitit[1]
93 pn = os.path.basename(splitit[0]).split('_')[0]
94 if key.startswith('virtual:native:'):
95 pn = pn + '-native'
96
97 filedates = {}
98
99 # First search in stamps dir
100 localdata = d.createCopy()
101 localdata.setVar('MULTIMACH_TARGET_SYS', '*')
102 localdata.setVar('PN', pn)
103 localdata.setVar('PV', '*')
104 localdata.setVar('PR', '*')
105 localdata.setVar('EXTENDPE', '')
106 stamp = localdata.getVar('STAMP', True)
107 filespec = '%s.%s.sigdata.*' % (stamp, taskname)
108 foundall = False
109 import glob
110 for fullpath in glob.glob(filespec):
111 match = False
112 if taskhashlist:
113 for taskhash in taskhashlist:
114 if fullpath.endswith('.%s' % taskhash):
115 hashfiles[taskhash] = fullpath
116 if len(hashfiles) == len(taskhashlist):
117 foundall = True
118 break
119 else:
120 filedates[fullpath] = os.stat(fullpath).st_mtime
121
122 if len(filedates) < 2 and not foundall:
123 # That didn't work, look in sstate-cache
124 hashes = taskhashlist or ['*']
125 localdata = bb.data.createCopy(d)
126 for hashval in hashes:
127 localdata.setVar('PACKAGE_ARCH', '*')
128 localdata.setVar('TARGET_VENDOR', '*')
129 localdata.setVar('TARGET_OS', '*')
130 localdata.setVar('PN', pn)
131 localdata.setVar('PV', '*')
132 localdata.setVar('PR', '*')
133 localdata.setVar('BB_TASKHASH', hashval)
134 if pn.endswith('-native') or pn.endswith('-crosssdk') or pn.endswith('-cross'):
135 localdata.setVar('SSTATE_EXTRAPATH', "${NATIVELSBSTRING}/")
136 sstatename = d.getVarFlag(taskname, "sstate-name")
137 if not sstatename:
138 sstatename = taskname
139 filespec = '%s_%s.*.siginfo' % (localdata.getVar('SSTATE_PKG', True), sstatename)
140
141 if hashval != '*':
142 sstatedir = "%s/%s" % (d.getVar('SSTATE_DIR', True), hashval[:2])
143 else:
144 sstatedir = d.getVar('SSTATE_DIR', True)
145
146 filedates = {}
147 for root, dirs, files in os.walk(sstatedir):
148 for fn in files:
149 fullpath = os.path.join(root, fn)
150 if fnmatch.fnmatch(fullpath, filespec):
151 if taskhashlist:
152 hashfiles[hashval] = fullpath
153 else:
154 filedates[fullpath] = os.stat(fullpath).st_mtime
155
156 if taskhashlist:
157 return hashfiles
158 else:
159 return filedates
160
161bb.siggen.find_siginfo = find_siginfo