]> code.ossystems Code Review - openembedded-core.git/commitdiff
base.bbclass: Move package metadata handling functions into their own class file
authorRichard Purdie <richard@ted.(none)>
Sun, 25 Jan 2009 17:14:57 +0000 (17:14 +0000)
committerRichard Purdie <richard@ted.(none)>
Thu, 5 Feb 2009 23:54:11 +0000 (23:54 +0000)
meta/classes/base.bbclass
meta/classes/package.bbclass
meta/classes/packagedata.bbclass [new file with mode: 0644]

index 5f83af1fa3ab14bb7c0bad7bbdae6230b728c8de..0a5facf6e34556c50352733c2856fc0abed47d2d 100644 (file)
@@ -955,88 +955,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):
-       import bb, os
-       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):
-       import bb, os
-       return os.access(get_subpkgedata_fn(pkg, d), os.R_OK)
-
-def read_subpkgdata(pkg, d):
-       import bb
-       return read_pkgdatafile(get_subpkgedata_fn(pkg, d))
-
-def has_pkgdata(pn, d):
-       import bb, os
-       fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
-       return os.access(fn, os.R_OK)
-
-def read_pkgdata(pn, d):
-       import bb
-       fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
-       return read_pkgdatafile(fn)
-
-python read_subpackage_metadata () {
-       import bb
-       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):
-       import bb
-       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"
index a714b082257b2b28d9a40d73132c25aa0eb2f724..3edec82e4ad459934b57c0bd84ffaa60781f4c1c 100644 (file)
@@ -2,6 +2,8 @@
 # General packaging help functions
 #
 
+inherit packagedata
+
 PKGDEST = "${WORKDIR}/install"
 
 def legitimize_package_name(s):
diff --git a/meta/classes/packagedata.bbclass b/meta/classes/packagedata.bbclass
new file mode 100644 (file)
index 0000000..c9d64d6
--- /dev/null
@@ -0,0 +1,82 @@
+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):
+       import bb, os
+       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):
+       import bb, os
+       return os.access(get_subpkgedata_fn(pkg, d), os.R_OK)
+
+def read_subpkgdata(pkg, d):
+       import bb
+       return read_pkgdatafile(get_subpkgedata_fn(pkg, d))
+
+def has_pkgdata(pn, d):
+       import bb, os
+       fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
+       return os.access(fn, os.R_OK)
+
+def read_pkgdata(pn, d):
+       import bb
+       fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
+       return read_pkgdatafile(fn)
+
+python read_subpackage_metadata () {
+       import bb
+       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):
+       import bb
+       ret = {}
+       subd = read_pkgdatafile(get_subpkgedata_fn(pkg, d))
+       for var in subd:
+               newvar = var.replace("_" + pkg, "")
+               ret[newvar] = subd[var]
+       return ret
+