diff options
Diffstat (limited to 'meta/classes/utils.bbclass')
-rw-r--r-- | meta/classes/utils.bbclass | 107 |
1 files changed, 38 insertions, 69 deletions
diff --git a/meta/classes/utils.bbclass b/meta/classes/utils.bbclass index c2d323235b..f37b565da2 100644 --- a/meta/classes/utils.bbclass +++ b/meta/classes/utils.bbclass | |||
@@ -1,12 +1,42 @@ | |||
1 | # like os.path.join but doesn't treat absolute RHS specially | 1 | # For compatibility |
2 | def base_path_join(a, *p): | 2 | def base_path_join(a, *p): |
3 | path = a | 3 | return oe.path.join(a, *p) |
4 | for b in p: | 4 | |
5 | if path == '' or path.endswith('/'): | 5 | def base_path_relative(src, dest): |
6 | path += b | 6 | return oe.path.relative(src, dest) |
7 | else: | 7 | |
8 | path += '/' + b | 8 | def base_path_out(path, d): |
9 | return path | 9 | return oe.path.format_display(path, d) |
10 | |||
11 | def base_read_file(filename): | ||
12 | return oe.utils.read_file(filename) | ||
13 | |||
14 | def base_ifelse(condition, iftrue = True, iffalse = False): | ||
15 | return oe.utils.ifelse(condition, iftrue, iffalse) | ||
16 | |||
17 | def base_conditional(variable, checkvalue, truevalue, falsevalue, d): | ||
18 | return oe.utils.conditional(variable, checkvalue, truevalue, falsevalue, d) | ||
19 | |||
20 | def base_less_or_equal(variable, checkvalue, truevalue, falsevalue, d): | ||
21 | return oe.utils.less_or_equal(variable, checkvalue, truevalue, falsevalue, d) | ||
22 | |||
23 | def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d): | ||
24 | return oe.utils.version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d) | ||
25 | |||
26 | def base_contains(variable, checkvalues, truevalue, falsevalue, d): | ||
27 | return oe.utils.contains(variable, checkvalues, truevalue, falsevalue, d) | ||
28 | |||
29 | def base_both_contain(variable1, variable2, checkvalue, d): | ||
30 | return oe.utils.both_contain(variable1, variable2, checkvalue, d) | ||
31 | |||
32 | def base_prune_suffix(var, suffixes, d): | ||
33 | return oe.utils.prune_suffix(var, suffixes, d) | ||
34 | |||
35 | def oe_filter(f, str, d): | ||
36 | return oe.utils.str_filter(f, str, d) | ||
37 | |||
38 | def oe_filter_out(f, str, d): | ||
39 | return oe.utils.str_filter_out(f, str, d) | ||
10 | 40 | ||
11 | # for MD5/SHA handling | 41 | # for MD5/SHA handling |
12 | def base_chk_load_parser(config_path): | 42 | def base_chk_load_parser(config_path): |
@@ -80,67 +110,6 @@ def base_chk_file(parser, pn, pv, src_uri, localpath, data): | |||
80 | 110 | ||
81 | return True | 111 | return True |
82 | 112 | ||
83 | def base_read_file(filename): | ||
84 | try: | ||
85 | f = file( filename, "r" ) | ||
86 | except IOError, reason: | ||
87 | return "" # WARNING: can't raise an error now because of the new RDEPENDS handling. This is a bit ugly. :M: | ||
88 | else: | ||
89 | return f.read().strip() | ||
90 | return None | ||
91 | |||
92 | def base_conditional(variable, checkvalue, truevalue, falsevalue, d): | ||
93 | if bb.data.getVar(variable,d,1) == checkvalue: | ||
94 | return truevalue | ||
95 | else: | ||
96 | return falsevalue | ||
97 | |||
98 | def base_less_or_equal(variable, checkvalue, truevalue, falsevalue, d): | ||
99 | if float(bb.data.getVar(variable,d,1)) <= float(checkvalue): | ||
100 | return truevalue | ||
101 | else: | ||
102 | return falsevalue | ||
103 | |||
104 | def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d): | ||
105 | result = bb.vercmp(bb.data.getVar(variable,d,True), checkvalue) | ||
106 | if result <= 0: | ||
107 | return truevalue | ||
108 | else: | ||
109 | return falsevalue | ||
110 | |||
111 | def base_contains(variable, checkvalues, truevalue, falsevalue, d): | ||
112 | matches = 0 | ||
113 | if type(checkvalues).__name__ == "str": | ||
114 | checkvalues = [checkvalues] | ||
115 | for value in checkvalues: | ||
116 | if bb.data.getVar(variable,d,1).find(value) != -1: | ||
117 | matches = matches + 1 | ||
118 | if matches == len(checkvalues): | ||
119 | return truevalue | ||
120 | return falsevalue | ||
121 | |||
122 | def base_both_contain(variable1, variable2, checkvalue, d): | ||
123 | if bb.data.getVar(variable1,d,1).find(checkvalue) != -1 and bb.data.getVar(variable2,d,1).find(checkvalue) != -1: | ||
124 | return checkvalue | ||
125 | else: | ||
126 | return "" | ||
127 | |||
128 | def base_prune_suffix(var, suffixes, d): | ||
129 | # See if var ends with any of the suffixes listed and | ||
130 | # remove it if found | ||
131 | for suffix in suffixes: | ||
132 | if var.endswith(suffix): | ||
133 | return var.replace(suffix, "") | ||
134 | return var | ||
135 | |||
136 | def oe_filter(f, str, d): | ||
137 | from re import match | ||
138 | return " ".join(filter(lambda x: match(f, x, 0), str.split())) | ||
139 | |||
140 | def oe_filter_out(f, str, d): | ||
141 | from re import match | ||
142 | return " ".join(filter(lambda x: not match(f, x, 0), str.split())) | ||
143 | |||
144 | oe_soinstall() { | 113 | oe_soinstall() { |
145 | # Purpose: Install shared library file and | 114 | # Purpose: Install shared library file and |
146 | # create the necessary links | 115 | # create the necessary links |