今天嘗試重新拿從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會出現難以預計的錯誤