summaryrefslogtreecommitdiffstats
path: root/Rakefile
diff options
context:
space:
mode:
authorTails developers <amnesia@boum.org>2012-05-14 23:51:37 +0200
committerTails developers <amnesia@boum.org>2012-05-16 13:30:41 +0200
commit1431b891565b2a12eab80c1f52ae52b2e0990b02 (patch)
tree87cad30c5993255507bb05e70bbe08d22c435cf7 /Rakefile
parent799f1e8e2d6990273f09087eda65b8ae8cf34ae6 (diff)
vagrant: Add suport for in-memory build settings
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile25
1 files changed, 24 insertions, 1 deletions
diff --git a/Rakefile b/Rakefile
index c4c29a9..7c909d3 100644
--- a/Rakefile
+++ b/Rakefile
@@ -28,11 +28,17 @@ require 'tails_build_settings'
VAGRANT_PATH = File.expand_path('../vagrant', __FILE__)
# Environment variables that will be exported to the build script
-EXPORTED_VARIABLES = ['http_proxy', 'MKSQUASHFS_OPTIONS']
+EXPORTED_VARIABLES = ['http_proxy', 'MKSQUASHFS_OPTIONS', 'TAILS_RAM_BUILD']
# Let's save the http_proxy set before playing with it
EXTERNAL_HTTP_PROXY = ENV['http_proxy']
+def current_vm_memory
+ env = Vagrant::Environment.new(:cwd => VAGRANT_PATH, :ui_class => Vagrant::UI::Basic)
+ uuid = env.primary_vm.uuid
+ info = env.primary_vm.driver.execute 'showvminfo', uuid, '--machinereadable'
+ $1.to_i if info =~ /^memory=(\d+)/
+end
task :parse_build_options do
options = ''
@@ -43,6 +49,11 @@ task :parse_build_options do
options += ENV['TAILS_BUILD_OPTIONS'] if ENV['TAILS_BUILD_OPTIONS']
options.split(' ').each do |opt|
case opt
+ # Memory build settings
+ when 'ram'
+ ENV['TAILS_RAM_BUILD'] = '1'
+ when 'noram'
+ ENV['TAILS_RAM_BUILD'] = nil
# HTTP proxy settings
when 'extproxy'
abort "No HTTP proxy set, but one is required by TAILS_BUILD_OPTIONS. Aborting." unless EXTERNAL_HTTP_PROXY
@@ -120,6 +131,18 @@ namespace :vm do
$ rake vm:halt
END_OF_MESSAGE
+ when :running
+ if ENV['TAILS_RAM_BUILD'] && current_vm_memory < VM_MEMORY_FOR_RAM_BUILDS
+ $stderr.puts <<-END_OF_MESSAGE.gsub(/^ /, '')
+
+ The virtual machine is not currently set with enough memory to
+ perform an in-memory build. Either remove the `ram` option from
+ the TAILS_BUILD_OPTIONS environment variable, or shut the
+ virtual machine down using `rake vm:halt` before trying again.
+
+ END_OF_MESSAGE
+ abort 'Not enough memory for the virtual machine to run an in-memory build. Aborting.'
+ end
end
result = env.cli('up')
abort "'vagrant up' failed" unless result