yocto使用本地http服务加速下载

选定以某个版本为基线,下载所有源码

  • 编辑build/{machine}/conf/local.conf,添加BB_GENERATE_MIRROR_TARBALLS = "1"
  • 下载所有源码
#bitbake {target} --runall=do_fetch

将build/{machine}/downloads保存起来,作为后续本地源,可以打包为squash文件系统

#mksquash downloads ob_download.sqsh -noappend

搭建http服务

  • 安装docker
#sudo apt install docker.io
  • 下载lighttpd镜像
#sudo docker pull sebp/lighttpd
  • 启动http服务,这里把host的/opt/www目录map到容器中,作为web根目录。
#docker run --rm -td -v /opt/www:/var/www/localhost/htdocs -p 8080:80 sebp/lighttpd
  • 可以在/opt/www/创建一个文本文件用来测试http服务,如:
#echo "Welcome to OpenBMC Source Reposity" > /opt/www/index.htm

假设服务器的ip为192.168.1.1, 浏览器地址栏输入"http://192.168.1.1:8080/index.htm",应该能看到Welcome to OpenBMC Source Reposity这句话

  • 挂载源码镜像到web根目录
#sudo mkdir /opt/www/source
#sudo mount ob_download.sqsh /opt/www/source

优先从本地源下载源码

  • 编辑build/{machine}/conf/local.conf,添加配置:
INHERIT += "own-mirrors"
SOURCE_MIRROR_URL = "http://192.168.1.1:8080/source"
  • 下载源码
#bitbake {target} --runall=do_fetch

可以看到,下载速度很快,因为是从本地http服务器下载的

posted on 2022-11-09 15:03  zlyang  阅读(258)  评论(0编辑  收藏  举报

导航