更新 Yocto 导致异常 'bb.data' 没有属性 'getVar'

Updating Yocto causes exception 'bb.data' has no attribute 'getVar'

我正在尝试将使用 Yocto 1.6 Fido 的项目升级到 Yocto 2.6 Thud。

我在构建过程中收到以下异常。 meta-eca 层的问题

ERROR: ExpansionError during parsing /home/poky-thud/build- 
bbgw/../meta-eca/meta-iot/recipes-web/the-thing-system/steward_git.bb                                                                                         
| ETA:  0:01:02

Traceback (most recent call last):

bb.data_smart.ExpansionError: Failure expanding variable TTS_ARCH[:=], 
expression was ${@get_arch(bb, d)} which triggered exception AttributeError:

module 'bb.data' has no attribute 'getVar'

我想 'getVar' 不知何故被弃用了。

解决此问题的最佳方法是什么?

不是 getVar 什么被弃用,而是 use/access 它的方法。您只需要 BitBake 的数据字典结构 (d) 即可访问其环境变量。您应该按如下方式修改配方:

def get_arch(d):
    val = (d.getVar("MACHINEOVERRIDES", True) or "")
    if val.find("genericx86") > 0:
        return "--arch=i686"
    elif val.find("x86") > 0:
        return "--arch=i686"
    elif val.find("arm") > 0:
        return "--arch=arm"
    else:
        return ""

# Always compile 32-bit in npm because many modules that npm
# compiles do not support 64 bit in x86.
TTS_ARCH := "${@get_arch(d)}"

有关详细信息,请参阅 BitBake user manual