构建ZedBoard的Yocto Gatesgarth SDK时出现do_fetch仓库拉取失败问题
在为ZedBoard构建Yocto Project (Gatesgarth) SDK过程中,多个Qt相关组件出现do_fetch拉取失败错误,报错信息如下:
ERROR: qtsvg-5.15.2+gitAUTOINC+52d3788c7b-r0 do_fetch: Fetcher failure for URL: 'git://code.qt.io/qt/qtsvg.git;name=qtsvg;branch=5.15.2;protocol=git'. Unable to fetch URL from any source.
ERROR: qtxmlpatterns-5.15.2+gitAUTOINC+50421402f0-r0 do_fetch: Fetcher failure for URL: 'git://code.qt.io/qt/qtxmlpatterns.git;name=qtxmlpatterns;branch=5.15.2;protocol=git'. Unable to fetch URL from any source.
ERROR: qtquickcontrols2-5.15.2+gitAUTOINC+16f27dfa35-r0 do_fetch: Fetcher failure for URL: 'git://code.qt.io/qt/qtquickcontrols2.git;name=qtquickcontrols2;branch=5.15.2;protocol=git'. Unable to fetch URL from any source.
ERROR: qtbase-native-5.15.2+gitAUTOINC+40143c189b-r0 do_fetch: Fetcher failure for URL: 'git://code.qt.io/qt/qtbase.git;name=qtbase;branch=5.15.2;protocol=git'. Unable to fetch URL from any source.
ERROR: qtdeclarative-5.15.2+gitAUTOINC+104eae5b17-r0 do_fetch: Fetcher failure for URL: 'git://code.qt.io/qt/qtdeclarative.git;name=qtdeclarative;branch=5.15.2;protocol=git'. Unable to fetch URL from any source.
ERROR: qtbase-5.15.2+gitAUTOINC+40143c189b-r0 do_fetch: Fetcher failure for URL: 'git://code.qt.io/qt/qtbase.git;name=qtbase;branch=5.15.2;protocol=git'. Unable to fetch URL from any source.
手动克隆这些仓库正常,说明网络访问无问题,当前使用的qt5-git.inc内容如下:
#######Copyright (C) 2012-2016 O.S. Systems Software LTDA. ########Copyright (C) 2013-2020 Martin Jansa <martin.jansa@gmail.com> QT_MODULE ?= "${BPN}" QT_MODULE_BRANCH ?= "5.15.2" QT_MODULE_BRANCH_PARAM ?= "branch=${QT_MODULE_BRANCH}" ####### each module needs to define valid SRCREV SRC_URI = " \ ${QT_GIT}/${QT_MODULE}.git;name=${QT_MODULE};${QT_MODULE_BRANCH_PARAM};protocol=${QT_GIT_PROTOCOL} \ " CVE_PRODUCT = "qt" S = "${WORKDIR}/git" PV = "5.15.2+git${SRCPV}"
解决方案
更新SRCREV配置
Yocto的Git fetcher需要对应分支的有效commit哈希(SRCREV)。如果现有SRCREV对应的commit已从5.15.2分支移除(比如分支被强制推送更新),就会拉取失败。- 手动克隆对应Qt仓库,切换到
5.15.2分支,获取最新commit哈希:git clone git://code.qt.io/qt/qtsvg.git cd qtsvg && git checkout 5.15.2 git rev-parse HEAD # 得到当前分支的commit哈希 - 在对应Qt组件的recipe文件(如
qtsvg_5.15.2.bb)中更新SRCREV_qtsvg为新的哈希值即可。
- 手动克隆对应Qt仓库,切换到
修改Git协议
尝试将Git协议从git改为https,避免Yocto fetcher的协议兼容性问题:
在local.conf中添加:QT_GIT_PROTOCOL = "https"明确分支引用路径
部分情况下,Yocto fetcher需要明确的分支引用路径,修改qt5-git.inc中的分支参数:QT_MODULE_BRANCH_PARAM ?= "branch=refs/heads/${QT_MODULE_BRANCH}"这样可以让fetcher准确识别分支位置。
手动预克隆到Yocto下载目录
既然手动克隆正常,可以将仓库预克隆到Yocto的downloads目录,让fetcher直接使用本地克隆:# 以qtsvg为例,其他仓库替换对应名称 DL_DIR=$(bitbake -e | grep '^DL_DIR' | cut -d '"' -f2) git clone git://code.qt.io/qt/qtsvg.git ${DL_DIR}/git2/code.qt.io.qt.qtsvg.git cd ${DL_DIR}/git2/code.qt.io.qt.qtsvg.git git checkout 5.15.2对所有报错的Qt仓库执行上述操作。
内容的提问来源于stack exchange,提问作者Shah

