summaryrefslogtreecommitdiffstats
path: root/meta/classes/utils.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-11-02 10:33:52 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2010-11-02 10:33:52 +0000
commit26a4b23220073343f03f789ef4c0ed0b4443d50c (patch)
tree7cfa16fd7ac3b1a5236a1c4b5efbeba77793950f /meta/classes/utils.bbclass
parentc299112c95d40f1a209dc538e10e963f3b11b687 (diff)
downloadpoky-26a4b23220073343f03f789ef4c0ed0b4443d50c.tar.gz
utils.bbclass: Add functions from OE.dev
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'meta/classes/utils.bbclass')
-rw-r--r--meta/classes/utils.bbclass97
1 files changed, 92 insertions, 5 deletions
diff --git a/meta/classes/utils.bbclass b/meta/classes/utils.bbclass
index f37b565da2..ae6fb0d719 100644
--- a/meta/classes/utils.bbclass
+++ b/meta/classes/utils.bbclass
@@ -38,13 +38,57 @@ def oe_filter(f, str, d):
38def oe_filter_out(f, str, d): 38def oe_filter_out(f, str, d):
39 return oe.utils.str_filter_out(f, str, d) 39 return oe.utils.str_filter_out(f, str, d)
40 40
41def machine_paths(d):
42 """List any existing machine specific filespath directories"""
43 machine = d.getVar("MACHINE", True)
44 filespathpkg = d.getVar("FILESPATHPKG", True).split(":")
45 for basepath in d.getVar("FILESPATHBASE", True).split(":"):
46 for pkgpath in filespathpkg:
47 machinepath = os.path.join(basepath, pkgpath, machine)
48 if os.path.isdir(machinepath):
49 yield machinepath
50
51def is_machine_specific(d):
52 """Determine whether the current recipe is machine specific"""
53 machinepaths = set(machine_paths(d))
54 urldatadict = bb.fetch.init(d.getVar("SRC_URI", True).split(), d, True)
55 for urldata in (urldata for urldata in urldatadict.itervalues()
56 if urldata.type == "file"):
57 if any(urldata.localpath.startswith(mp + "/") for mp in machinepaths):
58 return True
59
60def oe_popen_env(d):
61 env = d.getVar("__oe_popen_env", False)
62 if env is None:
63 env = {}
64 for v in d.keys():
65 if d.getVarFlag(v, "export"):
66 env[v] = d.getVar(v, True) or ""
67 d.setVar("__oe_popen_env", env)
68 return env
69
70def oe_run(d, cmd, **kwargs):
71 import oe.process
72 kwargs["env"] = oe_popen_env(d)
73 return oe.process.run(cmd, **kwargs)
74
75def oe_popen(d, cmd, **kwargs):
76 import oe.process
77 kwargs["env"] = oe_popen_env(d)
78 return oe.process.Popen(cmd, **kwargs)
79
80def oe_system(d, cmd, **kwargs):
81 """ Popen based version of os.system. """
82 if not "shell" in kwargs:
83 kwargs["shell"] = True
84 return oe_popen(d, cmd, **kwargs).wait()
85
41# for MD5/SHA handling 86# for MD5/SHA handling
42def base_chk_load_parser(config_path): 87def base_chk_load_parser(config_paths):
43 import ConfigParser 88 import ConfigParser
44 parser = ConfigParser.ConfigParser() 89 parser = ConfigParser.ConfigParser()
45 if not len(parser.read(config_path)) == 1: 90 if len(parser.read(config_paths)) < 1:
46 bb.note("Can not open the '%s' ini file" % config_path) 91 raise ValueError("no ini files could be found")
47 raise Exception("Can not open the '%s'" % config_path)
48 92
49 return parser 93 return parser
50 94
@@ -216,7 +260,7 @@ oe_libinstall() {
216 eval `cat $lafile|grep "^library_names="` 260 eval `cat $lafile|grep "^library_names="`
217 libtool=1 261 libtool=1
218 else 262 else
219 library_names="$libname.so* $libname.dll.a" 263 library_names="$libname.so* $libname.dll.a $libname.*.dylib"
220 fi 264 fi
221 265
222 __runcmd install -d $destpath/ 266 __runcmd install -d $destpath/
@@ -307,3 +351,46 @@ oe_machinstall() {
307 touch $4 351 touch $4
308 fi 352 fi
309} 353}
354
355create_wrapper () {
356 # Create a wrapper script
357 #
358 # These are useful to work around relocation issues, by setting environment
359 # variables which point to paths in the filesystem.
360 #
361 # Usage: create_wrapper FILENAME [[VAR=VALUE]..]
362
363 cmd=$1
364 shift
365
366 # run echo via env to test syntactic validity of the variable arguments
367 env $@ echo "Generating wrapper script for $cmd"
368
369 mv $cmd $cmd.real
370 cmdname=`basename $cmd`.real
371 cat <<END >$cmd
372#!/bin/sh
373exec env $@ \`dirname \$0\`/$cmdname "\$@"
374END
375 chmod +x $cmd
376}
377
378def check_app_exists(app, d):
379 from bb import which, data
380
381 app = data.expand(app, d)
382 path = data.getVar('PATH', d, 1)
383 return bool(which(path, app))
384
385def explode_deps(s):
386 return bb.utils.explode_deps(s)
387
388def base_set_filespath(path, d):
389 bb.note("base_set_filespath usage is deprecated, %s should be fixed" % d.getVar("P", 1))
390 filespath = []
391 # The ":" ensures we have an 'empty' override
392 overrides = (bb.data.getVar("OVERRIDES", d, 1) or "") + ":"
393 for p in path:
394 for o in overrides.split(":"):
395 filespath.append(os.path.join(p, o))
396 return ":".join(filespath)