diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2009-10-30 21:59:06 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2009-11-09 12:55:03 +0000 |
commit | c942cea699be2e07b4dfe9ced8b200756c80eb02 (patch) | |
tree | 9d1ee9798d8eef8e145729aa9f929989f5ecf976 /classes | |
parent | f6c3cb05c0ef1836a3146a39dc40cbee367486e8 (diff) |
packagedata.bbclass: Split package data handling functions out from base.bclass (from Poky)
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'classes')
-rw-r--r-- | classes/base.bbclass | 77 | ||||
-rw-r--r-- | classes/packagedata.bbclass | 73 |
2 files changed, 75 insertions, 75 deletions
diff --git a/classes/base.bbclass b/classes/base.bbclass index a3ea7bc685..7f24482605 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -1008,6 +1008,8 @@ addtask build after do_populate_staging do_build = "" do_build[func] = "1" +INHERIT =+ "packagedata" + # Functions that update metadata based on files outputted # during the build process. @@ -1028,81 +1030,6 @@ def explode_deps(s): r.append(i) return r -def packaged(pkg, d): - import os, bb - return os.access(get_subpkgedata_fn(pkg, d) + '.packaged', os.R_OK) - -def read_pkgdatafile(fn): - pkgdata = {} - - def decode(str): - import codecs - c = codecs.getdecoder("string_escape") - return c(str)[0] - - import os - 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) - -python read_subpackage_metadata () { - data = read_pkgdata(bb.data.getVar('PN', d, 1), d) - - for key in data.keys(): - bb.data.setVar(key, data[key], d) - - for pkg in bb.data.getVar('PACKAGES', d, 1).split(): - sdata = read_subpkgdata(pkg, d) - for key in sdata.keys(): - bb.data.setVar(key, sdata[key], d) -} - - -# -# 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 - # Make sure MACHINE isn't exported # (breaks binutils at least) MACHINE[unexport] = "1" diff --git a/classes/packagedata.bbclass b/classes/packagedata.bbclass new file mode 100644 index 0000000000..86f18a9e96 --- /dev/null +++ b/classes/packagedata.bbclass @@ -0,0 +1,73 @@ +def packaged(pkg, d): + return os.access(get_subpkgedata_fn(pkg, d) + '.packaged', os.R_OK) + +def read_pkgdatafile(fn): + pkgdata = {} + + def decode(str): + import codecs + 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) + +python read_subpackage_metadata () { + data = read_pkgdata(bb.data.getVar('PN', d, 1), d) + + for key in data.keys(): + bb.data.setVar(key, data[key], d) + + for pkg in bb.data.getVar('PACKAGES', d, 1).split(): + sdata = read_subpkgdata(pkg, d) + for key in sdata.keys(): + bb.data.setVar(key, sdata[key], d) +} + + +# +# 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 + |