[oe-commits] Chris Larson : Move packagedata code into oe.packagedata

git version control git at git.openembedded.org
Sun Oct 10 05:40:13 UTC 2010


Module: openembedded.git
Branch: master
Commit: b680c0dd6ba53257f742e7250cc4e1c3fed32bc2
URL:    http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=b680c0dd6ba53257f742e7250cc4e1c3fed32bc2

Author: Chris Larson <chris_larson at mentor.com>
Date:   Sat Oct  9 21:24:38 2010 -0700

Move packagedata code into oe.packagedata

Signed-off-by: Chris Larson <chris_larson at mentor.com>

---

 classes/package.bbclass          |    4 ++-
 classes/package_rpm.bbclass      |    4 ++-
 classes/packaged-staging.bbclass |    4 ++-
 classes/packagedata.bbclass      |   68 ++-----------------------------------
 lib/oe/packagedata.py            |   62 ++++++++++++++++++++++++++++++++++
 5 files changed, 75 insertions(+), 67 deletions(-)

diff --git a/classes/package.bbclass b/classes/package.bbclass
index 35d9864..e2a61bf 100644
--- a/classes/package.bbclass
+++ b/classes/package.bbclass
@@ -278,7 +278,9 @@ def write_package_md5sums (root, outfile, ignorepaths):
 #
 
 def get_package_mapping (pkg, d):
-	data = read_subpkgdata(pkg, d)
+	import oe.packagedata
+
+	data = oe.packagedata.read_subpkgdata(pkg, d)
 	key = "PKG_%s" % pkg
 
 	if key in data:
diff --git a/classes/package_rpm.bbclass b/classes/package_rpm.bbclass
index 56fa006..46c703a 100644
--- a/classes/package_rpm.bbclass
+++ b/classes/package_rpm.bbclass
@@ -10,6 +10,8 @@ RPMOPTS="--rcfile=${WORKDIR}/rpmrc --target ${TARGET_SYS}"
 RPM="rpm ${RPMOPTS}"
 
 python write_specfile() {
+	import oe.packagedata
+
 	version = bb.data.getVar('PV', d, 1)
 	version = version.replace('-', '+')
 	bb.data.setVar('RPMPV', version, d)
@@ -78,7 +80,7 @@ python write_specfile() {
 			ver = depends[dep]
 			if dep and ver:
 				if '-' in ver:
-					subd = read_subpkgdata_dict(dep, d)
+					subd = oe.packagedata.read_subpkgdata_dict(dep, d)
 					pv = subd['PV']
 					reppv = pv.replace('-', '+')
 					ver = ver.replace(pv, reppv)
diff --git a/classes/packaged-staging.bbclass b/classes/packaged-staging.bbclass
index 8292853..d0aaea1 100644
--- a/classes/packaged-staging.bbclass
+++ b/classes/packaged-staging.bbclass
@@ -424,6 +424,8 @@ python staging_package_libtoolhack () {
 }
 
 python do_package_stage () {
+    import oe.packagedata
+
     if bb.data.getVar("PSTAGING_ACTIVE", d, 1) != "1":
         return
 
@@ -452,7 +454,7 @@ python do_package_stage () {
             pr = bb.data.getVar('PR_%s' % pkg, d, 1)
             if not pr:
                 pr = bb.data.getVar('PR', d, 1)
-            if not packaged(pkg, d):
+            if not oe.packagedata.packaged(pkg, d):
                 continue
             if bb.data.inherits_class('package_ipk', d):
                 srcname = bb.data.expand(pkgname + "_${PKGV}-" + pr + "${DISTRO_PR}" + "_" + arch + ".ipk", d)
diff --git a/classes/packagedata.bbclass b/classes/packagedata.bbclass
index 86f18a9..bf051fe 100644
--- a/classes/packagedata.bbclass
+++ b/classes/packagedata.bbclass
@@ -1,73 +1,13 @@
-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)
+	import oe.packagedata
+
+	data = oe.packagedata.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)
+		sdata = oe.packagedata.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
-
diff --git a/lib/oe/packagedata.py b/lib/oe/packagedata.py
new file mode 100644
index 0000000..d93cafb
--- /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





More information about the Openembedded-commits mailing list