aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-10-09 21:24:38 -0700
committerChris Larson <chris_larson@mentor.com>2010-10-09 22:38:02 -0700
commitb680c0dd6ba53257f742e7250cc4e1c3fed32bc2 (patch)
treea43aa31abaa1471b18398e32c66288adcfecd715 /lib
parent24c7cb878cbf5cd7b8d07d113ba477d828161ea5 (diff)
downloadopenembedded-b680c0dd6ba53257f742e7250cc4e1c3fed32bc2.tar.gz
openembedded-b680c0dd6ba53257f742e7250cc4e1c3fed32bc2.tar.bz2
openembedded-b680c0dd6ba53257f742e7250cc4e1c3fed32bc2.zip
Move packagedata code into oe.packagedata
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/oe/packagedata.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/oe/packagedata.py b/lib/oe/packagedata.py
new file mode 100644
index 0000000000..d93cafb892
--- /dev/null
+++ b/lib/oe/packagedata.py
@@ -0,0 +1,62 @@
+import os
+import bb.data
+import codecs
+
+def packaged(pkg, d):
+ return os.access(get_subpkgedata_fn(pkg, d) + '.packaged', os.R_OK)
+
+def read_pkgdatafile(fn):
+ pkgdata = {}
+
+ def decode(str):
+ c = codecs.getdecoder("string_escape")
+ return c(str)[0]
+
+ if os.access(fn, os.R_OK):
+ import re
+ f = file(fn, 'r')
+ lines = f.readlines()
+ f.close()
+ r = re.compile("([^:]+):\s*(.*)")
+ for l in lines:
+ m = r.match(l)
+ if m:
+ pkgdata[m.group(1)] = decode(m.group(2))
+
+ return pkgdata
+
+def get_subpkgedata_fn(pkg, d):
+ archs = bb.data.expand("${PACKAGE_ARCHS}", d).split(" ")
+ archs.reverse()
+ pkgdata = bb.data.expand('${TMPDIR}/pkgdata/', d)
+ targetdir = bb.data.expand('${TARGET_VENDOR}-${TARGET_OS}/runtime/', d)
+ for arch in archs:
+ fn = pkgdata + arch + targetdir + pkg
+ if os.path.exists(fn):
+ return fn
+ return bb.data.expand('${PKGDATA_DIR}/runtime/%s' % pkg, d)
+
+def has_subpkgdata(pkg, d):
+ return os.access(get_subpkgedata_fn(pkg, d), os.R_OK)
+
+def read_subpkgdata(pkg, d):
+ return read_pkgdatafile(get_subpkgedata_fn(pkg, d))
+
+def has_pkgdata(pn, d):
+ fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
+ return os.access(fn, os.R_OK)
+
+def read_pkgdata(pn, d):
+ fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
+ return read_pkgdatafile(fn)
+
+#
+# Collapse FOO_pkg variables into FOO
+#
+def read_subpkgdata_dict(pkg, d):
+ ret = {}
+ subd = read_pkgdatafile(get_subpkgedata_fn(pkg, d))
+ for var in subd:
+ newvar = var.replace("_" + pkg, "")
+ ret[newvar] = subd[var]
+ return ret