summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/base.bbclass82
-rw-r--r--meta/classes/package.bbclass2
-rw-r--r--meta/classes/packagedata.bbclass82
3 files changed, 84 insertions, 82 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 5f83af1fa3..0a5facf6e3 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -955,88 +955,6 @@ def explode_deps(s):
955 r.append(i) 955 r.append(i)
956 return r 956 return r
957 957
958def packaged(pkg, d):
959 import os, bb
960 return os.access(get_subpkgedata_fn(pkg, d) + '.packaged', os.R_OK)
961
962def read_pkgdatafile(fn):
963 pkgdata = {}
964
965 def decode(str):
966 import codecs
967 c = codecs.getdecoder("string_escape")
968 return c(str)[0]
969
970 import os
971 if os.access(fn, os.R_OK):
972 import re
973 f = file(fn, 'r')
974 lines = f.readlines()
975 f.close()
976 r = re.compile("([^:]+):\s*(.*)")
977 for l in lines:
978 m = r.match(l)
979 if m:
980 pkgdata[m.group(1)] = decode(m.group(2))
981
982 return pkgdata
983
984def get_subpkgedata_fn(pkg, d):
985 import bb, os
986 archs = bb.data.expand("${PACKAGE_ARCHS}", d).split(" ")
987 archs.reverse()
988 pkgdata = bb.data.expand('${TMPDIR}/pkgdata/', d)
989 targetdir = bb.data.expand('${TARGET_VENDOR}-${TARGET_OS}/runtime/', d)
990 for arch in archs:
991 fn = pkgdata + arch + targetdir + pkg
992 if os.path.exists(fn):
993 return fn
994 return bb.data.expand('${PKGDATA_DIR}/runtime/%s' % pkg, d)
995
996def has_subpkgdata(pkg, d):
997 import bb, os
998 return os.access(get_subpkgedata_fn(pkg, d), os.R_OK)
999
1000def read_subpkgdata(pkg, d):
1001 import bb
1002 return read_pkgdatafile(get_subpkgedata_fn(pkg, d))
1003
1004def has_pkgdata(pn, d):
1005 import bb, os
1006 fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
1007 return os.access(fn, os.R_OK)
1008
1009def read_pkgdata(pn, d):
1010 import bb
1011 fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
1012 return read_pkgdatafile(fn)
1013
1014python read_subpackage_metadata () {
1015 import bb
1016 data = read_pkgdata(bb.data.getVar('PN', d, 1), d)
1017
1018 for key in data.keys():
1019 bb.data.setVar(key, data[key], d)
1020
1021 for pkg in bb.data.getVar('PACKAGES', d, 1).split():
1022 sdata = read_subpkgdata(pkg, d)
1023 for key in sdata.keys():
1024 bb.data.setVar(key, sdata[key], d)
1025}
1026
1027
1028#
1029# Collapse FOO_pkg variables into FOO
1030#
1031def read_subpkgdata_dict(pkg, d):
1032 import bb
1033 ret = {}
1034 subd = read_pkgdatafile(get_subpkgedata_fn(pkg, d))
1035 for var in subd:
1036 newvar = var.replace("_" + pkg, "")
1037 ret[newvar] = subd[var]
1038 return ret
1039
1040# Make sure MACHINE isn't exported 958# Make sure MACHINE isn't exported
1041# (breaks binutils at least) 959# (breaks binutils at least)
1042MACHINE[unexport] = "1" 960MACHINE[unexport] = "1"
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index a714b08225..3edec82e4a 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -2,6 +2,8 @@
2# General packaging help functions 2# General packaging help functions
3# 3#
4 4
5inherit packagedata
6
5PKGDEST = "${WORKDIR}/install" 7PKGDEST = "${WORKDIR}/install"
6 8
7def legitimize_package_name(s): 9def legitimize_package_name(s):
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