From 20d07c796492b4d7e4b7a7d5237e1e9d0d414bda Mon Sep 17 00:00:00 2001 From: Tails developers Date: Sun, 13 May 2012 21:50:56 +0200 Subject: vagrant: Add build task We export some environment variables to the build script inside the virtual machine. One of them is http_proxy, so we first validate if it is not set to use a proxy on localhost. In order to properly get output from Vagrant, we handle its replication on stderr/stdout manually. --- Rakefile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 938e915..031a278 100644 --- a/Rakefile +++ b/Rakefile @@ -24,6 +24,9 @@ require 'uri' # Path to the directory which holds our Vagrantfile VAGRANT_PATH = File.expand_path('../vagrant', __FILE__) +# Environment variables that will be exported to the build script +EXPORTED_VARIABLES = ['http_proxy', 'MKSQUASHFS_OPTIONS'] + task :validate_http_proxy do if ENV['http_proxy'] proxy_host = URI.parse(ENV['http_proxy']).host @@ -38,6 +41,19 @@ task :validate_http_proxy do end end +desc 'Build Tails' +task :build => ['validate_http_proxy', 'vm:up'] do + exported_env = EXPORTED_VARIABLES.select { |k| ENV[k] }. + collect { |k| "#{k}='#{ENV[k]}'" }.join(' ') + + env = Vagrant::Environment.new(:cwd => VAGRANT_PATH) + status = env.primary_vm.channel.execute("#{exported_env} build-tails", + :error_check => false) do |fd, data| + (fd == :stdout ? $stdout : $stderr).write data + end + exit status +end + namespace :vm do desc 'Start the build virtual machine' task :up do -- cgit v1.1