Configure yocto to download from local mirror to save bandwidth

If you once have downloaded and compiled yocto build, it generates local tar files of all the source codes, using which we can configure yocto to make sure our next build, if we start at any other location, downloads all the files from local server instead of always going to internet to download, thus saving lot of bandwidth.

For this first step will be to setup a local apache server and then copy the contents of DL_DIR i.e. downloads folder into /var/www/html/my_folder so that we can access those at http://mylocal_ip/my_folder

if you have check conf/local.conf for where to download the contents while first compilation of yocto build.

# Where to place downloads
# During a first build the system will download many different source code tarballs
# from various upstream projects. This can take a while, particularly if your network
# connection is slow. These are all stored in DL_DIR. When wiping and rebuilding you
# can preserve this directory to speed up this part of subsequent builds. This directory
# is safe to share between multiple builds on the same machine too.
# The default is a downloads directory under TOPDIR which is the build directory.
#DL_DIR ?= "${TOPDIR}/downloads"

Now, open your distro.conf as conf/distro/my_platform.conf and modify the below lines,

bzr://.*/.* http://mylocal_ip/my_folder/ \n \
cvs://.*/.* http://mylocal_ip/my_folder/ \n \
git://.*/.* http://mylocal_ip/my_folder/ \n \
hg://.*/.* http://mylocal_ip/my_folder/ \n \
osc://.*/.* http://mylocal_ip/my_folder/ \n \
p4://.*/.* http://mylocal_ip/my_folder/ \n \
svk://.*/.* http://mylocal_ip/my_folder/ \n \
svn://.*/.* http://mylocal_ip/my_folder/ \n”

ftp://.*/.* http://mylocal_ip/my_folder/ \n \
http://.*/.* http://mylocal_ip/my_folder/ \n \
https://.*/.* http://mylocal_ip/my_folder/ \n”

Now, save and compile, so yocto will first try to download from local mirrors instead of external network.

Related :   How to install Chromium depot_tools on Ubuntu / Linux

Reference :

3.3.4. Source Mirror(s)ΒΆ
Two kinds of mirrors exist: pre-mirrors and regular mirrors. The PREMIRRORS and MIRRORS variables point to these, respectively. BitBake checks pre-mirrors before looking upstream for any source files. Pre-mirrors are appropriate when you have a shared directory that is not a directory defined by the DL_DIR variable. A Pre-mirror typically points to a shared directory that is local to your organization.

Regular mirrors can be any site across the Internet that is used as an alternative location for source code should the primary site not be functioning for some reason or another.

Specifies additional paths from which the OpenEmbedded build system gets source code. When the build system searches for source code, it first tries the local download directory. If that location fails, the build system tries locations defined by PREMIRRORS, the upstream source, and then locations specified by MIRRORS in that order.

Assuming your distribution (DISTRO) is “poky”, the default value for PREMIRRORS is defined in the conf/distro/poky.conf file in the meta-yocto Git repository.

Typically, you could add a specific server for the build system to attempt before any others by adding something like the following to the local.conf configuration file in the Build Directory:

PREMIRRORS_prepend = “\
git://.*/.* \n \
ftp://.*/.* \n \
http://.*/.* \n \
https://.*/.* \n”

These changes cause the build system to intercept Git, FTP, HTTP, and HTTPS requests and direct them to the http:// sources mirror. You can use file:// URLs to point to local directories or network shares as well.

Android Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Commands and Packages Compilation Content Management System - CMS Core Kernel C Programs Development & Build Development Environment Setup Errors & Failures Flutter git Go Language Programs Hardware Platforms HTML JAVA Programs Kernel & Device Drivers Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Monetization / Google AdSense NDK / Middleware / HAL OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized User Interface Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply / Ask Question