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