Commit f7652e56 authored by Tails developers's avatar Tails developers
Browse files

vagrant: Add suport for HTTP proxy build settings

We support three options: external proxy, a proxy inside the virtual machine
and no proxy at all.

The first and the last are both trivial to implement.

For the in-VM proxy, we install and configure apt-cacher-ng during
provisioning. We do that all the time to support different proxy options once
the VM is started.

The custom apt-cacher-ng configuration is required to support downloads of `.o`
and `.tar.bz2` files by the firmware installers.
parent 55c016f2
......@@ -27,10 +27,24 @@ VAGRANT_PATH = File.expand_path('../vagrant', __FILE__)
# Environment variables that will be exported to the build script
# Let's save the http_proxy set before playing with it
# Hostname of the virtual machine (must be in /etc/hosts)
task :parse_build_options do
options = ENV['TAILS_BUILD_OPTIONS'] || ''
options.split(' ').each do |opt|
case opt
# HTTP proxy settings
when 'extproxy'
abort "No HTTP proxy set, but one is required by TAILS_BUILD_OPTIONS. Aborting." unless EXTERNAL_HTTP_PROXY
when 'vmproxy'
ENV['http_proxy'] = "http://#{VIRTUAL_MACHINE_HOSTNAME}:3142"
when 'noproxy'
ENV['http_proxy'] = nil
# SquashFS compression settings
when 'gzipcomp'
ENV['MKSQUASHFS_OPTIONS'] = '-comp gzip'
......@@ -75,7 +89,7 @@ end
namespace :vm do
desc 'Start the build virtual machine'
task :up => 'validate_http_proxy' do
task :up => ['parse_build_options', 'validate_http_proxy'] do
env = => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic)
case env.primary_vm.state
when :not_created
......@@ -113,7 +127,7 @@ namespace :vm do
desc 'Re-run virtual machine setup'
task :provision => 'validate_http_proxy' do
task :provision => ['parse_build_options', 'validate_http_proxy'] do
env = => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic)
result = env.cli('provision')
abort "'vagrant provision' failed" unless result
CacheDir: /var/cache/apt-cacher-ng
LogDir: /var/log/apt-cacher-ng
Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian
Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu
Remap-debvol: file:debvol_mirror*.gz /debian-volatile ; file:backends_debvol
Remap-cygwin: file:cygwin_mirrors /cygwin # ; file:backends_cygwin # incomplete, please create this file
ReportPage: acng-report.html
ExTreshold: 4
VfilePattern = (^|.*?/)(Index|Packages(\.gz|\.bz2|\.lzma|\.xz)?|InRelease|Release|Release\.gpg|Sources(\.gz|\.bz2|\.lzma|\.xz)?|release|index\.db-.*\.gz|Contents-[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|pkglist[^/]*\.bz2|rclist[^/]*\.bz2|/meta-release[^/]*|Translation[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|MD5SUMS|SHA1SUMS|((setup|setup-legacy)(\.ini|\.bz2|\.hint)(\.sig)?)|mirrors\.lst|repo(index|md)\.xml(\.asc|\.key)?|directory\.yast|products|content(\.asc|\.key)?|media|filelists\.xml\.gz|filelists\.sqlite\.bz2|repomd\.xml|packages\.[a-zA-Z][a-zA-Z]\.gz|info\.txt|license\.tar\.gz|license\.zip|.*\.db(\.tar\.gz)?|.*\.files\.tar\.gz|.*\.abs\.tar\.gz|metalink\?repo|.*prestodelta\.xml\.gz)$|/dists/.*/installer-[^/]+/[^0-9][^/]+/images/.*
PfilePattern = .*(\.d?deb|\.rpm|\.dsc|\.tar(\.gz|\.bz2|\.lzma|\.xz)(\.gpg)?|\.diff(\.gz|\.bz2|\.lzma|\.xz)|\.o|\.jigdo|\.template|changelog|copyright|\.udeb|\.debdelta|\.diff/.*\.gz|(Devel)?ReleaseAnnouncement(\?.*)?|[a-f0-9]+-(susedata|updateinfo|primary|deltainfo).xml.gz|fonts/(final/)?[a-z]+32.exe(\?download.*)?|/dists/.*/installer-[^/]+/[0-9][^/]+/images/.*)$
WfilePattern = (^|.*?/)(Release|InRelease|Release\.gpg|(Packages|Sources)(\.gz|\.bz2|\.lzma|\.xz)?|Translation[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|MD5SUMS|SHA1SUMS|.*\.xml|.*\.db\.tar\.gz|.*\.files\.tar\.gz|.*\.abs\.tar\.gz|[a-z]+32.exe)$|/dists/.*/installer-.*/images/.*
......@@ -2,8 +2,24 @@
set -e
# Refresh packages lists
# Do not use virtual machine proxy before apt-cacher-ng is installed
if [ "$http_proxy" = "http://$(hostname -f):3142" ] &&
! [ -f /etc/apt-cacher-ng/acng.conf ]; then
apt-get update
apt-get -y install apt-cacher-ng
# Install custom configuration for apt-cacher-ng and restart
sudo cp /vagrant/provision/assets/acng.conf /etc/apt-cacher-ng/acng.conf
service apt-cacher-ng restart
# Restore local HTTP proxy if needed
if [ "$LOCAL_HTTP_PROXY" ]; then
# Upgrade if needed
apt-get -y dist-upgrade
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment