已经release的一个项目,在最近编译时发现,解析bb很慢,以前没有出现过这个问题。
打开调试,发现卡在解析selinux相关的bb处。
DEBUG: /home/user44/3.15_/poky/…/meta/meta-selinux/recipes-security/refpolicy/refpolicy-minimum_git.bb: Fetcher accessed the network with the command git -c core.fsyncobjectfiles=0 ls-remote git://github.com/TresysTechnology/refpolicy-contrib.git
DEBUG: /home/user44/3.15_/poky/…/meta/meta-selinux/recipes-security/refpolicy/refpolicy-minimum_git.bb: Running export PATH="/home/user44/3.15_/build/tmp/work/g6s-poky-linux/refpolicy-minimum/fetcheravoidrecurse-r0/recipe-sysroot-native/usr/bin/bzip2-native:/home/user443.15_/build/tmp/work/g6s-poky-linux/refpolicy-minimum/fetcheravoidrecurse-r0/recipe-sysroot-native/usr/bin/python-native:/home/user44/3.15_/poky/scripts:/home/user44/3.15_/build/tmp/work/g6s-poky-linux/refpolicy-minimum/fetcheravoidrecurse-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux:/home/user44/3.15_/build/tmp/work/g6s-poky-linux/refpolicy-minimum/fetcheravoidrecurse-r0/recipe-sysroot/usr/bin/crossscripts:/home/user443.15_/build/tmp/work/g6s-poky-linux/refpolicy-minimum/fetcheravoidrecurse-r0/recipe-sysroot-native/usr/sbin:/home/user44/3.15_/build/tmp/work/g6s-poky-linux/refpolicy-minimum/fetcheravoidrecurse-r0/recipe-sysroot-native/usr/bin:/home/user44/3.15_/build/tmp/work/g6s-poky-linux/refpolicy-minimum/fetcheravoidrecurse-r0/recipe-sysroot-native/sbin:/home/user44/3.15_/build/tmp/work/g6s-poky-linux/refpolicy-minimum/fetcheravoidrecurse-r0/recipe-sysroot-native/bin:/home/user44/3.15_/poky/bitbake/bin:/home/user44/3.15_*/build/tmp/hosttools"; export HOME="/home/user44"; git -c core.fsyncobjectfiles=0 ls-remote git://github.com/TresysTechnology/refpolicy-contrib.git
研究发现,meta-selinux/recipes-security/refpolicy/refpolicy_git.inc的文件中,是这么写的:
SRCREV_refpolicy和SRCREV_refpolicy-contrib仓库都指定为自动去git://github.com/TresysTechnology/refpolicy.git和git://github.com/TresysTechnology/refpolicy-contrib.git的master分支获取信息(tag,Hash等信息)。这样就会导致每次在解析BB时,首先会先去反问github网站,如果网络不稳定则会导致编译解析BB时卡主。很不稳定,影响软件正常发布。
解决方法:
研究发现原因是文件中设置成AUTOREV的原因,同时发现git://github.com/TresysTechnology/refpolicy.git和git://github.com/TresysTechnology/refpolicy-contrib.git两个仓库master分支的更新并不是很频繁(上一次更新是在18年),且这两个仓库被Selinux所用,Selinux的更新是和BSP同步的,也就是说这两个仓库的更新和BSP更新保持同步。
那么也就找到也比较简洁的解决方法:
把SRCREV_refpolicy和SRCREV_refpolicy-contrib的值设置为当前两个仓库的master分支的HASH值即可,这样就不用每次在编译解析阶段去访问github获取最新的Hash值。
如果BSP需要更新,则同步BSP时更新这两个HASH值即可。
对于AUTOREV的详细了解,可以在yoctoproject上找到答案。
https://wiki.yoctoproject.org/wiki/How_do_I
Solve the problem of compiling access to gtihub slow: