summaryrefslogtreecommitdiffstats
path: root/meta/classes/utils.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/utils.bbclass')
-rw-r--r--meta/classes/utils.bbclass144
1 files changed, 52 insertions, 92 deletions
diff --git a/meta/classes/utils.bbclass b/meta/classes/utils.bbclass
index 800b56578c..cd3d05709e 100644
--- a/meta/classes/utils.bbclass
+++ b/meta/classes/utils.bbclass
@@ -1,49 +1,8 @@
-# For compatibility
-def base_path_join(a, *p):
- return oe.path.join(a, *p)
-
-def base_path_relative(src, dest):
- return oe.path.relative(src, dest)
-
-def base_path_out(path, d):
- return oe.path.format_display(path, d)
-
-def base_read_file(filename):
- return oe.utils.read_file(filename)
-
-def base_ifelse(condition, iftrue = True, iffalse = False):
- return oe.utils.ifelse(condition, iftrue, iffalse)
-
-def base_conditional(variable, checkvalue, truevalue, falsevalue, d):
- return oe.utils.conditional(variable, checkvalue, truevalue, falsevalue, d)
-
-def base_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
- return oe.utils.less_or_equal(variable, checkvalue, truevalue, falsevalue, d)
-
-def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
- return oe.utils.version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d)
-
-def base_contains(variable, checkvalues, truevalue, falsevalue, d):
- bb.note('base_contains is deprecated, please use bb.utils.contains instead.')
- return bb.utils.contains(variable, checkvalues, truevalue, falsevalue, d)
-
-def base_both_contain(variable1, variable2, checkvalue, d):
- return oe.utils.both_contain(variable1, variable2, checkvalue, d)
-
-def base_prune_suffix(var, suffixes, d):
- return oe.utils.prune_suffix(var, suffixes, d)
-
-def oe_filter(f, str, d):
- return oe.utils.str_filter(f, str, d)
-
-def oe_filter_out(f, str, d):
- return oe.utils.str_filter_out(f, str, d)
-
def machine_paths(d):
"""List any existing machine specific filespath directories"""
- machine = d.getVar("MACHINE", True)
- filespathpkg = d.getVar("FILESPATHPKG", True).split(":")
- for basepath in d.getVar("FILESPATHBASE", True).split(":"):
+ machine = d.getVar("MACHINE")
+ filespathpkg = d.getVar("FILESPATHPKG").split(":")
+ for basepath in d.getVar("FILESPATHBASE").split(":"):
for pkgpath in filespathpkg:
machinepath = os.path.join(basepath, pkgpath, machine)
if os.path.isdir(machinepath):
@@ -52,7 +11,7 @@ def machine_paths(d):
def is_machine_specific(d):
"""Determine whether the current recipe is machine specific"""
machinepaths = set(machine_paths(d))
- srcuri = d.getVar("SRC_URI", True).split()
+ srcuri = d.getVar("SRC_URI").split()
for url in srcuri:
fetcher = bb.fetch2.Fetch([srcuri], d)
if url.startswith("file://"):
@@ -264,10 +223,17 @@ create_cmdline_wrapper () {
mv $cmd $cmd.real
cmdname=`basename $cmd`
+ dirname=`dirname $cmd`
+ cmdoptions=$@
+ if [ "${base_prefix}" != "" ]; then
+ relpath=`python3 -c "import os; print(os.path.relpath('${D}${base_prefix}', '$dirname'))"`
+ cmdoptions=`echo $@ | sed -e "s:${base_prefix}:\\$realdir/$relpath:g"`
+ fi
cat <<END >$cmd
#!/bin/bash
realpath=\`readlink -fn \$0\`
-exec -a \`dirname \$realpath\`/$cmdname \`dirname \$realpath\`/$cmdname.real $@ "\$@"
+realdir=\`dirname \$realpath\`
+exec -a \`dirname \$realpath\`/$cmdname \`dirname \$realpath\`/$cmdname.real $cmdoptions "\$@"
END
chmod +x $cmd
}
@@ -287,11 +253,18 @@ create_wrapper () {
mv $cmd $cmd.real
cmdname=`basename $cmd`
+ dirname=`dirname $cmd`
+ exportstring=$@
+ if [ "${base_prefix}" != "" ]; then
+ relpath=`python3 -c "import os; print(os.path.relpath('${D}${base_prefix}', '$dirname'))"`
+ exportstring=`echo $@ | sed -e "s:${base_prefix}:\\$realdir/$relpath:g"`
+ fi
cat <<END >$cmd
#!/bin/bash
realpath=\`readlink -fn \$0\`
-export $@
-exec -a \`dirname \$realpath\`/$cmdname \`dirname \$realpath\`/$cmdname.real "\$@"
+realdir=\`dirname \$realpath\`
+export $exportstring
+exec -a "\$0" \$realdir/$cmdname.real "\$@"
END
chmod +x $cmd
}
@@ -306,8 +279,8 @@ hardlinkdir () {
def check_app_exists(app, d):
- app = d.expand(app).strip()
- path = d.getVar('PATH', d, True)
+ app = d.expand(app).split()[0].strip()
+ path = d.getVar('PATH')
return bool(bb.utils.which(path, app))
def explode_deps(s):
@@ -315,14 +288,14 @@ def explode_deps(s):
def base_set_filespath(path, d):
filespath = []
- extrapaths = (d.getVar("FILESEXTRAPATHS", True) or "")
+ extrapaths = (d.getVar("FILESEXTRAPATHS") or "")
# Remove default flag which was used for checking
extrapaths = extrapaths.replace("__default:", "")
# Don't prepend empty strings to the path list
if extrapaths != "":
path = extrapaths.split(":") + path
# The ":" ensures we have an 'empty' override
- overrides = (":" + (d.getVar("FILESOVERRIDES", True) or "")).split(":")
+ overrides = (":" + (d.getVar("FILESOVERRIDES") or "")).split(":")
overrides.reverse()
for o in overrides:
for p in path:
@@ -333,7 +306,7 @@ def base_set_filespath(path, d):
def extend_variants(d, var, extend, delim=':'):
"""Return a string of all bb class extend variants for the given extend"""
variants = []
- whole = d.getVar(var, True) or ""
+ whole = d.getVar(var) or ""
for ext in whole.split():
eext = ext.split(delim)
if len(eext) > 1 and eext[0] == extend:
@@ -341,7 +314,7 @@ def extend_variants(d, var, extend, delim=':'):
return " ".join(variants)
def multilib_pkg_extend(d, pkg):
- variants = (d.getVar("MULTILIB_VARIANTS", True) or "").split()
+ variants = (d.getVar("MULTILIB_VARIANTS") or "").split()
if not variants:
return pkg
pkgs = pkg
@@ -349,24 +322,18 @@ def multilib_pkg_extend(d, pkg):
pkgs = pkgs + " " + v + "-" + pkg
return pkgs
+def get_multilib_datastore(variant, d):
+ return oe.utils.get_multilib_datastore(variant, d)
+
def all_multilib_tune_values(d, var, unique = True, need_split = True, delim = ' '):
"""Return a string of all ${var} in all multilib tune configuration"""
values = []
- value = d.getVar(var, True) or ""
- if value != "":
- if need_split:
- for item in value.split(delim):
- values.append(item)
- else:
- values.append(value)
- variants = d.getVar("MULTILIB_VARIANTS", True) or ""
- for item in variants.split():
- localdata = bb.data.createCopy(d)
- overrides = localdata.getVar("OVERRIDES", False) + ":virtclass-multilib-" + item
- localdata.setVar("OVERRIDES", overrides)
- localdata.setVar("MLPREFIX", item + "-")
- bb.data.update_data(localdata)
- value = localdata.getVar(var, True) or ""
+ variants = (d.getVar("MULTILIB_VARIANTS") or "").split() + ['']
+ for item in variants:
+ localdata = get_multilib_datastore(item, d)
+ # We need WORKDIR to be consistent with the original datastore
+ localdata.setVar("WORKDIR", d.getVar("WORKDIR"))
+ value = localdata.getVar(var) or ""
if value != "":
if need_split:
for item in value.split(delim):
@@ -393,29 +360,22 @@ def all_multilib_tune_list(vars, d):
values = {}
for v in vars:
values[v] = []
-
- localdata = bb.data.createCopy(d)
- overrides = localdata.getVar("OVERRIDES", False).split(":")
- newoverrides = []
- for o in overrides:
- if not o.startswith("virtclass-multilib-"):
- newoverrides.append(o)
- localdata.setVar("OVERRIDES", ":".join(newoverrides))
- localdata.setVar("MLPREFIX", "")
- origdefault = localdata.getVar("DEFAULTTUNE_MULTILIB_ORIGINAL", True)
- if origdefault:
- localdata.setVar("DEFAULTTUNE", origdefault)
- bb.data.update_data(localdata)
values['ml'] = ['']
- for v in vars:
- values[v].append(localdata.getVar(v, True))
- variants = d.getVar("MULTILIB_VARIANTS", True) or ""
- for item in variants.split():
- localdata = bb.data.createCopy(d)
- overrides = localdata.getVar("OVERRIDES", False) + ":virtclass-multilib-" + item
- localdata.setVar("OVERRIDES", overrides)
- localdata.setVar("MLPREFIX", item + "-")
- bb.data.update_data(localdata)
- values[v].append(localdata.getVar(v, True))
+
+ variants = (d.getVar("MULTILIB_VARIANTS") or "").split() + ['']
+ for item in variants:
+ localdata = get_multilib_datastore(item, d)
+ values[v].append(localdata.getVar(v))
values['ml'].append(item)
return values
+all_multilib_tune_list[vardepsexclude] = "OVERRIDES"
+
+# If the user hasn't set up their name/email, set some defaults
+check_git_config() {
+ if ! git config user.email > /dev/null ; then
+ git config --local user.email "${PATCH_GIT_USER_EMAIL}"
+ fi
+ if ! git config user.name > /dev/null ; then
+ git config --local user.name "${PATCH_GIT_USER_NAME}"
+ fi
+}