yocto d.getVar失败

时间:2017-11-01 21:42:17

标签: yocto bitbake

http://book.yoctoprojectbook.com/index学习Yocto。第4章有以下代码

SUMMARY = "Recipe to build the 'nano' editor"

PN = "nano"
PV = "2.2.6"

SITE = "http://www.nano-editor.org/dist"
PV_MAJOR = "${@bb.data.getVar('PV', d, 1).split('.')[0]}"
PV_MINOR = "${@bb.data.getVar('PV', d, 1).split('.')[1]}"

SRC_URI = "${SITE}/v${PV_MAJOR}.${PV_MINOR}/${PN}-${PV}.tar.gz"
SRC_URI[md5sum] = "03233ae480689a008eb98feb1b599807"
SRC_URI[sha256sum] = \
"be68e133b5e81df41873d32c517b3e5950770c00fc5f4dd23810cd635abce67a"

python do_fetch() {
    bb.plain("Downloading source tarball from ${SRC_URI} ...")
    src_uri = (d.getVar('SRC_URI', True) or "").split()
    if 0 == len(src_uri):
        bb.fatal('Empty URI')
    try:
        fetcher = bb.fetch2.Fetch(src_uri, d)
        fetcher.download()
    except bb.fetch2.BBFetchException:
        bb.fatal('Could not fetch source tarball.')
    bb.plain("Download successful.")
}

addtask fetch before do_build

python do_unpack() {
    bb.plain("Unpacking source tarball ...")
    os.system("tar x -C ${WORKDIR} -f ${DL_DIR}/${P}.tar.gz")
    bb.plain("Unpacked source tarball.")
}

addtask unpack before do_build after do_fetch

python do_configure() {
    bb.plain("Configuring source package ...")
    os.system("cd ${WORKDIR}/${P} && ./configure")
    bb.plain("Configured source package.")
}

addtask configure before do_build after do_unpack

python do_compile() {
    bb.plain("Compiling package ...")
    os.system("cd ${WORKDIR}/${P} && make")
    bb.plain("Compiled package.")
}

addtask compile before do_build after do_configure

do_clean[nostamp] = "1"
do_clean() {
    rm -rf ${WORKDIR}/${P}
    rm -f ${TMPDIR}/stamps/*
}

addtask clean

配方位于meta-hello / recipes-editor / nano中。基本上它正在尝试构建一个nano文本编辑器包。它在do_fetch()任务失败了。在一些打印语句调试之后,我发现故障发生在这一行:src_uri = (d.getVar('SRC_URI', True) or "").split(),特别是在d.getVar('SRC_URI', True)。我不确定究竟是什么导致了这个问题。有人愿意帮忙吗?我正在运行rockoyocto

这是我运行食谱时得到的终端输出:

$bitbake nano
NOTE: Not using a cache. Set CACHE = <directory> to enable.
Parsing recipes: 100% |#################################################################################################################| Time: 0:00:00
Parsing of 2 .bb files complete (0 cached, 2 parsed). 2 targets, 0 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Initialising tasks: 100% |##############################################################################################################| Time: 0:00:00
NOTE: Executing RunQueue Tasks
Downloading source tarball from ${SRC_URI} ...
ERROR: nano-2.2.6-r0 do_fetch: Function failed: do_fetch
ERROR: Logfile of failure stored in: /home/some-user/projects/bbhello/tmp/work/nano-2.2.6-r0/temp/log.do_fetch.14350
ERROR: Task (/home/some-user/projects/bbhello/meta-hello/recipes-editor/nano/nano.bb:do_fetch) failed with exit code '1'
NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be rerun and 1 failed.

Summary: 1 task failed:
  /home/some-user/projects/bbhello/meta-hello/recipes-editor/nano/nano.bb:do_fetch
Summary: There was 1 ERROR message shown, returning a non-zero exit code.

这是实际的日志文件:

DEBUG: Executing python function do_fetch
Downloading source tarball from ${SRC_URI} ...
DEBUG: Python function do_fetch finished
ERROR: Function failed: do_fetch

1 个答案:

答案 0 :(得分:2)

我不确定你在测试什么,但是如果我尝试这个例子,它在解析过程中会失败:

  

错误:解析期间出现ExpansionError   /media/build/poky/meta/recipes-core/base-files/test_1.0.bb
  Traceback(最近一次调用最后一次):     文件“/media/build/poky/bitbake/lib/bb/data_smart.py”,第412行,   DataSmart.expandWithRefs(S = '$ {SITE} / v的$ {PV_MAJOR} $ {PV_MINOR} / $ {PN} - $ {PV}名为.tar.gz',   VARNAME = 'SRC_URI'):                    尝试:       &GT; s = expand_var_regexp .sub(varparse.var_sub,s)                        尝试:文件“/media/build/poky/bitbake/lib/bb/data_smart.py”,第111行,   VariableParse.var_sub(match =&lt; _sre.SRE_Match object; span =(9,20),   匹配= '$ {PV_MAJOR}' &GT):                    其他:       &GT; var = self.d.getVarFlag(key,“_ content”)                    self.references.add(key)文件“/media/build/poky/bitbake/lib/bb/data_smart.py”,第794行,in   DataSmart.getVarFlag(var ='PV_MAJOR',flag ='_ content',expand = True,   noweakdefault = False,parsing = False):                        cachename = var +“[”+ flag +“]”       &GT; value = self.expand(value,cachename)           在DataSmart.expand中输入文件“/media/build/poky/bitbake/lib/bb/data_smart.py”,第436行(s =“$ {@ bb.data.getVar('PV',d,   1).split('。')[0]}“,varname ='PV_MAJOR'):            def expand(self,s,varname = None):       &GT; return self.expandWithRefs(s,varname).value           文件“/media/build/poky/bitbake/lib/bb/data_smart.py”,第426行,在DataSmart.expandWithRefs中(s =“$ {@ bb.data.getVar('PV',d,   1).split('。')[0]}“,varname ='PV_MAJOR'):                    除了异常为exc:       &GT;从exc中引发ExpansionError(varname,s,exc)         bb.data_smart.ExpansionError:扩展变量PV_MAJOR失败,表达式为$ {@bb.data.getVar('PV',d,1).split('。')[0]}   触发了异常AttributeError:模块'bb.data'没有   属性'getVar'

这是因为bb.data.getVar('PV',d,1)需要是d.getVar('PV',True)。如上所述,这个食谱无法在摇滚下解析,所以我不认为你正在运行你认为的食谱?