summaryrefslogtreecommitdiffstats
path: root/Rakefile
diff options
context:
space:
mode:
authorTails developers <amnesia@boum.org>2012-05-14 20:56:59 +0200
committerTails developers <amnesia@boum.org>2012-05-16 13:30:41 +0200
commitf7652e5671ee43a6c32461ae06b9d1b8be06c916 (patch)
treec183c1d5e5c3c0658e8a703eab2a86441cb31131 /Rakefile
parent55c016f2c7907f9865043bf6bc681c16df50cdbe (diff)
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.
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile18
1 files changed, 16 insertions, 2 deletions
diff --git a/Rakefile b/Rakefile
index 204b5e3..ba15ffd 100644
--- a/Rakefile
+++ b/Rakefile
@@ -27,10 +27,24 @@ VAGRANT_PATH = File.expand_path('../vagrant', __FILE__)
# Environment variables that will be exported to the build script
EXPORTED_VARIABLES = ['http_proxy', 'MKSQUASHFS_OPTIONS']
+# Let's save the http_proxy set before playing with it
+EXTERNAL_HTTP_PROXY = ENV['http_proxy']
+
+# Hostname of the virtual machine (must be in /etc/hosts)
+VIRTUAL_MACHINE_HOSTNAME = 'squeeze.vagrantup.com'
+
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
+ ENV['http_proxy'] = 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::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic)
case env.primary_vm.state
when :not_created
@@ -113,7 +127,7 @@ namespace :vm do
end
desc 'Re-run virtual machine setup'
- task :provision => 'validate_http_proxy' do
+ task :provision => ['parse_build_options', 'validate_http_proxy'] do
env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic)
result = env.cli('provision')
abort "'vagrant provision' failed" unless result