summaryrefslogtreecommitdiffstats
path: root/Rakefile
diff options
context:
space:
mode:
authorTails developers <amnesia@boum.org>2012-05-13 21:50:03 +0200
committerTails developers <amnesia@boum.org>2012-05-16 12:53:18 +0200
commit5193c435d244417d02e6bf1a6fbda9116a7000b4 (patch)
tree41b7acdd9a3808c5ad474645abc8e4fb3f19e880 /Rakefile
parent50a930ee5b41b062ffab17e294f2c96b61ed5337 (diff)
vagrant: Factor out http_proxy validation
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile30
1 files changed, 16 insertions, 14 deletions
diff --git a/Rakefile b/Rakefile
index 0f67a9c..938e915 100644
--- a/Rakefile
+++ b/Rakefile
@@ -19,10 +19,25 @@
require 'rubygems'
require 'vagrant'
+require 'uri'
# Path to the directory which holds our Vagrantfile
VAGRANT_PATH = File.expand_path('../vagrant', __FILE__)
+task :validate_http_proxy do
+ if ENV['http_proxy']
+ proxy_host = URI.parse(ENV['http_proxy']).host
+
+ if ['localhost', '[::1]'].include?(proxy_host) || proxy_host.start_with?('127.0.0.')
+ abort 'Using an HTTP proxy listening on the loopback is doomed to fail. Aborting.'
+ end
+
+ $stderr.puts "Using HTTP proxy: #{ENV['http_proxy']}"
+ else
+ $stderr.puts "No HTTP proxy set."
+ end
+end
+
namespace :vm do
desc 'Start the build virtual machine'
task :up do
@@ -78,21 +93,8 @@ namespace :vm do
end
namespace :basebox do
- task :create_preseed_cfg do
+ task :create_preseed_cfg => 'validate_http_proxy' do
require 'erb'
- require 'uri'
-
- if ENV['http_proxy']
- proxy_host = URI.parse(ENV['http_proxy']).host
-
- if ['localhost', '[::1]'].include?(proxy_host) || proxy_host.start_with?('127.0.0.')
- abort 'Using an HTTP proxy listening on the loopback is doomed to fail.'
- end
-
- $stderr.puts "Building basebox using HTTP proxy: #{ENV['http_proxy']}"
- else
- $stderr.puts "No HTTP proxy set to build basebox"
- end
preseed_cfg_path = File.expand_path('../vagrant/definitions/squeeze/preseed.cfg', __FILE__)
template = ERB.new(File.read("#{preseed_cfg_path}.erb"))