diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2012-08-27 20:45:14 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-09-10 13:03:55 +0100 |
commit | 27f842eba51cc4e2ad9faffbcef347a9d3717952 (patch) | |
tree | 3b42e61b2808a71824441e8961998d979440e961 /meta | |
parent | 950c85e398c53c8b4f00f1728e947f339dd37e7b (diff) | |
download | poky-27f842eba51cc4e2ad9faffbcef347a9d3717952.tar.gz |
lib/oe/sstatesig.py: add signature data query function
Add a function that can be used from BitBake code which will find
signature data (sigdata/siginfo) files based on specified criteria, and
hook it into BitBake as bb.siggen.find_siginfo.
(From OE-Core rev: 9f0453c29891e32f8038c4bbc22ada28bfbf818a)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oe/sstatesig.py | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/meta/lib/oe/sstatesig.py b/meta/lib/oe/sstatesig.py index 50b4027bd6..39f9ccf77e 100644 --- a/meta/lib/oe/sstatesig.py +++ b/meta/lib/oe/sstatesig.py | |||
@@ -74,3 +74,84 @@ class SignatureGeneratorOEBasicHash(bb.siggen.SignatureGeneratorBasicHash): | |||
74 | # Insert these classes into siggen's namespace so it can see and select them | 74 | # Insert these classes into siggen's namespace so it can see and select them |
75 | bb.siggen.SignatureGeneratorOEBasic = SignatureGeneratorOEBasic | 75 | bb.siggen.SignatureGeneratorOEBasic = SignatureGeneratorOEBasic |
76 | bb.siggen.SignatureGeneratorOEBasicHash = SignatureGeneratorOEBasicHash | 76 | bb.siggen.SignatureGeneratorOEBasicHash = SignatureGeneratorOEBasicHash |
77 | |||
78 | |||
79 | def find_siginfo(pn, taskname, taskhashlist, d): | ||
80 | """ Find signature data files for comparison purposes """ | ||
81 | |||
82 | import fnmatch | ||
83 | |||
84 | if taskhashlist: | ||
85 | hashfiles = {} | ||
86 | |||
87 | if not taskname: | ||
88 | # We have to derive pn and taskname | ||
89 | key = pn | ||
90 | splitit = key.split('.bb.') | ||
91 | taskname = splitit[1] | ||
92 | pn = os.path.basename(splitit[0]).split('_')[0] | ||
93 | if key.startswith('virtual:native:'): | ||
94 | pn = pn + '-native' | ||
95 | |||
96 | # First search in stamps dir | ||
97 | stampdir = d.getVar('TMPDIR', True) + '/stamps' | ||
98 | filespec = '%s-*.%s.sigdata.*' % (pn, taskname) | ||
99 | filedates = {} | ||
100 | foundall = False | ||
101 | for root, dirs, files in os.walk(stampdir): | ||
102 | for fn in files: | ||
103 | if fnmatch.fnmatch(fn, filespec): | ||
104 | fullpath = os.path.join(root, fn) | ||
105 | match = False | ||
106 | if taskhashlist: | ||
107 | for taskhash in taskhashlist: | ||
108 | if fn.endswith('.%s' % taskhash): | ||
109 | hashfiles[taskhash] = fullpath | ||
110 | if len(hashfiles) == len(taskhashlist): | ||
111 | foundall = True | ||
112 | break | ||
113 | else: | ||
114 | filedates[fullpath] = os.stat(fullpath).st_mtime | ||
115 | if foundall: | ||
116 | break | ||
117 | |||
118 | if len(filedates) < 2 and not foundall: | ||
119 | # That didn't work, look in sstate-cache | ||
120 | hashes = taskhashlist or ['*'] | ||
121 | localdata = bb.data.createCopy(d) | ||
122 | for hashval in hashes: | ||
123 | localdata.setVar('PACKAGE_ARCH', '*') | ||
124 | localdata.setVar('TARGET_VENDOR', '*') | ||
125 | localdata.setVar('TARGET_OS', '*') | ||
126 | localdata.setVar('PN', pn) | ||
127 | localdata.setVar('PV', '*') | ||
128 | localdata.setVar('PR', '*') | ||
129 | localdata.setVar('BB_TASKHASH', hashval) | ||
130 | if pn.endswith('-native') or pn.endswith('-crosssdk') or pn.endswith('-cross'): | ||
131 | localdata.setVar('SSTATE_EXTRAPATH', "${NATIVELSBSTRING}/") | ||
132 | sstatename = d.getVarFlag(taskname, "sstate-name") | ||
133 | if not sstatename: | ||
134 | sstatename = taskname | ||
135 | filespec = '%s_%s.*.siginfo' % (localdata.getVar('SSTATE_PKG', True), sstatename) | ||
136 | |||
137 | if hashval != '*': | ||
138 | sstatedir = "%s/%s" % (d.getVar('SSTATE_DIR', True), hashval[:2]) | ||
139 | else: | ||
140 | sstatedir = d.getVar('SSTATE_DIR', True) | ||
141 | |||
142 | filedates = {} | ||
143 | for root, dirs, files in os.walk(sstatedir): | ||
144 | for fn in files: | ||
145 | fullpath = os.path.join(root, fn) | ||
146 | if fnmatch.fnmatch(fullpath, filespec): | ||
147 | if taskhashlist: | ||
148 | hashfiles[hashval] = fullpath | ||
149 | else: | ||
150 | filedates[fullpath] = os.stat(fullpath).st_mtime | ||
151 | |||
152 | if taskhashlist: | ||
153 | return hashfiles | ||
154 | else: | ||
155 | return filedates | ||
156 | |||
157 | bb.siggen.find_siginfo = find_siginfo | ||