Working Behind a Network Proxy
The Yocto Project build system provides the tools and environment to build the packages that comprise a bootable Linux image. All the sources for the packages must be fetched through various means, including wget, git, and others. You need to configure your system to work with your corporate proxies and there are two options for doing this
- Environment variables and configuration files - this is the traditional and least intrusive option but involves a number of steps and it can fail in some situations.
- Chameleonsocks - this is Redsocks auto-configured in a docker container, the Yocto team's favorite option. If in doubt, go with this option.
Option 1: Environment Variables and Configuration Files
Set the following environment variables in your ~/.bashrc file. This example uses the same proxy server and port number for all three protocols.
export http_proxy='http://myproxy.example.com:1080/' export https_proxy='https://myproxy.example.com:1080/' export ftp_proxy='http://myproxy.example.com:1080/' export ALL_PROXY='socks://myproxy.example.com:1080/' export all_proxy='socks://myproxy.example.com:1080/' export no_proxy='example.com'
Git Proxy Configuration
Git allows you to specify a command via GIT_PROXY_COMMAND to proxy its network communications. The script, oe-git-proxy, uses socat and standard proxy environment variables. Make sure socat is installed otherwise oe-git-proxy will fail silently.
Copy oe-git-proxy to a location in your PATH, typically ~/bin/ is a good choice. /usr/local/bin is another common option. oe-git-proxy is provided in poky/scripts/oe-git-proxy, but use the link below to get you bootstrapped. Replacing it with the latest from the poky git repository is recommended.
$ sudo apt-get install socat $ wget http://git.yoctoproject.org/cgit/cgit.cgi/poky/plain/scripts/oe-git-proxy $ cp oe-git-proxy ~/bin $ chmod +x ~/bin/oe-git-proxy
Update your .bashrc to setup the GIT_PROXY_COMMAND variable. You also need to set the NO_PROXY variable as oe-git-proxy does no recognize no_proxy
export GIT_PROXY_COMMAND="oe-git-proxy" export NO_PROXY=$no_proxy
Be sure to log out and back in for the settings to take effect.
Wget Proxy Configuration
Proxy environment variables are not propagated to all stages of the Yocto build process so sometimes wget cannot pick them up. To workaround this add the following to ~/.wgetrc.
https_proxy = http://socks.example.com:1080 http_proxy = http://socks.example.com:1080 ftp_proxy = http://socks.example.com:1080 no_proxy = example.com:1080;127.0.0.1 use_proxy = on
Option 2: Chameleonsocks
Chameleonsocks is a containerized proxy solution that is very easy to set up.