From: Brian Pomerantz Date: Fri, 15 Jan 2010 07:36:58 +0000 (+0000) Subject: base.bbclass: in base_contains, check for var existance before using it X-Git-Tag: Release-2010-05/1~617 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc735a4fa20c2829d187eacc7dd5b943e1132265;p=openembedded.git base.bbclass: in base_contains, check for var existance before using it When using base_contains() to check for a string in a variable for a, if the variable is not defined an exception occurs. By checking the existance of the variable and returning false if it isn't there, a value can be checked for a variable regardless of whether or not it is defined. Signed-off-by: Brian Pomerantz Signed-off-by: Chris Larson Acked-by: Khem Raj Acked-by: Marcin Juszkiewicz Signed-off-by: Marcin Juszkiewicz --- diff --git a/classes/base.bbclass b/classes/base.bbclass index 846528618a..9a242720e7 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -244,14 +244,17 @@ def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d): return falsevalue def base_contains(variable, checkvalues, truevalue, falsevalue, d): + val = bb.data.getVar(variable,d,1) + if not val: + return falsevalue matches = 0 if type(checkvalues).__name__ == "str": checkvalues = [checkvalues] for value in checkvalues: - if bb.data.getVar(variable,d,1).find(value) != -1: + if val.find(value) != -1: matches = matches + 1 if matches == len(checkvalues): - return truevalue + return truevalue return falsevalue def base_both_contain(variable1, variable2, checkvalue, d):