Update drivers
[vuplus_openembedded] / classes / packagedata.bbclass
1 def packaged(pkg, d):
2         return os.access(get_subpkgedata_fn(pkg, d) + '.packaged', os.R_OK)
3
4 def read_pkgdatafile(fn):
5         pkgdata = {}
6
7         def decode(str):
8                 import codecs
9                 c = codecs.getdecoder("string_escape")
10                 return c(str)[0]
11
12         if os.access(fn, os.R_OK):
13                 import re
14                 f = file(fn, 'r')
15                 lines = f.readlines()
16                 f.close()
17                 r = re.compile("([^:]+):\s*(.*)")
18                 for l in lines:
19                         m = r.match(l)
20                         if m:
21                                 pkgdata[m.group(1)] = decode(m.group(2))
22
23         return pkgdata
24
25 def get_subpkgedata_fn(pkg, d):
26         archs = bb.data.expand("${PACKAGE_ARCHS}", d).split(" ")
27         archs.reverse()
28         pkgdata = bb.data.expand('${TMPDIR}/pkgdata/', d)
29         targetdir = bb.data.expand('${TARGET_VENDOR}-${TARGET_OS}/runtime/', d)
30         for arch in archs:
31                 fn = pkgdata + arch + targetdir + pkg
32                 if os.path.exists(fn):
33                         return fn
34         return bb.data.expand('${PKGDATA_DIR}/runtime/%s' % pkg, d)
35
36 def has_subpkgdata(pkg, d):
37         return os.access(get_subpkgedata_fn(pkg, d), os.R_OK)
38
39 def read_subpkgdata(pkg, d):
40         return read_pkgdatafile(get_subpkgedata_fn(pkg, d))
41
42 def has_pkgdata(pn, d):
43         fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
44         return os.access(fn, os.R_OK)
45
46 def read_pkgdata(pn, d):
47         fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
48         return read_pkgdatafile(fn)
49
50 python read_subpackage_metadata () {
51         data = read_pkgdata(bb.data.getVar('PN', d, 1), d)
52
53         for key in data.keys():
54                 bb.data.setVar(key, data[key], d)
55
56         for pkg in bb.data.getVar('PACKAGES', d, 1).split():
57                 sdata = read_subpkgdata(pkg, d)
58                 for key in sdata.keys():
59                         bb.data.setVar(key, sdata[key], d)
60 }
61
62
63 #
64 # Collapse FOO_pkg variables into FOO
65 #
66 def read_subpkgdata_dict(pkg, d):
67         ret = {}
68         subd = read_pkgdatafile(get_subpkgedata_fn(pkg, d))
69         for var in subd:
70                 newvar = var.replace("_" + pkg, "")
71                 ret[newvar] = subd[var]
72         return ret
73