今天尝试重新拿从github上面clone一份yoctoproject进行构建,执行以下步骤
git clone git://git.yoctoproject.org/poky.git poky_new
cd poky_new
source oe-init-build-env
vim conf/local.conf 将下面变量前的“#”符号删除
DL_DIR ?= "${TOPDIR}/downloads"
SSTATE_DIR ?= "${TOPDIR}/sstate-cache"
TMPDIR = "${TOPDIR}/tmp"
bitbake core-image-minimal
结果报以下错误
ERROR: Unable to start bitbake server (None)
ERROR: Server log for this session (/home/ts/michaelma/2019/poky_new/build/bitbake-cookerdaemon.log):
--- Starting bitbake server pid 27859 at 2019-03-18 17:48:27.381861 ---
Traceback (most recent call last):
File "/home/ts/michaelma/2019/poky_new/bitbake/lib/bb/cookerdata.py", line 290, in parseBaseConfiguration
bb.event.fire(bb.event.ConfigParsed(), self.data)
File "/home/ts/michaelma/2019/poky_new/bitbake/lib/bb/event.py", line 225, in fire
fire_class_handlers(event, d)
File "/home/ts/michaelma/2019/poky_new/bitbake/lib/bb/event.py", line 134, in fire_class_handlers
execute_handler(name, handler, event, d)
File "/home/ts/michaelma/2019/poky_new/bitbake/lib/bb/event.py", line 106, in execute_handler
ret = handler(event)
File "/home/ts/michaelma/2019/poky_new/meta/classes/base.bbclass", line 238, in base_eventhandler
setup_hosttools_dir(d.getVar('HOSTTOOLS_DIR'), 'HOSTTOOLS', d)
File "/home/ts/michaelma/2019/poky_new/meta/classes/base.bbclass", line 142, in setup_hosttools_dir
bb.fatal("The following required tools (as specified by HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:\n %s" % " ".join(notfound))
File "/home/ts/michaelma/2019/poky_new/bitbake/lib/bb/__init__.py", line 120, in fatal
raise BBHandledException()
bb.BBHandledException
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ts/michaelma/2019/poky_new/bitbake/lib/bb/daemonize.py", line 83, in createDaemon
function()
File "/home/ts/michaelma/2019/poky_new/bitbake/lib/bb/server/process.py", line 474, in _startServer
self.cooker = bb.cooker.BBCooker(self.configuration, self.featureset)
File "/home/ts/michaelma/2019/poky_new/bitbake/lib/bb/cooker.py", line 210, in __init__
self.initConfigurationData()
File "/home/ts/michaelma/2019/poky_new/bitbake/lib/bb/cooker.py", line 375, in initConfigurationData
self.databuilder.parseBaseConfiguration()
File "/home/ts/michaelma/2019/poky_new/bitbake/lib/bb/cookerdata.py", line 317, in parseBaseConfiguration
raise bb.BBHandledException
bb.BBHandledException
ERROR: The following required tools (as specified by HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:
realpath
虽然从错误提示信息上可以看到缺少“realpath”工具,不过我就很奇怪,我先前clone的yocto执行上面的步骤也没有报错,为什么新版本会报错呢。
由于bitbake是python代码,我就通过不停的添加print语句打印,最终定位到
meta/classes/meta.bbclass文件第142行
fatal这个变量在函数内部没有被赋值,且默认参数就是True。那看起来报这个错是由于notfound这个变量不为空导致的。
那就输出上下文把。
不过输出语句有异常,会出现输出补全print信息的问题,将所有的print改为bb.warn,之后,打印信息就全部输出了。
从输出的结果看,果然desttool有一个是
${TOPDIR}/tmp/hosttools/realpath
不过这个路径下却没有这个文件
执行
sudo apt-get install realpath
重新source oe-init-build-env
bitbake core-image-minimal
正常构建了
总结:
- 新版本的yocto使用到了工具realpath
- 所有bitbake使用的工具都在${TOPDIR}/tmp/hosttools/这个路径下
- 在bitbake源码里面可以使用print语句进行调试打印
- 在bbclass里面建议使用bb.warn进行调试打印,print会出现难以预计的错误